From 9229aee1d7656e41498f04aa3125f1486da3a48b Mon Sep 17 00:00:00 2001 From: QTbin <52951453+QT-one@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:44:25 +0800 Subject: [PATCH] =?UTF-8?q?[BSP][HT32]=E6=96=B0=E5=A2=9E=E5=90=88=E6=B3=B0?= =?UTF-8?q?ht32f52352=E5=92=8Cht32f12366?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manual_trigger_scons_except_STM32_all.yml | 2 + bsp/ht32/ht32f12366/.config | 1095 ++++ bsp/ht32/ht32f12366/Kconfig | 22 + bsp/ht32/ht32f12366/README.md | 107 + bsp/ht32/ht32f12366/SConscript | 15 + bsp/ht32/ht32f12366/SConstruct | 60 + bsp/ht32/ht32f12366/applications/SConscript | 21 + bsp/ht32/ht32f12366/applications/main.c | 37 + bsp/ht32/ht32f12366/board/Kconfig | 77 + bsp/ht32/ht32f12366/board/SConscript | 27 + bsp/ht32/ht32f12366/board/inc/board.h | 64 + bsp/ht32/ht32f12366/board/inc/ht32_msp.h | 211 + .../board/inc/ht32f1xxxx_01_usbdconf.h | 453 ++ .../ht32f12366/board/inc/ht32f1xxxx_conf.h | 490 ++ .../ht32f12366/board/linker_scripts/link.icf | 28 + .../ht32f12366/board/linker_scripts/link.lds | 156 + .../ht32f12366/board/linker_scripts/link.sct | 15 + bsp/ht32/ht32f12366/board/src/board.c | 17 + bsp/ht32/ht32f12366/board/src/ht32_msp.c | 138 + bsp/ht32/ht32f12366/figures/board.png | Bin 0 -> 420464 bytes bsp/ht32/ht32f12366/project.uvoptx | 1219 +++++ bsp/ht32/ht32f12366/project.uvprojx | 2439 +++++++++ bsp/ht32/ht32f12366/rtconfig.h | 273 + bsp/ht32/ht32f12366/rtconfig.py | 152 + bsp/ht32/ht32f12366/template.uvoptx | 179 + bsp/ht32/ht32f12366/template.uvprojx | 392 ++ bsp/ht32/ht32f52352/.config | 1094 ++++ bsp/ht32/ht32f52352/Kconfig | 21 + bsp/ht32/ht32f52352/README.md | 108 + bsp/ht32/ht32f52352/SConscript | 15 + bsp/ht32/ht32f52352/SConstruct | 60 + bsp/ht32/ht32f52352/applications/SConscript | 21 + bsp/ht32/ht32f52352/applications/main.c | 37 + bsp/ht32/ht32f52352/board/Kconfig | 77 + bsp/ht32/ht32f52352/board/SConscript | 27 + bsp/ht32/ht32f52352/board/inc/board.h | 64 + bsp/ht32/ht32f52352/board/inc/ht32_msp.h | 210 + .../board/inc/ht32f5xxxx_01_usbdconf.h | 453 ++ .../board/inc/ht32f5xxxx_02_usbdconf.h | 569 ++ .../ht32f52352/board/inc/ht32f5xxxx_conf.h | 556 ++ .../ht32f52352/board/linker_scripts/link.icf | 28 + .../ht32f52352/board/linker_scripts/link.lds | 156 + .../ht32f52352/board/linker_scripts/link.sct | 15 + bsp/ht32/ht32f52352/board/src/board.c | 17 + bsp/ht32/ht32f52352/board/src/ht32_msp.c | 138 + bsp/ht32/ht32f52352/figures/board.png | Bin 0 -> 381664 bytes bsp/ht32/ht32f52352/project.uvoptx | 1183 ++++ bsp/ht32/ht32f52352/project.uvprojx | 2424 +++++++++ bsp/ht32/ht32f52352/rtconfig.h | 271 + bsp/ht32/ht32f52352/rtconfig.py | 152 + bsp/ht32/ht32f52352/template.uvoptx | 179 + bsp/ht32/ht32f52352/template.uvprojx | 392 ++ bsp/ht32/libraries/.ignore_format.yml | 7 + .../HT32_STD_1xxxx_FWLib/Release_Notes.txt | 876 +++ .../libraries/HT32_STD_1xxxx_FWLib/SConscript | 48 + .../library/CMSIS/ARM.CMSIS.pdsc | 3271 +++++++++++ .../CMSIS/Core/Include/cachel1_armv7.h | 411 ++ .../library/CMSIS/Core/Include/cmsis_armcc.h | 888 +++ .../CMSIS/Core/Include/cmsis_armclang.h | 1503 +++++ .../CMSIS/Core/Include/cmsis_armclang_ltm.h | 1928 +++++++ .../CMSIS/Core/Include/cmsis_compiler.h | 283 + .../library/CMSIS/Core/Include/cmsis_gcc.h | 2211 ++++++++ .../library/CMSIS/Core/Include/cmsis_iccarm.h | 1002 ++++ .../CMSIS/Core/Include/cmsis_version.h | 39 + .../CMSIS/Core/Include/core_armv81mml.h | 4228 +++++++++++++++ .../CMSIS/Core/Include/core_armv8mbl.h | 2222 ++++++++ .../CMSIS/Core/Include/core_armv8mml.h | 3209 +++++++++++ .../library/CMSIS/Core/Include/core_cm0.h | 952 ++++ .../library/CMSIS/Core/Include/core_cm0plus.h | 1087 ++++ .../library/CMSIS/Core/Include/core_cm1.h | 979 ++++ .../library/CMSIS/Core/Include/core_cm23.h | 2297 ++++++++ .../library/CMSIS/Core/Include/core_cm3.h | 1943 +++++++ .../library/CMSIS/Core/Include/core_cm33.h | 3277 +++++++++++ .../library/CMSIS/Core/Include/core_cm35p.h | 3277 +++++++++++ .../library/CMSIS/Core/Include/core_cm4.h | 2129 ++++++++ .../library/CMSIS/Core/Include/core_cm55.h | 4817 +++++++++++++++++ .../library/CMSIS/Core/Include/core_cm7.h | 2366 ++++++++ .../library/CMSIS/Core/Include/core_cm85.h | 4672 ++++++++++++++++ .../library/CMSIS/Core/Include/core_sc000.h | 1030 ++++ .../library/CMSIS/Core/Include/core_sc300.h | 1917 +++++++ .../library/CMSIS/Core/Include/core_starmc1.h | 3592 ++++++++++++ .../library/CMSIS/Core/Include/mpu_armv7.h | 275 + .../library/CMSIS/Core/Include/mpu_armv8.h | 352 ++ .../library/CMSIS/Core/Include/pac_armv81.h | 206 + .../library/CMSIS/Core/Include/pmu_armv8.h | 337 ++ .../library/CMSIS/Core/Include/tz_context.h | 70 + .../CMSIS/Core/Template/ARMv8-M/main_s.c | 58 + .../CMSIS/Core/Template/ARMv8-M/tz_context.c | 200 + .../library/CMSIS/Include/cmsis_armcc.h | 888 +++ .../library/CMSIS/Include/cmsis_armclang.h | 1503 +++++ .../CMSIS/Include/cmsis_armclang_ltm.h | 1928 +++++++ .../library/CMSIS/Include/cmsis_compiler.h | 283 + .../library/CMSIS/Include/cmsis_gcc.h | 2211 ++++++++ .../library/CMSIS/Include/cmsis_iccarm.h | 1002 ++++ .../library/CMSIS/Include/cmsis_version.h | 39 + .../library/CMSIS/Include/core_cm0plus.h | 1087 ++++ .../library/CMSIS/Include/core_cm3.h | 1943 +++++++ .../library/CMSIS/Include/mpu_armv7.h | 275 + .../library/CMSIS/LICENSE.txt | 201 + .../library/CMSIS/README.md | 141 + .../Holtek/HT32F1xxxx/Include/ht32f1xxxx_01.h | 1462 +++++ .../HT32F1xxxx/Include/system_ht32f1xxxx_01.h | 74 + .../HT32F1xxxx/Include/system_ht32f1xxxx_02.h | 74 + .../HT32F1xxxx/Include/system_ht32f1xxxx_03.h | 74 + .../Source/ARM/startup_ht32f12345.s | 469 ++ .../Source/ARM/startup_ht32f12364.s | 393 ++ .../Source/ARM/startup_ht32f12365_66.s | 469 ++ .../HT32F1xxxx/Source/ARM/startup_ht32f165x.s | 469 ++ .../Source/ARM/startup_ht32f1xxxx_01.s | 469 ++ .../Source/ARM/startup_ht32f1xxxx_03.s | 393 ++ .../CodeSourcery/startup_ht32f1xxxx_cs3_01.s | 427 ++ .../CodeSourcery/startup_ht32f1xxxx_cs3_03.s | 370 ++ .../Source/GCC/startup_ht32f1xxxx_gcc_01.s | 485 ++ .../Source/GCC/startup_ht32f1xxxx_gcc_03.s | 428 ++ .../Source/IAR/startup_ht32f1xxxx_iar_01.s | 416 ++ .../Source/IAR/startup_ht32f1xxxx_iar_03.s | 339 ++ .../Source/emStudio/SEGGER_THUMB_Startup.s | 435 ++ .../emStudio/startup_ht32f1xxxx_es_01.s | 391 ++ .../emStudio/startup_ht32f1xxxx_es_03.s | 335 ++ .../HT32F1xxxx/Source/system_ht32f1xxxx_01.c | 462 ++ .../HT32F1xxxx/Source/system_ht32f1xxxx_02.c | 525 ++ .../HT32F1xxxx/Source/system_ht32f1xxxx_03.c | 526 ++ .../library/HT32F1xxxx_Driver/inc/ht32.h | 35 + .../HT32F1xxxx_Driver/inc/ht32_cm3_misc.h | 132 + .../HT32F1xxxx_Driver/inc/ht32_dependency.h | 86 + .../library/HT32F1xxxx_Driver/inc/ht32_rand.h | 43 + .../inc/ht32_retarget_desc.h | 182 + .../inc/ht32_retarget_usbdconf.h | 321 ++ .../HT32F1xxxx_Driver/inc/ht32_serial.h | 84 + .../library/HT32F1xxxx_Driver/inc/ht32_time.h | 170 + .../HT32F1xxxx_Driver/inc/ht32_undef_IP.h | 200 + .../HT32F1xxxx_Driver/inc/ht32f12345_libcfg.h | 57 + .../HT32F1xxxx_Driver/inc/ht32f12364_libcfg.h | 77 + .../inc/ht32f12365_66_libcfg.h | 78 + .../inc/ht32f1653_54_libcfg.h | 77 + .../inc/ht32f1655_56_libcfg.h | 86 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_adc.h | 498 ++ .../HT32F1xxxx_Driver/inc/ht32f1xxxx_aes.h | 202 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_bftm.h | 99 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_ckcu.h | 734 +++ .../HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp.h | 230 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp_op.h | 124 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_crc.h | 124 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_ebi.h | 289 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_exti.h | 208 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_flash.h | 191 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_gpio.h | 426 ++ .../HT32F1xxxx_Driver/inc/ht32f1xxxx_i2c.h | 325 ++ .../HT32F1xxxx_Driver/inc/ht32f1xxxx_i2s.h | 240 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_lib.h | 223 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_mctm.h | 237 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_pdma.h | 344 ++ .../HT32F1xxxx_Driver/inc/ht32f1xxxx_pwrcu.h | 285 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_rstcu.h | 266 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_rtc.h | 245 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_sci.h | 278 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_sdio.h | 413 ++ .../HT32F1xxxx_Driver/inc/ht32f1xxxx_spi.h | 297 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_tm.h | 623 +++ .../inc/ht32f1xxxx_tm_type.h | 113 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_usart.h | 585 ++ .../HT32F1xxxx_Driver/inc/ht32f1xxxx_usbd.h | 325 ++ .../inc/ht32f1xxxx_usbdchk.h | 504 ++ .../inc/ht32f1xxxx_usbdinit.h | 283 + .../HT32F1xxxx_Driver/inc/ht32f1xxxx_wdt.h | 148 + .../HT32F1xxxx_Driver/inc/ht32f2xxxx_csif.h | 302 ++ .../HT32F1xxxx_Driver/src/ht32_cm3_misc.c | 232 + .../library/HT32F1xxxx_Driver/src/ht32_rand.c | 106 + .../HT32F1xxxx_Driver/src/ht32_retarget.c | 413 ++ .../src/ht32_retarget_desc.c | 272 + .../HT32F1xxxx_Driver/src/ht32_serial.c | 549 ++ .../library/HT32F1xxxx_Driver/src/ht32_time.c | 185 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_adc.c | 724 +++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_adc_02.c | 559 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_aes.c | 550 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_bftm.c | 240 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_ckcu.c | 1076 ++++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_cmp.c | 298 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_cmp_op.c | 307 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_crc.c | 190 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_ebi.c | 339 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_exti.c | 516 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_flash.c | 603 +++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_gpio.c | 730 +++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_gptm.c | 2 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_i2c.c | 773 +++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_i2s.c | 336 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_mctm.c | 253 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_pdma.c | 341 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_pwm.c | 2 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_pwrcu.c | 665 +++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_rstcu.c | 142 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_rtc.c | 372 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_sci.c | 444 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_sctm.c | 2 + .../HT32F1xxxx_Driver/src/ht32f1xxxx_sdio.c | 355 ++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_spi.c | 623 +++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_tm.c | 1656 ++++++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_usart.c | 1105 ++++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_usbd.c | 796 +++ .../HT32F1xxxx_Driver/src/ht32f1xxxx_wdt.c | 363 ++ .../HT32F1xxxx_Driver/src/ht32f2xxxx_csif.c | 386 ++ .../library/HT32F1xxxx_Driver/src/printf.c | 390 ++ .../library/HT32F1xxxx_Driver/src/syscalls.c | 127 + .../example/ht32_usbd_class.c | 426 ++ .../example/ht32_usbd_class.h | 87 + .../example/ht32_usbd_descriptor.c | 368 ++ .../example/ht32_usbd_descriptor.h | 59 + .../example/ht32fxxxxx_usbdconf.h | 453 ++ .../HT32_USBD_Library/inc/ht32_usbd_core.h | 435 ++ .../HT32_USBD_Library/src/ht32_usbd_core.c | 1037 ++++ .../HT32_STD_5xxxx_FWLib/Release_Notes.txt | 1674 ++++++ .../libraries/HT32_STD_5xxxx_FWLib/SConscript | 49 + .../library/CMSIS/ARM.CMSIS.pdsc | 3271 +++++++++++ .../CMSIS/Core/Include/cachel1_armv7.h | 411 ++ .../library/CMSIS/Core/Include/cmsis_armcc.h | 888 +++ .../CMSIS/Core/Include/cmsis_armclang.h | 1503 +++++ .../CMSIS/Core/Include/cmsis_armclang_ltm.h | 1928 +++++++ .../CMSIS/Core/Include/cmsis_compiler.h | 283 + .../library/CMSIS/Core/Include/cmsis_gcc.h | 2211 ++++++++ .../library/CMSIS/Core/Include/cmsis_iccarm.h | 1002 ++++ .../CMSIS/Core/Include/cmsis_version.h | 39 + .../CMSIS/Core/Include/core_armv81mml.h | 4228 +++++++++++++++ .../CMSIS/Core/Include/core_armv8mbl.h | 2222 ++++++++ .../CMSIS/Core/Include/core_armv8mml.h | 3209 +++++++++++ .../library/CMSIS/Core/Include/core_cm0.h | 952 ++++ .../library/CMSIS/Core/Include/core_cm0plus.h | 1087 ++++ .../library/CMSIS/Core/Include/core_cm1.h | 979 ++++ .../library/CMSIS/Core/Include/core_cm23.h | 2297 ++++++++ .../library/CMSIS/Core/Include/core_cm3.h | 1943 +++++++ .../library/CMSIS/Core/Include/core_cm33.h | 3277 +++++++++++ .../library/CMSIS/Core/Include/core_cm35p.h | 3277 +++++++++++ .../library/CMSIS/Core/Include/core_cm4.h | 2129 ++++++++ .../library/CMSIS/Core/Include/core_cm55.h | 4817 +++++++++++++++++ .../library/CMSIS/Core/Include/core_cm7.h | 2366 ++++++++ .../library/CMSIS/Core/Include/core_cm85.h | 4672 ++++++++++++++++ .../library/CMSIS/Core/Include/core_sc000.h | 1030 ++++ .../library/CMSIS/Core/Include/core_sc300.h | 1917 +++++++ .../library/CMSIS/Core/Include/core_starmc1.h | 3592 ++++++++++++ .../library/CMSIS/Core/Include/mpu_armv7.h | 275 + .../library/CMSIS/Core/Include/mpu_armv8.h | 352 ++ .../library/CMSIS/Core/Include/pac_armv81.h | 206 + .../library/CMSIS/Core/Include/pmu_armv8.h | 337 ++ .../library/CMSIS/Core/Include/tz_context.h | 70 + .../CMSIS/Core/Template/ARMv8-M/main_s.c | 58 + .../CMSIS/Core/Template/ARMv8-M/tz_context.c | 200 + .../library/CMSIS/Include/cmsis_armcc.h | 888 +++ .../library/CMSIS/Include/cmsis_armclang.h | 1503 +++++ .../CMSIS/Include/cmsis_armclang_ltm.h | 1928 +++++++ .../library/CMSIS/Include/cmsis_compiler.h | 283 + .../library/CMSIS/Include/cmsis_gcc.h | 2211 ++++++++ .../library/CMSIS/Include/cmsis_iccarm.h | 1002 ++++ .../library/CMSIS/Include/cmsis_version.h | 39 + .../library/CMSIS/Include/core_cm0plus.h | 1087 ++++ .../library/CMSIS/Include/core_cm3.h | 1943 +++++++ .../library/CMSIS/Include/mpu_armv7.h | 275 + .../library/CMSIS/LICENSE.txt | 201 + .../library/CMSIS/README.md | 141 + .../Holtek/HT32F5xxxx/Include/ht32f5xxxx_01.h | 2749 ++++++++++ .../HT32F5xxxx/Include/system_ht32f0006.h | 74 + .../HT32F5xxxx/Include/system_ht32f5826.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_01.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_02.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_03.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_04.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_05.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_06.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_07.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_08.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_09.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_10.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_11.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_12.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_13.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_14.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_15.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_16.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_17.h | 74 + .../HT32F5xxxx/Include/system_ht32f5xxxx_18.h | 74 + .../HT32F5xxxx/Source/ARM/startup_hf5032.s | 327 ++ .../HT32F5xxxx/Source/ARM/startup_ht32f0006.s | 304 ++ .../HT32F5xxxx/Source/ARM/startup_ht32f0008.s | 403 ++ .../Source/ARM/startup_ht32f50020_30.s | 235 + .../Source/ARM/startup_ht32f50220_30.s | 327 ++ .../Source/ARM/startup_ht32f50231_41.s | 327 ++ .../Source/ARM/startup_ht32f50343.s | 298 + .../Source/ARM/startup_ht32f50431_41.s | 264 + .../Source/ARM/startup_ht32f50442_52.s | 264 + .../Source/ARM/startup_ht32f52142.s | 403 ++ .../Source/ARM/startup_ht32f52220_30.s | 482 ++ .../Source/ARM/startup_ht32f52231_41.s | 482 ++ .../Source/ARM/startup_ht32f52234_44.s | 239 + .../Source/ARM/startup_ht32f52243_53.s | 482 ++ .../Source/ARM/startup_ht32f52331_41.s | 482 ++ .../Source/ARM/startup_ht32f52342_52.s | 482 ++ .../Source/ARM/startup_ht32f52344_54.s | 403 ++ .../Source/ARM/startup_ht32f52357_67.s | 403 ++ .../Source/ARM/startup_ht32f53231_41.s | 266 + .../Source/ARM/startup_ht32f53242_52.s | 266 + .../Source/ARM/startup_ht32f54231_41.s | 343 ++ .../Source/ARM/startup_ht32f54243_53.s | 343 ++ .../Source/ARM/startup_ht32f57331_41.s | 350 ++ .../Source/ARM/startup_ht32f57342_52.s | 350 ++ .../HT32F5xxxx/Source/ARM/startup_ht32f5826.s | 311 ++ .../HT32F5xxxx/Source/ARM/startup_ht32f5828.s | 350 ++ .../Source/ARM/startup_ht32f59041.s | 327 ++ .../Source/ARM/startup_ht32f59046.s | 327 ++ .../Source/ARM/startup_ht32f59741.s | 350 ++ .../Source/ARM/startup_ht32f59746.s | 350 ++ .../Source/ARM/startup_ht32f5xxxx_01.s | 482 ++ .../Source/ARM/startup_ht32f5xxxx_02.s | 327 ++ .../Source/ARM/startup_ht32f5xxxx_03.s | 403 ++ .../Source/ARM/startup_ht32f5xxxx_05.s | 350 ++ .../Source/ARM/startup_ht32f5xxxx_06.s | 298 + .../Source/ARM/startup_ht32f5xxxx_07.s | 304 ++ .../Source/ARM/startup_ht32f5xxxx_08.s | 278 + .../Source/ARM/startup_ht32f5xxxx_09.s | 343 ++ .../Source/ARM/startup_ht32f5xxxx_10.s | 235 + .../Source/ARM/startup_ht32f5xxxx_11.s | 245 + .../Source/ARM/startup_ht32f5xxxx_12.s | 278 + .../Source/ARM/startup_ht32f5xxxx_13.s | 235 + .../Source/ARM/startup_ht32f5xxxx_14.s | 264 + .../Source/ARM/startup_ht32f5xxxx_15.s | 266 + .../Source/ARM/startup_ht32f5xxxx_16.s | 275 + .../Source/ARM/startup_ht32f5xxxx_17.s | 239 + .../Source/ARM/startup_ht32f61030.s | 235 + .../Source/ARM/startup_ht32f61041.s | 327 ++ .../Source/ARM/startup_ht32f61141.s | 278 + .../Source/ARM/startup_ht32f61244_45.s | 235 + .../Source/ARM/startup_ht32f61352.s | 304 ++ .../Source/ARM/startup_ht32f61355_56_57.s | 304 ++ .../Source/ARM/startup_ht32f61630.s | 235 + .../Source/ARM/startup_ht32f61641.s | 327 ++ .../Source/ARM/startup_ht32f62030.s | 482 ++ .../Source/ARM/startup_ht32f62040.s | 482 ++ .../Source/ARM/startup_ht32f62050.s | 482 ++ .../Source/ARM/startup_ht32f65230_40.s | 278 + .../Source/ARM/startup_ht32f65232.s | 278 + .../Source/ARM/startup_ht32f66242.s | 275 + .../Source/ARM/startup_ht32f66246.s | 275 + .../Source/ARM/startup_ht32f67041_51.s | 245 + .../Source/ARM/startup_ht32f67232.s | 482 ++ .../Source/ARM/startup_ht32f67233.s | 482 ++ .../Source/ARM/startup_ht32f67741.s | 482 ++ .../Source/ARM/startup_ht32f67742.s | 350 ++ .../Source/ARM/startup_ht50f32002.s | 327 ++ .../Source/ARM/startup_ht50f32003.s | 482 ++ .../Source/ARM/startup_ht50f3200s.s | 278 + .../Source/ARM/startup_ht50f3200t.s | 403 ++ .../HT32F5xxxx/Source/ARM/startup_mxtx6306.s | 278 + .../CodeSourcery/startup_ht32f5xxxx_cs3_01.s | 461 ++ .../CodeSourcery/startup_ht32f5xxxx_cs3_02.s | 324 ++ .../CodeSourcery/startup_ht32f5xxxx_cs3_03.s | 386 ++ .../CodeSourcery/startup_ht32f5xxxx_cs3_05.s | 338 ++ .../CodeSourcery/startup_ht32f5xxxx_cs3_06.s | 289 + .../CodeSourcery/startup_ht32f5xxxx_cs3_07.s | 296 + .../CodeSourcery/startup_ht32f5xxxx_cs3_08.s | 258 + .../CodeSourcery/startup_ht32f5xxxx_cs3_09.s | 329 ++ .../CodeSourcery/startup_ht32f5xxxx_cs3_10.s | 230 + .../CodeSourcery/startup_ht32f5xxxx_cs3_11.s | 235 + .../CodeSourcery/startup_ht32f5xxxx_cs3_12.s | 278 + .../CodeSourcery/startup_ht32f5xxxx_cs3_13.s | 234 + .../CodeSourcery/startup_ht32f5xxxx_cs3_14.s | 254 + .../CodeSourcery/startup_ht32f5xxxx_cs3_15.s | 255 + .../CodeSourcery/startup_ht32f5xxxx_cs3_16.s | 259 + .../CodeSourcery/startup_ht32f5xxxx_cs3_17.s | 233 + .../Source/GCC/startup_ht32f5xxxx_gcc_01.s | 519 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_02.s | 382 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_03.s | 444 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_05.s | 396 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_06.s | 347 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_07.s | 355 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_08.s | 315 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_09.s | 387 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_10.s | 289 + .../Source/GCC/startup_ht32f5xxxx_gcc_11.s | 294 + .../Source/GCC/startup_ht32f5xxxx_gcc_12.s | 336 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_13.s | 292 + .../Source/GCC/startup_ht32f5xxxx_gcc_14.s | 312 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_15.s | 313 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_16.s | 317 ++ .../Source/GCC/startup_ht32f5xxxx_gcc_17.s | 291 + .../Source/IAR/startup_ht32f5xxxx_iar_01.s | 430 ++ .../Source/IAR/startup_ht32f5xxxx_iar_02.s | 275 + .../Source/IAR/startup_ht32f5xxxx_iar_03.s | 351 ++ .../Source/IAR/startup_ht32f5xxxx_iar_05.s | 298 + .../Source/IAR/startup_ht32f5xxxx_iar_06.s | 245 + .../Source/IAR/startup_ht32f5xxxx_iar_07.s | 252 + .../Source/IAR/startup_ht32f5xxxx_iar_08.s | 224 + .../Source/IAR/startup_ht32f5xxxx_iar_09.s | 291 + .../Source/IAR/startup_ht32f5xxxx_iar_10.s | 184 + .../Source/IAR/startup_ht32f5xxxx_iar_11.s | 194 + .../Source/IAR/startup_ht32f5xxxx_iar_12.s | 226 + .../Source/IAR/startup_ht32f5xxxx_iar_13.s | 184 + .../Source/IAR/startup_ht32f5xxxx_iar_14.s | 213 + .../Source/IAR/startup_ht32f5xxxx_iar_15.s | 215 + .../Source/IAR/startup_ht32f5xxxx_iar_16.s | 224 + .../Source/IAR/startup_ht32f5xxxx_iar_17.s | 188 + .../Source/IAR/startup_ht32f65230_40_iar.s | 209 + .../Source/emStudio/SEGGER_THUMB_Startup.s | 435 ++ .../emStudio/startup_ht32f5xxxx_es_01.s | 426 ++ .../emStudio/startup_ht32f5xxxx_es_02.s | 289 + .../emStudio/startup_ht32f5xxxx_es_03.s | 351 ++ .../emStudio/startup_ht32f5xxxx_es_05.s | 303 ++ .../emStudio/startup_ht32f5xxxx_es_06.s | 254 + .../emStudio/startup_ht32f5xxxx_es_07.s | 262 + .../emStudio/startup_ht32f5xxxx_es_08.s | 222 + .../emStudio/startup_ht32f5xxxx_es_09.s | 294 + .../emStudio/startup_ht32f5xxxx_es_10.s | 194 + .../emStudio/startup_ht32f5xxxx_es_11.s | 199 + .../emStudio/startup_ht32f5xxxx_es_12.s | 243 + .../emStudio/startup_ht32f5xxxx_es_13.s | 197 + .../emStudio/startup_ht32f5xxxx_es_14.s | 216 + .../emStudio/startup_ht32f5xxxx_es_15.s | 217 + .../emStudio/startup_ht32f5xxxx_es_16.s | 221 + .../emStudio/startup_ht32f5xxxx_es_17.s | 195 + .../HT32F5xxxx/Source/system_ht32f0006.c | 478 ++ .../HT32F5xxxx/Source/system_ht32f5826.c | 508 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_01.c | 518 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_02.c | 525 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_03.c | 518 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_04.c | 335 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_05.c | 497 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_06.c | 488 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_07.c | 482 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_08.c | 518 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_09.c | 489 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_10.c | 455 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_11.c | 511 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_12.c | 485 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_13.c | 325 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_14.c | 487 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_15.c | 487 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_16.c | 472 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_17.c | 488 ++ .../HT32F5xxxx/Source/system_ht32f5xxxx_18.c | 518 ++ .../library/HT32F5xxxx_Driver/inc/ht32.h | 35 + .../HT32F5xxxx_Driver/inc/ht32_cm0plus_misc.h | 132 + .../HT32F5xxxx_Driver/inc/ht32_config.h | 307 ++ .../HT32F5xxxx_Driver/inc/ht32_dependency.h | 86 + .../library/HT32F5xxxx_Driver/inc/ht32_div.h | 37 + .../library/HT32F5xxxx_Driver/inc/ht32_rand.h | 43 + .../inc/ht32_retarget_desc.h | 182 + .../inc/ht32_retarget_usbdconf.h | 321 ++ .../HT32F5xxxx_Driver/inc/ht32_serial.h | 84 + .../library/HT32F5xxxx_Driver/inc/ht32_time.h | 170 + .../HT32F5xxxx_Driver/inc/ht32_undef_IP.h | 200 + .../HT32F5xxxx_Driver/inc/ht32f0006_libcfg.h | 73 + .../HT32F5xxxx_Driver/inc/ht32f0008_libcfg.h | 74 + .../inc/ht32f50020_30_libcfg.h | 111 + .../inc/ht32f50220_30_libcfg.h | 75 + .../inc/ht32f50231_41_libcfg.h | 79 + .../HT32F5xxxx_Driver/inc/ht32f50343_libcfg.h | 87 + .../inc/ht32f50431_41_libcfg.h | 95 + .../inc/ht32f50442_52_libcfg.h | 99 + .../inc/ht32f52220_30_libcfg.h | 61 + .../inc/ht32f52231_41_libcfg.h | 76 + .../inc/ht32f52234_44_libcfg.h | 83 + .../inc/ht32f52243_53_libcfg.h | 84 + .../inc/ht32f52331_41_libcfg.h | 78 + .../inc/ht32f52342_52_libcfg.h | 91 + .../inc/ht32f52344_54_libcfg.h | 84 + .../inc/ht32f52357_67_libcfg.h | 102 + .../inc/ht32f53231_41_libcfg.h | 96 + .../inc/ht32f53242_52_libcfg.h | 100 + .../inc/ht32f54231_41_libcfg.h | 87 + .../inc/ht32f54243_53_libcfg.h | 95 + .../inc/ht32f57331_41_libcfg.h | 79 + .../inc/ht32f57342_52_libcfg.h | 89 + .../HT32F5xxxx_Driver/inc/ht32f5826_libcfg.h | 85 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_adc.h | 660 +++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_aes.h | 209 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_bftm.h | 111 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_can.h | 498 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_ckcu.h | 936 ++++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_cmp.h | 362 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_crc.h | 124 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_dac.h | 130 + .../inc/ht32f5xxxx_dac_dual16.h | 92 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_div.h | 113 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_ebi.h | 183 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_exti.h | 263 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_flash.h | 190 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_gpio.h | 508 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_i2c.h | 412 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_i2s.h | 240 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_lcd.h | 382 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_ledc.h | 209 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_lib.h | 332 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_mctm.h | 298 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_midi.h | 404 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_pdma.h | 377 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_pwrcu.h | 376 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_rstcu.h | 238 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_rtc.h | 255 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_sci.h | 280 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_sled.h | 157 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_spi.h | 375 ++ .../inc/ht32f5xxxx_spi_midi.h | 204 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_tkey.h | 311 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_tm.h | 942 ++++ .../inc/ht32f5xxxx_tm_type.h | 129 + .../HT32F5xxxx_Driver/inc/ht32f5xxxx_usart.h | 499 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_usbd.h | 346 ++ .../inc/ht32f5xxxx_usbdchk.h | 706 +++ .../inc/ht32f5xxxx_usbdinit.h | 330 ++ .../HT32F5xxxx_Driver/inc/ht32f5xxxx_wdt.h | 149 + .../HT32F5xxxx_Driver/inc/ht32f61141_libcfg.h | 76 + .../inc/ht32f61244_45_libcfg.h | 73 + .../inc/ht32f65230_40_libcfg.h | 92 + .../HT32F5xxxx_Driver/inc/ht32f65232_libcfg.h | 90 + .../inc/ht32f65xxx_66xxx_adc.h | 417 ++ .../inc/ht32f65xxx_66xxx_opa.h | 215 + .../inc/ht32f65xxx_66xxx_pga.h | 62 + .../HT32F5xxxx_Driver/inc/ht32f66242_libcfg.h | 52 + .../HT32F5xxxx_Driver/inc/ht32f66246_libcfg.h | 52 + .../HT32F5xxxx_Driver/inc/ht32f66xxx_cordic.h | 62 + .../HT32F5xxxx_Driver/inc/ht32f66xxx_pid.h | 62 + .../inc/ht32f67041_51_libcfg.h | 78 + .../HT32F5xxxx_Driver/src/ht32_cm0plus_misc.c | 243 + .../library/HT32F5xxxx_Driver/src/ht32_div.c | 55 + .../library/HT32F5xxxx_Driver/src/ht32_rand.c | 81 + .../HT32F5xxxx_Driver/src/ht32_retarget.c | 413 ++ .../src/ht32_retarget_desc.c | 272 + .../HT32F5xxxx_Driver/src/ht32_serial.c | 555 ++ .../library/HT32F5xxxx_Driver/src/ht32_time.c | 185 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_adc.c | 603 +++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_aes.c | 552 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_bftm.c | 242 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_can.c | 1029 ++++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_ckcu.c | 1105 ++++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_cmp.c | 336 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_crc.c | 190 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_dac.c | 249 + .../src/ht32f5xxxx_dac_dual16.c | 191 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_div.c | 211 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_ebi.c | 189 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_exti.c | 548 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_flash.c | 471 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_gpio.c | 767 +++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_gptm.c | 2 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_i2c.c | 861 +++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_i2s.c | 336 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_lcd.c | 577 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_ledc.c | 309 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_lstm.c | 32 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_mctm.c | 293 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_midi.c | 1176 ++++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_pdma.c | 312 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_pwm.c | 2 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_pwrcu.c | 846 +++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_rstcu.c | 142 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_rtc.c | 393 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_sci.c | 446 ++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_sctm.c | 2 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_sled.c | 289 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_spi.c | 712 +++ .../src/ht32f5xxxx_spi_midi.c | 182 + .../HT32F5xxxx_Driver/src/ht32f5xxxx_tkey.c | 703 +++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_tm.c | 1853 +++++++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_usart.c | 911 ++++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_usbd.c | 855 +++ .../HT32F5xxxx_Driver/src/ht32f5xxxx_wdt.c | 343 ++ .../HT32F5xxxx_Driver/src/ht32f652xx_adc.c | 32 + .../HT32F5xxxx_Driver/src/ht32f652xx_opa.c | 32 + .../src/ht32f65xxx_66xxx_adc.c | 784 +++ .../src/ht32f65xxx_66xxx_opa.c | 456 ++ .../src/ht32f65xxx_66xxx_pga.c | 49 + .../HT32F5xxxx_Driver/src/ht32f66xxx_cordic.c | 49 + .../HT32F5xxxx_Driver/src/ht32f66xxx_pid.c | 49 + .../library/HT32F5xxxx_Driver/src/printf.c | 390 ++ .../library/HT32F5xxxx_Driver/src/syscalls.c | 127 + .../example/ht32_usbd_class.c | 426 ++ .../example/ht32_usbd_class.h | 87 + .../example/ht32_usbd_descriptor.c | 368 ++ .../example/ht32_usbd_descriptor.h | 59 + .../example/ht32fxxxxx_usbdconf.h | 453 ++ .../HT32_USBD_Library/inc/ht32_usbd_core.h | 435 ++ .../HT32_USBD_Library/src/ht32_usbd_core.c | 1037 ++++ bsp/ht32/libraries/Kconfig | 12 + bsp/ht32/libraries/ht32_drivers/SConscript | 37 + bsp/ht32/libraries/ht32_drivers/drv_common.c | 82 + bsp/ht32/libraries/ht32_drivers/drv_common.h | 37 + bsp/ht32/libraries/ht32_drivers/drv_gpio.c | 910 ++++ bsp/ht32/libraries/ht32_drivers/drv_gpio.h | 30 + bsp/ht32/libraries/ht32_drivers/drv_i2c.c | 208 + bsp/ht32/libraries/ht32_drivers/drv_i2c.h | 30 + bsp/ht32/libraries/ht32_drivers/drv_spi.c | 352 ++ bsp/ht32/libraries/ht32_drivers/drv_spi.h | 29 + bsp/ht32/libraries/ht32_drivers/drv_usart.c | 372 ++ bsp/ht32/libraries/ht32_drivers/drv_usart.h | 26 + bsp/ht32/tools/sdk_dist.py | 40 + 592 files changed, 296882 insertions(+) create mode 100644 bsp/ht32/ht32f12366/.config create mode 100644 bsp/ht32/ht32f12366/Kconfig create mode 100644 bsp/ht32/ht32f12366/README.md create mode 100644 bsp/ht32/ht32f12366/SConscript create mode 100644 bsp/ht32/ht32f12366/SConstruct create mode 100644 bsp/ht32/ht32f12366/applications/SConscript create mode 100644 bsp/ht32/ht32f12366/applications/main.c create mode 100644 bsp/ht32/ht32f12366/board/Kconfig create mode 100644 bsp/ht32/ht32f12366/board/SConscript create mode 100644 bsp/ht32/ht32f12366/board/inc/board.h create mode 100644 bsp/ht32/ht32f12366/board/inc/ht32_msp.h create mode 100644 bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_01_usbdconf.h create mode 100644 bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_conf.h create mode 100644 bsp/ht32/ht32f12366/board/linker_scripts/link.icf create mode 100644 bsp/ht32/ht32f12366/board/linker_scripts/link.lds create mode 100644 bsp/ht32/ht32f12366/board/linker_scripts/link.sct create mode 100644 bsp/ht32/ht32f12366/board/src/board.c create mode 100644 bsp/ht32/ht32f12366/board/src/ht32_msp.c create mode 100644 bsp/ht32/ht32f12366/figures/board.png create mode 100644 bsp/ht32/ht32f12366/project.uvoptx create mode 100644 bsp/ht32/ht32f12366/project.uvprojx create mode 100644 bsp/ht32/ht32f12366/rtconfig.h create mode 100644 bsp/ht32/ht32f12366/rtconfig.py create mode 100644 bsp/ht32/ht32f12366/template.uvoptx create mode 100644 bsp/ht32/ht32f12366/template.uvprojx create mode 100644 bsp/ht32/ht32f52352/.config create mode 100644 bsp/ht32/ht32f52352/Kconfig create mode 100644 bsp/ht32/ht32f52352/README.md create mode 100644 bsp/ht32/ht32f52352/SConscript create mode 100644 bsp/ht32/ht32f52352/SConstruct create mode 100644 bsp/ht32/ht32f52352/applications/SConscript create mode 100644 bsp/ht32/ht32f52352/applications/main.c create mode 100644 bsp/ht32/ht32f52352/board/Kconfig create mode 100644 bsp/ht32/ht32f52352/board/SConscript create mode 100644 bsp/ht32/ht32f52352/board/inc/board.h create mode 100644 bsp/ht32/ht32f52352/board/inc/ht32_msp.h create mode 100644 bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_01_usbdconf.h create mode 100644 bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_02_usbdconf.h create mode 100644 bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_conf.h create mode 100644 bsp/ht32/ht32f52352/board/linker_scripts/link.icf create mode 100644 bsp/ht32/ht32f52352/board/linker_scripts/link.lds create mode 100644 bsp/ht32/ht32f52352/board/linker_scripts/link.sct create mode 100644 bsp/ht32/ht32f52352/board/src/board.c create mode 100644 bsp/ht32/ht32f52352/board/src/ht32_msp.c create mode 100644 bsp/ht32/ht32f52352/figures/board.png create mode 100644 bsp/ht32/ht32f52352/project.uvoptx create mode 100644 bsp/ht32/ht32f52352/project.uvprojx create mode 100644 bsp/ht32/ht32f52352/rtconfig.h create mode 100644 bsp/ht32/ht32f52352/rtconfig.py create mode 100644 bsp/ht32/ht32f52352/template.uvoptx create mode 100644 bsp/ht32/ht32f52352/template.uvprojx create mode 100644 bsp/ht32/libraries/.ignore_format.yml create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/Release_Notes.txt create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/SConscript create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_version.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm3.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/LICENSE.txt create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/README.md create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/ht32f1xxxx_01.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_01.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_02.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_03.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12345.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12364.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12365_66.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f165x.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/SEGGER_THUMB_Startup.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_01.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_02.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_03.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_cm3_misc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_dependency.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_rand.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_desc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_usbdconf.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_serial.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_time.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_undef_IP.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12345_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12364_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12365_66_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1653_54_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1655_56_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_adc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_aes.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_bftm.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ckcu.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp_op.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_crc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ebi.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_exti.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_flash.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_gpio.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2c.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2s.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_lib.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_mctm.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pdma.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pwrcu.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rstcu.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rtc.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sci.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sdio.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_spi.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm_type.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usart.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbd.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdchk.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdinit.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_wdt.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f2xxxx_csif.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_cm3_misc.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_rand.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget_desc.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_serial.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_time.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc_02.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_aes.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_bftm.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ckcu.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp_op.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_crc.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ebi.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_exti.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_flash.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gpio.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gptm.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2c.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2s.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_mctm.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pdma.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwm.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwrcu.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rstcu.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rtc.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sci.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sctm.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sdio.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_spi.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_tm.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usart.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usbd.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_wdt.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f2xxxx_csif.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/printf.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/syscalls.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h create mode 100644 bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/Release_Notes.txt create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/SConscript create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_version.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm3.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/LICENSE.txt create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/README.md create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/ht32f5xxxx_01.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f0006.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5826.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_01.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_02.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_03.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_04.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_05.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_06.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_07.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_08.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_09.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_10.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_11.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_12.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_13.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_14.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_15.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_16.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_17.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_18.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_hf5032.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0006.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0008.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50020_30.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50220_30.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50231_41.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50343.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50431_41.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50442_52.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52142.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52220_30.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52231_41.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52234_44.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52243_53.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52331_41.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52342_52.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52344_54.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52357_67.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53231_41.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53242_52.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54231_41.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54243_53.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57331_41.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57342_52.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5826.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5828.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59041.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59046.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59741.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59746.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_02.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_05.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_06.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_07.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_08.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_09.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_10.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_11.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_12.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_13.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_14.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_15.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_16.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_17.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61030.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61041.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61141.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61244_45.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61352.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61355_56_57.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61630.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61641.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62030.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62040.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62050.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65230_40.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65232.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66242.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66246.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67041_51.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67232.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67233.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67741.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67742.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32002.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32003.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200s.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200t.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_mxtx6306.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_02.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_05.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_06.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_07.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_08.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_09.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_10.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_11.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_12.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_13.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_14.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_15.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_16.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_17.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_02.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_05.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_06.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_07.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_08.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_09.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_10.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_11.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_12.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_13.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_14.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_15.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_16.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_17.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_02.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_05.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_06.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_07.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_08.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_09.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_10.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_11.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_12.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_13.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_14.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_15.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_16.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_17.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f65230_40_iar.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/SEGGER_THUMB_Startup.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_01.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_02.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_03.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_05.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_06.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_07.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_08.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_09.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_10.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_11.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_12.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_13.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_14.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_15.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_16.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_17.s create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f0006.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5826.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_01.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_02.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_03.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_04.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_05.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_06.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_07.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_08.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_09.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_10.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_11.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_12.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_13.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_14.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_15.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_16.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_17.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_18.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_cm0plus_misc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_config.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_dependency.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_div.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_rand.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_desc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_usbdconf.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_serial.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_time.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_undef_IP.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0006_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0008_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50020_30_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50220_30_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50231_41_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50343_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50431_41_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50442_52_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52220_30_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52231_41_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52234_44_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52243_53_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52331_41_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52342_52_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52344_54_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52357_67_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53231_41_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53242_52_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54231_41_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54243_53_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57331_41_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57342_52_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5826_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_adc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_aes.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_bftm.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_can.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ckcu.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_cmp.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_crc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac_dual16.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_div.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ebi.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_exti.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_flash.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_gpio.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2c.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2s.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lcd.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ledc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lib.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_mctm.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_midi.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pdma.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pwrcu.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rstcu.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rtc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sci.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sled.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi_midi.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tkey.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm_type.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usart.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbd.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdchk.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdinit.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_wdt.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61141_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61244_45_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65230_40_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65232_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_adc.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_opa.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_pga.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66242_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66246_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_cordic.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_pid.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f67041_51_libcfg.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_cm0plus_misc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_div.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_rand.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget_desc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_serial.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_time.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_adc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_aes.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_bftm.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_can.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ckcu.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_cmp.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_crc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac_dual16.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_div.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ebi.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_exti.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_flash.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gpio.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gptm.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2c.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2s.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lcd.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ledc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lstm.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_mctm.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_midi.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pdma.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwm.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwrcu.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rstcu.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rtc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sci.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sctm.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sled.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi_midi.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tkey.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tm.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usart.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usbd.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_wdt.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_adc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_opa.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_adc.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_opa.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_pga.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_cordic.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_pid.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/printf.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/syscalls.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h create mode 100644 bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c create mode 100644 bsp/ht32/libraries/Kconfig create mode 100644 bsp/ht32/libraries/ht32_drivers/SConscript create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_common.c create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_common.h create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_gpio.c create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_gpio.h create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_i2c.c create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_i2c.h create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_spi.c create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_spi.h create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_usart.c create mode 100644 bsp/ht32/libraries/ht32_drivers/drv_usart.h create mode 100644 bsp/ht32/tools/sdk_dist.py diff --git a/.github/workflows/manual_trigger_scons_except_STM32_all.yml b/.github/workflows/manual_trigger_scons_except_STM32_all.yml index 7658f948c0..f3b4186b64 100644 --- a/.github/workflows/manual_trigger_scons_except_STM32_all.yml +++ b/.github/workflows/manual_trigger_scons_except_STM32_all.yml @@ -126,6 +126,8 @@ jobs: #- {RTT_BSP_NAME: "hk32_hk32f030c8-mini", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "hk32/hk32f030c8-mini"} #scons dist有问题 - {RTT_BSP_NAME: "hpmicro_hpm6750evk", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "hpmicro/hpm6750evk"} - {RTT_BSP_NAME: "hpmicro_hpm6750evkmini", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "hpmicro/hpm6750evkmini"} + - {RTT_BSP_NAME: "ht32f12366", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "ht32/ht32f12366"} + - {RTT_BSP_NAME: "ht32f52352", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "ht32/ht32f52352"} #- {RTT_BSP_NAME: "imx_imx6ull-smart", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "imx/imx6ull-smart"} # toolchain还没支持 - {RTT_BSP_NAME: "imx6sx_cortex-a9", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "imx6sx/cortex-a9"} - {RTT_BSP_NAME: "imx6ul", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "imx6ul"} diff --git a/bsp/ht32/ht32f12366/.config b/bsp/ht32/ht32f12366/.config new file mode 100644 index 0000000000..ca3e7e11bd --- /dev/null +++ b/bsp/ht32/ht32f12366/.config @@ -0,0 +1,1095 @@ +# +# Automatically generated file; DO NOT EDIT. +# RT-Thread Configuration +# + +# +# RT-Thread Kernel +# +CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_ARCH_DATA_TYPE is not set +# CONFIG_RT_USING_SMART is not set +# CONFIG_RT_USING_NANO is not set +# CONFIG_RT_USING_AMP is not set +# CONFIG_RT_USING_SMP is not set +CONFIG_RT_CPUS_NR=1 +CONFIG_RT_ALIGN_SIZE=4 +# CONFIG_RT_THREAD_PRIORITY_8 is not set +CONFIG_RT_THREAD_PRIORITY_32=y +# CONFIG_RT_THREAD_PRIORITY_256 is not set +CONFIG_RT_THREAD_PRIORITY_MAX=32 +CONFIG_RT_TICK_PER_SECOND=1000 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_HOOK_USING_FUNC_PTR=y +# CONFIG_RT_USING_HOOKLIST is not set +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=256 +# CONFIG_RT_USING_TIMER_SOFT is not set + +# +# kservice optimization +# +# CONFIG_RT_KSERVICE_USING_STDLIB is not set +# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set +# CONFIG_RT_USING_TINY_FFS is not set +# CONFIG_RT_KPRINTF_USING_LONGLONG is not set +CONFIG_RT_USING_DEBUG=y +CONFIG_RT_DEBUGING_COLOR=y +CONFIG_RT_DEBUGING_CONTEXT=y +# CONFIG_RT_DEBUGING_AUTO_INIT is not set + +# +# Inter-Thread communication +# +CONFIG_RT_USING_SEMAPHORE=y +CONFIG_RT_USING_MUTEX=y +CONFIG_RT_USING_EVENT=y +CONFIG_RT_USING_MAILBOX=y +CONFIG_RT_USING_MESSAGEQUEUE=y +# CONFIG_RT_USING_MESSAGEQUEUE_PRIORITY is not set +# CONFIG_RT_USING_SIGNALS is not set + +# +# Memory Management +# +CONFIG_RT_USING_MEMPOOL=y +CONFIG_RT_USING_SMALL_MEM=y +# CONFIG_RT_USING_SLAB is not set +CONFIG_RT_USING_MEMHEAP=y +CONFIG_RT_MEMHEAP_FAST_MODE=y +# CONFIG_RT_MEMHEAP_BEST_MODE is not set +CONFIG_RT_USING_SMALL_MEM_AS_HEAP=y +# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set +# CONFIG_RT_USING_SLAB_AS_HEAP is not set +# CONFIG_RT_USING_USERHEAP is not set +# CONFIG_RT_USING_NOHEAP is not set +# CONFIG_RT_USING_MEMTRACE is not set +# CONFIG_RT_USING_HEAP_ISR is not set +CONFIG_RT_USING_HEAP=y +CONFIG_RT_USING_DEVICE=y +# CONFIG_RT_USING_DEVICE_OPS is not set +# CONFIG_RT_USING_INTERRUPT_INFO is not set +# CONFIG_RT_USING_THREADSAFE_PRINTF is not set +# CONFIG_RT_USING_SCHED_THREAD_CTX is not set +CONFIG_RT_USING_CONSOLE=y +CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLE_DEVICE_NAME="usart0" +CONFIG_RT_VER_NUM=0x50100 +# CONFIG_RT_USING_STDC_ATOMIC is not set +CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32 +# CONFIG_RT_USING_CACHE is not set +CONFIG_RT_USING_HW_ATOMIC=y +# CONFIG_ARCH_ARM_BOOTWITH_FLUSH_CACHE is not set +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set +CONFIG_RT_USING_CPU_FFS=y +CONFIG_ARCH_ARM=y +CONFIG_ARCH_ARM_CORTEX_M=y +CONFIG_ARCH_ARM_CORTEX_M3=y + +# +# RT-Thread Components +# +CONFIG_RT_USING_COMPONENTS_INIT=y +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 +# CONFIG_RT_USING_LEGACY is not set +CONFIG_RT_USING_MSH=y +CONFIG_RT_USING_FINSH=y +CONFIG_FINSH_USING_MSH=y +CONFIG_FINSH_THREAD_NAME="tshell" +CONFIG_FINSH_THREAD_PRIORITY=20 +CONFIG_FINSH_THREAD_STACK_SIZE=4096 +CONFIG_FINSH_USING_HISTORY=y +CONFIG_FINSH_HISTORY_LINES=5 +CONFIG_FINSH_USING_SYMTAB=y +CONFIG_FINSH_CMD_SIZE=80 +CONFIG_MSH_USING_BUILT_IN_COMMANDS=y +CONFIG_FINSH_USING_DESCRIPTION=y +# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set +# CONFIG_FINSH_USING_AUTH is not set +CONFIG_FINSH_ARG_MAX=10 +CONFIG_FINSH_USING_OPTION_COMPLETION=y + +# +# DFS: device virtual file system +# +# CONFIG_RT_USING_DFS is not set +# CONFIG_RT_USING_FAL is not set + +# +# Device Drivers +# +# CONFIG_RT_USING_DM is not set +CONFIG_RT_USING_DEVICE_IPC=y +CONFIG_RT_UNAMED_PIPE_NUMBER=64 +# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set +CONFIG_RT_USING_SERIAL=y +CONFIG_RT_USING_SERIAL_V1=y +# CONFIG_RT_USING_SERIAL_V2 is not set +CONFIG_RT_SERIAL_USING_DMA=y +CONFIG_RT_SERIAL_RB_BUFSZ=64 +# CONFIG_RT_USING_CAN is not set +# CONFIG_RT_USING_CPUTIME is not set +CONFIG_RT_USING_I2C=y +# CONFIG_RT_I2C_DEBUG is not set +CONFIG_RT_USING_I2C_BITOPS=y +# CONFIG_RT_I2C_BITOPS_DEBUG is not set +# CONFIG_RT_USING_SOFT_I2C is not set +# CONFIG_RT_USING_PHY is not set +# CONFIG_RT_USING_ADC is not set +# CONFIG_RT_USING_DAC is not set +# CONFIG_RT_USING_NULL is not set +# CONFIG_RT_USING_ZERO is not set +# CONFIG_RT_USING_RANDOM is not set +# CONFIG_RT_USING_PWM is not set +# CONFIG_RT_USING_MTD_NOR is not set +# CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_PM is not set +# CONFIG_RT_USING_RTC is not set +# CONFIG_RT_USING_SDIO is not set +CONFIG_RT_USING_SPI=y +# CONFIG_RT_USING_SPI_BITOPS is not set +# CONFIG_RT_USING_QSPI is not set +# CONFIG_RT_USING_SPI_MSD is not set +# CONFIG_RT_USING_SFUD is not set +# CONFIG_RT_USING_ENC28J60 is not set +# CONFIG_RT_USING_SPI_WIFI is not set +# CONFIG_RT_USING_WDT is not set +# CONFIG_RT_USING_AUDIO is not set +# CONFIG_RT_USING_SENSOR is not set +# CONFIG_RT_USING_TOUCH is not set +# CONFIG_RT_USING_LCD is not set +# CONFIG_RT_USING_HWCRYPTO is not set +# CONFIG_RT_USING_PULSE_ENCODER is not set +# CONFIG_RT_USING_INPUT_CAPTURE is not set +# CONFIG_RT_USING_DEV_BUS is not set +# CONFIG_RT_USING_WIFI is not set +# CONFIG_RT_USING_VIRTIO is not set +CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_KTIME is not set +# CONFIG_RT_USING_HWTIMER is not set + +# +# Using USB +# +# CONFIG_RT_USING_USB is not set +# CONFIG_RT_USING_USB_HOST is not set +# CONFIG_RT_USING_USB_DEVICE is not set + +# +# C/C++ and POSIX layer +# + +# +# ISO-ANSI C layer +# + +# +# Timezone and Daylight Saving Time +# +# CONFIG_RT_LIBC_USING_FULL_TZ_DST is not set +CONFIG_RT_LIBC_USING_LIGHT_TZ_DST=y +CONFIG_RT_LIBC_TZ_DEFAULT_HOUR=8 +CONFIG_RT_LIBC_TZ_DEFAULT_MIN=0 +CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 + +# +# POSIX (Portable Operating System Interface) layer +# +# CONFIG_RT_USING_POSIX_FS is not set +# CONFIG_RT_USING_POSIX_DELAY is not set +# CONFIG_RT_USING_POSIX_CLOCK is not set +# CONFIG_RT_USING_POSIX_TIMER is not set +# CONFIG_RT_USING_PTHREADS is not set +# CONFIG_RT_USING_MODULE is not set + +# +# Interprocess Communication (IPC) +# +# CONFIG_RT_USING_POSIX_PIPE is not set +# CONFIG_RT_USING_POSIX_MESSAGE_QUEUE is not set +# CONFIG_RT_USING_POSIX_MESSAGE_SEMAPHORE is not set + +# +# Socket is in the 'Network' category +# +# CONFIG_RT_USING_CPLUSPLUS is not set + +# +# Network +# +# CONFIG_RT_USING_SAL is not set +# CONFIG_RT_USING_NETDEV is not set +# CONFIG_RT_USING_LWIP is not set +# CONFIG_RT_USING_AT is not set + +# +# Memory protection +# +# CONFIG_RT_USING_MEM_PROTECTION is not set +# CONFIG_RT_USING_HW_STACK_GUARD is not set + +# +# Utilities +# +# CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set +# CONFIG_RT_USING_UTEST is not set +# CONFIG_RT_USING_VAR_EXPORT is not set +# CONFIG_RT_USING_RESOURCE_ID is not set +# CONFIG_RT_USING_ADT is not set +# CONFIG_RT_USING_RT_LINK is not set +# CONFIG_RT_USING_VBUS is not set + +# +# RT-Thread Utestcases +# +# CONFIG_RT_USING_UTESTCASES is not set + +# +# RT-Thread online packages +# + +# +# IoT - internet of things +# +# CONFIG_PKG_USING_LWIP is not set +# CONFIG_PKG_USING_LORAWAN_DRIVER is not set +# CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_UMQTT is not set +# CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_WEBNET is not set +# CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_MYMQTT is not set +# CONFIG_PKG_USING_KAWAII_MQTT is not set +# CONFIG_PKG_USING_BC28_MQTT is not set +# CONFIG_PKG_USING_WEBTERMINAL is not set +# CONFIG_PKG_USING_FREEMODBUS is not set +# CONFIG_PKG_USING_NANOPB is not set + +# +# Wi-Fi +# + +# +# Marvell WiFi +# +# CONFIG_PKG_USING_WLANMARVELL is not set + +# +# Wiced WiFi +# +# CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_RW007 is not set + +# +# CYW43012 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43012 is not set + +# +# BL808 WiFi +# +# CONFIG_PKG_USING_WLAN_BL808 is not set + +# +# CYW43439 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43439 is not set +# CONFIG_PKG_USING_COAP is not set +# CONFIG_PKG_USING_NOPOLL is not set +# CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_CMUX is not set +# CONFIG_PKG_USING_PPP_DEVICE is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_ATSRV_SOCKET is not set +# CONFIG_PKG_USING_WIZNET is not set +# CONFIG_PKG_USING_ZB_COORDINATOR is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set +# CONFIG_PKG_USING_JIOT-C-SDK is not set +# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set +# CONFIG_PKG_USING_JOYLINK is not set +# CONFIG_PKG_USING_IOTSHARP_SDK is not set +# CONFIG_PKG_USING_NIMBLE is not set +# CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set +# CONFIG_PKG_USING_OTA_DOWNLOADER is not set +# CONFIG_PKG_USING_IPMSG is not set +# CONFIG_PKG_USING_LSSDP is not set +# CONFIG_PKG_USING_AIRKISS_OPEN is not set +# CONFIG_PKG_USING_LIBRWS is not set +# CONFIG_PKG_USING_TCPSERVER is not set +# CONFIG_PKG_USING_PROTOBUF_C is not set +# CONFIG_PKG_USING_DLT645 is not set +# CONFIG_PKG_USING_QXWZ is not set +# CONFIG_PKG_USING_SMTP_CLIENT is not set +# CONFIG_PKG_USING_ABUP_FOTA is not set +# CONFIG_PKG_USING_LIBCURL2RTT is not set +# CONFIG_PKG_USING_CAPNP is not set +# CONFIG_PKG_USING_AGILE_TELNET is not set +# CONFIG_PKG_USING_NMEALIB is not set +# CONFIG_PKG_USING_PDULIB is not set +# CONFIG_PKG_USING_BTSTACK is not set +# CONFIG_PKG_USING_BT_CYW43012 is not set +# CONFIG_PKG_USING_CYW43XX is not set +# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set +# CONFIG_PKG_USING_WAYZ_IOTKIT is not set +# CONFIG_PKG_USING_MAVLINK is not set +# CONFIG_PKG_USING_BSAL is not set +# CONFIG_PKG_USING_AGILE_MODBUS is not set +# CONFIG_PKG_USING_AGILE_FTP is not set +# CONFIG_PKG_USING_EMBEDDEDPROTO is not set +# CONFIG_PKG_USING_RT_LINK_HW is not set +# CONFIG_PKG_USING_RYANMQTT is not set +# CONFIG_PKG_USING_RYANW5500 is not set +# CONFIG_PKG_USING_LORA_PKT_FWD is not set +# CONFIG_PKG_USING_LORA_GW_DRIVER_LIB is not set +# CONFIG_PKG_USING_LORA_PKT_SNIFFER is not set +# CONFIG_PKG_USING_HM is not set +# CONFIG_PKG_USING_SMALL_MODBUS is not set +# CONFIG_PKG_USING_NET_SERVER is not set +# CONFIG_PKG_USING_ZFTP is not set +# CONFIG_PKG_USING_WOL is not set +# CONFIG_PKG_USING_ZEPHYR_POLLING is not set +# CONFIG_PKG_USING_MATTER_ADAPTATION_LAYER is not set +# CONFIG_PKG_USING_LHC_MODBUS is not set + +# +# security packages +# +# CONFIG_PKG_USING_MBEDTLS is not set +# CONFIG_PKG_USING_LIBSODIUM is not set +# CONFIG_PKG_USING_LIBHYDROGEN is not set +# CONFIG_PKG_USING_TINYCRYPT is not set +# CONFIG_PKG_USING_TFM is not set +# CONFIG_PKG_USING_YD_CRYPTO is not set + +# +# language packages +# + +# +# JSON: JavaScript Object Notation, a lightweight data-interchange format +# +# CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_LJSON is not set +# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set +# CONFIG_PKG_USING_RAPIDJSON is not set +# CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_AGILE_JSMN is not set +# CONFIG_PKG_USING_PARSON is not set + +# +# XML: Extensible Markup Language +# +# CONFIG_PKG_USING_SIMPLE_XML is not set +# CONFIG_PKG_USING_EZXML is not set +# CONFIG_PKG_USING_LUATOS_SOC is not set +# CONFIG_PKG_USING_LUA is not set +# CONFIG_PKG_USING_JERRYSCRIPT is not set +# CONFIG_PKG_USING_MICROPYTHON is not set +# CONFIG_PKG_USING_PIKASCRIPT is not set +# CONFIG_PKG_USING_RTT_RUST is not set + +# +# multimedia packages +# + +# +# LVGL: powerful and easy-to-use embedded GUI library +# +# CONFIG_PKG_USING_LVGL is not set +# CONFIG_PKG_USING_LV_MUSIC_DEMO is not set +# CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set + +# +# u8g2: a monochrome graphic library +# +# CONFIG_PKG_USING_U8G2_OFFICIAL is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set +# CONFIG_PKG_USING_STEMWIN is not set +# CONFIG_PKG_USING_WAVPLAYER is not set +# CONFIG_PKG_USING_TJPGD is not set +# CONFIG_PKG_USING_PDFGEN is not set +# CONFIG_PKG_USING_HELIX is not set +# CONFIG_PKG_USING_AZUREGUIX is not set +# CONFIG_PKG_USING_TOUCHGFX2RTT is not set +# CONFIG_PKG_USING_NUEMWIN is not set +# CONFIG_PKG_USING_MP3PLAYER is not set +# CONFIG_PKG_USING_TINYJPEG is not set +# CONFIG_PKG_USING_UGUI is not set +# CONFIG_PKG_USING_MCURSES is not set +# CONFIG_PKG_USING_TERMBOX is not set +# CONFIG_PKG_USING_VT100 is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_GUIENGINE is not set +# CONFIG_PKG_USING_3GPP_AMRNB is not set + +# +# tools packages +# +# CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set +# CONFIG_PKG_USING_EASYLOGGER is not set +# CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_SEGGER_RTT is not set +# CONFIG_PKG_USING_RTT_AUTO_EXE_CMD is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set +# CONFIG_PKG_USING_LOGMGR is not set +# CONFIG_PKG_USING_ADBD is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_DHRYSTONE is not set +# CONFIG_PKG_USING_MEMORYPERF is not set +# CONFIG_PKG_USING_NR_MICRO_SHELL is not set +# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set +# CONFIG_PKG_USING_LUNAR_CALENDAR is not set +# CONFIG_PKG_USING_BS8116A is not set +# CONFIG_PKG_USING_GPS_RMC is not set +# CONFIG_PKG_USING_URLENCODE is not set +# CONFIG_PKG_USING_UMCN is not set +# CONFIG_PKG_USING_LWRB2RTT is not set +# CONFIG_PKG_USING_CPU_USAGE is not set +# CONFIG_PKG_USING_GBK2UTF8 is not set +# CONFIG_PKG_USING_VCONSOLE is not set +# CONFIG_PKG_USING_KDB is not set +# CONFIG_PKG_USING_WAMR is not set +# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set +# CONFIG_PKG_USING_LWLOG is not set +# CONFIG_PKG_USING_ANV_TRACE is not set +# CONFIG_PKG_USING_ANV_MEMLEAK is not set +# CONFIG_PKG_USING_ANV_TESTSUIT is not set +# CONFIG_PKG_USING_ANV_BENCH is not set +# CONFIG_PKG_USING_DEVMEM is not set +# CONFIG_PKG_USING_REGEX is not set +# CONFIG_PKG_USING_MEM_SANDBOX is not set +# CONFIG_PKG_USING_SOLAR_TERMS is not set +# CONFIG_PKG_USING_GAN_ZHI is not set +# CONFIG_PKG_USING_FDT is not set +# CONFIG_PKG_USING_CBOX is not set +# CONFIG_PKG_USING_SNOWFLAKE is not set +# CONFIG_PKG_USING_HASH_MATCH is not set +# CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set +# CONFIG_PKG_USING_VOFA_PLUS is not set +# CONFIG_PKG_USING_RT_TRACE is not set +# CONFIG_PKG_USING_ZDEBUG is not set + +# +# system packages +# + +# +# enhanced kernel services +# +# CONFIG_PKG_USING_RT_MEMCPY_CM is not set +# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set +# CONFIG_PKG_USING_RT_VSNPRINTF_FULL is not set + +# +# acceleration: Assembly language or algorithmic acceleration packages +# +# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set +# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set +# CONFIG_PKG_USING_QFPLIB_M3 is not set + +# +# CMSIS: ARM Cortex-M Microcontroller Software Interface Standard +# +# CONFIG_PKG_USING_CMSIS_5 is not set +# CONFIG_PKG_USING_CMSIS_CORE is not set +# CONFIG_PKG_USING_CMSIS_DSP is not set +# CONFIG_PKG_USING_CMSIS_NN is not set +# CONFIG_PKG_USING_CMSIS_RTOS1 is not set +# CONFIG_PKG_USING_CMSIS_RTOS2 is not set + +# +# Micrium: Micrium software products porting for RT-Thread +# +# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set +# CONFIG_PKG_USING_UCOSII_WRAPPER is not set +# CONFIG_PKG_USING_UC_CRC is not set +# CONFIG_PKG_USING_UC_CLK is not set +# CONFIG_PKG_USING_UC_COMMON is not set +# CONFIG_PKG_USING_UC_MODBUS is not set +# CONFIG_PKG_USING_FREERTOS_WRAPPER is not set +# CONFIG_PKG_USING_LITEOS_SDK is not set +# CONFIG_PKG_USING_TZ_DATABASE is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_PERF_COUNTER is not set +# CONFIG_PKG_USING_FILEX is not set +# CONFIG_PKG_USING_LEVELX is not set +# CONFIG_PKG_USING_FLASHDB is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_LITTLEFS is not set +# CONFIG_PKG_USING_DFS_JFFS2 is not set +# CONFIG_PKG_USING_DFS_UFFS is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_THREAD_POOL is not set +# CONFIG_PKG_USING_ROBOTS is not set +# CONFIG_PKG_USING_EV is not set +# CONFIG_PKG_USING_SYSWATCH is not set +# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set +# CONFIG_PKG_USING_PLCCORE is not set +# CONFIG_PKG_USING_RAMDISK is not set +# CONFIG_PKG_USING_MININI is not set +# CONFIG_PKG_USING_QBOOT is not set +# CONFIG_PKG_USING_PPOOL is not set +# CONFIG_PKG_USING_OPENAMP is not set +# CONFIG_PKG_USING_RPMSG_LITE is not set +# CONFIG_PKG_USING_LPM is not set +# CONFIG_PKG_USING_TLSF is not set +# CONFIG_PKG_USING_EVENT_RECORDER is not set +# CONFIG_PKG_USING_ARM_2D is not set +# CONFIG_PKG_USING_MCUBOOT is not set +# CONFIG_PKG_USING_TINYUSB is not set +# CONFIG_PKG_USING_CHERRYUSB is not set +# CONFIG_PKG_USING_KMULTI_RTIMER is not set +# CONFIG_PKG_USING_TFDB is not set +# CONFIG_PKG_USING_QPC is not set +# CONFIG_PKG_USING_AGILE_UPGRADE is not set +# CONFIG_PKG_USING_FLASH_BLOB is not set +# CONFIG_PKG_USING_MLIBC is not set +# CONFIG_PKG_USING_TASK_MSG_BUS is not set +# CONFIG_PKG_USING_SFDB is not set +# CONFIG_PKG_USING_RTP is not set +# CONFIG_PKG_USING_REB is not set +# CONFIG_PKG_USING_R_RHEALSTONE is not set + +# +# peripheral libraries and drivers +# + +# +# HAL & SDK Drivers +# + +# +# STM32 HAL & SDK Drivers +# +# CONFIG_PKG_USING_STM32L4XX_HAL_DRIVER is not set +# CONFIG_PKG_USING_STM32WB55_SDK is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_BLUETRUM_SDK is not set +# CONFIG_PKG_USING_EMBARC_BSP is not set +# CONFIG_PKG_USING_ESP_IDF is not set + +# +# Kendryte SDK +# +# CONFIG_PKG_USING_K210_SDK is not set +# CONFIG_PKG_USING_KENDRYTE_SDK is not set +# CONFIG_PKG_USING_NRF5X_SDK is not set +# CONFIG_PKG_USING_NRFX is not set +# CONFIG_PKG_USING_RASPBERRYPI_PICO_SDK is not set + +# +# sensors drivers +# +# CONFIG_PKG_USING_LSM6DSM is not set +# CONFIG_PKG_USING_LSM6DSL is not set +# CONFIG_PKG_USING_LPS22HB is not set +# CONFIG_PKG_USING_HTS221 is not set +# CONFIG_PKG_USING_LSM303AGR is not set +# CONFIG_PKG_USING_BME280 is not set +# CONFIG_PKG_USING_BME680 is not set +# CONFIG_PKG_USING_BMA400 is not set +# CONFIG_PKG_USING_BMI160_BMX160 is not set +# CONFIG_PKG_USING_SPL0601 is not set +# CONFIG_PKG_USING_MS5805 is not set +# CONFIG_PKG_USING_DA270 is not set +# CONFIG_PKG_USING_DF220 is not set +# CONFIG_PKG_USING_HSHCAL001 is not set +# CONFIG_PKG_USING_BH1750 is not set +# CONFIG_PKG_USING_MPU6XXX is not set +# CONFIG_PKG_USING_AHT10 is not set +# CONFIG_PKG_USING_AP3216C is not set +# CONFIG_PKG_USING_TSL4531 is not set +# CONFIG_PKG_USING_DS18B20 is not set +# CONFIG_PKG_USING_DHT11 is not set +# CONFIG_PKG_USING_DHTXX is not set +# CONFIG_PKG_USING_GY271 is not set +# CONFIG_PKG_USING_GP2Y10 is not set +# CONFIG_PKG_USING_SGP30 is not set +# CONFIG_PKG_USING_HDC1000 is not set +# CONFIG_PKG_USING_BMP180 is not set +# CONFIG_PKG_USING_BMP280 is not set +# CONFIG_PKG_USING_SHTC1 is not set +# CONFIG_PKG_USING_BMI088 is not set +# CONFIG_PKG_USING_HMC5883 is not set +# CONFIG_PKG_USING_MAX6675 is not set +# CONFIG_PKG_USING_TMP1075 is not set +# CONFIG_PKG_USING_SR04 is not set +# CONFIG_PKG_USING_CCS811 is not set +# CONFIG_PKG_USING_PMSXX is not set +# CONFIG_PKG_USING_RT3020 is not set +# CONFIG_PKG_USING_MLX90632 is not set +# CONFIG_PKG_USING_MLX90393 is not set +# CONFIG_PKG_USING_MLX90392 is not set +# CONFIG_PKG_USING_MLX90397 is not set +# CONFIG_PKG_USING_MS5611 is not set +# CONFIG_PKG_USING_MAX31865 is not set +# CONFIG_PKG_USING_VL53L0X is not set +# CONFIG_PKG_USING_INA260 is not set +# CONFIG_PKG_USING_MAX30102 is not set +# CONFIG_PKG_USING_INA226 is not set +# CONFIG_PKG_USING_LIS2DH12 is not set +# CONFIG_PKG_USING_HS300X is not set +# CONFIG_PKG_USING_ZMOD4410 is not set +# CONFIG_PKG_USING_ISL29035 is not set +# CONFIG_PKG_USING_MMC3680KJ is not set +# CONFIG_PKG_USING_QMP6989 is not set +# CONFIG_PKG_USING_BALANCE is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_SHT3X is not set +# CONFIG_PKG_USING_SHT4X is not set +# CONFIG_PKG_USING_AD7746 is not set +# CONFIG_PKG_USING_ADT74XX is not set +# CONFIG_PKG_USING_MAX17048 is not set +# CONFIG_PKG_USING_AS7341 is not set +# CONFIG_PKG_USING_CW2015 is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_PAJ7620 is not set +# CONFIG_PKG_USING_STHS34PF80 is not set + +# +# touch drivers +# +# CONFIG_PKG_USING_GT9147 is not set +# CONFIG_PKG_USING_GT1151 is not set +# CONFIG_PKG_USING_GT917S is not set +# CONFIG_PKG_USING_GT911 is not set +# CONFIG_PKG_USING_FT6206 is not set +# CONFIG_PKG_USING_FT5426 is not set +# CONFIG_PKG_USING_FT6236 is not set +# CONFIG_PKG_USING_XPT2046_TOUCH is not set +# CONFIG_PKG_USING_CST816X is not set +# CONFIG_PKG_USING_CST812T is not set +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_SX12XX is not set +# CONFIG_PKG_USING_SIGNAL_LED is not set +# CONFIG_PKG_USING_LEDBLINK is not set +# CONFIG_PKG_USING_LITTLED is not set +# CONFIG_PKG_USING_LKDGUI is not set +# CONFIG_PKG_USING_WM_LIBRARIES is not set +# CONFIG_PKG_USING_INFRARED is not set +# CONFIG_PKG_USING_MULTI_INFRARED is not set +# CONFIG_PKG_USING_AGILE_BUTTON is not set +# CONFIG_PKG_USING_AGILE_LED is not set +# CONFIG_PKG_USING_AT24CXX is not set +# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set +# CONFIG_PKG_USING_PCA9685 is not set +# CONFIG_PKG_USING_ILI9341 is not set +# CONFIG_PKG_USING_I2C_TOOLS is not set +# CONFIG_PKG_USING_NRF24L01 is not set +# CONFIG_PKG_USING_RPLIDAR is not set +# CONFIG_PKG_USING_AS608 is not set +# CONFIG_PKG_USING_RC522 is not set +# CONFIG_PKG_USING_WS2812B is not set +# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set +# CONFIG_PKG_USING_MULTI_RTIMER is not set +# CONFIG_PKG_USING_MAX7219 is not set +# CONFIG_PKG_USING_BEEP is not set +# CONFIG_PKG_USING_EASYBLINK is not set +# CONFIG_PKG_USING_PMS_SERIES is not set +# CONFIG_PKG_USING_CAN_YMODEM is not set +# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set +# CONFIG_PKG_USING_QLED is not set +# CONFIG_PKG_USING_AGILE_CONSOLE is not set +# CONFIG_PKG_USING_LD3320 is not set +# CONFIG_PKG_USING_WK2124 is not set +# CONFIG_PKG_USING_LY68L6400 is not set +# CONFIG_PKG_USING_DM9051 is not set +# CONFIG_PKG_USING_SSD1306 is not set +# CONFIG_PKG_USING_QKEY is not set +# CONFIG_PKG_USING_RS485 is not set +# CONFIG_PKG_USING_RS232 is not set +# CONFIG_PKG_USING_NES is not set +# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set +# CONFIG_PKG_USING_VDEVICE is not set +# CONFIG_PKG_USING_SGM706 is not set +# CONFIG_PKG_USING_RDA58XX is not set +# CONFIG_PKG_USING_LIBNFC is not set +# CONFIG_PKG_USING_MFOC is not set +# CONFIG_PKG_USING_TMC51XX is not set +# CONFIG_PKG_USING_TCA9534 is not set +# CONFIG_PKG_USING_KOBUKI is not set +# CONFIG_PKG_USING_ROSSERIAL is not set +# CONFIG_PKG_USING_MICRO_ROS is not set +# CONFIG_PKG_USING_MCP23008 is not set +# CONFIG_PKG_USING_MISAKA_AT24CXX is not set +# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set +# CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set +# CONFIG_PKG_USING_SOFT_SERIAL is not set +# CONFIG_PKG_USING_MB85RS16 is not set +# CONFIG_PKG_USING_RFM300 is not set +# CONFIG_PKG_USING_IO_INPUT_FILTER is not set +# CONFIG_PKG_USING_LRF_NV7LIDAR is not set +# CONFIG_PKG_USING_AIP650 is not set +# CONFIG_PKG_USING_FINGERPRINT is not set +# CONFIG_PKG_USING_BT_ECB02C is not set +# CONFIG_PKG_USING_UAT is not set +# CONFIG_PKG_USING_ST7789 is not set +# CONFIG_PKG_USING_VS1003 is not set +# CONFIG_PKG_USING_X9555 is not set +# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set +# CONFIG_PKG_USING_BT_MX01 is not set +# CONFIG_PKG_USING_RGPOWER is not set +# CONFIG_PKG_USING_SPI_TOOLS is not set + +# +# AI packages +# +# CONFIG_PKG_USING_LIBANN is not set +# CONFIG_PKG_USING_NNOM is not set +# CONFIG_PKG_USING_ONNX_BACKEND is not set +# CONFIG_PKG_USING_ONNX_PARSER is not set +# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set +# CONFIG_PKG_USING_ELAPACK is not set +# CONFIG_PKG_USING_ULAPACK is not set +# CONFIG_PKG_USING_QUEST is not set +# CONFIG_PKG_USING_NAXOS is not set +# CONFIG_PKG_USING_R_TINYMAIX is not set + +# +# Signal Processing and Control Algorithm Packages +# +# CONFIG_PKG_USING_FIRE_PID_CURVE is not set +# CONFIG_PKG_USING_QPID is not set +# CONFIG_PKG_USING_UKAL is not set +# CONFIG_PKG_USING_DIGITALCTRL is not set +# CONFIG_PKG_USING_KISSFFT is not set + +# +# miscellaneous packages +# + +# +# project laboratory +# + +# +# samples: kernel and components samples +# +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set + +# +# entertainment: terminal games and other interesting software packages +# +# CONFIG_PKG_USING_CMATRIX is not set +# CONFIG_PKG_USING_SL is not set +# CONFIG_PKG_USING_CAL is not set +# CONFIG_PKG_USING_ACLOCK is not set +# CONFIG_PKG_USING_THREES is not set +# CONFIG_PKG_USING_2048 is not set +# CONFIG_PKG_USING_SNAKE is not set +# CONFIG_PKG_USING_TETRIS is not set +# CONFIG_PKG_USING_DONUT is not set +# CONFIG_PKG_USING_COWSAY is not set +# CONFIG_PKG_USING_MORSE is not set +# CONFIG_PKG_USING_TINYSQUARE is not set +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set +# CONFIG_PKG_USING_FASTLZ is not set +# CONFIG_PKG_USING_MINILZO is not set +# CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_LZMA is not set +# CONFIG_PKG_USING_RALARAM is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_MINIZIP is not set +# CONFIG_PKG_USING_HEATSHRINK is not set +# CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set +# CONFIG_PKG_USING_KENDRYTE_DEMO is not set +# CONFIG_PKG_USING_UPACKER is not set +# CONFIG_PKG_USING_UPARAM is not set +# CONFIG_PKG_USING_HELLO is not set +# CONFIG_PKG_USING_VI is not set +# CONFIG_PKG_USING_KI is not set +# CONFIG_PKG_USING_ARMv7M_DWT is not set +# CONFIG_PKG_USING_CRCLIB is not set +# CONFIG_PKG_USING_LWGPS is not set +# CONFIG_PKG_USING_STATE_MACHINE is not set +# CONFIG_PKG_USING_DESIGN_PATTERN is not set +# CONFIG_PKG_USING_CONTROLLER is not set +# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set +# CONFIG_PKG_USING_MFBD is not set +# CONFIG_PKG_USING_SLCAN2RTT is not set +# CONFIG_PKG_USING_SOEM is not set +# CONFIG_PKG_USING_QPARAM is not set +# CONFIG_PKG_USING_CorevMCU_CLI is not set + +# +# Arduino libraries +# +# CONFIG_PKG_USING_RTDUINO is not set + +# +# Projects and Demos +# +# CONFIG_PKG_USING_ARDUINO_MSGQ_C_CPP_DEMO is not set +# CONFIG_PKG_USING_ARDUINO_SKETCH_LOADER_DEMO is not set +# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set +# CONFIG_PKG_USING_ARDUINO_NINEINONE_SENSOR_SHIELD is not set +# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set +# CONFIG_PKG_USING_ARDUINO_MATLAB_SUPPORT is not set + +# +# Sensors +# +# CONFIG_PKG_USING_ARDUINO_SENSOR_DEVICE_DRIVERS is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SENSOR is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SENSORLAB is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL375 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VL53L0X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VL53L1X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VL6180X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX31855 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX31865 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX31856 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX6675 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90614 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM9DS1 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AHTX0 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM9DS0 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP280 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADT7410 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP085 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BME680 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP9808 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP4728 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_INA219 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LTR390 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL345 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DHT is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP9600 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM6DS is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO055 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX1704X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MMC56X3 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90393 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90395 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ICM20X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DPS310 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HTS221 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT4X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT31 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL343 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BME280 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AS726X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AMG88XX is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AM2320 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AM2315 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LTR329_LTR303 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP085_UNIFIED is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP183 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP183_UNIFIED is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP3XX is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MS8607 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS3MDL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90640 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MMA8451 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MSA301 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPL115A2 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO08X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO08X_RVC is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS2MDL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM303DLH_MAG is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LC709203F is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_CAP1188 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_CCS811 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_NAU7802 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS331 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LPS2X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LPS35HW is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM303_ACCEL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS3DH is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCF8591 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPL3115A2 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPR121 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPRLS is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPU6050 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCT2075 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PM25AQI is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_EMC2101 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_FXAS21002C is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SCD30 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_FXOS8700 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HMC5883_UNIFIED is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SGP30 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TMP006 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TLA202X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TCS34725 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI7021 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI1145 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SGP40 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHTC3 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HDC1000 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HTU21DF is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AS7341 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HTU31D is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_INA260 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TMP007_LIBRARY is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_L3GD20 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TMP117 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TSC2007 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TSL2561 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TSL2591_LIBRARY is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VCNL4040 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VEML6070 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VEML6075 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VEML7700 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LIS3DHTR is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_DHT is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_ADXL335 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_ADXL345 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BME280 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BMP280 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_H3LIS331DL is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_MMA7660 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_TSL2561 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_PAJ7620 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_VL53L0X is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_ITG3200 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_SHT31 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HP20X is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_DRV2605L is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BBM150 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HMC5883L is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LSM303DLH is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_TCS3414CS is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_MP503 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BMP085 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HIGHTEMP is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_VEML6070 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_SI1145 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_SHT35 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_AT42QT1070 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LSM6DS3 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HDC1000 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HM3301 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_MCP9600 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LTC2941 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LDC1612 is not set +# CONFIG_PKG_USING_ARDUINO_CAPACITIVESENSOR is not set +# CONFIG_PKG_USING_ARDUINO_JARZEBSKI_MPU6050 is not set + +# +# Display +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set +# CONFIG_PKG_USING_ARDUINO_U8G2 is not set +# CONFIG_PKG_USING_ARDUINO_TFT_ESPI is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set +# CONFIG_PKG_USING_SEEED_TM1637 is not set + +# +# Timing +# +# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set +# CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set +# CONFIG_PKG_USING_ARDUINO_TICKER is not set +# CONFIG_PKG_USING_ARDUINO_TASKSCHEDULER is not set + +# +# Data Processing +# +# CONFIG_PKG_USING_ARDUINO_KALMANFILTER is not set +# CONFIG_PKG_USING_ARDUINO_ARDUINOJSON is not set +# CONFIG_PKG_USING_ARDUINO_TENSORFLOW_LITE_MICRO is not set +# CONFIG_PKG_USING_ARDUINO_RUNNINGMEDIAN is not set + +# +# Data Storage +# + +# +# Communication +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PN532 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI4713 is not set + +# +# Device Control +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCF8574 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCA9685 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TPA2016 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DRV2605 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DS1841 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DS3502 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_PCF85063TP is not set + +# +# Other +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set + +# +# Signal IO +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BUSIO is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TCA8418 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP23017 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADS1X15 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AW9523 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP3008 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP4725 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BD3491FS is not set + +# +# Uncategorized +# +CONFIG_SOC_FAMILY_HT32=y +CONFIG_SOC_SERIES_HT32F1=y + +# +# Hardware Drivers Config +# +CONFIG_SOC_HT32F12366=y + +# +# Onboard Peripheral Drivers +# + +# +# On-chip Peripheral Drivers +# +CONFIG_BSP_USING_GPIO=y +CONFIG_BSP_USING_UART=y +CONFIG_BSP_USING_USART0=y +# CONFIG_BSP_USING_USART1 is not set +# CONFIG_BSP_USING_UART0 is not set +# CONFIG_BSP_USING_UART1 is not set +# CONFIG_BSP_USING_SPI is not set +# CONFIG_BSP_USING_I2C is not set + +# +# Board extended module Drivers +# diff --git a/bsp/ht32/ht32f12366/Kconfig b/bsp/ht32/ht32f12366/Kconfig new file mode 100644 index 0000000000..7a400db91f --- /dev/null +++ b/bsp/ht32/ht32f12366/Kconfig @@ -0,0 +1,22 @@ +mainmenu "RT-Thread Configuration" + +config BSP_DIR + string + option env="BSP_ROOT" + default "." + +config RTT_DIR + string + option env="RTT_ROOT" + default "../../.." + +config PKGS_DIR + string + option env="PKGS_ROOT" + default "packages" + +source "$RTT_DIR/Kconfig" +source "$PKGS_DIR/Kconfig" +source "../libraries/Kconfig" +source "board/Kconfig" + diff --git a/bsp/ht32/ht32f12366/README.md b/bsp/ht32/ht32f12366/README.md new file mode 100644 index 0000000000..04de7527d7 --- /dev/null +++ b/bsp/ht32/ht32f12366/README.md @@ -0,0 +1,107 @@ +# HT32F12366 BSP 说明 + +## 简介 + +ESK32-30105是合泰基于HT32F12366芯片并针对Cortex®-M3入门而设计的评估板。本文档是为ESK32-30105开发板提供的BSP(板级支持包)说明。 + +主要内容如下: + +- 开发板资源介绍 +- BSP 快速上手 +- 进阶使用方法 + +通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。 + +## 开发板介绍 + +ESK32-30105使用32位ARM® Cortex®-M3高性能、低功耗单片机HT32F12366,针对Cortex®-M3入门而设计。开发板外观如下图所示: + +![board.png](figures/board.png) + +该开发板常用 **板载资源** 如下: + +- MCU:HT32F12366,主频 96MHz,256KB FLASH ,128KB SRAM +- 常用外设 + - LED:2个,(绿色,PE0、PD15) +- 常用接口:USB 转串口 、USB SLAVE +- 调试接口:板载的 e-Link32 Lite SWD 下载 + +开发板更多详细信息请参考合泰官网的相关文档 [ESK32-30105](https://www.holtek.com.cn/page/detail/dev_kit/ESK32-30105)。 + +## 外设支持 + +本 BSP 目前对外设的支持情况如下: + +| **板载外设** | **支持情况** | **备注** | +| :--- | :---: | :--- | +| USB 转串口 | 支持 | 使用 USART0 | +| **片上外设** | **支持情况** | **备注** | +| GPIO | 支持 | PA0, PA1...PE15 ---> PIN: 0, 1...79 | +| USART | 支持 | USART0/1 | +| UART | 支持 | UART0/1 | +| SPI | 支持 | SPI0/1 | +| I2C | 支持 | 硬件 I2C0/1 | +| ADC | 暂不支持 | | +| WDT | 暂不支持 | | + +## 使用说明 + +使用说明分为如下两个章节: + +- 快速上手 + + 本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。 + +- 进阶使用 + + 本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多片上资源,实现更多高级功能。 + +### 快速上手 + +本 BSP 为仅为开发者提供MDK5的工程。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。 + +#### 硬件连接 + +使用数据线通过板载的 e-Link32 Lite将芯片连接到 PC。 + +#### 编译下载 + +双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。 + +> 注:工程默认配置使用CMSIS-DAP下载方式,在通过 e-Link32 Lite 连接开发板的基础上,点击下载按钮即可下载程序到开发板。 + +#### 运行结果 + +下载程序成功之后,系统会自动运行,观察开发板上 LED 的运行效果,LED1和LED2交替闪烁。 + +连接开发板对应串口到 PC(也可以通过e-Link32 Lite的模拟串口将开发板连接到PC), 在终端工具里调整好串口配置(115200-8-1-N)并打开相应的串口,复位设备后,可以看到 RT-Thread 的输出信息: + +> 注:由于RT-Thread的finsh控制台使用的是命令行的输入形式,推荐使用串口调试工具如:Tabby terminal 或者 Tera Term。 + +```bash + \ | / +- RT - Thread Operating System + / | \ 5.1.0 build Apr 10 2024 14:39:43 + 2006 - 2024 Copyright by RT-Thread team +msh > +``` + +### 进阶使用 + +此 BSP 默认只开启了 GPIO 和 USART0 的功能,如果需使用更多的片上资源,需要利用 ENV 工具对BSP 进行配置,步骤如下: + +1. 在 bsp 下打开 env 工具。 + +2. 输入`menuconfig`命令配置工程,配置好之后保存退出。 + +3. 输入`scons --target=mdk5` 命令重新生成工程。 + +## 注意事项 + +开发板和芯片的相关资料可以在[合泰官网](https://www.holtek.com.cn/page/index)进行查找和下载,如芯片的数据手册和开发使用手册、开发板的原理图、Keil_v5的pack安装包等。 + +## 联系人信息 + +维护人: + +- [QT-one](https://github.com/QT-one) \ No newline at end of file diff --git a/bsp/ht32/ht32f12366/SConscript b/bsp/ht32/ht32f12366/SConscript new file mode 100644 index 0000000000..682f94215c --- /dev/null +++ b/bsp/ht32/ht32f12366/SConscript @@ -0,0 +1,15 @@ +# for module compiling +import os #包含os库 +Import('RTT_ROOT') #导入RTT_ROOT对象(RTT_ROOT代表的是RT-Thread源码包) +from building import * #把building模块的所有内容都导入到当前模块中 + +cwd = GetCurrentDir() #获取当前路径,并将该路径信息保存到变量cwd中 +objs = [] #创建一个list型变量objs +list = os.listdir(cwd) #得到当前目录下的所有子目录,并保存到变量list中 + +for d in list: #for循环用d记录循环的次数,直到寻遍所有路径 + path = os.path.join(cwd, d) #根据d获取到不同的路径 + if os.path.isfile(os.path.join(path, 'SConscript')): #如果该路径下存在名为SConscript的文件 + objs = objs + SConscript(os.path.join(d, 'SConscript')) #将路径中SConscript文件内的源码读取到objs中 + +Return('objs') #将objs返回出去 diff --git a/bsp/ht32/ht32f12366/SConstruct b/bsp/ht32/ht32f12366/SConstruct new file mode 100644 index 0000000000..5fcd0e3860 --- /dev/null +++ b/bsp/ht32/ht32f12366/SConstruct @@ -0,0 +1,60 @@ +import os +import sys +import rtconfig + +if os.getenv('RTT_ROOT'): + RTT_ROOT = os.getenv('RTT_ROOT') +else: + RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') + +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +try: + from building import * +except: + print('Cannot found RT-Thread root directory, please check RTT_ROOT') + print(RTT_ROOT) + exit(-1) + +TARGET = 'rt-thread.' + rtconfig.TARGET_EXT + +DefaultEnvironment(tools=[]) +env = Environment(tools = ['mingw'], + AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, + CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, + AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, + LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) +env.PrependENVPath('PATH', rtconfig.EXEC_PATH) + +if rtconfig.PLATFORM == 'iar': + env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES']) + env.Replace(ARFLAGS = ['']) + env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map') + +Export('RTT_ROOT') +Export('rtconfig') + +SDK_ROOT = os.path.abspath('./') + +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) + +ht32_library = 'HT32_STD_1xxxx_FWLib' +rtconfig.BSP_LIBRARY_TYPE = ht32_library + +# include libraries +objs.extend(SConscript(os.path.join(libraries_path_prefix, ht32_library, 'SConscript'))) + +# include drivers +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'ht32_drivers', 'SConscript'))) + +# make a building +DoBuilding(TARGET, objs) diff --git a/bsp/ht32/ht32f12366/applications/SConscript b/bsp/ht32/ht32f12366/applications/SConscript new file mode 100644 index 0000000000..9023be657a --- /dev/null +++ b/bsp/ht32/ht32f12366/applications/SConscript @@ -0,0 +1,21 @@ +#导入其他模块的变量 +Import('RTT_ROOT') +Import('rtconfig') + +#导入使用到的模块 +from building import * + +#获取当前目录的路径 +cwd = GetCurrentDir() + +#创建一个列表,用于保存需要使用到的C文件路径 +src = Glob('*c') + +#创建一个列表,用于保存需要包含的H文件路径 +path = [cwd] + +#创建一个组别 +group = DefineGroup('Applications', src, depend = [''], CPPPATH = path) + +#返回创建好的组别 +Return('group') \ No newline at end of file diff --git a/bsp/ht32/ht32f12366/applications/main.c b/bsp/ht32/ht32f12366/applications/main.c new file mode 100644 index 0000000000..6df261c71b --- /dev/null +++ b/bsp/ht32/ht32f12366/applications/main.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include +#include +#include "board.h" + +/* defined the led2 pin: pd15 */ +#define LED1_PIN GET_PIN(D, 15) +/* defined the led3 pin: pe0 */ +#define LED2_PIN GET_PIN(E, 0) + +int main(void) +{ + rt_uint32_t speed = 200; + /* set led1 pin mode to output */ + rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT); + /* set led2 pin mode to output */ + rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT); + + while (1) + { + rt_pin_write(LED1_PIN, PIN_LOW); + rt_pin_write(LED2_PIN, PIN_HIGH); + rt_thread_mdelay(speed); + rt_pin_write(LED1_PIN, PIN_HIGH); + rt_pin_write(LED2_PIN, PIN_LOW); + rt_thread_mdelay(speed); + } +} diff --git a/bsp/ht32/ht32f12366/board/Kconfig b/bsp/ht32/ht32f12366/board/Kconfig new file mode 100644 index 0000000000..3ee604b7be --- /dev/null +++ b/bsp/ht32/ht32f12366/board/Kconfig @@ -0,0 +1,77 @@ +menu "Hardware Drivers Config" + +config SOC_HT32F12366 + bool + select SOC_SERIES_HT32F1 + select RT_USING_COMPONENTS_INIT + select RT_USING_USER_MAIN + default y + +menu "Onboard Peripheral Drivers" + +endmenu + +menu "On-chip Peripheral Drivers" + + config BSP_USING_GPIO + bool "Enable GPIO" + select RT_USING_PIN + default n + +    menuconfig BSP_USING_UART + bool "Enable UART" + default n + select RT_USING_SERIAL + if BSP_USING_UART + config BSP_USING_USART0 + bool "Enable USART0" + default n + + config BSP_USING_USART1 + bool "Enable USART1" + default n + + config BSP_USING_UART0 + bool "Enable UART0" + default n + + config BSP_USING_UART1 + bool "Enable UART1" + default n +        endif + + menuconfig BSP_USING_SPI + bool "Enable SPI Bus" + default n + select RT_USING_SPI + if BSP_USING_SPI + config BSP_USING_SPI0 + bool "Enable SPI0 Bus" + default n + + config BSP_USING_SPI1 + bool "Enable SPI1 Bus" + default n  + endif + + menuconfig BSP_USING_I2C + bool "Enable I2C Bus" + default n + select RT_USING_I2C + if BSP_USING_I2C + config BSP_USING_I2C0 + bool "Enable I2C0 Bus" + default n + + config BSP_USING_I2C1 + bool "Enable I2C1 Bus" + default n + endif + +endmenu + +menu "Board extended module Drivers" + +endmenu + +endmenu diff --git a/bsp/ht32/ht32f12366/board/SConscript b/bsp/ht32/ht32f12366/board/SConscript new file mode 100644 index 0000000000..ba173ea968 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/SConscript @@ -0,0 +1,27 @@ + +import os +import rtconfig +from building import * + +Import('SDK_LIB') + +cwd = GetCurrentDir() + +src = Glob('src/*.c') + +startup_path_prefix = SDK_LIB +if rtconfig.CROSS_TOOL == 'gcc': + src += [startup_path_prefix + '/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_01.s'] +elif rtconfig.CROSS_TOOL == 'keil': + src += [startup_path_prefix + '/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_01.s'] +elif rtconfig.CROSS_TOOL == 'iar': + src += [startup_path_prefix + '/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_01.s'] + +path = [cwd] +path = [cwd + '/inc'] + +CPPDEFINES = ['USE_HT32F12366_SK, USE_HT32F12365_66, USE_MEM_HT32F12366'] + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) + +Return('group') \ No newline at end of file diff --git a/bsp/ht32/ht32f12366/board/inc/board.h b/bsp/ht32/ht32f12366/board/inc/board.h new file mode 100644 index 0000000000..91d5c2d0a5 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/inc/board.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __BOARD_H__ +#define __BOARD_H__ + +#include +#include "ht32.h" +#include "ht32_msp.h" + +#ifdef BSP_USING_GPIO + #include "drv_gpio.h" +#endif + +#ifdef BSP_USING_UART + #include "drv_usart.h" +#endif + +#ifdef BSP_USING_SPI + #include "drv_spi.h" +#endif + +#ifdef BSP_USING_I2C + #include "drv_i2c.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* whether use board external SRAM memory */ +#define HT32_EXT_SRAM 0 +#define HT32_EXT_SRAM_BEGIN 0x68000000 +#define HT32_EXT_SRAM_END (HT32_EXT_SRAM_BEGIN + HT32_EXT_SRAM*1024) + +/* internal sram memory size */ +#define HT32_SRAM_END (0x20000000 + LIBCFG_RAM_SIZE) + +#ifdef __CC_ARM +extern int Image$$RW_IRAM1$$ZI$$Limit; +#define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit) +#elif __ICCARM__ +#pragma section="HEAP" +#define HEAP_BEGIN (__segment_end("HEAP")) +#else +extern int __bss_end; +#define HEAP_BEGIN ((void *)&__bss_end) +#endif +#define HEAP_END HT32_SRAM_END + +void rt_hw_board_clock_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __BOARD_H__ */ diff --git a/bsp/ht32/ht32f12366/board/inc/ht32_msp.h b/bsp/ht32/ht32f12366/board/inc/ht32_msp.h new file mode 100644 index 0000000000..8d05995146 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/inc/ht32_msp.h @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __HT32_MSP_H__ +#define __HT32_MSP_H__ + +#include +#include "ht32.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* UART gpio */ +#ifdef BSP_USING_UART +#ifdef BSP_USING_USART0 + + #define HTCFG_USART0_IPN USART0 + + #define _HTCFG_USART0_TX_GPIOX A + #define _HTCFG_USART0_TX_GPION 8 + #define _HTCFG_USART0_RX_GPIOX A + #define _HTCFG_USART0_RX_GPION 10 + + #define HTCFG_USART0_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART0_TX_GPIOX) + #define HTCFG_USART0_TX_GPIO_CLK STRCAT2(P, _HTCFG_USART0_TX_GPIOX) + #define HTCFG_USART0_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART0_TX_GPIOX) + #define HTCFG_USART0_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART0_TX_GPION) + + #define HTCFG_USART0_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART0_RX_GPIOX) + #define HTCFG_USART0_RX_GPIO_CLK STRCAT2(P, _HTCFG_USART0_RX_GPIOX) + #define HTCFG_USART0_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART0_RX_GPIOX) + #define HTCFG_USART0_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART0_RX_GPION) + +#endif +#ifdef BSP_USING_USART1 + + #define HTCFG_USART1_IPN USART1 + + #define _HTCFG_USART1_TX_GPIOX A + #define _HTCFG_USART1_TX_GPION 4 + #define _HTCFG_USART1_RX_GPIOX A + #define _HTCFG_USART1_RX_GPION 5 + + #define HTCFG_USART1_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART1_TX_GPIOX) + #define HTCFG_USART1_TX_GPIO_CLK STRCAT2(P, _HTCFG_USART1_TX_GPIOX) + #define HTCFG_USART1_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART1_TX_GPIOX) + #define HTCFG_USART1_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART1_TX_GPION) + + #define HTCFG_USART1_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART1_RX_GPIOX) + #define HTCFG_USART1_RX_GPIO_CLK STRCAT2(P, _HTCFG_USART1_RX_GPIOX) + #define HTCFG_USART1_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART1_RX_GPIOX) + #define HTCFG_USART1_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART1_RX_GPION) + +#endif +#ifdef BSP_USING_UART0 + + #define HTCFG_UART0_IPN UART0 + + #define _HTCFG_UART0_TX_GPIOX C + #define _HTCFG_UART0_TX_GPION 9 + #define _HTCFG_UART0_RX_GPIOX C + #define _HTCFG_UART0_RX_GPION 10 + + #define HTCFG_UART0_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART0_TX_GPIOX) + #define HTCFG_UART0_TX_GPIO_CLK STRCAT2(P, _HTCFG_UART0_TX_GPIOX) + #define HTCFG_UART0_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART0_TX_GPIOX) + #define HTCFG_UART0_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART0_TX_GPION) + + #define HTCFG_UART0_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART0_RX_GPIOX) + #define HTCFG_UART0_RX_GPIO_CLK STRCAT2(P, _HTCFG_UART0_RX_GPIOX) + #define HTCFG_UART0_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART0_RX_GPIOX) + #define HTCFG_UART0_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART0_RX_GPION) + +#endif +#ifdef BSP_USING_UART1 + + #define HTCFG_UART1_IPN UART1 + + #define _HTCFG_UART1_TX_GPIOX C + #define _HTCFG_UART1_TX_GPION 2 + #define _HTCFG_UART1_RX_GPIOX C + #define _HTCFG_UART1_RX_GPION 3 + + #define HTCFG_UART1_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART1_TX_GPIOX) + #define HTCFG_UART1_TX_GPIO_CLK STRCAT2(P, _HTCFG_UART1_TX_GPIOX) + #define HTCFG_UART1_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART1_TX_GPIOX) + #define HTCFG_UART1_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART1_TX_GPION) + + #define HTCFG_UART1_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART1_RX_GPIOX) + #define HTCFG_UART1_RX_GPIO_CLK STRCAT2(P, _HTCFG_UART1_RX_GPIOX) + #define HTCFG_UART1_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART1_RX_GPIOX) + #define HTCFG_UART1_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART1_RX_GPION) + +#endif +#endif + +/* SPI gpio */ +#ifdef BSP_USING_SPI +#ifdef BSP_USING_SPI0 + + #define HTCFG_SPI0_IPN SPI0 + + #define _HTCFG_SPI0_SCK_GPIOX B + #define _HTCFG_SPI0_SCK_GPION 3 + + #define _HTCFG_SPI0_MISO_GPIOX B + #define _HTCFG_SPI0_MISO_GPION 5 + + #define _HTCFG_SPI0_MOSI_GPIOX B + #define _HTCFG_SPI0_MOSI_GPION 4 + + #define HTCFG_SPI0_SCK_GPIO_CLK STRCAT2(P, _HTCFG_SPI0_SCK_GPIOX) + #define HTCFG_SPI0_SCK_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI0_SCK_GPIOX) + #define HTCFG_SPI0_SCK_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI0_SCK_GPION) + + #define HTCFG_SPI0_MISO_GPIO_CLK STRCAT2(P, _HTCFG_SPI0_MISO_GPIOX) + #define HTCFG_SPI0_MISO_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI0_MISO_GPIOX) + #define HTCFG_SPI0_MISO_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI0_MISO_GPION) + + #define HTCFG_SPI0_MOSI_GPIO_CLK STRCAT2(P, _HTCFG_SPI0_MOSI_GPIOX) + #define HTCFG_SPI0_MOSI_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI0_MOSI_GPIOX) + #define HTCFG_SPI0_MOSI_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI0_MOSI_GPION) + +#endif +#ifdef BSP_USING_SPI1 + + #define HTCFG_SPI1_IPN SPI1 + + #define _HTCFG_SPI1_SCK_GPIOX B + #define _HTCFG_SPI1_SCK_GPION 7 + + #define _HTCFG_SPI1_MISO_GPIOX B + #define _HTCFG_SPI1_MISO_GPION 9 + + #define _HTCFG_SPI1_MOSI_GPIOX B + #define _HTCFG_SPI1_MOSI_GPION 8 + + #define HTCFG_SPI1_SCK_GPIO_CLK STRCAT2(P, _HTCFG_SPI1_SCK_GPIOX) + #define HTCFG_SPI1_SCK_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI1_SCK_GPIOX) + #define HTCFG_SPI1_SCK_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI1_SCK_GPION) + + #define HTCFG_SPI1_MISO_GPIO_CLK STRCAT2(P, _HTCFG_SPI1_MISO_GPIOX) + #define HTCFG_SPI1_MISO_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI1_MISO_GPIOX) + #define HTCFG_SPI1_MISO_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI1_MISO_GPION) + + #define HTCFG_SPI1_MOSI_GPIO_CLK STRCAT2(P, _HTCFG_SPI1_MOSI_GPIOX) + #define HTCFG_SPI1_MOSI_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI1_MOSI_GPIOX) + #define HTCFG_SPI1_MOSI_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI1_MOSI_GPION) + +#endif +#endif + +/* I2C gpio */ +#ifdef BSP_USING_I2C +#ifdef BSP_USING_I2C0 + + #define HTCFG_I2C0_IPN I2C0 + + #define _HTCFG_I2C0_SCL_GPIOX B + #define _HTCFG_I2C0_SCL_GPION 12 + + #define _HTCFG_I2C0_SDA_GPIOX B + #define _HTCFG_I2C0_SDA_GPION 13 + + #define HTCFG_I2C0_SCL_GPIO_CLK STRCAT2(P, _HTCFG_I2C0_SCL_GPIOX) + #define HTCFG_I2C0_SCL_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C0_SCL_GPIOX) + #define HTCFG_I2C0_SCL_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C0_SCL_GPION) + + #define HTCFG_I2C0_SDA_GPIO_CLK STRCAT2(P, _HTCFG_I2C0_SDA_GPIOX) + #define HTCFG_I2C0_SDA_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C0_SDA_GPIOX) + #define HTCFG_I2C0_SDA_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C0_SDA_GPION) + +#endif +#ifdef BSP_USING_I2C1 + + #define HTCFG_I2C1_IPN I2C1 + + #define _HTCFG_I2C1_SCL_GPIOX A + #define _HTCFG_I2C1_SCL_GPION 0 + + #define _HTCFG_I2C1_SDA_GPIOX A + #define _HTCFG_I2C1_SDA_GPION 1 + + #define HTCFG_I2C1_SCL_GPIO_CLK STRCAT2(P, _HTCFG_I2C1_SCL_GPIOX) + #define HTCFG_I2C1_SCL_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C1_SCL_GPIOX) + #define HTCFG_I2C1_SCL_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C1_SCL_GPION) + + #define HTCFG_I2C1_SDA_GPIO_CLK STRCAT2(P, _HTCFG_I2C1_SDA_GPIOX) + #define HTCFG_I2C1_SDA_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C1_SDA_GPIOX) + #define HTCFG_I2C1_SDA_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C1_SDA_GPION) + +#endif +#endif + +void ht32_usart_gpio_init(void *instance); +void ht32_spi_gpio_init(void *instance); +void ht32_i2c_gpio_init(void *instance); + +#ifdef __cplusplus +} +#endif + +#endif /* __HT32_MSP_H__ */ diff --git a/bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_01_usbdconf.h b/bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_01_usbdconf.h new file mode 100644 index 0000000000..432b323d7a --- /dev/null +++ b/bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_01_usbdconf.h @@ -0,0 +1,453 @@ +/*********************************************************************************************************//** + * @file IP/Example/ht32f1xxxx_01_usbdconf.h + * @version $Rev:: 1090 $ + * @date $Date:: 2018-01-29 #$ + * @brief The configuration file of USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_01_USBDCONF_H +#define __HT32F1XXXX_01_USBDCONF_H + +// Enter Low Power mode when Suspended +#define USBDCORE_ENABLE_LOW_POWER (0) +// + +#if (USBDCORE_ENABLE_LOW_POWER == 1) + #define USBDCore_LowPower() PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_WFE) +#else + #define USBDCore_LowPower(...) +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Interrupt Enable */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Interrupt Setting (UIER) +// USB Global Interrupt Enable (UGIE) (Default) +// Start Of Frame Interrupt Enable (SOFIE) +// USB Reset Interrupt Enable (URSTIE) (Default) +// Resume Interrupt Enable (RSMIE) (Default) +// Suspend Interrupt Enable (SUSPIE) (Default) +// Expected Start of Frame Interrupt Enable (ESOFE) +// Control Endpoint Interrupt Enable (EP0IE) (Default) +// Endpoint1 Interrupt Enable (EP1IE) +// Endpoint2 Interrupt Enable (EP2IE) +// Endpoint3 Interrupt Enable (EP3IE) +// Endpoint4 Interrupt Enable (EP4IE) +// Endpoint5 Interrupt Enable (EP5IE) +// Endpoint6 Interrupt Enable (EP6IE) +// Endpoint7 Interrupt Enable (EP7IE) +#define _UIER (0x011D) +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Control Endpoint0 Configuration +// Endpoint Buffer Length (EPLEN) +// <8=> 8 bytes +// <16=> 16 bytes +// <32=> 32 bytes +// <64=> 64 bytes + /* Maximum: 64 Bytes */ +#define _EP0LEN (64) + + +// Control Endpoint0 Interrupt Enable Settings (EP0IER) +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) (Default) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) (Default) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +// SETUP Token Packet Received Interrupt Enable (STRXIE) +// SETUP Data Packet Received Interrupt Enable (SDRXIE) (Default) +// SETUP Data Error Interrupt Enable (SDERIE) +// Zero Length Data Packet Received Interrupt Enable (ZLRXIE) +#define _EP0_IER (0x212) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint1 Configuration +#define _EP1_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP1_CFG_EPADR (1) + +// Endpoint Enable (EPEN) +#define _EP1_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP1_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP1_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP1LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP1_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint2 Configuration +#define _EP2_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP2_CFG_EPADR (2) + +// Endpoint Enable (EPEN) +#define _EP2_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP2_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP2_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP2LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP2_IER (0x002) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint3 Configuration +#define _EP3_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP3_CFG_EPADR (3) + +// Endpoint Enable (EPEN) +#define _EP3_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP3_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP3_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP3LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP3_IER (0x10) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint4 Configuration +#define _EP4_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP4_CFG_EPADR (4) + +// Endpoint Enable (EPEN) +#define _EP4_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP4_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP4_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP4LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP4_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP4_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint5 Configuration +#define _EP5_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP5_CFG_EPADR (5) + +// Endpoint Enable (EPEN) +#define _EP5_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP5_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP5_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP5LEN_TMP (8) + + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP5_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP5_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint6 Configuration +#define _EP6_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP6_CFG_EPADR (6) + +// Endpoint Enable (EPEN) +#define _EP6_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP6_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP6_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP6LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP6_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP6_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint7 Configuration +#define _EP7_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP7_CFG_EPADR (7) + +// Endpoint Enable (EPEN) +#define _EP7_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP7_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP7_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP7LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP7_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP7_IER (0x10) +// +// + +#endif diff --git a/bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_conf.h b/bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_conf.h new file mode 100644 index 0000000000..1128790b11 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/inc/ht32f1xxxx_conf.h @@ -0,0 +1,490 @@ +/*********************************************************************************************************//** + * @file IP/Example/ht32f1xxxx_conf.h + * @version $Rev:: 2922 $ + * @date $Date:: 2023-06-07 #$ + * @brief Library configuration file. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +//-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_CONF_H +#define __HT32F1XXXX_CONF_H + +/* Exported constants --------------------------------------------------------------------------------------*/ + +#define RETARGET_ITM 0 +#define RETARGET_USB 1 +#define RETARGET_SYSLOG 2 +#define RETARGET_COM1 10 +#define RETARGET_COM2 11 +#define RETARGET_USART0 12 +#define RETARGET_USART1 13 +#define RETARGET_UART0 14 +#define RETARGET_UART1 15 + + +/* Retarget settings of the C standard I/O library functions (printf, scanf, getchar, ...etc.) */ +/* +// Enable Retarget +// Retarget Port +// <0=> ITM +// <1=> USB Virtual COM +// <2=> Syslog +// <10=> COM1 +// <11=> COM2 +// <12=> USART0 +// <13=> USART1 +// <14=> UART0 +// <15=> UART1 +// Enable Auto Return +// Auto Return function adds "\r" before "\n" automatically when print message by Retarget. +*/ +#define _RETARGET 1 +#define RETARGET_PORT 10 +#define _AUTO_RETURN 0 + +#ifndef AUTO_RETURN +#if (_AUTO_RETURN == 1) +#define AUTO_RETURN +#endif +#endif + +/* Enable Interrupt Mode for UxART Retarget +// Retarget COM/UxART Setting +// UxART Baudrate +// Enable Interrupt Mode for UxART Tx Retarget +// Define UxARTn_IRQHandler By Retarget (ht32_serial.c) +// Disable (RETARGET_DEFINE_HANDLER = 0) if application already have UxARTn_IRQHandler. +// RETARGET_UART_IRQHandler() shall be called by UxARTn_IRQHandler when disable. +// Tx Buffer Length (in byte) +// +*/ +#define RETARGET_UxART_BAUDRATE 115200 +#define RETARGET_INT_MODE 0 +#define RETARGET_DEFINE_HANDLER 1 +#define RETARGET_INT_BUFFER_SIZE 64 + +#if (_RETARGET == 1) +#if (RETARGET_PORT == RETARGET_ITM) +#elif (RETARGET_PORT == RETARGET_USB) + #define RETARGET_IS_USB +// Retarget USB Virtual COM Setting +// Communication (Interrupt IN) +// <1=> Endpoint 1 +// <2=> Endpoint 2 +// <3=> Endpoint 3 +// <4=> Endpoint 4 +// <5=> Endpoint 5 +// <6=> Endpoint 6 +// <7=> Endpoint 7 +// Data Rx (Bulk OUT) +// <1=> Endpoint 1 +// <2=> Endpoint 2 +// <3=> Endpoint 3 +// <4=> Endpoint 4 +// <5=> Endpoint 5 +// <6=> Endpoint 6 +// <7=> Endpoint 7 +// Data Tx (Bulk IN) +// <1=> Endpoint 1 +// <2=> Endpoint 2 +// <3=> Endpoint 3 +// <4=> Endpoint 4 +// <5=> Endpoint 5 +// <6=> Endpoint 6 +// <7=> Endpoint 7 +// Communication Endpoint Buffer Length (in byte) <4-64:4> +// Data Rx Endpoint Buffer Length (in byte) <4-64:4> +// Data Tx Endpoint Buffer Length (in byte) <4-64:4> +// Rx Buffer Length (in byte) <64-1024:4> +// Tx Buffer Length (in byte) <1-63:1> +// Please use "SERIAL_Flush()" to sent out the buffer data immediately when Tx Buffer Length > 1. +// USB Tx Mode (BULK IN) +// <0=> Block Mode (Wait until both USB and terminal software are ready) +// <1=> Non-Block Mode (Drop data if USB or terminal software is not ready) +// Enable HSI Auto Trim By USB Function +// Need turn on if the USB clock source is from HSI (PLL USBPLL clock Source). + #define RETARGET_CTRL_EPT (5) + #define RETARGET_RX_EPT (6) + #define RETARGET_TX_EPT (7) + #define RETARGET_CTRL_EPTLEN (8) + #define RETARGET_RX_EPTLEN (64) + #define RETARGET_TX_EPTLEN (64) + #define RETARGET_BUFFER_SIZE (64) + #define RETARGET_TXBUFFER_SIZE (1) // Use "SERIAL_Flush()" to sent out the buffer data immediately when Tx Buffer Length > 1. + #define RETARGET_USB_MODE (0) + #define RETARGET_HSI_ATM (1) +// +#elif (RETARGET_PORT == RETARGET_COM1) + #define RETARGET_COM_PORT COM1 + #define RETARGET_USART_PORT COM1_PORT + #define RETARGET_UART_IRQn COM1_IRQn + #define RETARGET_UART_IRQHandler COM1_IRQHandler + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_COM2) + #define RETARGET_COM_PORT COM2 + #define RETARGET_USART_PORT COM2_PORT + #define RETARGET_UART_IRQn COM2_IRQn + #define RETARGET_UART_IRQHandler COM2_IRQHandler + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_USART0) + #define RETARGET_UxART_IPN USART0 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_USART1) + #define RETARGET_UxART_IPN USART1 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_UART0) + #define RETARGET_UxART_IPN UART0 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_UART1) + #define RETARGET_UxART_IPN UART1 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#endif + extern void RETARGET_Configuration(void); +#else + #define RETARGET_Configuration(...) + #undef printf + #undef getchar + #define printf(...) + #define getchar() (0) +#endif + +#if (RETARGET_DEFINE_HANDLER == 0) +#undef RETARGET_UART_IRQHandler +#endif + +/* +// Enable HT32 Time Function +// Provide "Time_GetTick()" and "Time_Dealy()" functions. + +// Timer Selection +// <0=> BFTM0 +// <1=> BFTM1 +// <2=> SCTM0 +// <3=> SCTM1 +// <4=> SCTM2 +// <5=> SCTM3 +// <6=> PWM0 +// <7=> PWM1 +// <8=> PWM2 +// <9=> GPTM0 +// <10=> GPTM1 +// <11=> MCTM0 + +// Timer Clock Setting +// +// Timer Clock = (Core Clock) / (APB Peripheral Clock Prescaler) +// HTCFG_TIME_CLKSRC = _HTCFG_TIME_CORECLK / (2^HTCFG_TIME_PCLK_DIV) +// _HTCFG_TIME_CORECLK = LIBCFG_MAX_SPEED or HTCFG_TIME_CLK_MANUAL (selected by HTCFG_TIME_CLKSEL) + +// -- Core Clock Setting (CK_AHB) +// HTCFG_TIME_CLKSEL +// 0 = Default Maximum (LIBCFG_MAX_SPEED) +// 1 = Manual Input (HTCFG_TIME_CLK_MANUAL) +// <0=> Default Maximum (LIBCFG_MAX_SPEED) +// <1=> Manual Input (HTCFG_TIME_CLK_MANUAL) + +// -- Core Clock Manual Input (Hz) +// HTCFG_TIME_CLK_MANUAL +// Only meaningful when Core Clock Setting (HTCFG_TIME_CLKSEL) = Manual Input (1) + +// -- APB Peripheral Clock Prescaler +// HTCFG_TIME_PCLK_DIV +// <0=> /1 +// <1=> /2 +// <2=> /4 +// <3=> /8 + +// Time Tick (Hz, not applicable for BFTM) <1-1000000:100> +// Not applicable for BFTM, fixed TICKHZ to HTCFG_TIME_CLKSRC for BFTM. +*/ +#if (0) // Enable HT32 Time Function +#define HTCFG_TIME_IPSEL (0) +#define HTCFG_TIME_CLKSEL (0) // 0 = Default Maximum (LIBCFG_MAX_SPEED), 1 = Manual Input (HTCFG_TIME_CLKSRC) +#define HTCFG_TIME_CLK_MANUAL (20000000) // Only meaningful when HTCFG_TIME_CLKSEL = 1 (Manual Input) +#define HTCFG_TIME_PCLK_DIV (0) // 0 ~ 3. (/1, /2, /4, /8) +#define HTCFG_TIME_TICKHZ (1000) // Hz, not applicable for BFTM, fixed TICKHZ to HTCFG_TIME_CLKSRC for BFTM +#define HTCFG_TIME_MULTIPLE (1) // MUST be 1, 2, 4, 8. TICK = COUNT / MULTIPLE. Not applicable for BFTM. +/* + + Timer Clock = (Core Clock) / (APB Peripheral Clock Prescaler) + HTCFG_TIME_CLKSRC = (_HTCFG_TIME_CORECLK) / (2^HTCFG_TIME_PCLK_DIV) + where _HTCFG_TIME_CORECLK can be LIBCFG_MAX_SPEED or HTCFG_TIME_CLK_MANUAL (selected by HTCFG_TIME_CLKSEL) + + Tick Range: 0 ~ 2^32 / HTCFG_TIME_TICKHZ (maximum tick time) + Interrupt Time: _HTCFG_TIME_OVERFLOW_VALUE / (HTCFG_TIME_TICKHZ * HTCFG_TIME_MULTIPLE) Second + (Interrupt Time is not applicable for BFTM) + + Example: 32-bit BFTM with 48 MHz Timer Clock + HTCFG_TIME_TICKHZ = HTCFG_TIME_CLKSRC = 48000000 + Tick Range: 0 ~ 2^32 / 48000000 = 0 ~ 89.478485 Second (maximum tick time, return to 0 every 89.478485 Second) + BFTM do not use interrupt + + Example: 16-bit GPTM with 1 ms tick + HTCFG_TIME_TICKHZ = 1000 (Hz) + HTCFG_TIME_MULTIPLE = 1 (1 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 1000 = 0 ~ 4294967 Second = 0 ~ 49.7 Day (maximum tick time, return to 0 every 49.7 Day) + Interrupt Time: 65536 / (1000 * 1) = 65.536 Second (Trigger interrupt every 65.536 Second) +*/ +#endif +/* +// +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f1xxxx_conf.h" file (this file). +*/ +/* +// Enable User Define HSE Value +// Enable user define HSE value to overwrite default "HSE_VALUE" define in "ht32fxxxxx_nn.h". +// HSE Value (Hz) +*/ +#if (0) +#define HSE_VALUE 16000000 +#endif +/* +// +*/ + +/* +// Enable CKOUT Function +*/ +#define ENABLE_CKOUT 0 + + +/* The DEBUG definition to enter debug mode for library */ +/* +// Library Debug Mode +*/ +#define HT32_LIB_DEBUG 0 + + +/* Enable/disable the specific peripheral inclusion */ + +// Library Inclusion Configuration +/* ADC -----------------------------------------------------------------------------------------------------*/ +/* +// ADC Library +*/ +#define _ADC 1 + +/* AES -----------------------------------------------------------------------------------------------------*/ +/* +// AES Library +*/ +#define _AES 1 + +/* BFTM ----------------------------------------------------------------------------------------------------*/ +/* +// BFTM Library +*/ +#define _BFTM 1 + +/* Clock Control -------------------------------------------------------------------------------------------*/ +/* +// Clock Control Library +*/ +#define _CKCU 1 + +/* Comparator/OPA ------------------------------------------------------------------------------------------*/ +/* +// Comparator/OPA Library +*/ +#define _CMP_OPA 1 + +/* Comparator ----------------------------------------------------------------------------------------------*/ +/* +// Comparator Library +*/ +#define _CMP 1 + +/* CRC -----------------------------------------------------------------------------------------------------*/ +/* +// CRC Library +*/ +#define _CRC 1 + +/* CSIF ----------------------------------------------------------------------------------------------------*/ +/* +// CSIF Library +*/ +#define _CSIF 1 + +/* EBI -----------------------------------------------------------------------------------------------------*/ +/* +// EBI Library +*/ +#define _EBI 1 + +/* EXTI ----------------------------------------------------------------------------------------------------*/ +/* +// EXTI Library +*/ +#define _EXTI 1 + +/* Flash ---------------------------------------------------------------------------------------------------*/ +/* +// Flash Library +*/ +#define _FLASH 1 + +/* GPIO ----------------------------------------------------------------------------------------------------*/ +/* +// GPIO Library +*/ +#define _GPIO 1 + +/* GPTM ----------------------------------------------------------------------------------------------------*/ +/* +// GPTM Library +*/ +#define _GPTM 1 + +/* I2C -----------------------------------------------------------------------------------------------------*/ +/* +// I2C Library +*/ +#define _I2C 1 + +/* I2S -----------------------------------------------------------------------------------------------------*/ +/* +// I2S Library +*/ +#define _I2S 1 + +/* MCTM ----------------------------------------------------------------------------------------------------*/ +/* +// MCTM Library +*/ +#define _MCTM 1 + +/* PDMA ----------------------------------------------------------------------------------------------------*/ +/* +// PDMA Library +*/ +#define _PDMA 1 + +/* PWM -----------------------------------------------------------------------------------------------------*/ +/* +// PWM Library +*/ +#define _PWM 1 + +/* PWRCU ---------------------------------------------------------------------------------------------------*/ +/* +// PWRCU Library +*/ +#define _PWRCU 1 + +/* RSTCU ---------------------------------------------------------------------------------------------------*/ +/* +// RSTCU Library +*/ +#define _RSTCU 1 + +/* RTC -----------------------------------------------------------------------------------------------------*/ +/* +// RTC Library +*/ +#define _RTC 1 + +/* SCI -----------------------------------------------------------------------------------------------------*/ +/* +// SCI Library +*/ +#define _SCI 1 + +/* SCTM ----------------------------------------------------------------------------------------------------*/ +/* +// SCTM Library +*/ +#define _SCTM 1 + +/* SDIO ----------------------------------------------------------------------------------------------------*/ +/* +// SDIO Library +*/ +#define _SDIO 1 + +/* SPI -----------------------------------------------------------------------------------------------------*/ +/* +// SPI Library +*/ +#define _SPI 1 + +/* USART ---------------------------------------------------------------------------------------------------*/ +/* +// USART/UART Library +*/ +#define _USART 1 + +/* USBD ----------------------------------------------------------------------------------------------------*/ +/* +// USB Library +*/ +#define _USB 1 + +/* WDT -----------------------------------------------------------------------------------------------------*/ +/* +// WDT Library +*/ +#define _WDT 1 + +/* Misc ----------------------------------------------------------------------------------------------------*/ +/* +// Misc Library +*/ +#define _MISC 1 + +/* Serial --------------------------------------------------------------------------------------------------*/ +/* +// Serial Library +*/ +#define _SERIAL 1 + +/* Software Random Number ----------------------------------------------------------------------------------*/ +/* +// Software Random Number Library +*/ +#define _SWRAND 1 + + +// + +#endif diff --git a/bsp/ht32/ht32f12366/board/linker_scripts/link.icf b/bsp/ht32/ht32f12366/board/linker_scripts/link.icf new file mode 100644 index 0000000000..65c2bfc8b7 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/linker_scripts/link.icf @@ -0,0 +1,28 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x08000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x08000000; +define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF; +define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM_end__ = 0x20017FFF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x0400; +define symbol __ICFEDIT_size_heap__ = 0x0000; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_region { readonly }; +place in RAM_region { readwrite, last block CSTACK}; \ No newline at end of file diff --git a/bsp/ht32/ht32f12366/board/linker_scripts/link.lds b/bsp/ht32/ht32f12366/board/linker_scripts/link.lds new file mode 100644 index 0000000000..27269dd77e --- /dev/null +++ b/bsp/ht32/ht32f12366/board/linker_scripts/link.lds @@ -0,0 +1,156 @@ +/* + * linker script for AT32 with GNU ld + */ + +/* Program Entry, set to mark it as "used" and avoid gc */ +MEMORY +{ + ROM (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */ + RAM (rw) : ORIGIN = 0x20000000, LENGTH = 96k /* 96K sram */ +} +ENTRY(Reset_Handler) +_system_stack_size = 0x200; + +SECTIONS +{ + .text : + { + . = ALIGN(4); + _stext = .; + KEEP(*(.isr_vector)) /* Startup code */ + + . = ALIGN(4); + *(.text) /* remaining code */ + *(.text.*) /* remaining code */ + *(.rodata) /* read-only data (constants) */ + *(.rodata*) + *(.glue_7) + *(.glue_7t) + *(.gnu.linkonce.t*) + + /* section information for finsh shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + + /* section information for initial. */ + . = ALIGN(4); + __rt_init_start = .; + KEEP(*(SORT(.rti_fn*))) + __rt_init_end = .; + + . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + + _etext = .; + } > ROM = 0 + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + + /* This is used by the startup in order to initialize the .data secion */ + _sidata = .; + } > ROM + __exidx_end = .; + + /* .data section which is used for initialized data */ + + .data : AT (_sidata) + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _sdata = . ; + + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _edata = . ; + } >RAM + + .stack : + { + . = ALIGN(4); + _sstack = .; + . = . + _system_stack_size; + . = ALIGN(4); + _estack = .; + } >RAM + + __bss_start = .; + .bss : + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; + + *(.bss) + *(.bss.*) + *(COMMON) + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _ebss = . ; + + *(.bss.init) + } > RAM + __bss_end = .; + + _end = .; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to the beginning + * of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} diff --git a/bsp/ht32/ht32f12366/board/linker_scripts/link.sct b/bsp/ht32/ht32f12366/board/linker_scripts/link.sct new file mode 100644 index 0000000000..16cced4f77 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/linker_scripts/link.sct @@ -0,0 +1,15 @@ +; ************************************************************* +; *** Scatter-Loading Description File generated by uVision *** +; ************************************************************* + +LR_IROM1 0x00000000 0x0003FC00 { ; load region size_region + ER_IROM1 0x00000000 0x0003FC00 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + RW_IRAM1 0x20000000 0x00020000 { ; RW data + .ANY (+RW +ZI) + } +} + diff --git a/bsp/ht32/ht32f12366/board/src/board.c b/bsp/ht32/ht32f12366/board/src/board.c new file mode 100644 index 0000000000..e0160468e9 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/src/board.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include "board.h" + +/* This feature will initialize the HT32 chip clock */ +void rt_hw_board_clock_init(void) +{ + +} diff --git a/bsp/ht32/ht32f12366/board/src/ht32_msp.c b/bsp/ht32/ht32f12366/board/src/ht32_msp.c new file mode 100644 index 0000000000..4ef7b61b54 --- /dev/null +++ b/bsp/ht32/ht32f12366/board/src/ht32_msp.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include "ht32_msp.h" + +/* GPIO configuration for UART */ +#ifdef BSP_USING_UART +void ht32_usart_gpio_init(void *instance) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + HT_USART_TypeDef *usart_x = (HT_USART_TypeDef *)instance; +#ifdef BSP_USING_USART0 + if(HT_USART0 == usart_x) + { + CKCUClock.Bit.HTCFG_USART0_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_USART0_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_USART0_RX_GPIO_PORT,HTCFG_USART0_RX_GPIO_PIN,GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_USART0_TX_GPIO_ID,HTCFG_USART0_TX_GPIO_PIN,AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_USART0_RX_GPIO_ID,HTCFG_USART0_RX_GPIO_PIN,AFIO_FUN_USART_UART); + } +#endif +#ifdef BSP_USING_USART1 + if(HT_USART1 == usart_x) + { + CKCUClock.Bit.HTCFG_USART1_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_USART1_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_USART1_RX_GPIO_PORT,HTCFG_USART1_RX_GPIO_PIN,GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_USART1_TX_GPIO_ID,HTCFG_USART1_TX_GPIO_PIN,AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_USART1_RX_GPIO_ID,HTCFG_USART1_RX_GPIO_PIN,AFIO_FUN_USART_UART); + } +#endif +#ifdef BSP_USING_UART0 + if(HT_UART0 == usart_x) + { + CKCUClock.Bit.HTCFG_UART0_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_UART0_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_UART0_RX_GPIO_PORT,HTCFG_UART0_RX_GPIO_PIN,GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_UART0_TX_GPIO_ID,HTCFG_UART0_TX_GPIO_PIN,AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_UART0_RX_GPIO_ID,HTCFG_UART0_RX_GPIO_PIN,AFIO_FUN_USART_UART); + } +#endif +#ifdef BSP_USING_UART1 + if(HT_UART1 == usart_x) + { + CKCUClock.Bit.HTCFG_UART1_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_UART1_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_UART1_RX_GPIO_PORT,HTCFG_UART1_RX_GPIO_PIN,GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_UART1_TX_GPIO_ID,HTCFG_UART1_TX_GPIO_PIN,AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_UART1_RX_GPIO_ID,HTCFG_UART1_RX_GPIO_PIN,AFIO_FUN_USART_UART); + } +#endif +} +#endif + +/* GPIO configuration for SPI */ +#ifdef BSP_USING_SPI +void ht32_spi_gpio_init(void *instance) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + HT_SPI_TypeDef *spi_x = (HT_SPI_TypeDef *)instance; +#ifdef BSP_USING_SPI0 + if(HT_SPI0 == spi_x) + { + CKCUClock.Bit.HTCFG_SPI0_SCK_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI0_MISO_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI0_MOSI_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + + AFIO_GPxConfig(HTCFG_SPI0_SCK_GPIO_ID, HTCFG_SPI0_SCK_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI0_MISO_GPIO_ID, HTCFG_SPI0_MISO_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI0_MOSI_GPIO_ID, HTCFG_SPI0_MOSI_GPIO_PIN, AFIO_FUN_SPI); + } +#endif +#ifdef BSP_USING_SPI1 + if(HT_SPI1 == spi_x) + { + CKCUClock.Bit.HTCFG_SPI1_SCK_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI1_MISO_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI1_MOSI_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + + AFIO_GPxConfig(HTCFG_SPI1_SCK_GPIO_ID, HTCFG_SPI1_SCK_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI1_MISO_GPIO_ID, HTCFG_SPI1_MISO_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI1_MOSI_GPIO_ID, HTCFG_SPI1_MOSI_GPIO_PIN, AFIO_FUN_SPI); + } +#endif +} +#endif + +/* GPIO configuration for I2C */ +#ifdef BSP_USING_I2C +void ht32_i2c_gpio_init(void *instance) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + HT_I2C_TypeDef *i2c_x = (HT_I2C_TypeDef *)instance; +#ifdef BSP_USING_I2C0 + if(HT_I2C0 == i2c_x) + { + CKCUClock.Bit.HTCFG_I2C0_SCL_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_I2C0_SDA_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + /* Configure GPIO to I2C mode */ + AFIO_GPxConfig(HTCFG_I2C0_SCL_GPIO_ID,HTCFG_I2C0_SCL_GPIO_PIN,AFIO_FUN_I2C); + AFIO_GPxConfig(HTCFG_I2C0_SDA_GPIO_ID,HTCFG_I2C0_SDA_GPIO_PIN,AFIO_FUN_I2C); + } +#endif +#ifdef BSP_USING_I2C1 + if(HT_I2C1 == i2c_x) + { + CKCUClock.Bit.HTCFG_I2C1_SCL_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_I2C1_SDA_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock,ENABLE); + /* Configure GPIO to I2C mode */ + AFIO_GPxConfig(HTCFG_I2C1_SCL_GPIO_ID,HTCFG_I2C1_SCL_GPIO_PIN,AFIO_FUN_I2C); + AFIO_GPxConfig(HTCFG_I2C1_SDA_GPIO_ID,HTCFG_I2C1_SDA_GPIO_PIN,AFIO_FUN_I2C); + } +#endif +} +#endif diff --git a/bsp/ht32/ht32f12366/figures/board.png b/bsp/ht32/ht32f12366/figures/board.png new file mode 100644 index 0000000000000000000000000000000000000000..850221d1afab2e10ae37e5b0e2cb956132eb4fef GIT binary patch literal 420464 zcmV(~K+nI4P)OSe-xf6G0XLHi7R;z##N?-+&%_D<|_QwVz+a!Z|@7Y)nV`B{11l!19 zz<}YIXk>!G2uVDIKmutM7p=rftIct8xbdX!s^1@XR@$VM@X!6noVn+8_o=S#%2kI{ z6~9(fD3pl01BvMAj#E8ZX94)v17HCP05~$;lTM;f^m&R$WnN^R1^}lh%hD1HSbc7z zP{B|oW);`{U)2K)A`7+Fmg4ff001&f6a+z0q-E)XAaG6q4-l9vn<%zL$JhD>ilV61 zYHZD~vE-8@@V{~F)7gt7eU6~7dsTo=HvIn&%%_}006x|3{CIEX^6lE62mBQzN_o_rhtde=}ip&*dmSsT{GJ|12;=MPFo(i6jv8GVweo_e*%pJO6Y2pw~ikA~sD zy&Z?olZhE7K-Cj1aPSj11pu)EdTOrvl*E73%*W0{3!RR7D&1W;8j@4f>C>YBr^CgM zk^@h=$4Ad|stNT3W^uCl=!pxTl=*ch>Ha-#35>_l$^hE!W*A3o11fTBqacdCck}h> z(vgS+Ob`T0h@u3dwWQkD*XMlc zRVOB|E+!V!A zodF_(J{5&OHPM~~5AG{-5qzmy0z39X~NBvX+Kbii2r1Oaaljw0wOHt%R zh{7ZYV&_Uj))-VPef7p%5+&`lDIzAY)&$-;B12@#GK->UU|_H;OYgn+zAQ^3ELt>d z!=PTD2VksSwrXu0$5}Q%d1!2O@zT6-CWr*e%yFgX2t-GV>*Hnelm4V*`acbI^q8^7 zg`cDi%h)9JTPS{&ED`r|pnA<_sNk zIe9xZGEaE)G~qbn4mkQn$G+}(*?3et0kD&tfn%He7YXF?VG0ExdIHqPL2{Cx$ISP{ zqL_b8i}-2wJn`+SdI}WL5wUi%XWh&3^!}vs|5UpAlW^cCJAy|`;Nzy^V`LAXh!!F` zg%jl@O!SEx$Fn-21)HCa7)_6_F*2-7AZrMvZ{73Y{S#yJhxQy;wsghiS3IXuspe&# zby91sb1pB7N?a8YRhMR9W@9MJG9pSUmC_Y?no$(zWueMjAKLP(hwssjHtSfYRF-Aj z8_E$i-uu!pAK^z3@5KWE8!!hT2s|l>NJLbXiHPjc7*_QVQYElwwm53zj?oSlRGyOv zpT}`^!u^vv^A=`0VJD7LVik|S4#49|=~F9)N5AxlTC}ibU1OMllRJ`62H450sxBx` zeWDij=%~Yfl*~Bx=1KdUx*ff!W9}bAcgIs25gliT9o=JLZ+;yG=}GCoYs+=_O~p;l z%{My5Tz%dKL1+{2y+AuzCL#=YCCi9Rz|62`IaiJ7e-%SKhM+O`wNf_m>BrQo9r3Tf+QHe6Q90W|tBnVV<@kCG+1fh*MP!+Gz z6}f6y#1X=PI1a+VgpM<$zU4#Udgw8!ZFNp$!ZS8&&lJhKK-R z7$rfdD)1si3OE%KRq;$g5QWyVk-{5d@gfVvX^aU2GGqaOjEVrF1cs803=4w& zY{AShF;kbt2?;B!G2Xj?*jj6d*@#jXC{%kZX{)`gw{pShr{fqZU7+(_V-x>*|Mt+b zHHg@jr8CCZ(5e^boIs5+aTtYxVF-H#piExHD-mhPCW)-I)+m95nJux16rw~FM-;LN z*boKGT&h!e2ob4Oqj3GznvHGgMAb7}RV9cG0`DA?WrIo(Rg;L1;sK{{1f0tLpR2d- z*>&))Umg0@-swkXn%>6VWsP=j$*5%)MtQw8npAR<@yt^ztFQh2tC<&U>BpJ5s@}Kr@aOM5fTB<@L_L& zS(X%pN+pq1=SaLnOokPNLYY~dhZ716RKcE<#g`xg1yB&PN(l%o!xgZ$%j@9nkwyLEn0ptmem_XpadiB8}$rH&$-^ z$ok_vY6K{7?<14fe&IfsGqIo$PcS|sQouTpva*!q1>P`)%EDxo3kOm%#7aV>0xHQ1 z8ITD`RRuzrV*iHrcEF38feE;+3%&F+WC5C>n|;Jq+PQn;jA zT{pVu+zpj;*Dt%^w8iU}4~0yRySk2(i^tIaf{F#q&DFpB(_h}XeR=}%Y|=a1v$C}) z3Zf9|oL4QSC$v_JTx{VfB`v&)gxy^<#z^k901<(l28KGSr9s;+4|FcJN9&D#(RdB;sn!R z>54VARe7Tz7{S4ZwbiB#=gASj&6wVkEMUit-mW9h3VI`TLKRh(JxKitZ7XXUV zMBy8s`>a8G|93WTowa>4ohH&YNFh#Ft)sIp)zqRngP@AoVC&7#I(_9!e)EcUqiLhi zdi4Y!(k*vBc=vRq$r^M@CM)P_41^-kD8^i>?e?Y5vah~)+2tDtM;BE^oB`dwqxp@W z9KQ9TX1l{!7Gtni@BTNO`)o|?L0+e4yj%}V!4lX2AT}x<>QO+wkRb>_N~WSFK8F18vUA?}jSsx@c^il0^#kEI@1FdVf83?RedJ3CBV?+DgBI!)qDWY(A#6cp zR2Z7US`8y42JJe;Kr19(oktLncx43yu2dU9N`RmOB~&d{Sc5=Xf~-U*N5HD26d`L> z5}P$dq7YP29$-<3`2w!QfYIqTa)&sp4D_e12)78$gClSb5tPj0JA?5r9&G`F=rs5OEILTpi0yH9zN+5w%SW%fVas@JnIGLWO?)tQ1(=*jLx2cP2akre zFqWtDdT1aHIRl;os|pVw4LEla8h8akVaci5K<5ed0yab#Ax$NUKne#y5VAT3N=2s1 zfFsY!M5^i>NY!T)#cC4GbMhtBgOx(B$NTcj=sf*=ZuB2#b>gd!s16`VOIrAwQQFMjhYCJwZfzxA5`xqS6npE*?(;n0Lm z#^3qsXTJIQXI=Y?z2Cm0i6jC$(p>jGid|pDn&+Z2j7|%7fW?@xN3$I!jKX?jmclsk zW`1_+;61;>X|JGGp=n2%p@c91IT*%{gUc5e*Zs`}ue^9UfE}&+!}W=oPI>lV?SEX> z_qt~f?-(k(IscKJkV7|M)E%cRV(E_2tW7 ze(BP0{$%RzU1RTl)!7lzcYZeYf$#3g`$&uO`bMkkBk0{VtAXoC9I--`8atI-_2n0Dpm@Nwmutn|> zv3j5bATWh`qsjq@X}Y;#B@K-F&3DhBwiHZ^qi4T4y`SYz91`Pt9i5VENh^H*H*TZ5w`X`1);_LhZLRU266)n}b3O5)yL^->fC z!+P+AdL_g!0b8h`pH zf4VrbD66Oqf}rqp#@RZy9S`1!jW0p62s33|uYcq(UwhuU>-X>5BR=o6>f~_NGhf7i z`}t2iGy}7k3a?T`qk}ZRGpntj$;NLzr}y*kI)B+<@_}0(_}a|}4;)DI0%EGk|M=zo_imlj;n=S1S+q_MPmC#V(ubz0R@F`mhEXVBshO({ zVL;xgDnbiUq@F90m0DhSWFDnQ?$K5<7Sevhm5aarqiw!yefMwAcV(``eoo{M`I+Uzm(Md*hNty`TKvgIo>Y^86)1r+)oikN(ALF1>m8%r4xol+ep}VEFSof8nKv@Bh6Ezl6kTSpu4+GT_aYW08b^kt4 zNi*r-ie%!aNYg-^b`P@`m=Z$pq9IUMbp0Hx%BHJS!mtv71VUg1tA-Xm6+Ls% z%`g4(_a6D-&%S%z+b(#+l^1l~h6J)l)+hkqxOvMr?m95A>HPm!&t|7Qxd0NdvC{Nt zTI61Hr)-gWga&|+!W;6UmV_KMK+#ncNtvJmQICQg)b`+TedB5FCx3tOXn*k9kNo`l z?;XaHK|-biQc-xY0ULM+1>i}vs~bSQD#MikLmVu_11d0ph_n=>nh9V$ya|KjHmke7 z(u>ba^2O@Y*Z=Sb-;;wWkDO6%A5VtLH$Crys2Y1!*3vl_#@bg)hWi&~h34(~u2(XM ztg*Hz3L8egbWBP_S(f!Bao1umToDDKK+3#u5GGrx#OkwhSt1>2E>}RvEmu%7~cBB@RAp0o`Bi?bBE?0n%KBv?Wz^e zII!=LiJ8t_kL^o+D~uaOJ{x+;OD(fBTDbvj($3ghUiXY;gUK8J?cT5a^Iq*4(x@L% zgm571+<&mX^19Eu>uO*%R9>RQzDB;5gu6_BE ztDb#sWUJFt6J9#;lHsh~6Ltprdc(pOvj=CtdfP+an+djUDW~hR-~aG$E?>Rmmd|W^ z-f6W;Uj_4>bI*@I^S>{;=#1elvz@nnYs+JM=jwAAlb*J*??q=1z2-S*y!JUu-u8)y zKKr$US?CX%0a|pGZl4BNn<FIac|&v*Pv z55Mr)XFuos)8`9Uwlbtby(f*M3BW3boQ1T-E2NvlDo{r15PB+g;_g{l@sbgU zsnR3+4}Iy!+fO^=!mk}_&CLmEr~o=DErnVX0vjMNVF4#lf+G^ZkQxFJJVO;s-~g@! z2k=T#KvjbTbLq;_){P&zw71{wn9siXo@XaLcm3N}4(sT0SkcnJ2)Ux`(u1)iUH>f; zyh_&rZoq&6bb-~uyCeMAfE6V*JL;Vrm&Dq=P1m1&eqT@R ztTWe7+r20z+15k~Py{t}aPL_cto+-*{?i}abp5?sw+yc|U;NU)cq&g@v9#8kOx4r* z$yU3OwwtZfRac+&ycfLk>gQj)>CM;Od*?l~NEk`nY-9ko-ajQ2qNfc{C^MKs;b?9O z{rzLRao58WXFO-HXZ^+a##hSvEE;C1KV&X^ez~tX)nea1e8Dp}T>hKS@zQ}i%aDPT zFleO?KooEg_wCKU^4;&v)+Z}(|HMy!|HWs%XFlROk)59Azug-qC~9h0Yc%32qlODnJ9303K7GG>J%biK#2flA{Esq zqKq0EbQJTC{>`=P|IdpzjuoBPU*2E6?!wo-`+*D=JwQqD3h~;FTOP?@An%k6IVcGp zkNUfk$N&m~GLaJ{KmvWVj>RRt?9%*)`8z&-+j;-Ia{ZDec-;S|>c94*Evr^+x~1+9 zH5j!JGX+YE94Hy7Llki8MZkq>6e%l-C=pZvLg~;Aym>`nx@v{0sIhDVok|x~=WhDP zXRldYdD&-fd*B!Qe{kK)zx1|C+V0M8eSH!mOJFjn>n;xj5>?CaLR}631_%aF4`m`! z?z#pEL=aDgRTRuN=tdX1LCYh-%Pxefa0L{Nv8g2+&N{GVFB-Gd6RlgfG|T4GR?#=8 zssfT$tFvzPnlF9+pU9Y{BO}hX$H&JlM=Gw8^wgUTQdE*4FI-ucy_HIub<~S71|a90 z_hK!4Q4laSJsU;I``-V@J#j2XckbUkH8I;)9bjfa$~=3X|-Fkv%o6u?55p!^von41>MRZWtrx<|hG`QKR| z+jf@z@8|b_=w*HXdh5P_{`*JIeL=Far}D3N?fuplr!let%T-+oZ6l}W{+#_u>V*I$eG&)2JASTA+5lTz4Q z#MPVj%sx0jVZ;vhC!w*ewDZypi{5|Ds?Xf=s~_C4=UrEySMupEd;iZn_2!o^7)K}h z{LRxZc|rY$pM3dkJ7@m$!2_Ru^F=0eKiEF;lWqIo`rNaB@41`q7;oS6*aVWW%S}!i z%x8%B0u&ONZafhHj0Hr!C;=vfRj8^f0Sm))biNUrZZ;x_07qKI)WLVZWAxe=o&N8S zOugp=H^2H7t3LXg-}v5VE`0ghf0_G01{DRmUKpqa{ER zM4+kx*pUdqL^R#PfnD~uE}6PM{nYhau6tLP{uLlRyz5|^2fL$q>z;W83FZs5fR>Pl zmI7mtivS2om{59j*_khi1MQ|iih_ukwRGsWS}!>Wg;eH!FE_sZw-;_&QF+Hr4}AZI zj9RC^_&s<0^dFx4&39e)#^9c>ef5AWS`1TmGjtZ}nVbL&(?yv83L$j8^rFm0)RA~H zfk2f6Y=GRAAzSl!D)PdW2td2c9a|JG@!kd84diI)4$RKCiX{$8tPJ)5vmG8@RJa_B zvDUu4l?74QZntaIp0X^HBq2q+lUi#tnliUwH0Wqf18ojz?5XrEUc|Bwr#edQH;EaxEC_gD5QP)Xbbf z|Ko?-Kl5jw!0P_>=by_JGch%1^8|}Glv9U4`;qNuuN&RDZ91Kqrb@4NCg(r++CO^z zOXJ$`$FJXg^UfKVsD2=?ReQel#jWT3MxVOmH6PsE;mkU&%*TKD&zqMoj`!?uXVdAA zf7xtKcP3hK)?_TUDy-0xSpV7$EjwtStnjJ}WbHu)tnf_g)LM`uWw5GOFU3~?f@ruee@-leCwaid(|J`mo*vH03P6g z)T?^11qsBfWe9acV5$nyg>o1JNVgV41VRvH)-b`N^R#S9c<#pU+5Yj3~#V^@CpZ5IdC&0qY?1V)y?wp9vJ z0IY0CysCm0(oaAFV)CNQssI@>Eb10I5P?+G%Sni!+2O-d5F-51Pag89F=e`s| zDC$H+40{38moE3twc2ffjR{=gtJSI#Z{Uk8i;_xjZ>`m7CsCBQGpAy$RV5KX$f5Ki z0UPf%2#hhNC+YF@Ys{06CHN{L00Lzy7uV`_N+#ZM%P86jnw} zw(gw%FMs75_uccOIF5;!*{We7lvx>a$W7)Z001BWNklY`|H?Jp|H>ZPZFO0oj5sDnBDKh}ij-EsTY#~QgN+3fGUbmJxGpZ3aEUiqtse))sj z_AWbf<-z$~VF&fY^8WX}czoP`{tI7Ev*JJROnXH_;&SpwpMBTMe(Su`#g`_wovbw! z_aq4gKHqhqdE1?jo`1pWGf!VOHkr?*MQ;)e5A{yYwEpm;+xI;(k4=lb zEL-&GgLu)O-FnO4J@*U0dvRmt=imCqB$oFBnRY9J)hhvPARct2@K{B8fz+X1h={F< z0}0^ZRMKK0gK(iZysN*ls;Ln#2LDl@z<0XXlY zxGLURqeV$YmV*S=8WUt`)0$YEpP!velEfE23Il>Gb;#B$E z?YvT{zlg{)s%EV|t?e$n!O{n!<^KQ?~D{da%jU01yL_)u%9sA-4-aWC9HRcd=bkSv2ei>!WJeyixgP))M*uUJkx7GOC$N%J&FIax( zeN$>vu!cwH-aioskggM2*^oC{=3oOMSc3Sj3JmXHES#tTL_tcV3aeU@lCn|t9XT9bf_mqL7N~mQ4 zQZ*LN!`N6keAF1!*CW20!Nsc_|&xa~779#Rw!7)UZtXUhFBAC9v(qDm%AAGDnR_E2L zSNXDJHinrNat_2=nVJ33U7ezq~Q4PY_1_3j- z+i5owF)PwE%U~=SL}3WEA_A}z*>e8_-}=Uv2YY*gQ0K?tnt*6Ai(*!M5%|0k#d)3w zY@#UAveM}6Q&Zz(`}!-H`Z;mF*~#0@9q8#Wa!gEJPMqdB^JKpf>Z`VxE z4G)e5bNiR~Cx<&(T1p{4u#qc#=881S16!TS(Cnm4Xm*I#~;p3bS4jtJ7Z>>`Skcyt292SctpL%zxJx<-hJct$97FO(?Uan z6yQKTPW;$G_m1(N#6z{49|g!lU5T*@CAOptVn8rD90jAd0d?NxelrIJ{(fI#cx);OTnW@HDRusst~F;7jsG z$35meAy%e^SHi(732D0k5!8_lwNsE~6~H@?hbIVluJzaNIPIF}ul(iV>G{3c>woj~ z&3o#*4^<^lkcGpVq2^`JTGpPN|M8vs&%OHWZ@%Z!m$`dyzbi*i05X6>_rp0*Fst)W zz;taW>T-at!{NSt zMPN*qUrLr`d7d+KH;x$Ez?cQV>a9lH+wa24dq4N>L()TuQ=LKCfen?J+LP=1D`67D zd24iVuttFQE;2R<&G4eW^~=xMd0_wcJ!2JPgTNMG^`&PASBF^y*Y0FxN6=U6yzsI! zjM|xlhoYo1H8C|hx;hY@8E;pYde>;oHBz6=LQIt;veK5`}4z=LLrP!z8k4 zkx7F!XtF>m^0f6D$`DVM(nTuQPTy*BeS3kcRM2)t(sg4AJ zi4*H{k&XrJ-T83O(DKYyLMw&SMM(gr&)>QAjaQwQADF-Pomaj2rDtxq{C#IG_nf?; zu4nT-ShTL@>)D)TB%M9%E*Lg8 z7D-HV*Zv1gRxekt-_e;_t`!A^VUnlwS*KJJu03PLlF?yBSpaY)!~(_R4)qgL0Bsl$ zplYB+H+@E2NnL5YkTb0i?b_s|1edD`!Jvg&0E3z7tFP|={2yL+%Of*azvEUNAEcp7 zm{B2e0INDnjX5nBfB1hssEz!?ue-|s-9>MG|9zgIp^`pPo~f!(f)}s?48t%ndDjgP zLLDH`5*&aCWYiXE-s$hDOw2R^wosIXWZ;emv>UfqWLBp=g9J^@_EMR_d6-y(fO=M| zMpR^)dnA#npeU8XZj~O1Dm!F$V31z@l9i%v{o>y5{P}YTa?9?Cm%Qg!r5gm4n$7F} z@{E^UI1Iq6bj0(5RH4ZqbvHS0x1m9xx17YG4<#(;+FD z$Abts<|97{)w3~b!l|h#V@CGRHr&)6ifbCyzW4omFJCkCuD5K=)66S~$S_ou$%LWx zB7o$1UQH_EU0IgmB#eU~2+}+w)ilqFJhL`%u4D?@?Kaet35ejF7KN+CwbB=PS_E8V zS<&Cyr{ch2sXE!|d1$_K@a~5ZhN#t$r(i-lhelKDlgk$m)>~~~_|l1rEL}44$YZ;D zYqf#?>d4^0{+WrnRvHFY#OEC^^@)0Yu&|7HiYO*OU2n`Cm~LX~G2?~`KCM%ht*qW` zOdA`YwsylWZu(Yc+`+y3mapljG$Vsdb1%+Vm6DRcu3XxurJI;*vSshRD^&pEpwUcw zYe|;_2F8jn0YFrp%bhD&+O9A`h^gYnFW>l~=l?$Qe9xfKygo5DCewjZrS0kZVJKz1bH&h~2+v5rAY5jI} zfA4qh+xqPtJKz6*-tiMttgj6B@h~8O4I*P@YJRH8)xN%g9#<4G6ppE6b;Om0y5K4MpUnB!{N=sqPt+)kMJGiif^$Tw zHUdW=M`>HLCg5P1QI)s?A<9z?awx+Hz-dcsUT0e^BC=f_xe)TXA}|n#w!yTc>2Yc9 zr21aXn~ID|uVGJ6sbKM8H#myHRg{K0mLnpvMu}Kel$8Wz5u2H$^5Ty_Fx*oLDR4Wk=cRaI5uP{|zisj4S-&N-*Pgix!Qp~t#3M^aIE_y+YYilROy6?IVc zDn(g_HYlBnst}~ey_0s@35@M@Iz2r-MV=ZPMkW*pIXLHt*chuMw4nAu;kwFR;mUTq z69k6XPLE9l#wr+q%+3a{-T`@^jCurkL{fl_#jB& zeB0;D?3{C@W*zCN#;sO^0p~5TT5AGz9-4Pblyfq}p=0i}*6}0OJ<|vA-o4vvJp;4j zdpB-4qrZP}gzlPaXm1?uZ_d8qFK^4z(T{#<|Mhq5Gqz`d4+mj9+lZ#icqc5Dy4ASa1OZ289CvWc;K7xj z`s{XHRzXHf*3v&-b7oA@wq{eg|Hl)ZBuV%C3{eEbAV!|@+EG0`3sQ{+xRXhHCtACZ zcBqr8Dk3YD5J@ivSE8~83b+hPAcIm1>1#IHd#2_do;kQ{&(3A%mHStW)GNc-+0;sv$f$Y%q=1Jm4v1;z!+xg% z&SHP-mzz4HtE%D`YTcP!Wcb0U#`RyCQeA>xK?K+e;vA(y6LN)e2!+Om294$=nLslK zx4@I(9WjHgiaS!+sn)U$j;4A%UfC`nRe~>#^K2A$;R|jMR#FiM*ucg`k&}YiDv1&2 zA*qzCVnVB`MV2Q?VvO;gh)7ApATq{y?^V%L?alH|v)RasJhWk439~$lqDl~ijrqAs zr9Ufjwv;4QYb}5zidtFz+{<53sZ_pp!*{gW*Ny8ES*;G}lhE#-|!t;oyrRpJWVn+9irfxMcs_EN3(2o^21^`?J0!OUDl# zoFuE_c9tDb|GBIC4$n_`#Za{;n`RoaC~AARdBi<9oYMTh;pbi~QoQ+v&xpVAX_zGQ zxzDrN)P3cq=G0VsDxZDrUtN94s-=y#GcXp!Qh(hGR+biIf+VsRu3oaT8WbB>|Ht?D zPwcJ_^;EYWeC+=QljX=N+I{EhWy3uyHblMED=!|X^~7sO7Vm0AtSrc3OLB7J7frh- ztDA@eD_{md87+L4gAKGBhqt6c%mT1i5mKfFrGN=lyXUa^y$|m|ASi))cJW2!<_}*z z+-G3A{w#8&xpO!D%Dwu1|4#=iFconn%_#R)q;xP$#>o6URFMo~eoQ9rLVdrr#fp*I z=$e|5_`uZoWGd;*Ax!Sj#jAMu0-s+fi1LXlOCKqhUE^8X!Bw8 z_N%F&a3G>?#MM{@paLRQWrQN(RI}sVk*@$PZ~+EDL^ExV5)jiDvJbcw)sz4(5QU^t z5UH9V3P7IPCXU0>Iam74ciz6|@ZqG=*J{pQb;WO-v;LfY2lg>22qF_$RrM}ca1aC_ z?xd|KOp+iR9$I|Ek8j@o=(fS3;Z~Mja>hAV{l>EoOwHIZj>96)>Jt-tMuu0+<()<} zIJk0o1#O~8ZIvWdUkVGFGbnUfE$Hj5rFogAIr=LbHmrQ~(Y+&s1B(ax@7%nlR_$3l zGQuEMQKGiD-bUg>kcTDi>;I20-VhBWFSvNqij~8qa{$Qve|(*Hm}OO!_TRPlKH=tD zxvML5b@1LG7KCgU04-v9}dF%Hyq|(v!(y!jTg@ijb62I?Zp=_O~(=y&r2oTXM2O2Kl_I} ze{<`)MI9$f)l4E*E>}MLzVpe(AD`I8^&6#d`i6^s7&(@W|MobRMTXIl;GqGCCbn(( ze*LhiSHM%Per+J6k$UQLB!Uw4X1PeX993X9Fxfx=e-bb?UxF-91d=A8fH6`NJlcp% zGvx>1q&e#%)OAt}gDCHDycuJ=G5C7c&b{}-xtE^1Xu*>1rp6R}&QBB%42^EzH+Ii6 z{r!DMOlcfF=ZaLfsZ}j2N{2j|ua?8A0zhOzQdl#{2k3nXCwI^4YWx1DE<0;hM%$L# z*k-32l;sc+X|u33T)6C%bDn?Y&Ifl+8|@!nkltQR;&=cf*iz6{NXHCUkeQB#7{)?K zi)-2s8Cv_L66X`-!~)-!%mxgOm>6LhLltz+fi}>F*i2y>BvWo2*%_R&FjR$RM4Al? z5*!(pb>{_vjL`~-#)E?g`%VlmZfyL!sf~QTxb5g91rkOin%jqshgu#o2^E2v`}U2dGTzC)!-uwRz30B)5OEL$!sx>2 zXe<#AL%*q^S+gnTa_Mwh#VlK=8=6}l{p}OBv@W=0QUA#!hmQ5$@ZM{W4IYWuUAgj< zXI@zUyQg0WYWcpQTthlrE|(+WF*JoWa0o;Q2_gorv?QFc=0(~#j?+6ZDhJ2fnw!eS zl8%DLWD-)H7#^`=aT$406dB(~tyoRYpsdTKG2>bg77#y~^QvAY(tZ$nsdze6cHk8& z`FzXlWvN(D8Xkj+Q8R-FvT61`V>t#uA!jD@W#*U=zAZ&#Q`2~^lyK}wYdh}RmK|#C zSWZJqwqz0!oBUA8ag~(hdu6XssFbTv{`k=3=l|{QiDLsR7R-!il9L6`QYw*1R*LyV zOx7x;AO7H16D@0Rdg#q<2P$m2up}`!3K0p0fX$lPKXKbbkmJ;Lh9!g0P@GIzdZJKysHC2K}RAV?`NAtGff;51FtWbR{F;6S6%&{D`6$T0KzEnGd;mf zfA(ePdzY-~z4x)*KYMZy4!>&Vok#X`6>3Kq4g+GL07%jSi7=EH+JVBMj_K(KzHr&1 zd6~(oY42HLJF)*-NlF415I^IxtG?ctz4KQ)%*p;~(-#b#1R^2@7A_d5)DX)c=d&P~ zkOfOiv?t>iFU_7DGKMN0X}702dGKVOAebU>geqeoVq&-!dm2)((WHs}5IMqRbqW<` z*{nlmun?pTlc}qkhsP7aqpbW5gCEqd&a7Dn?y&^>!*Q**0ji{U+Qmhxk% zOxCY>Q4}deCw@PiA5x zCx(tb-}m?*);Fi8wa1(ruDoXF&z?jOMKNNMsGEO{ByEUbU|8x}7+98LqA>2d$z-y< zrMVOTZ|Yd07O zWyf3@_x-R?(_UDE6vQEmWVXreZfgln4w8t%$g^!HWC0*xRV-Lk8?qN3tBvGldC6KTn4GIyov3n*zdF%O$8lA|R9#kt@7=pEHpmOgE{ZS=y z9sSw=vvOA2D*K^{n3M*~vd<50%uV$>3j+i|L_$CZECaO7*!cJ>uQ*9c zu4Qi$=?oow6>~4ueHZAOw*GW0*9QMBRi#fU=kkh)Bu8!4Yy@Lda~`7-MX}Sfro?Nddz`*^)#E zjhJ0LkV8yC2q2nLAESt@ENWFg`P#y^%J1&_)cobk|EgPQDaQgs+uAGT7c6PLYuUxK zrZs=zu1#WStLZqC!ggtkk}=gb&Pr*JV-&S?~5UG(rK!l$-|19Fmjd&_fiG5DYUlyclX0Da^j&{teIhpZ@k8 zAAL{Hj1C<|d;3oO$EIVy-%_dO1)PYLDVK625<1;gV;`DWdMH&cJZ;VA-+yk~kAL>Z z_3Qs-;9n7U$0vpc2LEH>(z9DzlY_&3hmRc`864Vk=)mk*GrU^PNyLp6PE?Cgtri*0 z%q=Z#gT?aZ&6~wqN3*@-t(OM-51etqrOAvdNqy=QUzK*aWd72o#Ps%9iyc)z_odJD z=E@_b3Z(Lakm_BhEd-{Cn|Tsd#exlaGdL^fR-8+VkGZD}j? zeK#!Hs;Nf>>`fNEu4N}r9G_OH6eq`ESSZUFVB`g)KHTCPVQZ}9Tv80;LA)? zR0$z{PD*HnQl7HyTaM2@`vd>_)el{I$=RnRYGQJ-H@FE}#Njhv; zM3IRY+89Fw=yVLn-kk3AJ@EZc&0luP-%At#2vW*qwkb@cNBZ`D_O??-^0goQ=1ruw zh1n~^imG{`?}v)PL1bz&Mw3T)a`&XfGRmH+48M0DxJ=WN*f z}SdH4uYkS3m*;StORf?(<*8JQ`0MiVI};#vugi`iE{ymR-nxBv3gr87!y>S)<6 z6r`Dm;MDEV6oeI(?Wj$T29uK{2|8qwe$9+b3|xQ9dv5;lKNQDGCr2l5y!pDl2M*Q> zuwt>KtqK!kLD7G4!>hXw>}*IjWRfk9KK+EWVit!mTq>1p*I9nbDY=QN`Fp zNwAJY7^anWg)9bu5-^&|wVVFWyA~{1cK5fwIe+ouhUqg79X|$-LtD(4IU|{A?V8cu zyL;%`E68F$mK^%#ai68D0o77|=-dBrtZ(?%Yi9rGiRPbt|K+D&xaRJs4({w5191D-9(roS zPNZVav?hD{w9=+yux6m8qcqfi)wLUpAi;_qms~0I_>2E`eI`2tTzmhuEgw05Mahe* z0V!qsp{Gg21m5b?U;WW5U;fNFmn`p^Fs>shM%+;86?>jy`uA|Y4ZZ-m1T8fAa)0oy~>?9@RdoNs2<*2c9UfoOgKTu8o zYBPwp&RIO&-M*)oY7WZ@8wCMR!(s}37Lw8y8;43h$Lz7u_%9x;QMJrc!2zluVoD?s zi(oVhfoe$7V$v`X43VW^B4&#zM4bu8ddk4ySE=6bmjc?r5TXE5fh1}kSuS_1E>QT= zNyCERmBw1x&~EgZMKwJRQq zIqmJU7S6o+#`m|)Z2SG=k3IIp9~aMG@b(Yi(Azs^q-kw!_KH=dgiy3}`I2p$cON-= zu+NO%@$GMScXm`OrT_ftJukez4Ut}TR_iZ+``{x_{lQMS`%e@{DhULN+(fZh&Lo>m z7{N8r07t~a2!TjXZ)qx(3dR`L@Wa3}PT!%!EbRk_``Q|tBR0iK*)m2cAq1o(U2lsR zFa+x;8P`qeDDPMA`OSUj3?Dk$dr~lBiS*IILxr5K20^B)duDfL*}^tu#{(VKNQ{)m zMYUol6HDeSIzBk)`_<6%p*iqE3*PMZ8Lm-rH@@}24o`cEB>)SeGnJm+Hh1TqZ5mN^ zd}L&@(zoFy9z2w3iQV+!n~wI6M&(_noO20V>7n649U_w1(ZCItof6b0JKIwI!y|9J{Nj!4E|!)Z zckHv~rk|t>z zCP;97nusG1fdm=mx@(>pQccwe#()Sc*s;k3T&F;4gGvFcStvvyh{>{}bGUF^uuIBSu!-yB79t~v2y74;i%eT< zt8K@OF$a4Gl~NoTVJX*jM@hyroweJCklhycwowC|N73>5g^Y>C67}$M>&a|Jo-$ zd7GtVAq>h@FE@Jf-aEg$c+m=B#sBexw{P9MIS4~yQ7x6f@|};r?Wzyl@%3*#{HvcV zSaR_z2mDh13)DELc{+dW)7RYfz{VGTx2aejE9uG6@iEJGtF@wXyU2<9E4k*R{_0ID zEa4m*n!N79xop(-^+%rk?8VIbU1!d(ZbH7|uU*l8>leSCjfr9q+qC7CnXB7{uGK1P zP&chv(X{-mg>$CeV4LvRiQId?aZk*(ElD!}MvwcB=XU1i^r)ZQzxn)bvZ@7cuqHUu zA^ECvmlunp$waKnt|pvdbXx1R@BP}US?Nr2IV_MSRwP2rnougTtw<;i4Z8xYMHCsO z4Asr&re68OfVG*Ds8}%TDGt9Nn0kXsp;{9NQt_BqAzw!*3u=yWzJ{v3r`NslzHQwN zsVMMcaV3dbvhi|AzxeGaQVvT+H4k|Y%?Stv9l})@KRJ6wyld`U{1u)U|NXZ9=bxFT zY5qXpMW?oYO(vq;2(?h;gCkY|NRl0e2%;I&($f-g6;J<e%6>?j z6tQPwz_b5(#!vrv_&1M?p($41TBgo?0H}iosNU^Eq)FDzj|Px11}0)CV#9S#G60go zXd?woXpAAUSV$uT$PJV-!U9_$fEBw*av}pI5)H6siq=z2!_3CQ9)lBd`l4s{{bBQK zTdKoD#}1Dl8Ytdyf@e)G~Nv;NY%< z`<5S|L-Zea|Ger&*Ic$Xov=qoay_#b&0aD0*7n=-PafQVq=?WM}e)|l#^-bS`)>u7Fu8(NyDkEXkS_}GzTwy7~2w;H+vO-Q7Kb?}T;jjKN7l=hwWuYLC}+hIXYF<&bCrI=+mO`jFIE5ot; zL^W)Vp=)-_`5*h)z5n#K)8_V^{jo>C{ZD5`wip^4Cz4&Q>7m?EXc`2?gzH9dLJu;L zF6$#&*q-Orgh@0vE^2L`zUI>2f^N)`?pRfb0Jp)@?y^-2KKSls#p46LdtREp`tn-M zA3b?2)6^7qvO#HVVz{{G)GNBXdqORA#N;^aN_YVjxPGFB4E8~UVhIG6igd(MAu>=F zIAUW+*i-T?>g!@^)E9;!1Ph=NG_`sUd}Yn)J&ofv9R}uyzdQNkAMLsR!`*YIwSN64 zeUJYnq>dwB`oQ7`et+Pi^E&SPW#8zLDosmK%HoPYbGE+u{H5Qy|7a-;00G-VrLgGK z8THTje`b6C?E-cj%d@i0?WK6T>*sQQsC_AFey9NG2sP~!al&>e?%Ije|DI=1CyNjO zLKN0)){d~On7HxmX%k-Q_TOyN+WPK0m;U(Er`+-A?qyB!j#hg|S)(DmXmQfA6Bg7N zi{mO4Ma2w@B1LY)wCLT9-p=B6x|XZ92;(HUwGNuuRA*N+rni2^fedRw*A`HLn~LWz5YGdZ+!EEJw3Dj z@z#$twf*tYKRoAG`MvL6_taAxcK40TP#@j3kC^(SsOkOh6}DC!uyBYY)=rEd;|eUm zipZc2y_Od1$QH6(u7->N&}>{`g<-%9K|)wU2LYH9iFi4mlad4}+mhO(SvJB+!uC}% z)!o)U>Dg~Pb@lr$S^dh(FHTk_oTAknZ+iO;*M9j24~65UR6{D0vErGQO5TPFVv8=s zG~dl;Yo%gG=d{oN%NL9(XMgr!Lp*cArEil~Oergqv>F@TRcD?p9(mD~;$3fF+0i*& zN1hW)&Rn|KvkHDCg58Y3lVn)oi5#b;>3@iIrN8~_FAJH7SSo1=SIH<6 zN^9-0=SQkuUBul4GoQ>COQlM-L;lrU#ozA&f9r@I%oWQaVy-31RW{<~-r*;Hox_CF z&4<2q`?A?hu|lYgA41v0rWkN70$5gSBqD}j2x0<4E{3`qMc{xa&O$*)Fbt_+sGjC9 zrSkzG4Q(LQlnq-7(qI!#8LWgPCTIObc_UwCYhYe?xQ1+}?TvbbB z9WBX|UM*%*+;yOp5w`F%^XIgv%B+E7W0sDSrO!Tdb=27ZdT;4%mtCH1ZV_RvG23+c z+b%dUe6m)anA*^9V?lJcI?{0!hzGC$;Ol|VH8;|Jj0;}L0}DK*RKNvW5Xz=>X|D95Q$Jn^|aj} z2th_b!JJuzaow;=B@*m#yz1LpfygPPy-3P7@Cy!A| z8{3X6X~&z$9_Gjm8|T*2qYcfCf)s#;)`mh}QM$SR#7Jjra?b2|9I+9yp)GrQV{_Vy zTU47lr#+rbRjbvu_SQv=)SDNvoo+&rA6+1e* zuf5^Dx#7xrxBZ~tOt)gFjjAXAeJ?t@_V1|Bj((guXUiYo!sM=%AG$6g9-aud_6{C7 zv`s=DJb1(p3=C&dF%ii>?b>~$;GH)sfYSo)8SEcblJ~+0}(S^uWl(!J*+93+McAQBYHGt@^9WBV)*9 zr|09YSDMt&aoZw`kj5Fa+k6d=p_s^)u-GCcK#C;{Y8(X?p&9}L!jdwQB#f2>o3tTB zhQPvrHL+lcDQ12h?58CIFox?;Fb%*!N#;LK2(p1t#6FV)3Q_f(a_LuhoOAl>mhqvU z!pZTxj9>lnhrjuyb@MXTg1Ig0K6RfimD`%K=t-bG!3T2(2K?{cc2nQ6zIE@qzN@Rv z4~i#?Rm*WZyV`}cW_ET@j21v>X=+?NXBOE4z`{AR%GFRqCli^u3zmgm0l>7*2IB=q z4~5J^ZQj0D+MObQyV)^uZgsAX(che(E|Hp#K+mSx#Cl^5wj)p+A0HY#(J^;{;o3!)oHbHa;_g18EZbV9-B?^@8=9@WxZz!w?B8?f z*Z1E&bKX3!W=6+ziDcsB(cZ-AYXpo%KywzxgKM)DqoT*@7)(PDm{`o&b*Osh9e4BM zWhgcfT#?^nDd*I4R;6O?U;OCZAc;(~uq~qrp-F%2s6ehD;D%|@{Xsf=Nv*{}u_3_+;6 zpM{uNOA?BWA!#ug)E&M?GwR`O^{6TV9k8g!+*>4Ui$t6qcnq(kG;_oe+gd;?BPa+c z0+0)g&oU5_jLjM#0&~a!Q1uxQ5U`6{G<9t`vbk0sizQqBzE=OA>vrR$QhWQ$x>BNe z#*+-GwJ}P7pamHljWfLyBad!8eEzv>t-npk{O?blt5?bOZ#g>Am|n2cQ=Bt7k1v|v z`Sf>UDOa7fr0MIgAKlqkidn)72&@7Tg<+&QVk31O?Q10<6?7F85h37+h097!mHkG5 zBvSybKvVxY)pZAhDGHh)L2RUesgDMNXo|DQDo&v$f|;m(@Tx_tRyLmc!C$Uj+WEn= zdahd8@v)munUj)%s48hPP4P(Do>!qFBjIxfo8R2{TxZYPi_ds*{bQY-oo-w6zQIDa zX}Xja0O80)DhWoYqmJ(OY-0mpgpI~n+HvFQwBMY~B;yGH3E^ldfAQ37m!3Xj{;E|S z9UU)k+49ySFE%%?_FC3x&jmZeNvXICj3Pq zI`ooGg9#&Fa44;@$$ZU^e(}H~a>?aqE?ePyRU?~WCBbn^Di>ccE?cR3m4M+$OE104&{W;3UD*5u6ix>K(-k<&AXLD!G?(Uk~($!H5O=mW7 z*_H2l;@RIq+bvBeE0j(7tHKTpR+uX%qSu5yX#9AoH_Gz zkDb8b5p=gghcHAsG9=-|5ry@ETV@6`I}R+#r3zUt5km`x#uTU$n2K`cDV16fhykvY zptb(Nr{-+9@Wh2HX3lJBdv@26i{{!yAYqw=qfL!TXkkLbR1Yz;>ODfPr`m-OWGPm< zI#H3crk!}p+OTog6_;K3H*Avn4d5>skbfoN8zCRtc9bchlRci6QiPJU0-#yD9E!#n z#_Ip=3r8Zigku3Zs-=8(`Cnc+@QphU zoHnmZ5PC8OqbJ->w<&4)B&CTQL8z3FOGEmoglJcg+5{m+#)Y3XQGl32MnU^^i5^T$ zb@-u;$Y=TIJ%ZUVsNQS&FUC^6ePDyih8$r^vwC7DM+@VJoF_JJUTb@+7R|i%ic{M% z$@hHw_aD6`n@Ghq3~9p?7RbTyUNxirbN8N@mC41ldTKD3fab9I!iBAtAOP{EY%-gw z>piv;tKR^V@tBDuU?QVau1cjF0XR~KS<8EM_O2HXPIC@9NvD52%UCQMmYSSFv5ac0 z;-dkKc$(b|v0+kEGuz|ncBo`K1s=2CX+jw3s^zfnxh;vEu_(lbmdxn~*s(JUrYRM(@3L={v7k zDg{D7V%e5SbLFjns*b19t&`vW*=4IzvL5+TKO3sR;GTmRdgb39O|3h1TE1Mhlkv_4 zvnbFZx20Q?spEoQ(6YO|ZS9Q76O+kg+?703nY`s!J0E^7hh&;-5&Qs+S%?sxC%6ur zHq1nO9YGLL`BbPuC}fC?p;q_amiYU zx0uRo?W%} zw9d}Xzj@JLwv#{S1?<`V>N9VYJGz%|imd$JV#0Cfv?pF08hO`8U#D0rM@+is;L*a~ z@$&a?T00|o^z7M*-%wOsV|!^h6E8V8tB4R$xsAOcER+tT6-x8QXpM_2cim z`hsuVzHs5ZOW(Pw?cr?)U)z7;hc{lRvx!-4sm6wkul40iXKXreG_qpW*vzG?PCc4; zM|+P-$8SovG^862_8-sX_d^)~2&v9Zwxn%aF=Yt=La10W!4Q$>NypAMBmoH9;o{iB zRjYd%R#Xn}g0#CAFO-o+P^`rw)saAF^_tb)yCz0O?toEU2*;qksg10fn>cZN#r0?Z z=-#_ymVNKNKb%In&erCIt51D-`{so+=Un%`cV!cq!{g;jviqZ-`*^8ZTsS*@+Yep^ zTU@I_%b4p}B*^WY5LZ6*T-9VVusuO>6J4PL8)sK zb1ob_nSbqDzi#e&-K(imy7>d2`FUk@zmcvjX!hP*#n%*T8nDxEzw`NIEMZaSSa!y) zjnQQP^Q2;EITsO!%>_-!B-H5k4KHk*T(sumA3yNayty-)7N53vU~t0*@}^r z^$KOW_S3(c-r|M6Af-vfjh1=4sqa__mD=>c;}b_N^D0sQHV=uQYq81~ROy5#8Wc5k zK6vke2fz7KbX^9x$WJ2wCb}*qm4r(O43Xr?JP84i37P7>J)yvWP!t(xI9*AjP6mi$ zB1?YA<}bhyGiCTO%z}tPB;i$C8>Oq<_kUr-i+hV4vylUu+cu4R9|JydRm-azkAMA^ z(j>e6Tj6=t(DF5QE;r*2o(8;n9 zHrN*VvEcfDedFHGuDbO-oz;*({rv7{ADL)*XWO7x{qVK(d~MQF9;`J#|4&DL^=AK- zYuY~fj|*%;5UP*~pWir4kzI#-0v405-|P+92qP8}Y#0JsL+Gh+r8<3u3=zSAh&VEw zcDB4#`oulkKD}s8_TlTNC19d;xS18q#)+{H1xt# z*WhRSFFkM0)fdef3C@)yMC2P2NfKT}wlZGCZZfg{@fS@PpgPJX0&BpqkVvGSeCCZ@ z6!@qGzIR|~{QP&Gw|wcWJMR1KWC72-w0G_Dxfk7V&Dc|$w(J=A=6w&jF{@_y)fY$5 zkO4`ARwWVu&RjEV_v?XaTLPy7+cq&9QIe{X3*~tWYiBR+D&_r8UOnghFUFpPHT6%#s&vs5B+xZjJbP0{-Jpv{ZLP2@ZRrk-?hH5_lDXH zmvmlo;UCSf&;S4+07*naRP>Bw3*z5j9&uE)V4@#FE_K&pPl5_J|(y(LH_SrDks-Oy7lKo)E{V9lnE zXJXE#AA0EIgMXaB;0|;Oa3cm==+VrC*K>%cK%oS03dj0ud^N=(&zmUO_-I&@-j%Z)L^cN}Us{rf*U@Pl8y z#U=yKM@%VKMS%y;gC$kmjY?HiZOr}v5)!(MvIjeYMS^3KwaODu43k~t(n-e=hevB~ zJo19Ct!1aKsQJOKo_ah#QT0PQym#=>u`ESZR?U=ZfTJJ;+{SO;zisC1<{#g-W^sG+ zo`(+a_FPjP5ao=pW0{os;JVhYynp2+uzCOBd(N5r*rx5*uA6`JmDis$x8aE+#nMOt zD#qQX!H*CIq%HPC2u)-GhSQpD8uY#HbjwYSm2|Dvtn=6_#U1w)x9xkT|99_y?A3$a9W57L zzU~+Me}th2Xzu&D^?GnL<*t{SjU&hy=@Z2`s-J#LQGxeA$pafGd208NWr9Fm<1r~J}$1C=tast(r>Q1tx?2h zpygC>5NT14m_4mQ3XDKU(zRtSG*#a$Y{kiQaCq~szM&8N-}S2>d-dkGozXr$rKDY} zmXGuej^u)TkgzlJ1`{pMzgVhl^O1_P2m!$|2@?S!vrWVx#iWr;n0#`40Ys zb_tTh3M>Vc05ka&rifE%$OIB881I_Px)(H=pa1Uooj5{Q zfAkMu{-?EHT(|P0>lSZ1nA@~(Y+Bk{IJ0p^cd}8*edX#kpMCs&Z(CZmQeXPVEttLU zrVlRMcqqBDC-artmVf!D`?x$nc8Z1Ist>~yMJ&DgJO=52b;x1l#B1lCH)rds-QCUM zU}Iuzi^sx1Bq-|)6~;G@*Djym^ba?8+$xR?O|E(!zK1&L?={Pty8_J=N@68%KoafAgLs^T{$2~3s%g9WiRQ_(eb zF`_fstH01&eT*Dpr`mkQwgdLmx>G~DGV5z7M8e$hxqOrTP|>GbCRxNUAy`>PxDZnMBR{?S)^ip%J^t3@@1NVg?%c%>ywbnx;22aq3~j&88&FJ^QAexN@ZPj-pm(|*Z%pN&ogCMhHTqlMH9JFq3gbv3tf78->x?b zg%SywZBKpj+xLu=HP2cDpCOge1}vcz02qVDWMmRw`7CcSz1xw_ zP`UEN-hszo8F+r+Q!zItV^2V2b_|_aPWzjVfnn}>HFE^R!JvlHsfnaRt~U2^pqU3u_(?%w?JLzBl3Rv-QLIp6=<86UrI z``u4X-t$ivZ99?s#CM)W`!wJ^7}yT42oS;$954(hqTzi=xAU}Fm>lJSZEP!q0e7v! z(syF>FJcpi&RMWD`>hWjuBZiznjinj=|5cGn;TS^d=urPSb7~PuvaC;7}&&}OV~51 zc`ZTJ_KOxO1p@(_P#d6$UJ_*~DdZH=3*a=e_K6~B0V$X@qB`x5KmZwN5QA*R#(;=T zeO_N9G_qFHa3CxQa4mp#AhZlB!WB}nGG1u{NT!Xd#v80!nGk6xmyr50RW3q1QQYjv1Z6B(h`j`bQBa!_v)b|ntmM7_#|L(8DIo1&igZdulBXijOr5gK zI)Wgf$V4C`IGLb{9n|~k1*gn!cWWvbGi3LbhW17iW6qfr)DT5%soSqV|7%a~yYt7} z&OUchvn*V9UUxc4Ob!I0qO(bT{>sj0UfI5G?UIYvUb&>vK9H;I+*v_Jg+(t6!!S5m z3CsI>2X`FX?9tO^XWiES$Jcqs*;SQ$|M#r5 z%V~4Y)J(~gB$G@kNgyO4h2DD;6$L@M1rrR>V&Xz+1 zW4UWDUD{L`RYr_;4q8rnZgcFlO?wY_kN)&iS9^uxn|pe;9O`HIa10TaHu?$tlfJ#^fO2f0L;Il5mi6Aav5fC6g{owAx zx3(VnR=iUtd~J$65};TP#3+^E7W?nd^;~df)0&4b_|dBeJB|*#@UssOJJ4z^Hx%69?wxUN&Ek15>=F(&L*2V($7u| zoP!-9C&I^GPnaWfn=9+(u(bV5+Uy=Z*jHSE%9+p}v1Sdyf(3`R9FSsRfdmtCpdbNh zh2yI5sHUR$#jh^>#cz*w3s_rfxBn4RV58{JR(Ouy7%Wtj~q*LL_%x$qa2M<(>W+)bhdXa z$N(0MLL`NXGImpBI~?SQ!9tQTaEWY(^1dWx0gx7Xf{YXhSU8fkU|}dlJP7SM`C^2} z{D~e0DYz5VbULDJMm<;#LaZM9@STQw^ZD~@-`#WU=uyzPKPQE070GhTESsMC)6UNE zqOMC|+={X7{l|x=pWGIE@$g__Jb&NiZ7kK^BNI2AlImBnf9~x$?nO=1Do{X{3rn(Z zm`<>cLt&f%BTC~IhM5?aV8;RaxpU(Om!CYRwop~ow0z}*qPT?J@D6`+;ncNJR*d} zhR18C+_m~}@|E_Hp6B?Kqg( zv3mk}gGqpxblX>UeyVbP!qZb5Yo2(c^XPbXY+qKS$vC-E3WE;bpqjVAQ4SaN+6f!h+U#Q6pJAq3nTrB{PFmt z#+pg63Zn+FNP>*gEG1yb1PB5m2}{5NYiO-K9f6E_nk)c@ zNlA-Xa5mtm&Bnk7Lz6`)226m|APxA!hv}O@Bm&!pF#wU)Y)47^zUPe;mG5OSRKTDf z8>?w4OH*40hG;Byl}ARihDNFAoc%8_V$ZstTOFcKe*yMYxcdZ zI5i2v1KX&G!}r61f0hD)7NN;co#?Nigj*)f>{!&bXU?>#%crKpAP=cBl94VM16NWNxcI+YYtGUBLbMolHR&3jXX=et} zS$YYKUN^}PFPQR$zr23#!fB1k zc-rTI?!nZ`xw>%{T3WcwCF4pxYJ~XGqdRk*{j2}-x&Qdqv%gui?^9PVEVD3D%pnoS zsIG_?zxnx<*IhKHHo_TD6zClCzwy}C$G45bZNT{Giqouz@4K*ZQp^#Q1pATKO z?C;1v_|si)yw`>18JIDhRE8@j(a=6*Ixy$M9803_J@o8)|GdOT4(yaqZaXiY$UOhx z;+mQo&seod8&Vl#6i5ZkWGpF%$Aepbbm+kTg6VyS(??Nv3fUDryc4l9(XzlO7b8R0 zeX!xdYd<*yuNT_!xh-M~${`}n8 zbMHQ<<;@)jcQ(}aZP=U6Of+Bk(TU^z=P#dRl>N^QgMl`1927l_?zryi#Xq_4I@fi> zXV08dPCet??zzuB^RxE`_l`}11cM=j!3pwr_^1lUQlUfW9}`%xAPRIbYl`EeIrJM= z>1@U;`fvpoz&CwvJ9;g&#%O|_dfSQOp+6n}*)NZvdE&(%&A;J_$^ZF87Xu%-Z+-ha z!)UEU;KPlgB0@^B6N6ST5?X-~o|iQdSdi8XW@(qG!~~EH8Gs}d46>f_EdW6fNK%|t z$UE=?q-;$1Ad4y^oXfxq$PtVHP{wgV8d^YDKmceK1Z`Maxe3k}_#0Q8bXvn$ENWeI z+T^uIdWW;Bt+Mj*uV3`)zT6+yWPlhj5(GM3EYe_{$7FiK*KE2c3USB%ud5etm|y(y z)1!s47!pMk^90F65QKo=w=t9?eL5kr5J5=c=ZsgJ-8#9dsp9f$uP#{?N){$udiIK^ zcD%K!pWrxOeSFLQSp8Lt8-MrDtz#pj*M9rey+WDM~!%nOi z1V4VS^Nk&7KYZXLA74~Er{(@@PJ3o=&tLw2w6>+~`5nQIg9pz(f8OxB+dg^i>0fzf z@9u4yDjH!a){e;sQp$2GNwSc#<;pWo`R+GgxN^mm8?RsVtuMcY3A?_QpZ(FLQzs|B z{P1HN+GXGH*i^UUi+5lDmwT7Ze6szUKR9sdH5E_af5sd84t?Q=Z||9?kB%RiUOx7d z2X24$p|dal%6qT9ef*CPop$4?&EI?C`Bg9X^r0m+vi_2@T7Px#O*5KeSKhHDky20m z_>5DhPx{rwNpYO*^|@TyXsr%TAv5=xZAfv>%d_PBO-j4y?E%Nd$S- zSfTE@aLI~!@%@kg<^z`{&t0;pta(;{U*^C@yuEq-q4s0c@*%e59TzsWR*T=fx4S!y zNLfs1uvQgTR&ep+1#RECy6&abmD~1>qXuwYn4*D(HVsY1$G(5Htuhy`oE;Q`Z41Y4 zIL5#KY(oky$IgC#@rSi%U1QTtANlC^q38E*^O+Ka zpyW!|CKUWjV}H!V;mQxI0XDYDj0b+eU%RvI)sqLJv6|U+bE zQjYc^T_#CVfFxT45$5!1_y)cTjMUIU;8~$f%`WFf+rF2zS;}N3+!EqtF*@ zlMw`AMWS-i;*;OEDx9z_F@ee_mBD5<{*?=-ol;d^E8L%dZ29-EU-87VdnUSu+WXVZ z)1sgM%_3?9?E?qvw2Yla;SoX+R zP!`-BD~k;%5zRLL@ac_W^4J$|`Q-Gf$f41qp-632L>i%thRxZ0K2orM_1lgI?p+7l zi&iF!8AYPy$KT!zw`|Pl-CMRW%wJyUL!K#7&0HX#0HZaH<^A7(FORqwQa^>a(U zeaFH?D)G|B-H0YJk-zcQSxcr=UU1g~9h-KZa{euIZJ!TM-2S1@_x$HQ_uY8qPoCR! z|21c|cXZ$L`R~oCpK`(MnYp93?l^kx`5$}zpO1d-BXhQO9s1bfmPcP)xBbPn7d9;1 zmJ3>Z_t~F4o*7C1Qu5Z?5L@)=FF__tShJGm8A zE0(tXdHZ12ci2HG#@mFQAu1UJO7sd2?_MIo%t8pkX5swk%th1Uu*wLQW>0C5xcTaq z)RN3g+lJU^RR{*t#gCj{*U>SMs&MZ*f62@H{hTK}tv-A0)Kf1iTz2cm@iBtqKq)W~ zrsG&H8-|c44$2Nl0){OC!w?n(m0~rdfs_tu0}4X^Co>DnLRl0U0}zS^Mxv;pB^(I= z+9%_)um!mWnqV^w7y*_E_ZLaalw~v z!dfO!T(-%*D_jqqtcEonLy|+6Sa|10RmYmaAd(EP01wD4hIdgmpHtjtW5th=F zjOyy9>cEyY#o~o4=cQ_6F)60EO?vlepBu}ib3OaJ1B)!ju{7DI&zLrATH7C=K9ZlP z6mhFK?y=**HIU^1U=b&(A&7kDm}H?tFB7p~%l-5(HePyBOYdOtw^ch&UQ~C{g)OiA zb<5VbMp0FVzI@PHdS+QhYU4uu;w(XQabIX)t_>?&EIFG%^)34=x0jfwO zqfskhf(7APii!t&4-5_t6VvSJZF!-Jb{eVqC=Luv6r_x=JZI%|Uq9V(D!t)ulJ-v~ zC%*K+Z!NL~NO5oiGig)k8c^DGlpi3!(|TfP|FsJnU)aEU*t@K^sUa&HMvg3gQ0O8^cU0*9KYkt>4=5 z+UB9ks`NA8KCL1a?ac}X7T)#JzU^8>Qmg~6lt$Cy*@@pjw6Koiy;=R)@2_7lBZyhf z#~$AN*y;fU)dY`&0D?+4zg7?gQA)cl4Iq?0I~+w|a49bfhDjM=yI`9XECBfc#u%Zs z(E`FD%^YrNq2-5+AZe@w5g8I-%?ubt>>IL(G-Q-@F&1~rY^!fTdA$uqqrHNxttQ7s zO(e3su{l>!R#Rbj438Z-uIrPjO~?E1`Q=+b_{0T^o66_cmivK@5G}52w0phEW;f^g zdpm;wHlRzaK?XxZhJfYJ*}yPNQgC?s(jF`)?m9Z~!j8uKbI+kpFg7%L(){>;-g3%Q zoA-Y1XK!bR<9=YrEwyUu`iJj0|KZP{{^T162MYcNf3RWby)CV7$Kb?RB3iEV-0Mu5 zcHZUhd~rp6!Yu~4_qVH```I6ws>|{aDEgI4PC8P))Eqpx_Pdum5nBLjb{)U@Td&V6 z%V&;l$#^+()L~?9+B#79j zo^x(KK(U~+xwI0^Y>B$M>SQ_3oHA`}eDKtjONZH+Fi?GKd1N~l-@r+i_PqeRUbL>{ z@%EitH!t7#WMhrY3@|EZ_W=^x|vBY8}6C>XDIr=?q(>z6GV7+V_TlmGxA z07*naR2Z1t5Fb}!QdMR=U+6l zA^yqV?fk=<-A~_teiqR^-NUxx0DwS$zq0xSBS2t>n~`n^|Zp5 z#eAsjxI2CE#ZP^@yzAh8TUtlkkKFlWSAk;8- z_WYWE?uNNi`GGN<(oDJZ>c{RoxaF1AFTQg2sY~A4y8Fi)l7ga&p&(&2EEg&WpYLE% zLQ24Z8BxYbv$?;3o-C1M6F>zhi-=^x=m0RNO0mtb0oEL3q5AT{)UN()eQnifuFyH$ zXDQS-HBFh>Iy~fM^I8OBS>HQ)_;3Yhx(5cv(>XUD9~&E;Ab8S>S?~&@{n>nb$G&BC z6-C8DND0!08)i%$&lLPjzEBovKYB=J2RxlWeDG*pV^d{K&E(nfy?eUi;Ck0PKIdx0 z8~E^39IeLm)46{yA6SF@@X}LHtE;LF^5gZDk&QbJA08->FkavrmVz!UPEy8_uH)p08@Ae%)zI+C0>tu2#KeuL;b+A*RXs+iB?z3lbI1-1+op51Zm z>zC9uN!yJ?h-AP5`Dap0jjcj_d=Ogm=bpT3+2|LXn)U%9I-;aWahH~+BXrPW7JZHEC?2xIRMhK>*mBBjHb z1rtuq!)9nO3lj)sNlOV^8B1FrHbxmikb)s#Ge-nQ1GqK?;E=Iz34+B&ffY;;9xW)u z9uqMOPRJu^vHZRbUHuMHE+TaAs-rrJ^hmL9a6>fC#xsdBI~$0hblFFLu{~S#xOLh{ zMqT)YtyRtO?jzB2AAGN=P8JKsaX7E6o$Yy~Vr&e_aHC;Bz-SgAX_fw^l)kJXEeORH ztZ0hEt@_`>e@Z)nkbd6yN;g$S8>@;F6S-o(aQxWuIaAwq^>|*9gCOvmlXYs!y}&779c`Z;DUFe{^d(x=X@ia7Zhtz|XU4aYl=O&&NPFv6BAgy%S-Fgjd0 zet7+Rs|)@6Pn|!jp`|>spU8LwsSF#XA*A3ix;PY2Kq10JN_K$pEVe61kO(^+2uBG@ z--|UBC)fs*X6=EBqy|UEM(t_!yLZ0bxjR2JFqn!*Gu`_(?i?$tZq5~g!o>L4_ylty zpU*ZlOpBN0Dk>@t9Xa^IH@`LKGoOjhtu5p-LxW>_bg*JhOEi)!=DjI1X1=n1=R428 z{F$qkNV_NNRAnv#WRD z)bi7M`};B4TUizX5RFC|KDnBiA)*+XIODv^D`z$y?iqgL%^o$bTis+NX=*;ba3Y(D zPMLh{;JA^&O=mTj^X-4`8tKUvbmYG=FaG_Z;wd8|q#b_x1ghw{c3en5{qW z{>>HTwS6Ns*FLmy+N79obi(GW?`%JmL&}8+XWp1#j3rBn*j#$_h187F0fZF+EXV+k zB81JMeOGH(0x$;7(cL~0 zAelwX9vh2dNWqQ2{!)fXKm$|&K;@~v_HjrDi5x1#csf45)u1f7_RT!B3fYMuMnxRb zkP$2xfewR|L59d-tw@HkS0``_S_#cY=)e?0o#6d~?L^B!I;@Jt;zY6NkQeyIQ&c&r zIna^L5icPfWrBz+j2F1Nml4_4UKr07Cf7DDJMWx@U7OY(8jzA$!vwyU?x~$qJ3eys z_}=#6vaXuuw%MmF7cXp0j||6ak^m<1xk+wu$<#(_Do>}=+7zbLH%FW8Tz=f9sgAS) z0b>ja0Wio4AwQ5BAP5PzCKIo9%WSo+Be1&eT)r`HbnfIx|)DZG8F?wq-WWV7#ti5#zuXm2YR|wsk3Su z>b-ofqNZ-&BY)ewVM9(?`H}ueTnyx#zQKWtXk?TFmxL=tS67#x&od$L^9VGVf{Dfn z9(S&z$;-HUQM6{4iJ7z-TD|54>B|pZ`w^FAWkY#I%=Lxrx7)B_5i(oM?#Jlln{euF zwC%U%*h^yODJ}^cs-`g(uZU*6p?r487^kwlVd?UdSM1xew|4@G_?B^pte8>Jpa1T! zI^Ukn(K##I-`aVc;*)mvjP3LE?yfvsn*~9*aNyL^oYs+huAY~ssR0`TGsy^Z5T1Pw6;sidH^u-0g26VlA3mH|5CT9L z2x95*C?RUW6e<_hPV}!=b*)HOZ+x==XkyJ_(VmDD`eU#duHl%KAFdP$kl6duJF_S~ z3gvO&gB_GbDPos47h(`YF~A_nd}0X@F@<`>iN*u~AvJ+5qlMDOg#15W0UWcC7NiV0 z;X8@AR8xQ$kT42DL%IM%5)?xiNzhsW0BMvFEU;z-9$W#}z!bU40tB=ISp+a;khB3n zX+U#KAi{z@Q)v-g078eFDFcE@BQT|8b;DuZ0ZTwrNn(Y7(XgZu5=u#-E&6Xzv=f*@ zKn2R=$1<6*;f`a4{-P0M{XLe93a4f`Nau@wMzb4@SVA5;KKiH5wMC!v`Rv@bdFAoN z&>e}gNHiXcOHoxGUH#tHgq(WxP#4p&rlygWQ!kB0qh*O`Bx>8RY@v;%9)Ipx#RU_{ z@uA)oXJ21enYHrSs(36KrCiPuj%~C@Cd9=VK(Z5o@ktp#uyjJADU4z;bU1YbvWOK6 zkRid^4?E5PEZg{j&K6Z963JxKjva9vCy`3BAt`MUv7(9i@X%P%9|wf;H2|-GoEKpt zAp}T8BF@-Iesnn9Jl!ZA1b(smP}l6XlU&D2xUy|>S9)>f^zj2wM;1={PYuh z|Ncz7jz%nw5>G%*XisZXBjS}D6oXTrBhW)9_n2n>fKaIB4B!{WpuhbS41!_3?8_Anf>WWtAGI1#IYLJm(K@_?jRI^C$X9@28M5~*kOl)f z05NIFLW3j#p~GYp14CqBSPLVWGz>u+pj7&XISQ;5QP}@uW(|@o0IeWwVguGphHRG+ zv4kZ=nA`k6l3P`tjPaGRz&zF$_`VRfZ^aM$6Ws%un3(mCzdy5SL*;1aAzi!hqHAu9 zm6yNq+Uop7ZrN$gzu(Yv;~#e%=<2MRv?5*9XWG)n?#v&tjC)+XKp^9UpV{ZKmPOij>8p&nP(ly6|!2uHLSo&);>tS0R{2rKWjE<0>&ueyLx;Qn{L9~7|H+#q5D5X8CQk%#gqS%{P@Wze@$9lJFjCDU#NjmHq$1-T)vrY#a=-9?Fm{ z*#nd!WthO>(4e6bghm2}g%C!R1USIJwGXa7N;8&V;|R0>6f;9J*n?7#7JMHI?)n|N6&X(0gN7f2MO}uA_GB*s|c{Q;J!Rq!PzRd}H#T z`0{`CdO=bb;|b@qnQiezFr{sJ=bW1OKvEqKtS6l6qzKn zk7+e1#!+A{7}%104hPyzs3a?oNHS1r^RNU5rDKka0`QEgD68|zCs}1R6>bB_jwj1D z{r;DA^Bl`|Ri>CP6w6cb`s!)LLK>DH9v`cnl&G#ECaJWrge?tXWfqYyg#ZjI{qDNA zy9RTY2Up6XnmVmcSn~9XFKwKEmMHIx$KwsgK7H|1{zRI>gNark$z(x;O%XPU0xy^z zU-PH$Olquyq4D0nqURkt&~x4II(K{3##erSk*x%cZe|SQv^%ij@7ViCZu^v+bd_`? zrjV;>a#uh4^^;oLq$3L1LjUn&Lu0t%OTRvxRz`6}O|?NHJ$8ISYdr4gOxDVbjt&Vc z=etOykrX&CP!@%d5H1CtomDlqZ8<*5t1-MW8R@K~<4*VbxMOK2o-Lo>G2F-XS8&X+ zrBETe!~B2n_ks&P5COnGzzP6c7GO$Ab|C^(SY$K{unxkxbc3@;+9P{S8d*H{`VN0!5^pfmtTi%i&ou)@Pt zNJV2v7KSLaUmB1kW)3_6ZX%|&#(y*aoOnqggn$aXY+eaR2Pot{Argf##mEDU5;Z;uuJC zBtc#dc7(&rdt{JfaTGmB0b^L6z?cD~6^k$zL^A7A{Y4>wC;-4lNz%5&)M<0)tz4=C zD8Cp_m0x>(rY9W~3OQ!BrIUHQoEW|MHK=qS4gYL~cfN<861{^z3WzFoZG;B4NlF z19qVk2n6Ty^XJ#rHr1!S;lmw=UVHxK#S2e4=dvpn?ke>5rI2}oxsq5=-k0G zuj50HW8WW!7A!xW4m!u2+H)^mc+xDu4376&OjAy3oeJm7Wit=|Z39{Qmp{90JS)ET z;4l9Cy&I-YX&N0K&kc_~{QSOO{$|YwE}s3xFD0Cf+8TpQbJfrfa)a<1Z+p)D`G$N|FD;X5FjFDjHNNTf+}L%tq3wac>pIi zLSx91Q0o2N)Q~`mF+N1qbJ0D*5@ZNO%!)`F6_o6a3F{#zpePztaaCYqd7(>h~(Y{<1mIgiY$cSd|s@VGSvxvX-><}JfVMkh^e+`a9+ z?b~-ws%fnp9NFG)ubV2ISPjL4T)HPSG}_XT934;ZSi3G|Czq{U_{7$?aq^Y+yF;xP zUU6XK+pq2&zhFjn;Q8s?#L|^3WNsikGzxn%B0lnpTo>7Fm|-4Tr=cNozF{UoYz#~( zQ?4}i6cW&wAta10Niu8z!ODXbjk+;uS+8%{w(r<+--%E$lg}3RcBN;}oEMEm$g(50 zh?Liq$Er7P*bK|DGQ|Z87G#Rd2yBN*M*IMFylPj+u6K7msS0WGC$75gj(vTFvX~@Y zJkT+4>f)1rz2VqoeY~o=BJiwC&tOI4{75{e0nbR1QKNmbk{}N{#%!ZJ_0$`OlHYtV z&|@#Z`fiyU+qvh^Tll^FbQ)*o4E^5{^1ogtDp`^VLf{`1NlP${02nYDB*Wn}Ljpz<88!w| zurVYorV^+U$}oi?R17}=MCjFH)}dvXNP-Pi2!rMlQ;-EDLj#5(3=Bbp^%sSXLkNNi z2eiZLnHai6BsCn01xO_WUl9PuvBLdKGKh#>7X=@-DamX~13t(G146_1aMTyk7Sol7 zu%H#O&+iBIST0lnFf43z51^(7!y4HfTMh-fgp!Sq>2_HQq5ti9&StDb!3t@Ox<0SXzz3S>n%@QH}698ADcWI6fkN4Csv zN@~?CTzB&UJpRht@MDQ(WtI?8FxZDxha+oP&w%eywaxWQtBOaeB34_2r8@_I`t4_w z9oTYDr4)IuIFe_RoQ_xoO!HiP{gfhf-6o!Z`4h_CqlO;fa29qHOW@6St2osK|oOlWm8z!5LF8TIImU`Pl!k80B zdkL*rn}2;Y32258fQI7m5eUNo1F}?xQ)veRPAGS_gbpP@FoB2!!!VsHL?-%v zXxar7v0#A0uSX!kOb&tB7-X~9Umz*iCKy7XnZo>!knm9o1!n-3gs{o?fzt9Y%wS?b znSjLqR<@DMYS9phI*Hh$e|t`kjHYTTjvhVMoUC8C?4mC8X|1_fbaatw+g|U>>G#$~ zqw$(#qHmyAw#=!?_djsQB~QQ8v7#;7+EA0MbkedgGBo5m&Omp^rUM1?$DFqZWK{JekAb?;Z#!e;56V27ttFxJvr_D|z62^&6nbP#;YwuXeNM(w+ ztgfuAOjT4o|JIu$`N3z_yfOQfrM0y!&a9QSRg;38>nAGes^S&V#PQxCVc89H+WLwU z2iL!oP3My_8L^#I)J-PJ8YVaQ4{d@)JN6#TsDJG17@OJBB!EI#UlrIw;${;eEiYw!`W(2t9Zht4$V^Bc>UQY&7Zup4{vQ9 z>N)({zLQt{ZcE3D?ZND`S3LKftJqjt`*lr|5AQ#Gq`l)OFYeiN$Y!^gNKGn|bCg|* zRsh9Jc03+08yX$P*kH_Fz|3{2NLyXiKw53zwB4$i;?!3tKX65anH#4y*tMNGKM7?glG^A zLnI^-8Da;=r2-MO0ErSu1z}dYG+|+5 z0Y;X{|0G$P@W&8I$wmtq2LF&Oi^kl4Keq7+A;5ssT1<BvzDD2XdnC_@-2<%%Wzu!a8P=Rm(ihf|{*n4vyrn$exp&8dza4iuR~spd#bVv#76p{?D4q6hC=<^c~ zeeb1)N?DNAqpO~)UD&+;)i13Z$aQpP(YGGujqEPOkxfhyArfXhbM@&{&b|0dBAO@; zzw+#pS6_48Vkh;BO)pI3g&~t3C}O;S)h|xH>C9OjW5ah>RF7w-U3u@(U9z^$m0g4O z{BzHke$uR?{T+XJ?#J`=+*|F8Xj!GLQ!!Vt)UF)VN*a07+Boe9Kb9TZHXK0<)1a+z3j`UIIFN7+X}* zk|dL1qf5Cx7KCLPE)6$W00O^cl7TIRVdLqNuTL{rm4f#WaA_POAd;*LMl!NWD44+FbHwvw6;Yfjo6l_AEp9(JqF%ZJl4TTBzEG_8p9p;35YFG-GQ2!@3 z+JqXUk>CO|O9P320n1NJ01yGL%`zqvjx%j?<5@FOuF92HmPc>Q8btsAAOJ~3K~y7R zSJ$!JXn!mkiP%;o;(EpWM^>J7>-pz@?DpGJyN-STmp}fm7oIC5TcijQFY&p&hBWfz|NhqsS=e(S=IpLP0~3pe`3PyPChfaq(F?M}w!)4%`P z+6~aR$t})@%~G%U(mXB^S)!sZELQ+{ew#fwEFBH-dI-Nzj4&!%IU4~ zPCq?#Tr4o85FB5dgbLp|+LQQovWk>G5zM-~a@`uly z_0d1>diD>`&Zrw-_0#`&^1rVC`3pO$QsrcK?%cZlFK-;CxXXRf{E ztPPpTbaYUtVQD_RWO97@No8-nvP-0$Y_Yg?=f=EWHDl2!7oV}j_jFlA+;q|0nKNsb zwOz1gU*?Vqm}#>b`G(@zZeyib{4@bY{A+vi4#Bhgy*kRVhd)Cl2T6yg(DW0fYwqe zZ2|C2=nk|(jQ|7?pEzBVzBH3vBAjW*=psp*nLztuR)=k2$gbN26#`wr^ocUM-{%F3*HlezcYz4x=9@_!^EMy~@a(?daWd`o@z zq3rwpBkuIGL_+@c#Sfl(cGVw$@#A!D%oD5}*Uj%NbS8Se#g|_8^-{KH_1d-j`})#T zXV}1xIV1_-SgwMKt<-c(IJ~20_3quCjG1CiI?5q89#e^Q{Ybwze*E}EZR7ThUHxIM zcFI(|-Kljz5Eew%5R(-O%tBkM1XWu#YrzqPlZjwJxgv*wF4v$XMZ%%|1r7JPmYqlSA#owN|?%ZoXGrKcaT+mY2Q{iuX=b4_KIA+c5+c@;;@4x)O z_m__!Uz2PbJ8x2JTG2VTz4FSddra#BI>tP^#e3r?FJ3wWr>hV1y7t6BzdiEuds}{e z>2X8hi9dVb;Ip^i4bii|nEc|^_r=_}6oQ0#b^ZR}FSnXtOzTNgOZvFaUp&h&|Lpbs z5BzC6H=n<8<%8FJ_qM11`ja1jX0aETWzGIyAKLnv*Ir3x>f@rhk_JTku)l@5A+BaAm$Evjl?s|Odn7ZunNDJj$iaADC zIMoo^kcbE>+H-** zInvgVgf{HRDymggpAwI@1JQ}(YSE9JL8I-vDOlz9grY4 zmIZ+=tRxa_LmLJl2?ZFySQ3JjfUkwCECJe9K|w*$1`UR-X3L6%uo3@{*t&v<4Tq-M zz%y|qY19S)35QJp)+Al#5LLJ3P*jcX1wbq!6u^*>T;)y*Rzx-`;Qa5kj@U8*hFL^R zKf%OgnH`6Wwq(c(9+mD#$zKeHW{_bP1j$wdRnrxahEzf*S2@wvw)$F)*am=s;bh&* zt9oAU9J=PSXW#L}`p4Gxl?F;pqT#+fZd-BkoG(4RT6L9M5@PX@vwwTnD{pN$IDPr) z+c$0<+_|>av@Yt1rxHouK(SeN#DvG!t-a{-KaAwU%1HcESN_GVn|S2JR9ja({G?A^^@osz;MrgP-UH;OCQUqYUV9qE)(}gF*?_`w!Yms z{b)~emqAl~F+KVAH`m_Yw+*-d>VGa<(R;ziUS7BB+Uw3d{|mop79YLvv&T>W_Ny*wel2(!2EFu54y)NKq)U3LiEr)vAT54MxGTGtb(DNSM z7BtqFgPp~E*OcvhH*ySeQZq3mS@Qb0V`Au@dZ;jYpzi?H*7?hRXsC^HgIp*8o3uMQ z=~@vJ)x-Ip_+OPy%3w)kn1zL*2%Qy|cnF*u-unoZ>k&KkgRUU2>%^?(6FcBgyj*x6Mq##4A zWQ5^!B-Dw>2?Ehk2T7758kqz!vmhe2nwg0t6O#~Cdq0Y}K86Jmxz&-0tFtp$fHVsN zE60^essC=+1f#|gg;L#lUw`TPE9ZUb)5m`P6R3n-8>cPV@)>umdg0#v7oRsZ#(3hk zukAj3aZ0K(MCF93ahGahv6lLjb$IRJ;z_fEo3A?k>Q61zfdPwR5Y{DJr9`GCR#%&N zeBIuT`qXERoBHNcKPeZzfMv{;(l8ObF*&Za=Dnd38%x6lkz^Yvjwui!9D#JvoI&Wp z2;z`soCmX)eXjNM=T7{~BX6Jg$)nF3)(uWr%$Q$)>zGTv`i@l+u^4;)Sz}@?DW3AV z=ckUJkRBt~H|=koHfy99JLg+}n%Fw#_uso%#jGgium02m5$7{5fBd3Pomf9%@+E(M zWyOT#4=+0I;TLzI&xdl!GaL@m__6cL1LuGHYfBf7dGkQ-uA6t?_vj|?g_YN(%(H*` z)}j@s@B2r-{PMjADbf0oW3K((jOo*ocdtCK{lN{}pWglZJFe;+DJO)jSi-TVh>m*9 zT}rP!V{M4Kb_8Wg3t5*ptZik^?g0TIBjKT_lS8&e{If%A>}$EWPUS zUw`wsuPmPAn}B0LB2G5JASeSB!BSbP>)v^Mc-~2=pM7+y4U7#q)s#44dPBn0-|<>c z*SewZavvuv=tyI*mTN32BZ-wHCW$b|wH-*ddF9#2ZRHL3V(hV;S%6vRWA&|0-|Wuz z$xQBlAN~(7hlp6SFi?!7gD`{<))=sea6OUCvY1nX;2tdpXC4>+% zh*)%p`hRw!T_Q$@lxQbGfHBeDfQ8^N02A4erK)0nY#0s*;AoQ(Fa#jMhS`FnorI|_ z1uzOnGIQicB7}%A3}z76{@Yid*?#cc6pX)z)!BNvEr2hKip%>rkMQT<{12v}qlKJUv%OdIpTt8bSJ#ZxXh4X+mLs(0zEGr2Z~Fb}5&#d72H zrgX!m;e;sdZZ+^Qa|s$+vG)lG;`Dew)VWaamSfv9$;7tZH~%Gf=FHEpII3~S#{Gzc zg^hq=f?#PO9ViD$=Y+ZG21nle=C=^y?56=Z#;Y3`7JdHQXriaBCyuN=D|$> z8L%Nhu&`|X9Au1Zn^Air4Yu&^H!(SmmW7yd*2Kozf)6JBq2b4WT^0cOp=gUs?{F9z zB*r7}!$!Q|DtEK0ScyUbgdh-EHXnAZN>b3nZW>4-@T&Vi*bh^~tKUsXD>Ww6qxSDy{Bh&3b#vTFVz1Yoq)6)mHrRKjRj$mk`MVr`JrNHq)} zD!#GLkg%AL;uuq-M%?lCIS<~t`{Hdu$cN+0n;#1uP1T5HLgiG}cvkv%io4n%m{AQ?fzHL~BE(bKs@-4}b5o^LlPO+w(Vr`{buz3ukzo^;DYZ+c<*mS2Bk z?QrRqTmLSam0fT#@7+F0_@NOWyXocYK7RC--~03r9)9;9k3Vz$SI+X_Tz|_W*yiJ? z<9PEX4CgVS14AVw;@MpTgOg`bTY`u3sAwGOg3XB3a=Z5pYA-?_y=0oBym-mjZ+_#n zNA7?8&G)y@IeIq!wi8GI4ul0+HMPYIZDZZc0fCLJ=m~9g|L>E_{`h9si}&`;Kek21 zl7D+>71Hy#9Ia1%c0j@i$QX&bOae->RL}$?U~&Y>W0xV*f?ZF71sXc`iH1|^E3w_1 z=!kzg|NZ;LObSd&2-k3`5m^ngU`b?0>AJ)OG7%4NRJQWrTFO|2#vRuvUG4Rgl@?Nv z))CwowZJd}Qn58;4F{UW)k00WeI8{y(Gf7n?t|(azNQo*m31VVLAu9D!5@VF}FCbV*#cY@(76et-3K7Xk zIczipkH-B95J{<&qz`+I|24L;)QCKeg@<&s^)wteRG(yue0VHc8_rlT`HlTuw>+~W zk#3AxCIw-QZxDbjlh)RR)=iMM!iE-#*gzRTQfSKrSq&*uEQBDVT)`<<6w2YG2KxOa z$DV!0_?2(%@Ist6e{#}w_Z`TNZL6UU*9tj zU$=YnZhPU6JEz8;+q?QL_UzqHzPG>jOl(#(Znh{X+qdR{J=4YCUysPH$WF;>~^K;;GlY15pPCybyvB6Jh@dTBe|AkP9i$ zOJ+1b`u^@=zcMM=p%R0S-t?(QUS8j`p$kinr9z&i2X?_R4pb)1f}Cx8_K_)atPWuw zy{oBt3TI|w|4KAXr^)B>p%S$6#Av9Hz>BC^)PReIP52{=ir1Wb{{ z&LXNKj?kDn{M*k_Q1;_)%o_3FD;qv@ z>cWpLo_y;w>o;sY@QbT2Xc{B>_ZyNiwwk5G?3+Mt-H}~3t9j?{-V?^xc}DEnpPN%( zf9&P8mW>TX3}7XS#r%^`?BDeE2v3=`cJ&7+E~c!w>g#{QxD}`{#T*`94L`W~e_p-$ z=Z_+@95VU*%GZUHMBxzoeGOBFM*2t6QiZ11Z%#k@@EZ?4^pZ1eSvM4akJcUO~%7;T4deSTY@S?_{pPAs9d^ z3K_ccrytDt&HbH^KDF(s8_#iL&P!|deDkd4-jU<)9gw!&*&JFW^ATL99Kg_uc#$w z_^b2PctI&RB5bnDu+c|UQ^_ooC6Hy3ART4FMHr2haS}R{k&;m~B7{<|yzFDgwbj+! zv;NT1qo$m)aLR_^a?z_nI!-2J0*cMxaropu^| zO%@3hdY88s@4SA-O}DL|IHmr?MeX1Japi|Uzjo8Q?HhXgzjw{#TYjEAVcEwU5{X+M zdinMr%>4abTYbm9_KG9E^X+FoaZ#JeHQiNO|NEc+;KpCy)i8eiDMwEE#&7?5^(7aq zd2jWADO`U=`>*b*y?;#)TBk)V8o4qT=-mf~Qwj?Fi66YSef#!J_kW>pcrTjUFy>P| zufEDMTy*h*TQ5Jk$yNQ?qo*_p?K(RKC>57UR}SQLL((ze(Aw69#NqzZx9?cBdd(0L z6TkG`_f;x!;gxTO-AUAX0Kg9GGKho+R`5fSlG@EQaQBcXZ=6-zHNCugd|N_m>^n3t zyKUlbk=Sy$8E)M3Jd#2PCD{H;hV`G9l#<}U60{Mdn1}_jwj@P$><6OeA5ui^DXQ&3 zq|DV2f{i3&V67k(N!F@dy{LVV!dNCjWWa%0IPC3S-F{Tufr?BHWhEJ^6ms+Bf zpXY~w@ku}&G0jaReLci6hqQ(^Ac7493o8gVAdaS=>P;g^2!;^QV3HL1c3EaN?aisf zW&ib;SMGmn!FkE7lUk2mG@f;7*^=3(ESa=$ z(Ub|(CI^o`Hnn5ylBEl09?`g9;o`T}Z=ODV%*7X;^v>&VPa4~B%z}w?CZt=&PFuV2 z?a8wyoOaI1+Uq&>f|E{N_5K+jnX%%8MK|7b%e zD^$FE&UoayWVRkCoH>8i3pboJ|4VNi8W2#m+9+s3O&R?FfWT8a(8ZB-DlGV3p;)O9 zx5Sg!xu&6I(=55}$}2uQ>%>zn$9BE9>aO44e&&(6{$i@Xn?fO26N1268R5_Wb^I-{ zW+qaKt+h;5p^B)=eyR_iu^dtQn4uZbt3gmi6Na%6RXUJ?7DNmJbanUzV66aI7DOOp zJ?&*E!Bz@wk7~_4@cyA`9q}3Ub;Yvtljk>Id`$D)wg%x?9sO$~A)yoz^k#KPQZa+1 zf@Rhk+E^0%P0#> zfHbQZc9oK;mPf8R!f|oq)5CXPzA!gZKIe?~v;W_Fd$tD1IHV;=u(DP0LlAIQqqPIW zIg$>5s-7|Gts_?xW+4O<*cb*#3fSr!jvWF?VUUi;2=-s@%K$~cNP2^%X5D+kSB{%H zxvggGgc5OoUk}QMDrYKuKl= zV=1yI5{ih04x`489SQ5h0*N>R&6Y&82qsRZoDa4f_{6mM;&VPdR0;y^pWe|}UNWtJ zc%&vByYMp~87dbZd+Fs3wXIYs&6|_CaN(G*{NxW8Etz@hq9evln0R1Yz5o%AHHO-{ z&68`}X6AF*axU9Y+wkKX|NO=8-+S^~3%`6p#}!Wwf*6K~1>2$wD+$gfyq=ntiTe&6 ztV`(Qmb4z+k}VNnEMiEw1R&7TB?;hgv0N+``?6uKTp*(Ud|_~qJTG9F!1MaD*)j(J zM#`0f@29mX5Ws=sNaGU&>BTGZWR$Q+o^;Y#h1`2@tXwkrh^O}s z6YDBhu9`IS-#1h1zSmEs`)j7V0;#e zs{p2X6A5Fi^_4IRKu8og3=LQkk^EE&fMGNt#ax1P zp*{42<0&fTm;{u7E`cMnAsJDfh`}m}AaFhZ?r+aHeR{+4Up~2Rtvct>JKF2na{DKn zTX^pVM)jv;5!th{jap_pILI<8;E{6Kk`T;Ph5aiC_N4XGi~1gWG~^)~#I%>2BD%`Rv(ePwHsx@hTLzAWf99JF;-x zQC6mfPzW_7Gcl1ugh%Q~+G&U+grTu96i2&%nHvBAAOJ~3K~&(>@lYNtInwPZHRSn| zn-VL&c2RBXxDTJB&?`uSh$XDiB;&{*+PHc( z;go}7M{RvwOI@NSZd%*MO__4W`Mdsk>xSo7_bi(+CSDKUR#*zIveOHVt`~+uDX26z zH^(R(9_%vCSV$HuY+QxXW#-U$jdjVKANCEDthKqJK2t7Qt9!c+W9qC*VBEN4EsEKk zD*$^yguksZrl+rqt<&VRHsnRK{=6p9gPid zuH5;lBlOHMKS}VkV*MBgJW9}`i~1zeX{fdo}b90t@-|HR4>E#F-{r~R=v_wVU0)FzucH}UeD)*eKNIn#gs zP>$^;)Fy}l6=P))1`x8EkQH6T#9)$O4GP#MNW_?AwP9eX5QYdNcLER*!jNP z5=?MWDY6@flOhmDR9``0X5+(ZmWqgx()oiCFqQ+Y?MOlUPHnCnbar>X^Y-d;v4n;WiYJ7&u#!n5Zb6zuO;wH~ zfQVmRHCiP$ETmOQ#M4j?jNwpF!*~un2vy~VS|+W*oQ{ze0+2gNVDh3P(L2NkMl6Z0{=uP&+21?lc|klG)5c3B+*Bf&O4U??isQ&~$@i@W(9$s$ zaVIQ>iKI&@myLxENQ6WQ6RXWqb6C?>?(Lk_HpcVAw|Dh=>8VultgeX4K*p6ODD2<9 z##V+7A3DH64_UvbbC;k>v5*_+KbVU1-d&py_3g};M*4dWq?FF(hy22jB;C1pH}XT} zN^$jjZ;fPo3;AIkWWl=c@cx6F*9Dc4k%25Yxa+$|U%sOK&L7Peb&PDyLwD`J=P%n4 zj#>Fc_R%~0@4WTEmQ_8VfDG49NTy@*k%!-!J98SKhO@csNCga`LhDK?|3wBpFwkAKkb4;7q*3v#({ zZ7?$Ec|kmp4nsfm{bX%}NY@PxXS>QwiDZ>O%79cvAC{8;YyhHOU2)VG1Avqq5q_hi zE+bApM=uLR#9l#A4q1i-h$$&4tq>DJj-rNwnXHYcNU$-63c2&n%G~_jMF;|RGfzK} zzwSp{*1uoLAB-K|IgIAkZLjqCmeA;S?X=zdil}qhA$By#5wSGfSoO1+Ar&#$k%SN3 z0TtW8AW%`e5^9i@h&gZt7Xyw|1c6UNT8d7T3oa9-Sr;KRQ;bZ=L|_|5oq>oiNk38yMcez&P+#jo&b&nj*+nm{_V7r zMPz|7`eG&%a4ZfcGQwI2axse5MnE6~mTY47!l0q4oX^G6sUY;3F*Mv8Pc^)?{+%uF zuAk64!%ZaP!q#Ns!l$Zy(rB2$HXK_ zmxV-7K*vdk_dOkxbK`Xl$X`w=Q zTYKxyy@g~#y2-}ox*AmS|M+0Xw@#V<jz5A(hC%6X zzxl~dUv1867VHoUu;qa0--9Int@txrYoP(hGEr6M7KYJuP0=GACDU7Dg(R-Zfyh{n zUJxP6)--gtH8DywSnB~2)(C);jTqj{hu(qAAlrA`m(RQU)MIYDaYOgs14vsIDP$Q! zu+b2bS#XztgJ`#3JxY!PO>8UZSST9jS#N|`vyH@p1|TBImXeO~UDhEKv(dzc2q}j> zi_pRfSPK!ePUOI0K?=fx6$^%SK`~;FMP%$pk&+K2SuhOSy7bz8#s7EzmX9CbdeuMH zzW+h-t$F!34)-oQe$F$Sb_RQV)VK^mGJ0`Rl^_&tN-YtI(IXBbf>dlYm>@w!FvK6~ zC7GcllYmebA)CO{##$}#VRD0rAOI<)ns?0b@GzN>h%UcBnTsb-Gf=7YaE5o?i|_FVLn`DvoPzo;7Qx*4k)W9_&GWh|g$S)4!`Y zG;-Dn3qRPgxo^wb!~45jokLhDz2Phvb(z{q(p5vG;F6V;;e)Y*;UXM5~bmiU)K%?0|Q~dug_j_%&X7d z=lKJ#yuFhB@a!|rmC}VDXp@sQ?juh<_RNF-_}IrkI&SLnJ#RjA+c$o@t2gX9TtPAs zk;~XR%tTUAq4dQICtR|0#y9SG=Adbgbu^Ai#M_ev)J*I1`hNb*n=ik6>G@|Yu1(iJ z{mjdU2F1SSlRUqL-0r{{!@^KpNGD3q`p?rJ?f(G)wi>KO5fv{Ywg@5}Ld8JVT7@XV zg_tcts;WN6Xqk!0cw1%I=YSyvv=0l;G@)+?cfWxd%cVQUjCg;4J$u4OiiMiFm^p(} z4!i*DLWBr33745+f~a?>szq%G0oEZSjzeoW?8Dg8kRL)sOpLJMkck~-MG(Xojv|uU zz)0dCgzrEQB!MKEurfSkxdiL@_AKVIE2lrP%negfX+BeJq&Cty6F?z}QK=e;)@iiu-IV ziRcwTmL#QgplXbpO1NdfI&R$a{R8{?euV2% zLRPE+pox08m(U)S2v)jxFO?Y}(G*Ne^O-R--q61U!V z)0SO_ZBV)8H$NRH`u9Ed9K~O*u)O)^8+PyRcbw8sZ@Ga|sXPC1|NhQFE!|shyJ^?K zgF~gTVF^N% zM?4fNaAW04&8?5D`}HT6Y~H;2+c*8AuM{XpJacH}rdL)cZG7Ls z9eDq~+gB`~cjn^hUw?QP!pH;5Fu74C4@<>maB*aOtqQW0>`2b{A*$0UF%!j{@IWp|B|t9OfFt|NR4wbcnS>-lVBTJV>@7k z#)n}ESOvfl#Kyu^s92DSw8ucCwF5|@XhaZN_>m(B1%_;3rG+&VOR%XrrdIV#ohyDeQO@GbW?sI4XN=Lly$YK)FD`IsxUt6zRb8T=B8saw&y%iacQgIccsqYzRV< zAr>UaSSfiJy>3wS^iks{1ERCHvmu>HrE3%M%!F~1wGRBUPNrh9WDV-#b?lVekG^l` z_7mP*_mxkdQ3)6#;%HdGBBoFxNP!xOFu+hH%%q)nbHUZ$|DD~%NX4v7BbG$Z4x67w zwbR&-l!XSCQ3>Za#cJ@@tp7-2iFJ&5PR&Us=!!VUfJ@oL(rl!Wg3-;_j zkjd1odUt)?b?WPDUwHAYbf!KCf{mMAY-t?x`m3vjKrEen?5USh$#{0Sv}NP2mN9K_ zys*R0|bRWCTPI zL^gy5OMzmMlw<;|MY;+7d+G2Ro_v;d#$(q$>|Kw+{j<+Ly{RcZF4^Dp)RWYdW(LRs zg%A!z2>@goP-K{`A9chmg$;`sH=kRVVd*!q`VTnxHg}wWkwE|~1$iN~feI-GM9)@0 zBpGB3shA}j86R-8mS;h_IBT*V*BZChcwQwFS8){wl0s@BSxb^u5-bsj6j&JT)x;b{ z7E(x+GNCp^tc_U1j~^x}l(?ILhs{)<#BS)<96?Z%9#+p{*_mnKUGUN0Zf1 z)lm>L5nG|i7)U`fhW`t)aU_xBR=~`huMGR47qXYn9vm6*YU*3Yj>&|jaAf50jy=0- z8)mi#+c7C4j{hugS<5O2d4o8gSD-b1bx)4iM_kyy?5VzclP*+LMf82Oge>fX?%S{GBt(5LetSp z`*-%?-DkquF_+%3{!0z(3-iP}B4o*B=iml0Zo01TP`f@boUDvH3cU)sR#e_1 zU-7^;w9e;ZH+DRPj^!vBs(37X*b><=9TfdwFq3u)mDWP3m`Wt6R)v9)PSTA_HnzUL z(P}u3lZZ7KW8$vM%(-GImP{4PB`HO1UE^@RkVwQ>ko8bglc`iHu8L)98;Zq>vFcD~ zj}5}6)>g#aLf4*&DYL&^kOQic81E-%qHhzZ0vUq?)K7zqvtI$?*z-DjL#5qNS~@$G@)L`Q%6oTG{Cfn4}@XLej;?Y^9M>5twuRvSwhz!{MKb|B2k&M<&fGrrKA$U>zo?t=n{m2&}65b1IEX1fA7exUUWGqX? z+JH1tEi|y354=P(RVq1lc6h)J1b_p1;l=N^eAm(iT_aSWh=7(lQ(vM3l0HIP8n1_1Dw<3wNtqxDxZf9S`n z!3oe8?pgP@ySmWWKt@|hWFv{B1YmVoZM1|UlAwr*?6T2-h7<%jDzpHL$PK_UE0w5K zQd(n#998~ReTM{FN-Fir#_d12?Jt?MWaDkvx;gJkm8lK)?HuVJoHu38qJb0t@z_h( zU3sK4>nK_}&c62&_Pz-#Sw-+k0y@t~Qekb0Wt>>7?B%4Cj_c|`D{#hLH1G{P~4!=v&PGOJcPisA}cewKY(ARH&;*S5hKx?j{@TBR03|rm|0QA~C3v80UdxMMUX5$B>xHkBuvc_3pc!z z{oNx6{`ljMPUxu3+nT?4&<}!KfHCOeoinf9AE-Iv>FF6BK7sKo?Cs0Sya3dqnA;%jT`xu_vD^ zrW@mt=@}rnULMl*Ud)}{%!3uDV!~!Mc*~b&PMosun>SfZJCU|N!3Uls5ukP9v@Yiht!?8C#ou1LMW<5> z<}dxxXC`OHoCwfx&#+$%&b{L2>&ru^pTj#|V7C!MLYJsM!|9|uvrVL1z3y&Gw{Wj$ zKXUAai#k4f&D+}#m&Q-1x$u&suf1sTrp{clmP;i+=#)JBYTmULyI;Zd72G(T_HDWU zk(X}#&Zi#y)9FiQ)<3nrRN0+P*QIvt@wsQKX-I%W=n9Ak4lBVnfYAsYC|8oO7Hl;` zM^2Uh>--ZCbCg3yTZ2L%VnK6lymz<=R!qb-aZ$`$C6X!QdBP4<&{6{eNY(RKk5E}jwV?k?Z(^qRh~enMkR8DGLFR*FK~SYvHXiXllTR>H9` zE;+74B#EWtFp~`(;krpzhao|B4wOGSr{)J2O}hW}!#f81==3Y;wLfusJCal2mstuH zM9fCZ$iSGDknkCiRM~NC#juj31+yot88YUjXI2fY>1wIhnw0Mc5Qu!v zKpe&UaFlv!t$}2)h+s^vE;c1uW~~J=2ijK3km_GI>ce|RY&)h?WBk|?0X;v_!)OuX_O);~sb&&PuE*vlfFqR_AwtQo?Pj6oZ=U`HZr3#~p&Q-8wQIB){$ z8B`$^+iiS1cU~lpW~;y!h_ln&I=u3hPki!$x7J_x<6oaJd)m0xx(OX)4jw$1AIS>K zvAQwNm}#Zl@cunp`@08s?&$vFH!u0gm7n~}lRLKTZsqx(K;OH(?^z7&*q_Azr|Uce z?5wJVz1H6QEvKKEGrebKl1w@&kc3bZLT?I+ASx-%wnpXGk<&-3%_w)S3YJFUaw88eg9<04$^=HXaU zk++?42f@Q}}g!ujHt&qScPb)hxq zwZHIWj~8#izGKk)0?xaX>gGabh|;_7|3lxVA!F6brB82O|KdAJI~A_>(mt_VPgN)t zg(BBXk`z2hihBT|2%B=MCN%j>aRdQMYfUFHv;VXOlz$|JR8ouQ!`q_HF?1H*e>j{NoV%n@KQ~K%o$}t|jL<^uLCtMcFZ^Y=esV03|R1 zBqCPQ^g*No%{U)QyI^z*;tSD~G@jaamDqawhdTA(;iE~`bSdvT(?8Koky%h80HqN~ zXkQitA|^{ZBLOT1hM{v3Qkif}7o3%%DI7s+>btW`d7Yi7MNxxHL&B|?RlxI z!d0{9*8lu3@7{mnm<|XK3OF#=r{32;abDAxKJ~G5YWT>Bi5FfuuxT_?T68rTLBlO+ zP^Kv;M;O##BjpKzvy!iw#-ISrC|3eR2-^?r)ncyYM!2i=}joY;9KMiWoeKONDd^>1^@t`L0|W^*Ut`CRo?N-Z`}8t z&z-$y`AA=PELtUVb7X#$39f-#(Uy`A14B(69W!29zxPxB_3KYuvG&#*mR|eqcR@SQ zej&u?Li)I%?8-TfjrQV})|sOthiYr=k6d?CU*Dcz{ou{tyf%>Zv}f0NtT|7M7YXMXY+Y%TTK#MVjd9$?HCk~s`Ql3WoVip;UNdo0!R`n zADLF*xUKCi(dM?}`!;lU9{`!J z4o2rKo*515cteaID(azaEF?&2^x)>}mfm{P+&%AY%%q&T^;PXx&9>wN)w@^e=`$NkU%k52wX%O`f}I(1G;@o- zWGql+d6hMbn`W7_B7LJyG`u39RDEaD0|Sf`To@F=f-|1iwrM$9qxOAIaYJyXA(vUR zdX6cK#zX*9iV7+co8a6}kJ=FQ8>7frU?fQjEN~{F-mX}FR?kSfXPhOaKQ`PqIyo(@ zSSpjxO(#v$WIR?KM9siaSkcfrV}729{`UMkAHQa8*H_NB zIE{`CE;;MG_xJ6+_KP3y-oHC4Vy&|ls(c1df@+Ag3Rt#V^2>Y{i&>@w(TrFgMSuAF zzdZ8P3p3|0IdkIP?xREv35o=z1V*qG_!; z*a^rC0P3&)c=K02(XMQE_hSRu5$n(DNF2NoYNX z8cqY{K=+F{b0O8VKxRlu2s5Th=CaPz)WGGJU2@t5mlu40?^|2`_S6&Ft27u#<(Uj6 zq05LH;$$P;2W@A6pG!(95)6YzfYGKSQ)kZY2oW3^%ALKa>fZlcJ(0|zfiJ&VeBr4* zpSW;dRXj4Cw>m40P5ZOOJR5OKnN;=@XV3oCH!e7MJm1_B{{AmFtE20;zw*m4Gb+MJ zN*O|ivxi{f#N{2G)iHJ8z_#9$8%n?xXP*1YAzx}DgV2c5(2hXh*y$atL!>hUdp2+C zYn;=OXb-${a3fT#G!PKMup+V@@w`PFM@CMxU5Efj$GEM3Ce1g|z_Uqn9*&_^VsgROr5kPJ7|azAf)2*WG!#l3r^~ zTp_I6678&xEtpxOf&RQ{@XJ5l!pLMAH7NGML(Si#08dGu8(^>k!*?c2H+^g4h6g_0 zbw&&$P;1d}CrXB`>-l^gXhXb5{p``-M4n*!b4( zx6f{?x%r~D{psQjKkdz*82-&qZo2d3_XZCgtvqX%AE@dcOP@NcO8c^u&j&4t*2IaB z1)?64q?w~N07Og^gcS>ieOdBedKwy68fGqhe4Cq3jjC+dg5QyxTsmi_>lI6d%ttQ1 za^b4R?cE2JQd;>W6%iok$XGsK)LMswwy=y;wh#&g-+X_6Wjvak&JK*H=FDo73Xcts zR)(#Lii-CR^x44xL-IV&G;G7*zNZYs@O&o}G?@rV>G_Ud;%+3Ym(E?#77eD3XTJW~ zTl3^up~UdOuo0@rRCJ-}CEo+kD2o*7fXomij{}BCdnf-wHxI%9D^kkC&%eAGc#vD2kIQT4ajx$z6Y8rq^@)WepD_{lG)3M%4cX3beB1sy)PE$NSgeGDN;;hLAS#y^Z#r+$NV4>L_i%ed zq~0}@R%@!|hCWLeb^sBzM#Ez=KRP!3-J3u8k?U^+ZcPo1{Q7qfy!!U5PrY|YhED^K zzywJJ)zz`dbvJa>oqO4*zzFob-~G+ozI)2z89tA{zN1%R7XXwBMKtB=iAlNm z+YkKmj4N(<3k(8{$O0&f0sv4+#snlYpS`AO_0r1sPvkFJ(*E1W`uC6JmE(n~0vwTq z-ufEK<#T2Gq>FEe`bc0&RCI_FZq#U9vV$WW0uxT zXm8@kZnNkV193|j#GoK4Yzkj`<5Q`|=B8vt=a4eZMEvPn?wQ@3=*=e#$7328rxJ1` zzaqqjb9%+%S^He~$ZHdUN^$3xPkH#|9VrJ^t!-ah8*Gd7r}mB|cWk=xlS@9otYX~@ znSGQR9q%2Q)7I#CZe?p7ax+_y;ZRU1ADHm951N?wy) zrY2tyAaKhvOoLZOLy4-2t3Pycd*`AX_8y#0=0brW19f6_`YTTjpD1*KslauJAq1k} zIZU|(0+b7AAY;TBAOaE~Bc*_IK%ZO$AQA#JB4;{Yg_$8b@)k&knpZ*dX;gBs=Oxkx ztG-kZO`#((iVU<=;AOIl7A7wI*r%sl%a=J}R^+sE)}>br^zA#A%K@`I7YvRDC{+Ku z02l$Z)}R&0(8F&I|Mm;3B1YS9HXf_0vG?@2FTc6-2e+J^%@n_I^~^6`J@e`Psbd4v z%CVl>apJ#LFYFzSZyCteM(OT%M~bEF6JJ`B&KG|6%?rQpU$}cP)f~bq3qe#2>+pB4 zKIhZlxqW;rtx-o>o4)&5-%y4w0G65M22rMY_LCmfSoi*1CFerFBIZ--#DD5lB z4LmZC@7a^iJ2Gl=M1@S$#G$@MIzFTwcWBbtzil|<>WU!i>re7gDrqnRN@{h|V)Cz_ zR+1F+Z@xP5jVl(!LLn=NsfSfFhS{W4Pza8NKsAb8vzU+N}duuo?Klh*4&!~?+aO>R=t{fO0 ze0be@BVbOao!$HQH%B@q{KEF$ot7}VySoqX-ZwThSW(x~v2ZEpTx&w4f>$)TX;?-& zos2~zjB(DnDGWsNec#|5fR@dl(bdsvpf(I+*P%Xx3qZ{o1%=RB1_G8Vea`HFVJ5Q~ zsW}Jaj0pzg)9L45c;oT=|D338oV9diOIxcJ49RY&i}482_#{XNxlNp*E|KzxGcpA* z1xlmhL=G?$qzgVRVf8Hi0j(btN<}A*#Cocy#~nEHKSQ#Lrq6e{r)FQk^rRjIo1za}o@QSA6SNJ#Qa|W;L?z z<;_mh{0w%fvCOIaZa3m{PCKZp{<|*lut+iMs>0O;!Dm;c@alWaKoA|6=yG;Q+nQd;Mw)q`9tzX0Kh;X*Nv)? zH*UY~<=x3YeeX@y(EzUIM8K6{1_YGbTcrLu>aqnt-gxBLl+4_{6Zn%Bq$o&oBBV)zn^<%WO790D~4O1Hc1jPFbRR;&6-w!-)>x_qF3y z)F=AJC&w~Hm>pJQ5*bT7>i!LfAHU_y>sHOVb4zbyDER%W=TEKiG*^B>-E#gcd3t*& zXpI#;t%Hwj9{SPc3qP}_>;Ct8&!18M!;5E+EotVc@{arEE9O@*(_@rzbSP*=!lv^4 z@}tH-d`u%`Q-xSdLwh3p-8c3f=t~Bsk0(0j4|$P2@4UtPcT{})*6tlIU3BY1ndpqT zCBosLKRp=9jr{Q&*I)jTOMZT+gVKup{U8wvK+FZ;K!gybbP5De)nZoNf{v?W0CpIa zBu_IiwDQYPFd{@>5yHrLF`M&lIHT5GV%9EcKhSe*&xSo0&#qp)yyM9oM?ZFI+huEJ z{P(^4Z~pzJJ-@oFC1j3ICVe|Zg{vr=DQGUa$(W1=4H<469M4pUd_^d7<@rnR+1|J1 z?Sru3wBDmrxBmA_Bs4G$n2qM9nyLcPSP)eyV5q;|^_S`7#Ql#ykSzHmi7`P$wqYZp zlrj(q0il%A;DU2hN;8hGuOd-1S`qS`V!SfyE0{x*jc|1`l?yWH_Zw|9ys|N3ah57L z?~j2meFBX}m<&SY0ofpZU2-b%mM%lIZ*y5-(Auk z53cO=SA1;owl@Z$(qMu!X^<2G0DNLaEy2LyN$bk*?~mImnPSAvm0#MC8ZKUcL7PS` zJyjj6ZJt@T32nWnpH&LMF08c zJ?>O6z*WgR+3XDe3~VzP=PnM66bR{+N1xmC;B#$fonC!mXV0#^6+?&4I&;N;TpX9P z=Do0aFgKZfb599FVLG${#twb!+DlKE77Qn0{2dG?2sp?xo)rOn@+Z-*q~_(IrA}o4 zG#CcvizFB@PQD8of%M5rDnPQ${AA{9_rCY*8<*K8-1gYMi(IpXLKs>PJ|AO=FY$4)h}MOz-$ObZPW2vtKL5zO z_q{ZRXMY|lOd6X80e~S8Y$okl|EKFsfu%y;5Mp?Ipu4~C^><$DA0DZxnjxhZ42C_= zK}4k_01E^xjv|{)lVAZYxMebK6f&90cx7^GIuO-`fL-#n9gbv6X{D5Ou__+VW%GHb z6bXiMg=|ZG-B_l`P*@>bI;B#nlt?7r-MbG=Z|wzFe)INQYO8B}B}b19bk1&Ha?2}L zQ^!-^UK9kF^5FE__6+qA1T9b=L#|z)0`^HZj443+fE+l0)}RnbDb!$aKm-y58b~q7 zQujK_4YE^j(Z?ne4QgPLcJ4hCPSk@H8=B6VMy({frm^kmdmq@hXZMxYUvI{$wr+gm z`A7eH&G}~(%^;9K4oZ=)h?V(S|9tZ=PbsCf1|PTwRD$X-R0eR$CoJ$G4|-APrSML?N45K)x$@(y1`RGD~Lr36Yf)Q_y6~47u8kQ_{72?>&^8qjybvG zP7R2V!8ic8l0caEZJ6G8b9t&>^b0i%*z_Tr|I5`&Bllj9Hkb-TEF z*08g2ex^4$J#z0uPxog|oBfGvx9>`c5|Tire26za^xy<22Lo*nK0f&1x_&e)n)ZWXOG}PVxyI~MLz}tWQ;P9^=KMWXxoB^f&pWk(iv}C~;<1s|eO@nh@ z-opQ}000>=%^4Ya&s*D8_w%Rk2v>`$Sopp6_0%?T`h#}_F;CX0STKYT`AnzF3ExO=> zFwv9n0Ypw4HZTd*l`p-N-n#D{MP7Qqeb5|lZ96zJ<*1Ye3m4z_#~u(IjIbHPHS=4l zLt)pG0RUiSe!XvSv;>pdOci7zU`Gs58IL3!skgrlF&jzpifUcV0RZHt2Se<<%U;V( zA8csv&{~fS3{;~Xw1W^drLR%&l2y{KK?JFV7Xf#@IoiGHO>g(U%e>hedKQcJwd0r?KQk)rrm5TZNc;>C= z-+KA6mt`o*LvbS*&lL(4(aPgf6~+GJmkz%hurTeLqemn-0+=LO08PLwKn*~sG!T+7 zfixlqUlEgF2-J8I4+}mLBVp>)2`uEGx{EeH*tTHa`rlr+^}xg*9^d)oou8a}PRsr4 z-!s}*7o#(V^9LH*yADnB?ms+(>1j`+m6(0p3HSIMEFs7T0AZ2V^51X%)D^26YGao+ zG&Q6$S@bd=`^=4pdfxxlFYoZQLQO)LQYru~m|%hz3OQd3+YETp1qQC`ORW&u(0Iz> zG%_%i&6P@?ClGBjD4ERWz3qFC68VU{J5-nsYac(PzwmX=a$K*UJEUVF`j7hkZp zva#!hN1yFJdMsAe;DdMk$k4lcdc6F=wp~6Gwnhe_2!apVqpCR|6e?Y|q@!dS8MqS2 zCoT{SQ07UErcwkxfFz}n+a#)~^E8;bi1xknKVM(Ew`aJ$F8tRYUwy|zyYnc|U9)0O zPZ9R_ylVxa_463*1a`tGZuVu7jKFJ~14<1*HZ4nTG{Ebds#$65AJ2UKK`}4_NXH>W z$U^}l7-y7oK~fq1skKH$gc>;~B_WuAsa`t14rX3J@h(UW!;zPuZYd;|LMBOCA`==U zGT~`6SMo}ZM^2$XDOBZIrpUgyEC0mSLtu(PS!vFq-7 z=HNpXAV%U?QWd#&VWD6kgq)LI| z$=#G80224X6r?=q%E7^$;*JiL34e&-8HRz3{eAKO1GAk32h9ERZV|>_VCUFlb3#S_QsvbLMDCT70sLW zX3_)Rndeme$C{Zx{L8x6pZ?o9t5y_)b%TfZq>t=cvg-7a;Z#18uW4@?Kh`I7Ze+sW zGnkqD)pu^a@!b30%#BS2*z)DHYaK3Hfjt$mVD!q5uj(J@H4WB2yZOMLk}Ue5ks%+7K*cg-fMU zWz>j76T{=lsp%X8Lcz0n$0<0j?*~ki$SyerM6?Z)wE6419)9|TC+9C%zG%hSmt22w zrsz+PkA3vIOV%H`Bh@_x)zz9fa+8#R!ZL?j6{prL&Q)m2~{;1i6ElPOUP zB0~Ma+^C3PK#(NRvf=b_`pvtYbI)z8Y3uFnuWOBO?;d{UN+? zmPG{@xgZ28!|B1pV4QM;aQsE+IuB}=!1O3|KMf5Fp?W#wCP8oz2517th(!Vu?^l>} ztIQlsZ1rTMH=96cqksS-0|34ZWE2kXO+s`Ut2lrOoM3to6YXGKN2ST()@9SBDV-aH zL<^EnQb`a5pfm>nRFV)u`-oi2JV?_AK~nLu-cNxhra&W=)#3^OH84?@oDwqP0z=hm zvJwm*6hhI1A{3GuWB?dLQANk{U~nYTOn^p^9z%yBRZN0DG~p@^0w4_FI7}dbM&t+v z83wvU%7y%tG-A*gg+l`X=1EK{aAF)h1*QN3010RSa*#elp>1obw*VFc21F);%h6Vz z|BuYJe|!QULkR(%^us};vZ6Yd9%0O40%DROhSQ4kRS6y87 zi!UwQ)pO#m?=Sw#n|;5yV!?v1y*_VQ{i9!Bvg$i;ZrfkDX7!>yC&nIm=$TjVzLmUG zeRbpbU{Fpp7=gH}WvsTds%>sx&*9wE;Nqn#zWT%ae|qm5pZV~)m!Da2-<@xgafWD% zusO~ChWm!oC)Qkex1XM9o6+oeB`l?Hy7nVWXUu))z<%Fx%Z60xds@i_oilcKA3gQ7 zg~EU>+YT(8JNxj_V=Yb9$~83CX0ut2ysfFL|7c%ZQ*}0*ZD^=G+Bc4% z8X9WGM#q;fm^n0&?m0Rd5T>U+NuaelfBCY8nuPE3+rM!~mfV6TT#bTTNznw6N+19( zNpdKTp7-%J*Ic|7y<&4bSW=1skC}KZ>3->lf6b;#rZB$$&C5>hsC8T|Q2{WU!HJx{ z?KiJY9UcLjfm0GI)>;>x=}ghH+jd`g=7NKHXGUB6&fi^l{ViK_(@t=n`Ga3vV*(GH zJQz;-r|UftA{GeN9T-oiT-Fx<2maST7j&RP=>RGuBF&Hisq*62C&?5jArPnR5cI9X z&U2`CIc84K;isXl3u~8=lL3PR0Z5mG0kL}6zeyH0XZdCcz4U)hq}43ub^Nnn@Ok3ouOsB?4$HBl9&70V%CzIU42M z1+JOYANaq^g)^L;1PL($;J|GlN4Sb>2B@ImAQFiH5TNIP6+`s2TO#nmKn7Bm-L*sj zpoKsH^0O=u(Sk9rsFg-$0n-A|Cr-#gNkR?40i>MB!B_@t0RqAG0XZQ8NG2GSVdTI; zY1E2{G$+sw1Wo38+BATCqOv5JBm1W}n-7K-wMT?377Fe<)cdKgf2VgmX$U)WqBmMq zeRwD>31Zar&$oHSukm z`cK^4WmyKW(!!ZlBa>r+j`_zY$E$3X(`-8HWRq#mbG}x^Kn+VK(G2l;Bd@G(>1-I? zc3>*)E?m~7c?ceTkj`4|KmH_54$i8AH=lffg(EQ&ORk^GOxDku|Jugqc;5lenD2N< zzzq{rv92~zF*-IlG+a>;n%CZ_Q~|WtTwOhtoX!>UzOO>jh+8Tuf_$+ET!$h-O_a{& zs%t6@lP4-GlvEJnAT?;6YgW1VRhuGvG=p!%D{I4En+^%VqyRUmy_R$j~nkGXTX& zJoMk)_Mk9OL4`5wdxKifpoUXnItkq`LG3(fTuIq17$3CQng-Yj?Ac8D_h`lW%noK9 z2_k@oMS?&%zyyG1Borz@1PtPw3#sQ7?0uFxFDEiUYEVTmgBS`EGVn`81R6n?Rl~$U zf~QfNq+L)p000-D2?P>TAh-Yk8==y`ED}fs9Kk^F0m&t9gY*qT;N^=JfDwn0Jz%*M zX@tRpP}|8Ws&#e(IBEsJ0f+!Kg(5g|oSYHpJcq`PfDzG&dMIU4bD|OmPCfxS02Xio zT7lMRaw?vU3WWil2aE&pGH?}63e2%Ae59C5MgQZrrh z0ZI(1zP`R9;qKgbxTdmVVmdFZ@X$c2zM*c9N>0IL~(c!M_)@etxfKWgD%1TmwTN_v@I%YvzZA# z0U#)ZNDvluK~n%sAasZn;=k&o0YLhsFiJ)oWZ@*4mI+WA3{Jj+P$fCX;OH|nV+}T( zPRSG;x}R$2VAI)DOo73H6d(d42vlI-E=s?TE3XTL^Kpa1ehH4euBUC(stgzdlnR0X zfRrXPN;A)cIakt==V5p&)Sn6>3{tUDO3N%WEie*fhJi{biD?@VeYAi_NdTY;OakMe zG;qO@EA0xB0stIE)1C%{!{3od3;_+$1YB^N6Os08WH$9a(PbXL<>t$x1Mio)mxpXibtt5CHyo>y6W&xFi^j3@3AQs;+--%=qm?N6FQ-XD`3=^YcQklb6x} z;S}BK2)5N#k9H5BgtCSlG=V5vM+iAl$unA`c1sU{>y=J*-=9EJoRt4?4xC}xS*#Q> zj%8jr5B&D!zNde1*6Mi`etqpl*FOQ=%rQb+c!4kp6AJpBy(g|&QEv<%lFpp%hYqwC zy`F(1*`tRHV6OD(_*ms=%0U}5nNyZ5NM?&&)n--9eDSS*bP(znQ}se1LZvcN?|k?D zcr-R?6pGoYdKSL-i5G{4`~UEl`yA~mhSGC|5P@KDU^LA@heN@1HWdtoCX;=x?}US) z%-}#g8qp*}VZ$kw5cy;>TM-FIY{O8BY2Px;U?@B=HaV3{d!FY?h1@U=AY{g=>vE_&#hlu@pt`+x7}!W} zS9s#OOV2%bWa^CxIth?#@s{`2d_=~Umc?+n%FrThWanGYCx5idhg1lj~<)?P=EnFNWY! z-$ravu;@J6^9Y3FI5J8TyUbwPV7{04T)z^69nidhs35^3q7W(|WXjWs<$NT9CdVU< zBy237|2~1Q5nLZc8Idi^>|6i>QlPX}puvLu>ppx={_dZCt(5N9@>t`AHLIHRgYP`v zKlfUwuEyzU;(}}&j=Xbj{q*mC{OLp6Hj2K!s_?`>LLYb3!K_IQi*On^=S(1s?-C`5`+LdNKTHK(B5U1{L=7Ig`qf_sHYvUJZ6ASDIiV(8!d|_)64=Z#JrLZ z5L590V~mxFX#C`v|M$mR-}eK-;4{0%x?Z>1YooQT6&xXnf>+to$3~%V0%{Y5sqX2K zFsrXn%3}trs5P^Wd~RRwD?9TfBH(+VG$Ej71Z8ic1_3mccW1QP4PpJ(6mWrv+V>$) z4ulk026_q@0s?6Qt#ozl?bpUXB(|Kru=2%wdM1;x8-BTKDkrHnan*OSbO&sYT=A34BHjIppH@4QvL1$L` zj9vSW2W_*yCgwO!XLEfjS=@JY&@zIAz%5e(?C9w(P~r5mYQB5hEp5$BfO!1qVG)R~ z`PA)4`i5b_N1f_z33NzxBiD*2wwlmON z4kIcCJ*}50@(TC15-g|l5KxGruug2oUHJ8WNoKlC9-}d-1gZtI~ z;LgJ*aLs3d!9w@_Nq<7yLC!f*0JN&EXYuT&NPaAz&kH*eY+H7Cye(fc(M?ey1AYzg zFpM1tOdkq|3Vi&XnU#U5qGLA98PDcMM~fIfwWP)osf_p0$WSA351329z!nk-eN##h zL`0x$&K<@4G-hTUWRpNEEEe-Xpk$`cm@2%|A z!Q_I=X(|H@F`cTKQTN?jR&9IvuAotU#idtALV@wY-g_T^)z9oc-qNOvTze{+an@cI ze)P5#iplqSCP$NcTW|LMhYtPjhpT2);^GAjmVlo;vFBHRoFpTD=5qMqr@L$u{`5jm zZB6By+m8>7&{w}Tv%nm6(-513{EqJ|U=`NbXnb_Cl+J5m(DoC_r(c;s2Pv}y7hMa{2w)lk2sEGu zk^q8`g8|Cda+~s43VZ;8T5CW6VL?ozUm`C^E+9xyh`>Q9(k@iiY8e`d_@;zB7C?Lx=eGw4B%0$r6!p@Hk zoV|4RoCO`{-M#@b0CgM+CCnws;y}80)L(SQrM{EuXlnqIAK1TpL32CzR1tI}rrnZb za+4Wcm3$yaN*S=saKt)xbkMMZV-u;W+8P8Mi^l}x!y{vJ+goRKwCz89I2aC?wk4%! z7zO~?wrLOp#suTcG|(`8g+fRL%CaLx$L&8dIMQ=u!wYYEEF5iV(xK`TJ>7|LU|^)k zx~|ssvtfD^hhLY=&%FJOq49~4A6#)!28;vUJ!VC7Hj@s=<9%akp3YWRL<>%4cycn{ z+!T()7Dt`syOUGX#kaB%Xm6a87zj2j-Pv7WAQyB7MpBT^4wQOdgRZk-#;K4#K|QZS z(P?ZBKYRB#T52l)y+@0P5b4FE*^mF}NM4!5+>;C7-|mudl6-A~_Q5nyx~fXvb=Swf zcuvPl{Zl{v`i#!?2YzwQ+)tA8=(;>*QteIdpZ@FItp~@HVbw1&|IddOrY61fC!&-t z+_WheD27k+hULfz(5G_O^`kTFOz$LnV_ZC z8VEce1t40$Y^^~MC~*?Pi46P_qD9)bZ4*fGZ0XvMU)sO#4es0Xy5`#zwT2y?pD+U8 z9or(_8ZUws1~02A6z!rf2GLc|5=ov%>S6z2W z=l1@=2j4t)(Snw9Ix9bQc8e^It(_B{)e!#a%X5|Tnz`Hl@sTF}ge)F``KJze*p)iedfc7urO2{+W)K{)t zblX+4JOV`EKp)dO%(w?&0uWIVRS<*=U;~tZx`%fhd|`rRO4KDGIe}J=8W}K?NS`E^ zNFTTf3;{VvL|#sy5CA|akF}MQh{5sP$;}8Ek@|p5A~6voVG(Nd6ofd0!r)C%!UPr| zrv!B~etmbJ;&|1mr9SB&YeCf)m>G6fL=U#c^Cr>+bS;LHZ>z;h!aBn}egONpZPaN$( z5^Ee|3n4QMM_(mx(rRtF?Ch?49v=rgFg-rP1aE9=No5OTscdC^Yslo=ckj7i@hnt) zcz9se?D-Sp$*%T_riR3UP3v#Iyz8r4_^W5vAo{OU@(v8rlMU-G5R@8`8vZV7$gvJKm|8DrP1S#n-SqP;q@uUH~7|9|nn z5DbkVkuFQ9fgwX1oD&PI?33FUUh}ml_da`Fhw1Gf8JqMXB&Shv0ZO{^t?sE`K33u< z)_ZH&h`9`;|9|Ov@Bg}rYyE$%nc3y^qFyaomb>MK3&u9h^creHNhl$tk>nJ6dPk38{=+VB^ODStX@ywWoFjr2N^E;-uvDEfX?e^pEYaEdYX zK;m{NS-dFO^7}h}6>pgD`~I9InTERY8#aD;?XpFGS-#ul3y8>I1`r1hfEr1Yu%IBp z(TJ!4r1k{>cz_u?p0R_7!~m28L^3#Vum#gfvZ@6~$v#^IN~TUEyVOjSIj)i-Qc_zf zKk0`|0UQT7B65{FG-FzP{M6|w-%6H^FSz;Pq3qJ7OaHlQcYl|Pk7OYr1fzoE9qP{`gU$?MQff zLw7G#4j=6Uhr-ElWSqqrKz_J8b?K?&etYc#LuO9DEP2_i8@7*F=EA0qzP@*whe0>k_L?9m!i6JNy7UHA|A8pt- z41z<(FNp*f*OinbWr zE^6!_9<3-T?&%%%v{JrX97}tyKHS!8aIk`buAc6SqN1LzUWLrHwCB0GTt1nMxsIz9 z8Ub5tt)wOa!JwTk`1k$e@#ynUG|gQwcgfPzuRNc8b>L9T<)>b_>aE`1wViNiEuu#x zyp_)koqFrc>aym;M=GOw%dUMQymIUQy@SJ<0Buf2?9p^~T6J!vb3=)yl<-TcI@7ySMG?gyXSzWm3h4`U39Lm>0evWj`5G=4Icj1M(R z&S1@+o;!Z>&}HW|))j|_hK2`I`Avrl1AT=B@BXr=G@0@=k!DEz{|x^ka`L{`ax9q^ zPyi_%i^85xnXU{^HX~)wP!xHjC)YSSTptl2HE9!k5<*O?EP?~CsO}>#?(9GBB#o`_ zm5Ie$jvQ+!FRmL`CQJ)VOtqV1I|nO>LT&eC^7o9=o@uf^Sj)S`qlj zxEMP8^>5EEnsr)R>oLK&^!&;5W^dcI8B{Nsmd6T+s6YYwKmxcVQlJx22r?x7 zV6b#JchJ?Q6)lz0Q@*sg81RPDeS=)|Kv@||?fAe=9UD^1Nnzm?Y?T!vb~ybn~u5tKKRt4%F3F z4-5^ZQv=ssc=4Hy(^hWV;CY@9LQ08x4040M_8H@ru$+QdQc{x5W?bL(9CzsnjSJ>9 z{r%ZD7tWcU&gVVHA74{q**p@cYwhe2hEWo)G)<9qoUm!8M$$?I4zzY#f&mG}1Ts2t z_KcE9Fzx7je)-q--o99(EMG_uN-m40ffFdP94iv?{aAn7fm4fVaV#6Z zl$4u)?4=_Fm?0yD#%NFfZ>}qU_|T<|^-X6~n&YdBe{=gAe=dD?*XoCMclX94G9)Sy zjA&)Th?ESEq!77gsI?g=Dhfx6QX?KP1GJAeBc%hTDyWb>^M;+i| z?D9ebXW(m12!faa7JvgFxY9zCU?2qmD5b<$bcfP}h}t3KW4)}_nxV2x(-M5+j(um$ z8_%-Yl5tJG@5e$>BO=+&Zs0&cq2O|J}u7BU)fy%i0^n)d5-)IJcjErD{{`uR- z6-}CQQe)e$ApzV({mjZkXZ`W?^C#5a@#cU<=d)1EV!qZI4ePZB zR$UOES6W{BmzO{Mg_=7n@y>_sXPlHcZ)W8czk5t~>|eZaK}~U0 z=kE1Jc3`C7m6X*F9ooC-%yXI#cX?d{^J|Ol`NI>f{n?-2c=rD0kykz#f?$BK3^=EJ zwz4?z$*V6XDylfsg@QXe+*3Jz(%Y+EmpeBK&Nb73+Sl53bSM;JOy_dBU@*u{J~A|1 zRU8kN$D*du*ihR&&^M>4VN!kBmc2)M2L?}^H#L+x9%iF!<1DW_@eV2Ok^;Z*iJu>&CA=cGsyNZQQqWch@yvp904|#KH(!VJHk6mak$Z zE))Dj~A ziA5z(ujvRiv{kX8KYuXLKg8~;Y~9qBrKpKW-9z>>D>hwvO8ucFGm2k15YpbN{YM>c zA&+GWc>9xU_w8ss|JRr0d=9p;Nlse3`kiyGymfGZyKbSXwt8>tf!3bkZ3RHfATB8{ z5qX~zc>kl#-#y{nd_LlNPFY3iU|0KrgZuWR%h9T|O$z`#R}wd1ETmKg!SMkAHJYZ> zTyX{h0CJv|Fy@?R00cY$N|V;W2$j}alkWyfXKnp>)vF)(+_$EM2!KR#@bI=Zn}(XcI$`(LH|EbjrE+}HLl6Jr)mQtPzV*wGN0r@Q z0E>qLfsLz2X7#U+1$Ae;{Bt->rX_o0=l)=OD9)$Xik$ZL9C1O$p_JeDz=5|n9}Nb? z>J2@?L{}jj-1f=HYg^ZaLVQMTU?43wwn$(_wspud`Il<;|6p5?Ksl%+dIVnTn3bs3 zyB}TD`_fI~d2s)Ml^?u6sB_1H)g$4PrRM-cnH~A%otG_HQoO0T_ulKzUAg=4 zK%XREf}aJCfoY>hR1}7M0i28oX^ztK7zHdu6ZGfuR01Ld+cc*7e%}sOc8T858I9*w zK6I)ryz=6icl_(K|2lWdip|~k|NWB{f4(FU!i$!KET2Bw-M0Dtjk{j`Lq0!PT2whW zHQM>vs))fAG8U?=oKn1`CaPpZ)zleX-F80B>fCi8NL4bA*i@)|lUrX8^=RN-1x8^2n2gV{Iz#@q9gJDd+!M4x}V zch=JGiV2lJS~59gs0SZk1ASc-i-8#d$8%P_3(1MeY9Eou{r-6C`z6s|pfK`%|) zI}egcP-Kx=jBT6$`?mGJUv#lFtKq<>H$S>pYXCAR89*>!y8lD4Gok2px#0{cCmXu_ zx~HGKr~lT|&b>TdRJn2O+kd|Mu3h=sp@Ib>4TzvMao>mJA6`48@Ml+DbyFf<*4ftb zyI=pdJ(c;aP(jhj%qakjDNu7j1kwkU2NFOodCHTdxsMzLj3on(Q7b?L98dq&z>t6h zGQ*To`Ghe2@+Vg=-+83>t0y}r6&Zhh@R41cVD7hm|A`lOH*~UKK!XOAfhlLL-@oSY zy`PhP{SNEa$fz{q(yLHI?@{*Q+-#!>rP zz#LnZ001BWNkl`}fqB7Ke&iRzTm- zXgxUCCWLUM8?Zx&j%k{TbkGV)sR9A~>5W&Sd6a^P6{4%bPc9Z4!7&kt}!tE1b&mzCb<9WDa;&-oLddne>>?6-tsq zu#uE(9jR&F77-tQJd3@*!NoFqC= zKL1Kfdy8#}fNAmg91KT-w(SB8c@A(=ivIKd?|-@gA%u3bp{9ueXUE{^2n(K|3mO~` zNl_$0p>e}}a_+f%FG`1B7|#lhae z+>tJ;UsO6piy!aG??b^KfhAkKwS=9<|0Aq|XMB=~%gav5?P!Iw}qzS-AkOTn}NfQwH62TywVSs^R z#0Ug|_J9$@Owt5ni%nZ&K?`KI5Xg=PlYFTNXd=>Nn5Iyk&)r;^o%+%DZq~8V41}3a zgB|S+a~5BA?d31Ldk`##O!7QgQW04^F>!Er{+E}YxU;?g8)q(hWu0Gb%XHc3ZEfip0$C=of< zoz5PHbzZNV8r@JI3zY?n;(^v;IDqdVR}e7)1tPR=RYx2I z(7+7jND6^72uRQd1&}q)J(pX$$Wjz&K^bO2g1X1Lf3 zj)!P9gvv29A}kXCkZBYiL!pIFpvluf98dvi;FA6+^6(A%w7 zo>^T}73%Ep!4QZD?6@)iM(3a`!sU`Go4Cd!F60 z{1<1w`OKB2rNLjl`svr^H7s|BYHO?C-SpvWYd5Ij9^KOt5td=2SzL0s5H_tqWh?+l z`wktNUTqM<3-9g$VL{g>NVNdiU<3{poQZSKbF!Uv^%J;3T}O7$Y?y?;;rfzS1Pg^B zLjVUNAqs_pVcGe-YZ<22+E)ZZ>~HOBJ<>CwvHr6??fVaPqu}A7?JEkHCV{dITWjqr zDLtQY!?XlSEg09Nv;ss9N|RPj-t9PYbhz#4j*qsq^kjS^5DbOeI*!JRtB37+bSx@V zL*rRsR?uh<#)42ZW>yi539UWg5)e^ol0=A*Bp?DMfC#xk;2|+$4AL3s*^f0fP`rSm zVHoYkfgQT~M3`|N?tGQ<-4IBCmSCXA5>Nc*Y2ri4vlb*uYvVQybhIs8uqa$Hes@dD zn)L#Db5Ktp3&3OS_zMU0pI$N~Vp`;frMoc)A^@6eML-Hz7=Qr>kUlU)krL?I4#S_q zyh|`PjkdoI0|&q=0$E^MYKCMOAPo=(xX3x#hB4v^7)fJxBb8P|xDH4ov$O&X1)X^p@vh6I9p8jt`OXQoBUAuUO}7zu%2fSd;g1EEnWLIB`^d~8HQ zKSx|ZJVGju1qVzbA;9OvByr|QMPtHgO~8RP5oe&Z20-G(0DMWDfEa-SVt|ZLjZN|d z1d2c*a2k_sf+o_Q?`5-v{C`Yqpa07UK}p6r=eCKK-8a~iN)J~|n>aL@N0KBlS`=&E zzpry3Z%!$qyl+|dV3+&bXLtST+f6@vVBL+X*}+u3sk|8k6~aVU-UIqT04=TdYTEY>O}PSG30k3L5fNn5 zVDPb6ZS83Q5So!61R^9sNJI(>n9MpA1501lBv4L$-B$8$B6PslVe2HG0)R*!{Q zn=$4q?WQm@Op#Iu7lSuE7UYZoK$^4!U}OXkk&Skf?~xs&NEyfiQyzUz<|&M^RSAJ{ z&=x8F9ODPgm-$r(U}8GH1zomt{sq!=ZS~{&%1J*W1}i-%FBo2WPkq@OsYu-z(d4B^cLCNBeKTd-lghbWD4;=w)0V|Bzs@op^ z`1v25-ZXK%%gv#D20YJoU8%r8RK(0kgj>N}!EsZgC(oH6Vgk2^++`9Mf%g#A?u(>2z(J*;t3YcLC$8mtjvMkQIS5QghSEM zk-}XMJo@kxPfngQchQ1{O()MGgl*eCKI4-4?@@kJ>jdnHQrD+2*a-mIm5_5#aN+`J z>^52>NgWZuZ2$qOJO|XMiCho?@Hr}zA`)hu22Gdh{cl2FJDl`QOdW&rd9>{bI`|Gv zI31cUgx#;h$WhW(d71j;jeG9<=bCrld!@te0~)NTXjrr2-KiJWxYbj>vj~5%Z0fSh z)^_=XOyQT0{V&avK4~oksN*5jq!fTc!HEns7%_&?V(j=#cWuGNUr{CXxa%G2Jq%_P zlmzX8u#kKZ0;EqW0N#LZScuh)7E@s>2j$ZsSqJ_o@GvM3luw4iFramgvT3ZGMO$9N zv7=X|LtqQgdTgR01XM%;L6iX_0@^_G zQ7cNuh!+v+mAxRnB za2&@l491x2dA4nvf-}an(uy(0>GTD2%Hv7P3O@dqf3&l|x;#eqQUc2y= zo+F2Y1*fiQYJV&?x^dsqi>6I34Oi8cbnWdjcs1w$C;k&aOHdw+nd*T9BM_W?7Xk*E z92BSh8_DfvCts?|8({PMbZjRCqreU3IW#89_ZdkB7y;D>jnkm!RI7bkHC29EsK8)7 zX@S0^-VL0k0VEOE;UXxT4NjioH8AcJ+Vnb{cp*$Z5B9Bvy{mLGjEICb7#zx`YmopP z8Eco6B2=2dKqO)wXjDLe;Ay3$fdqnx3}miW&_4{84T3=-g9u;+AsQi)!azr=f*Hb| z9TU8@xBhTpNs%8w-QC^0eC@6ej*P;LYp68?vH+YwgmAbcd~EgiFK*;;WME`)`qJ^Q zZff7w|9o!Z=ofJ{I-4>^Z1ph$!YDIgDghOr2R z7)nLlMqiW%!ZT}%4Q(*#0Yjfa0%r_@0tQ0)Xuw1SsUR2(KKA`ner|7lb43?bmOwBJ zL+hdLL{t+dlpbn%^eQxjS4e}aJNw$J8z!w;vtoP8PLC7=jT`}(BFq)imStJOLdnr$ zu9Ig3NN5Wo1oxHJS_>hBX=Jsp8D~t}hRHw!6Rxiaxn&B&FqF!I(ww7`9s@3=7Yc_b zR92pT%EF0FCtmU05uHkL&NuJcF|}dRO}~14{iY{q+Sw4Tgfs+j=!sumbm`y=_ z0|7wOk2dUE+kVPbRUh4U>X$Ee#%6+lyuRyqw?5dv?{%Fy9m-F})|GH@6O9bQ#7m&z zCTf2ca1~5A9cEqt{f<9)*we~)^M&-tsb`%Oikxc#+2PPbD_d~mOQTnRR|92z1kT2= zi11}2>F19aLxXNy2JUld|`w~BA%>2*4#ytE`-re zsGbfeVebbp(PDKA8%~rEfUIKQ?*)K@>w)0N4I*L?Aa?u` zosaQqHFC>zBV(?_dA*F%-NHp@yMB}u2{>! zmf??k%Fc%jAu)p_cFVVCjq3VNofy``hT)V( z0l}CT2zooaK}!~3wjmU1K(T*cdjE#aIP=EOKK|&P{hhf&H5on&m|7|T9~b~=G)&Nv z0s<@m0F;`59p}anBT}d&c??G#NF#B99CapFQ6|52LBmkC@UOMqKmO{>x}a+5DZKDe zf5$N&f(9E_OHZ|5{P8J|uGqMDZ!@c(`s@Ngnb5|mQF&|rj|dyeBOvJ6fHnjvQ>H892qwQZUNDpx3k zLLp+rQ24G3S}D@ahYzoQxB20xUkVn*%d3)e8mH!czpH=XjEjwdhQ-8AgOPo(=Pjg2 zxXM~s9vI2Xm)7k{<$X@tFXT92%H(;c zO_{gq-gGMSxwG$MHij>@~Q)w-o58uy5NEC7H~%3GhUhDql@&rxWY3F$5z z?bgB6oT0bRF7GUgCVPhcw9|jq%xRyY z5{MYhr(d~rYDE?N_@(B1uAdiT?#ErJ?vZ{dAnKg(Dl)`%`{o-jJJBEAMQMHIl~;LS z#*@X36Ay-it44Pn`Ltq+I}`*Ix_kF&vq~3FqEvrm<|)gJSfv$7%wN1Hd-t7gd$$)K z@|Zx0o$1l9T$y<8$Md@eGhZLfJ@op4-+$wTn;+P@uQUJNGxHXWPqvR{zV*P4jUSU{ zc+XE7m(EO%rgOi0djGgse8H0P|GHz}36sJP-@e!|`19-9?|W@nQ9n+)DKDx@PA)p!++Q^% z{Ks!h-_iR?$G#LrN*E6Q{-!0Lw6rgO^2Hm!a<>LI~HFB$a6h*{*_CsGwcX^Gwt5JTDv!YELOrwrLj% z1z;eAAw5q7ZQqwj+TbEza4gfXEIX4)MY~8?)l@wkKcQP4e-6kcKH*Qp0;S#2Yb4_gRfBhESU36 z-2D`aJXN1V^``?j%ZifZ7=OIykI%pQ?mwP;<{KBC-gw3p_rE(3vn~4E;roUE|9?k- z25pNm2Bd%?X#g}}wD()znEc4~OOB4hciP6?amzB1C{fazbN6>Hy6m=zGlTzr@)z}G zrNyPC+REPbov&=(d{3^b@rA$q*ZMt2zjgg&o38!SgKKOpGup&_M@02b)7yUi`)^M< z;Z!RSZ`rZu*SG$3=Cq!U%EYd84;V>Ir>J}q=0_F=KfQTjS<~6KXrH7DuRr~-zM*}W z&ue^P>kbGuApmlLegMcPZX6d5Xbr&g0D!_%ToAz5Pj8w!KK9I}mZQ5nGr76L29Fr_ z1rrlXE~>6h;Oub~9}SG6){|?KC2_Mf5y>bKEvdde_wx9{H*!|ZUZ6nt_RE^H|3A5J~@!QSs)IB(vpl6h6( z>GkZ$9=0b>4?g(8V_#o%>1k!_KRU{ozHm<2{?4`{JNm1eW~Wny3+LASIJSNE+zGq7 zQ(LySJ#x#k^_`nP{h*aha^#pK|4Tg^!Wb_M!6Q%_7~?iDL_`u65CKRKCU65~9*7YE zx*QQ1Xkak_0P;W>5G-a=6C!Z{sgPid`2>i-7@)@E+%o{J#-tN~8prk*+yI53Jz|Us ze$(92vJ!LY73;{07uP5I-#a?^)$p{Ynl&4{F`0y+Y)!q@)L3-I5B_oWg(qKg?WG;f zJL2;ec2*CYo`Z;a&##$W4o0ZlEYw$*^`AX+!kpF5KKI@?uD>i^RX&?LJW;WH!`{?L$|sOgo;tN|W>w&# zJ6D{yWc<8w_HS2g{^9G^g_EKyes#|IKYqiTeG$#O8b19Oq!UBIX+zqdR29r+t?O=o zWTd|*m*%56>#nC>gSu(DssRbcMT7g5p~=)*^Z!(mj6I69rz8jg$^*{8$5_z0?Xpw5 zQ)DoC-yK&ekj;ZR6a9+fG9q=`EtfQummV3--*L+sxBugvgI#^ene#-6c9C6po?Kk=NvBWRiMxHj{mnJ=&ii(EXLrG)(n)nc`T6Z{y!PmVDQE5exL=Pe zCr<&`R(k7|OZ-!Ay1TP8B|?S=BNu=D@>idFx}+%a{N_$+j0XUYjFbu50Ih(Vh)9Sq zw%1gklwt@_R2=-}iyNw~=<++x{rNk4F23!x_Pv8QpF26N^Mk$~@*LaCLCiinG+3N0 z2Rjf15Cb#Nna)PzNy9S3MU~tNO7NVV+caw?vrVCcnv+Hd z0`(8NiAeZ@lV)(kcw_zk5BGK}P?-_?M`yni7s=A1@W5yeka5H8&wJBqD(lOOT6=~c zetmDR<5}^@V^6o=^wamwm@|G|d;h_<0)z|##k7Jkbjg>uwTPeq6qlqK0cjstgwUYA z-O%$s41NSXYaw-*%s6od+LzJ+V6Njs-!UlUVRRG+`XQAiL{btJGT;D=*ccpABWH{o zfErAbG$3b03JHJ|FapHmm_yU#zyUnz=fb9488oWHRA!Lfh!6ba)R*5oBKwhSAlI2% z!U6yXooKhRwr<~$lay6B?3tZIqdl2iZ#qAi&N+%Z%yf7tR$gVzxv*`}licU^v$6hS za9n787n*bEg+Zp!EhrbsF#$t>1}Nr?su6oq!LD3(>YTOf)=aFgz5PeudGygo;}LVs z`|n(S!MXG1PF}O-y_!VyZ-4&neSi2oi|00i001BWNkl%=*&rzr&JFQr7I$2d;Rm~PyGF#ZvE-+e{}K*lk;wtqY6dsyI$MUp2`&kg8d_2 zLv>(60DAWItX{Wg?rAf_u^?`L0m4a`@hv#kY!0ng8tW<}KmE~FTqTQ2rz}4G$^%_i zV?vxZgL%1}tHGK)9fT(30qFnz;|BoX3{e3}Kn+R)kzu3B^_u39^+yI{VS^*uLL`Hh zbUiRdO+|8FPwu&u>kE#nTxTHb_BhsrkW~ysWerxiGRmQ5N||Ch97NEnKB1@1Tiib| z;weudlPp?4t#LwiO=>htf`AB#LBJ@^9GgG0mXxJQYN?nJ_0gO-eq2_0z$`vSs749o zqGq4~sz6o03Jeew03yiGsanzz0N_iya8_MaBE0-?|5v70|8mi|84V@3uiEpsdk%rm z{`j+b=bS(+82f}(Ue?{iBIR0xlsaJ8!Va`_v}N2fw8EIp68Dk2pQ!3Zds;4AR_vLk z^ff9TNhG)J`*bKLbh5Et8vyR@-XuSkEz+i@|i*cT!M&DnTD(%y;~`)2v(0YFapc zQJ)pb9~Cce>RGun4Z@%=0HD$*E`SR%IB5bQK`THUduIqWqDe}kDM%yOA<(`uU5JIZ z?djiqU~uh2XA~vu?=C-3Q(YP?i#++pAqd4mD+V~6_X+?s&{4?8xDnF`schEKGAMk5 zOBdyleY=w5aVVXyL$0;wnpL5adPgcZJe~#}s5%b@S7YulM5bciBUC^(a6(pu=xQSX zf-7d`M=+d>Br3wqrwe-INJaXOxVqtE!nDfB3%Q zhRM?xF7yWX)l8YxFnvnRlu7k7YhL>IlV$ber_NoN45z2en?G*yjIwdnOG>7Fylrc= zq+;CkIfbV-g9-t8pb6{kJNO&LxjZHt_NWT+CDlZNH>1UUG@t%zJ`Dwry!p4-| z%xnmTNGUpQ0s3DxKzd_c-dHUFr7Uo*uzBB8pEZn=XWV*LL4g2IOJ!I=^eGV!uiw`F zn_KR^_Vl^uUvScb#NHeL z#{O*Iu&fP-OJ~mB+@0)MU`D$>E2(WLt1bgB*R6Z%h1U-nr(V;S^T;EJ0H~qf#G==c zCqDe(jB^rIyt1Va44cU5cj3etwMxP(>)Ov*T5k(X1jShw6rVPyw96?xaOZ_L z-rrI z*tNGibM5>FXQ=1BPrCQ-ZLxV$rMu-oTh7zzf{MgGGvceKH_Zv_j9JqNy6=)x&pFuT zYST+JGQd#)lW4>!FHe@wdhU%^_H}gl>!>|Ted)pj z|9oV}XU(0>d!K&g`D23vPyFlUnyCldhjI@;|MZsqTeDs5|9JW3mhSAMPrq(POIlj{ zANj`vpB-w}g&ynqXW9pb{`$=GiL#md+Xf$f?w`F~z@jCZGcrP8Sm30wcWVsuO8c2X zfc#utJ`3DFoOM3M;;`X^_{jPx<<~a1joOwGFbyz8c|}Ryp^Qf*$wXJjQ6SIf0yK3T z*fW0G9M?ci3ISeNxx>$ty!LzxhCZX>1)xWP*UY=&&3ymv>~I*zHPZN#@JNC7KCh=; z(XB7M?AOodly>41PMlmG$PDy%v=-NvnUb&EbJUMV+D4?a^C*}G7z}}bnIiYaagy^S zz;Q+f5P?A>X8EnpY;Ng4ma0ABTlc-$d!+fle*Ucv75m%oULfENSH znZMlmhr`3U4u85%mO#M;*9DzS*Uft9#Z@!rzTY_eWJSWVtTpegcWLdW5CO2#h*cfbzF%SY65<&=l7#JW85;Ezel0fPZLIMdb7!0PF4z{sz!wq*? zvSi8XU01i?Q}%woKgeW0GvCaAa9`)#z4zJcS?j%8dyGUfzx?N0oSZZQzFbCwPZN@r zCzX^!JDvRd=jN?x8kEe~ZqW33=_9q3-ZVaO#W~9soV$_&;o?ZR`S7mCo_v0Icz*}g zkiQm+4s^wfLy?a@*f)R~*)?-tKiom2VdC09;q4JRl+uKvDJ5)~+@1k6njpaQL>< z0s*Q4(<{jca(5ae5HxJN;OQs2!Hj}}kzO@&!lqb=oV*embh!Qe1#JOT)fg-NVH8cAaILCaHK7L=A*dgPV0>-O&486TdxYwy7m&CM^p_;Sa|9${yn zfBdQAM-JQRto6yk!QP&ipM0jX>!j!6g}*%6eeCFF$)1#>qwzOieYdHl-3aNKe>~gY z*|~d@uKA92b{u(sJ>C7lFAH~@qoW4<3^EkAZ7a2M(?pMEFdZc*%RU)sy1G$pgoF56JpH%%Z}X4elpCI=@|pxulVM+Ng6o&$|p# zf&oDa9&1VuhI9Y{zvVBma)k=IK+xhq8L?ueKsvfVtkzebbn4nZ?d9SAqa6b`ZF6g) zVm`ouV8Z2I%l=obsWc!bVarAw7Q{pKhgBs+RJYnshNIq zQwN6FnqdOSI10+&)oYL>1Py5V$(Ag1MFB(F!2^dR$e@s5&xT(g=yBgYIZB#|Xklx! z(|RC7g`t6Aum6-o#LOv_76=bQLIVlyzx%%@jDG~7lOQsLAp|Q!jZZ3+-}u6s+8K>G z4jNjlKcmk%@5*T#xAvscC()+`>LUT)iys^$G;V+O!J(wr(cAmC7j|%Pj&O6#6S}@O zQKcZWS@fBt+d{HZ-b5CB;xEGlD8-~O8Yd^LWNxA&jy(rLLrDyPP|Q$VV6o?(78FRK zu=2(AC;$Db#`jTjy}HY*p@#(fnbsA z#E>39q@Kbvd8`X$LI6s#uCwNcM+85l$691$Yz&6@%fkb4mokoUPX9_fO z`wj@=k`?f^t52SI?3r6;Rn?@k@iS(P1Y>~}bE>8<{O0tA+C^v1UPkuH`BRtN^tU|+ zPm<&4g8t?GpIEVUN!M8sDL`Z7C5J)~c?d?Nh@C9-LJIgf=EFb=J{wiDx#0o~CUELa zOg#(5OOWj2h#%oFD@POuxL=bQFBmdtY?Lb}*_B`1KJxLN*N(9$g5<3z=tB@Z5gD=oD*%8k!16ImlEi`)JccrZ{{K1o7X&b~ zBRwW%D$Q{`PLEYk4O5E%xK`~UdeE1rIHYfDK1op;@)9nXKX@z$LmKKAmSj$=n#5cHEPS*g5yqEovEf@hOtf@ew8X3P`Q+o zBMgvK6R8$e6@^y}4SrLDX;8A8qh$zR>Bi@ArVqmeZ5+8EW?#X(|4u`v*ouK&bV-Xu`ra3{wSBd~lQ;rV6VJSU^ zCcrL~g61Q`$H)Fr+YpVvx}(Xo*p`qSe*aI=`O9O$}8 zj!#_{yY_;Hp|t(XGso-}lT4ip1IXscoXUlI;{}alsm%Ak&=7SJ8MiX&p)}%Ow{769 zSN5>m57!|EN@k(3POzbbrQEd4C?^hd*syIPYxk@*<1Q+5W(t!&>aR8-An!ik8|^ zDG~yom41G<_yIt95-v2wil6{VkYHwbHoFSsKuCxzvdlS86j!Qw%V}%`hhF8%X)^JHn6d~(^J(F=Y^Q`LprjHy zq(?%q^vKYmD<*(6C!4!N=Rlu#{3D#hL``kREIaL&vFp^y~_( zJS$gmw!8H>tT6l&=Dr#m73b9UWuTIF;iqsw@C=E{5Xdffz~{aP{BbeookOHM68FTKM`K&5IXKd*+S9 z4f9Jbo>}nvj-&5Cu=J%p9iM)B_-D7Cd+g-El&ZpY8xQ{NYfDz_c&D|wtt^-_1owBh z*wzUHnYK>^DqPVcCV!Ek`ggahXTosKKmXwu-N-8VMY6hKPUIepXk~&*qQdx@DcDEnm zXhT7Ew=V6Z<~w=H$&}B8?V)B7SYw$aui(B%JAYBouE-$H2;oyX5NRn_w{sGci;sNp z(t>LbI1NiNGUy-Jn=5IQ(P^pHL(cIXwDejSr81vR9Lh2&)D|GZ7#Y@Rs@J%hlVd21 zaOY9V9?%crvpMWz?uo=!ZO*iaPZl>dcSkUm)bw- z#Gy^Kw_ZJDn0t@payt*eZQ(>#1bv2S+8Gyud_^TP7Wi9O|+08Bx!6_g~!AU>Vu^(5i6b7rE(j5Sv%QUDZ_Hj!yo&;%e( zC;dH_6tguk!;#YUPMiP!*8qT(B$3RjpvIA!Nh7KHUmo3`_|?xJxc5IwDkcq%xBdF@ z$KKwap)Xud``oZj!Vn)fci+CO?whx+9!AN6X=U$iZYAjf49!41MPwUc%Nb8Yk06(a zt0*(}o(CUcWE6_X_1MtJwOKhsWAXBavP4>5Hmm6T z8B0uo8&)j$gbRPY+y&rb#ODrv&XG8gxAUYd{f%pKLH)5oViyF{)-AJFrr!T_p zL9iSPz6=N)SqpaqAkx^?A#`Gw6|0;F%LKVhgq#G2$R^S)RstCtRuxyC zjqx}p>^DjgG=>ypDlGsw5UiA9K~Mx?!ZMK@rr{LyF^mXRJ0A;fq{C}jI{@8;(%?#B zhqWl!fXYD-Jcr=1&jJLE*x5-j2IV{lUJk;7^x#T12$~KBR*H08sR{qT)R;Z62E&I# zuhveD8JDeT|F|8y*B4IGDre8@7*5znJ{0+J&fB+Nv9O@PK6v7I#CA@tnP5ZsA3}hpYeBOtsFdl; zhAOBd!KK$cKk(9tAN;1YB+}g0+L0{g%f354=tFm$wNTJ+KC!OpXnXeITUPW){gKx; z{bAi9R9uXa0i?NpDt>+MIa4PUJpX>vTOan-*Azx{F+4_%F`r>*D|&4?GBOk^v!)k>7fr8XpZ5C?hPHjQ!QXSJ#LDNjs53e`%gX6IAP+prdLYaC z5AVHWU;D`VkLYCQBsFxrr(-fkPa>u5Z6Y#qoT+JXHKbdqu6R;ew)LRB@#Ate8W}wMXS<4M?Hhw?$cz*j<>7{mUU{r%fRUoAQlu0}LoSJ640Tt@bYD(n*owla z003d2Y2#({-6ahR-~6y?Z`*p^i$CyhldfEG<=@wDef;C~LgsG&TySOM@(sI=KcBr2 z5ltL5#Do!7S>@1L@A@t^Lk zm{kVQ95AlT7$@-+F7YK%EY@C^d&!=KOuzR}TodmPV15LoG$P%aosXa*P{ z1qcNepXJC{+T6Rn*jLpa&yDrwIWvr&U5P;9CUXG~dI&DXyxAD=qrV@1O|hoPixgCC zc&>fJi_fF+CbV^-ubEU83g@7w^9MIAyn1f=csBdPFD;lqui}E4vhHji=L` z7>6uv>KHqtBrvVUsfmW>lm@=>o&%T3OnGNMXeeiyQK5gFIb!Y!u zMTz+HZ+=dCaLp~bj{A1)eDie`^ke$xk|zdiM{14Sm|zFF2s$DU=r@pGRpBOK+tkuc^T;n0hrD zF5}L((5|C;9xuHN2R>9T{;vYytm8VK8?6aWn;PG9xE1nJYCd_#osG+Ct8V)H@rvs4 zr=Iv$q@?PJkH`MDD~&1!kALfH%g$f6u%Iyb_~wy~o7z^L+wjy2U9;w@|GZ&NiQhQf ztG@sHJ>-$5F{~&Ck5!m$Q~jgS+>!BodMKHxX_pY&f^3aQc~WU4givsy1d#zEun>k&LJEy_VuS)F`7JcB zt0-gRs#`j?bmQZ<>MM*%_uRhqqc*Qf7A>jgoO8n!%j(KT-hAcl+rRjwlH#&pEOPA7 z#-7d%TLun{*Ia^>PF7G2omyO{&Y7z=Jh$x!U%k7yyiD_jHg10N`Sm;dbIomq<*pfk zg5MOBuotf^yleFo)1t>eICb#Tk^j7Zj-k`vw{{;toaA5_#N4tAo`0+&-)E8f|rea_~SX$m?Or7M?j%S z?Whk9{q==gnhv%R(dQbAzx>jdE|^#Ojil>MCxofHVgsj5m74V~4i(ivF91szA|^7HuP7V| zj;3ruN|6TzC>NFni_pG@E9dgGuDX7DeSJ-BY;0_7U~p(k-K=R1vtof{Dm~WO)6zI+(RnqQ zU8wzM^A~HumFnrP#{By_`~s-bx1WWx4xSskqTe4HDyR8y^LxqP;_ z`kK3ih-}@o^~IN8`NHR~e|E>={!Ar_5PP;DT~8e@2&Sw1Hh=YNR~8mlH8*wtW$oJK zmxT4IlI?v5yy>+P5)eeJl)}Vxc|uJy$y1t;mZ=*$Guw$Q_HCYADFR=-scC1o*!)UC z)TiHi`>qpdZ2GA7va4G1E{A>9WvMOi?Y;T>JMv%@PxXS4MHiRaS5dgpeLWXoa* zjP#tfv~vIUHy-%+J4$NmI9wSjnsnR!XAQ^i+R@T|N~J|8ObWIKxb{uU$}d||yrX&e zFZV3ocx>?Uv#PsK_Fs3&vSnZ2e5xgnh@pgrq%*lnJn{8;eZ$GyS5N(IL*UNO&r1!A z+;vUEmml7}<=rF~1VM@gv*QuF|Npl|G-24)G)?o7Fyc*UTn)QG#1qOeKpwd{CWg-s zR}!SgtbsI*F_NL;CDgW7r81a*6#`$uk(ZGPJn=;38PjiyMWQdf@ zJ9ZYHHT{C;zjwjb=H5?^^k<|uYj*Ipmv$abEYcgVd%D?w+#Jp1?5HNszyHpyzj(VX zAGzY@OP+2{JhylBM_*phHlF&%wF`TC-+S%9{>~+SMgU4pOr0kB%c1LR%lKg%Bq{9Y zaV_nFEv6xR@Q{n34)$f*GUU@a=fEFk+k+uM3SQPFw2kNESqDN>(jXQPKrq6T=Shvo z4f27PG3nA~QQqY^{oQ@keVhw!!;Gux=u>?16)IZA;Q$g@Xa+eR=f^!tYd+O8vnbcs)jfaSV$!vW%J9Oe74ygQ z&&#xsY1Rbi67UtlS4y5@c0evPA3S0w4-$q(|FZuFfMQ|^FE6~Eari<=rY~Gv8Pm<4 zq`R`Q{Ouj>T?J!{XHLljQ)>%8JnBi%@OWxkMfCocdfHwcnP0@0%&B8S+M}$?JvL^R z7)3?oy3!ZWV5Dj?y|-UhecN{*Ok~KD&dqZc>F^(J*>l07Oa5`7pUY#HxE^w=$Bm6ZWT@^r_x@-!*`Tdn;}|C^Y@YamUsY3YJNhEDKcD@6)pJ#cgE z_aj&cEdUW=%gv|VoYY3gh88qBKm6MHA#dR`YuEo{(|T&W8neC(w)c-D&$@fNztBqO z=VHl1kPQG#zuS;|V%L^nSkEPM$#nL~o!PO`oRg}%{3pj@Rj&X0*7dpv)b5nt1hf%A%Z{3A@eLqXOdye^0t+^DQp}Wvp^+z`nXmzsSDK;;RF+Oe zOwwW27=Uhq6<7)>Sx6|0wTWbOjs&x^pd{%QCsUXG@PLV!ntTp9<7#Lh z=6?xB7(;F7ejnuvzV&3>%4|ub^P=3R2J$Qcp|B5VM=g@MG-8W2~ai={FjTLnGH=R#n2^!J`j>VzF}Yyb%ql}@>}ECPTEf`Yksj^OKp3Zb#uPzU*x8c0`-S~) zeDvw?lef%1vwSS))f9o`ctt3^=7t+n92iaZTc$rFY1I|0MjksjoE{QxL@5PB11W91 z^XA*msW{`(j`n`t5J_9kUA}b1rx&HiyJ1yXc3Nk_jtfu0lLDkX1t@4Hq)SS&C7|g# z03yv_T-rON)Uj=p?K7{r>(H>{Y}{B~p0_T%?$mg8PHmLk{8-YE(#yHZBu#mqfbs>* zO*^-B^jDWGEbM9>&`1%8EJ7q^ znWk~Psr$A|W`FA|XJ7Q=4gJR%1;wN!gGp$lh;1ncGox76jL^t`R5z} zfNAPhATY5(|C7z~83c@UpJnNWlv05yn^%crfw7|v<(f&deQazz8E~l#fiTiO$D8hC zbDvvO_}v>;zWVk@$2#M`|M}M<{wE(>_dHFT55pjTKn)D1hq_Txjl2QRCZ7-4G#f^` zsV_|uz6kv0z>ZcF79diX8fzfwGBX?p0X^G31b+m64Y1LAK-Fhe&nGDhd0!<`CVo_$fId+5aGuH^RUjWl{c? zU$6Piw%mAcPUr#UxsWb6L_%lrukZgvtP6lWlElo=h(WGpZEx=V>)$qBd-b_<&TLpy z98|iye<=UXj#h*wLy;K`%`UT_xxN0)bH}FC8P!2rxwI%}jDF|JS$8ceO=w1YM*?mc zEO22cGw6^%Mg*ZztfY-KKHh3M{ra`Hw|#gr zG0mS*QRo$?hDLjOdK@=Dx4d2nt)`}Cpl|!fyIP{N*Ti)Ld4`|4xb{$U^Cs@|a>?_r z`Zp~YDv1^deQ5nlZwJah7uWnn-Z*r2a}H~|H0kOyYZpIrRZe-!me2U@m2+J7R?Mt9 zdMx4CHtQM)?06t|c1di*@2^-qxAO0w4sG0g{aAaa5)gialw?vw#2Tbct|XjBe*RB* zlO|l(#RM%-532p|mrpHUd9F2G47g6NGdOx65oiv~k|TKx9<3^Fh*{QstIuGW|IW`} zqptMV*PMUxwU_?+AHU+BBjj*#B>#s8udS~PfA68SMYC&1hf;@*w63{s)xN!lzyIw^ zOG|=3ct+(^g(J@0Sm+zvYfg zJDOU~n_s{BqD33F9sAWE-j$XK!xG8Nl^0L`_P<{-l5xKJvlrT1QwW4vv2Ppy0kkXk2guzo+!Ky~jNgP{`Nej_%F(A;f1KC#gF9J&#VHi4v zL+Bdd%`c;@fqWsFc9uH)4yU@H??TB6oOz`Mbf*6JUq_rrp483o!dY{# zIB)t%&-~<$=VvcBEMuYLXZN$nhq~duFJ9Dqwi(?gFExSqHCW%8Gn1jWoH)^%v!W|H)Y$#FlTB!>$~SS zub+A58RaG61o__DF)GkLD2-#E=70NMM?-P+uJs4Hj%NKn-OhT5*0guUHg4K_^{oqi z0l#Dw357p;b=QGYLr0S_#EOU&+gUCsiJRpwZ`l6hi*76|E^_jAFc|dgpRWa3uRx!czf0C**kaq<3GRubB{bc>Npoes~w0@G5 zLnJNM7>W_nTZZ$$-__SxSN@0n{f|8I$v1CYaLL)#54?5!_4fu52?1bDKxtCbrE)(z z^G^o>PfIvbDX=0iX&KwAsw?~4nZa2`_xy&1X4Eg8)NAWEbR2s%cjlisDtlypJezy? zz2o;@d&aEmu9pL@TNr)d*B{Zm8`&4&#PA;sGnd`g7HTT`~gL{{(-QD)fH5IA;BQHPv3YQn4yZ^qw-tzs+ zOAqx8-+V{?gA=$apzUn*PX zQty6pwB=L=W1B~MYx;W!Qpr)1nMu#(v&5bfn%^G`Mtq4(x-8-!7)@FJ3R5QGW=Nyn zkwjrAG?d9fct^X2&tE+4`innT84bMk;ep(60Fi2VlE}|WhtdF{l>EQ?zcpc!kRS)9 z&YpyZ#DFp0;p0MIe-Ds|z52u_T<>DxY7~Wl9L(68|9JJyEq=fR>tNcku^B-N{?K0^ z?}hAyZozM`A@aE#ylAp^+4uhN=8=|;bIx5>UR=I&+s+rC{YQ6fYCjrKREgXO6eFJY zmR$6^xBp^9e{lT`SNVd4J)OOO{r&H@9~x-#FGg&#-^&^#APA&`1)vD(GshjVro&J! zD}4fAB{WYmv+G$xXskI7U|Lp&ZOv3Z;W@VQOw?WT;?8$=o$PqK=^p{j-M(*d>XNTV zFSz)vox`dxiHHU1vX?{sB~3@x^%b7E@9m~vzxyo(PC0d<#!EWe263w2Ybf*>o~I~` z1BVj_cJ@OMOcMfoHy@a&BjaEQCc^_Xz(>i9xbM4rph;4K&5BC1N|4#!xGuyVqnx^SGF@v?~wb6^J^7H3j<}02YC@%Gdf^(Ow9=-Lt zX9r%8!4+Btnns3j`}?vF-L%BdiUZ-4D^=HSGR$DWzIfj9N8j1?qaVLkId|$aU%O~> z`4nHk92-q}q!Fv}cI(4KMfUsrbL${ilYrW?jGVro?C`j_*;^qj`%j`@%lboQ=P^D>Xi%x^^N^0F40! zvf#Rq9tnfV0u;Oq=^6_HX;92U2qBcrLs(EQy0)Wq9%fzwm(jhO`nI9ri(EVl`C+tg zM5>Dd=c&qaYCFu8^Vv6*I*-FJRrw0keV)2MhMPfhh`e%+6|v83&V>UOHopG-sZ%EZ z=g(ie>ypOondKBLKXvHsGZ)PqJ?dwM&Tw3}AXexzg=vuKk0i!iPf64C)lI4F?H$c# z#xogv|H-cY)*jAw_T(ydY~L918JV0-P|;XKN}EY!(>b5drwEp1S%x_{G8hhrg-6L` z(($BXQL5(!#Y2JctSKcY+sD86^!qP9eDl>09ewMa4p;_xHYmqtC0Ghif#ttk|DNXo zK6nhzA;ZVYQKY~gSR)Z+OCT1b!b0}DuoXNBCy!VG3SzJ=kc0+O%*rE{2wO}R03=|0 zo~H-{lIN~&8H@ko^&|dQA1~43X;C5yFYec>Xwup2xNHSs5xR$|ZhC6^4L@49;m_|p z7}Ya*$MLM{A$?Ika29bOXOH9|h;^_B<-uc~DD`Fot_|f76g)!*Kz_gS2__KvJrR%^ zpc}U9GHGDah?oF73!_3!yP{*bt>Z)nrM{xeXLQ60Pj2qxljDf`NHGTrkR9U_8>yst z+;$K?6OJN7M*#8WCLC)P4#%ph85d-7iX~CZFYORKN?jr6M9`2`NDqK>>M_jF9F3Or`lJwoMTUS28JvYdfA7w5&QabN1q8IjcYg z3(`3mPmfKis=evf>vul!Ny~|zK;vp1`lZtfrxY8%d-gS3>FlIc+(s9#bFIkBh~7iu7#_lFFX%yti_1A0}rL(d;*ziRHJu&FJcR=V>~_Z%M2AL`6fz|T-5 zwIRow6fp0;cHy*1g^#^)Afn5+esImNK0LN{%O_V{SG?tzO2y65(caz9+!6QO`ycrb zK8p;EAQW;eUFbS=#mWTfpgc4mdmgEYX9(y9doIX>1oBxbKa*;fDo>+RTe<&3o^dsb zXCOUB%`b9vGHPz&!|w#t(sMsIzc4YpXSm3%TG{o=vn4@2QNCpQlrzsgJFss58DmKe zP4A$lrZqeJbKiaY%8M5qe(~k~@9z#-fm&_g@QdqPJG-aOYczEdf;^HTpRXVs7#bP2 zeIZTfOx`XEMKn#*Sn|3DRCZBeI2sNP3}r&0*hv3y zc}ek5CfC~0Ra#O;lu({SiY*O9boXPMZ@GNln$16R3M+5>{ia`Bcg9s`RP@@iFJ;4T zLTXC4VOVf%kfv}N|M|ZVAPjiKiXa5kgom97x`4s(n8^gPtXv2Q;fG?d34@_5FhTQ( z!HOA*ggzlspH{F8Up%Gegp@x1sdt!&!Y);~!Rbllp@%V+L5R6;51cH>g65&*Oz!PN z@k~iZ?`TV}lJEomBKRl6U&^BiM`#LC2#}aC#SoZS5R?a+-APVloD@ znsSuqun{EPfa5{1O6HtUE=<%|XEq%G+cr#-1S@7>B1Z*=0u1O>iSg2of2 z-VzYZnt<(LqUW0cHUt?2^-t{IKW}Ty>?mbwTF^3G50p=yIb*tMX;~{snqW6Ch%%}1 zvfA2NrN>URIGQe$=Mag`{{Fu`{InS^3|5xJ8`hw*3Z+hBEdA=9(c4$dUG?q^_6H2z z9m@I!Qz63?OB(A&`^H?`$%TuSt-2s6sC;I_8AUTMoHu3X!4uUn-+=>%e*Md}Tw92) zz8^mE-3M>Ic*j#;D66P$9!jT$@!dacTKec$rWA!c)9#gzZ#i;;(<2d@u>ulY$WQI< zx%BwZPwu$lt&aHH`}_C3|47W_k-_v&zxt(nF08wGZTGW(KE8JCO|vFz?;h=%-Y~n@ z)>xaM6*7b%!4p-Jr)`nUkOC9IHD-ojL100a#!4|WOB-EVxMv3%uA!oN?2b{}1`bwG z^$Jp2C{nZGfrUm%aY=N_snv6mg&8S~cOwN^OW!GH$!^~KUCoh2R zJ9%LIH;0<2cPmGD%X8~!yq#m^qP(i@WVcV|Ow*FCtw_0^@?4Pcpleb}DDoNlcsk>G zk~9Q-MxwWKU|@vuvcyouWtG|PHde~e2rO*djYRceB<%B>e#inp4V33zBnDooLo@g43Ay@*XpbNN?bPdEp2z(|U{}25S zFo=Yqc!K!K3<4P@n*cmW3FSf<1c%{*6v!dhVkN)|WU%Lw4pN#@inNLLEthqR$Z3cn z7%(|tz)q7+D6NA$4YT8*MN;Qn8cfh^B*!rJ7G_+E#0dPAR9(fc13^Rvl!TLHL6X>m zAb89SO~(Wpn+U`Z05sMCY<|>Y6S>pKvF;{R}+pV7@lQV!Xo7|q*8(*m^@-B z+3?6T7|dFf>><5%L-d;KGg=Mp+y`WpWwBBKSUJ!FP%gaSurVpapuYX^N>MQnL%k3J zx&ScIF$9gEJSfFNKx6Pk(U%Ko#HY`7mJ;5?+t9!aSCWznBtE;Z{l9xQ5$S>q_JnDf zq|&Z@<51UyOKXbC3bGy)lLEyG!k-SbcE=?v5fG#ZhuV8?zUGnxd!8*0_{NF~ulj9U z`>R_Z+t~5G{w?AD=bEajqMtqV)|BdsW36qyCkF2QGd8}r ze{`K^fL&F&{-1ZPwf8=Kde6)xGmbl>&;S4+07*naRB0rn5|RL+hfWl!B1jXl`xiy* zV7uzYg5{!E5ClOG2+~U^(n1P^^j;^E=`&|e-({`!{y$9gdfWbXzMi%AyWjTwo?WqW zVegB-{oBg+8;+Sb`^Mir_v(wQdC6&T+To2n@Wi@IQ~k{8lkfWN0~X;*Dww7PJ{~0(EP7G2C6ER0D2+Sk|vjIR>GD(mHC7}z5d`OSu z84}FKMHJA;4xVy>Xj)|bJZ)J?={D{mu_e(j{9T-wg%}K9EWua_C2R&9dBlyO9%HL3@wP<7{E#? zSU{?}rp9tU2V=pM&1RWRppEBw9$ViJ@vrnI^R9 z7CPdX2bDz6I|v$g6uM3A9Mn2?0@NoM)-V8VK$5=^p0#&-}!$80uX^rG~pu25K!K$n}>h#mshV|5iUOM{8FisNXK{YTJ_V1 z-`t#?3S^DpWHRyEx{d4J+kWpIpKZ*fKJt_24?MXAdYC$wu#K{n{Egq)1SMfJZ?Dgj z*T(U#KR$4To$kxN`7W_#ZrOdL^6+bKSwD}ibG~@@Vd{N|$N<3uf$}hfV34D8<+5KIBv90nlB6~B4v!k+A24t;|_RwapJN(T9I$ZRsPM7dB2{pjG} zP(_D9XrY7@(rU|0shU)0y;J2>iD@frLkk;Ay3A<_Crx>W*?`MzHADh}*jSiQa$L#( zp8ro|?2^ENf#Y6INyYu}Wy>sl0QxS|fdmfK{;Ocy)+r0KVvg=W?>2%!*$JUG%dJl}+ ztgb~RgmU1pGkhcoICXP)3e%Pc_}J^IX%Y|jLb)J8mYFS-WS;n&kNN_WU?#vAuwZ8* ziT%&rEG7%fQcA~h{xeE57)MWzlnPil&|{S{S1k?)w?4FX@QDBB2lnloIlXoN;RFA% za`k%y9brflZcd>wwK4a{pZL(zI|ujoAO7t%%WmAbel<>Ervs6XDj+1%mX!btwi;3) zp&6tq?F)fhNi#6S9bb zBM1qOzyf3-C5!+dF*)<$r{YMh_jOMS<-PcaR_gk4g8yaL%pGgrOF!tP?|20xVTE z@t|inzfCREbRZJtBM!~jxNVasU`B_Pa*Qj3QYoR7_5&4*8%Se}<2Yd$x=M@;56(N~ zBrh2Q1gW&pyk+~A#`-!a#m45c;{YryMo0(>jpj(l5}qWCjukend&dvTLlprThmF9B z83bWDAgjPJI1XHwC}8IwSZ4+^|4Sq3Kg&u_IY*tQnMq0}Ibr)tidndbEJ?u=Gc~Ax zq+Je_U=a8yZWP+WaVb{K+g_kVk*8hds6?#|RB0@bJ{*sXl}Q{wlUx>r+Bc4&BY$I)Lgv=b&PKD0eC}bce9bjV63mD4^U@#MDVylgo z%36@oHmDGUwN{3f7$k%uZ9-UA2_dbGNF{mu3zr|4yW-rX!^3;xaW7upS=zY2ueTIs zb2RT{lRCz{_Ldla&z363OmF+(lFWh4uQ<6wLk9*b$=RlEX%qskoAosTorxoBI_GkA z2Jb(_Q!hYO7b;^YM>ZnF6=D*hCL)#-UQo=^MZ`2A`wJixta1<;OyIbrfFfaW6qNzX zOd$Fvy(yNi4Hqmf5!Hu2x%Je2&gj6CE7y*$dap0dg}g6H&SYi*TcM!r#iR}Gyt#8< zEqR~$^**z4Q~aBAt1tOD{11V4j^5g7Ukc3ds5oI-4uuu>#?|%iw zT{Qn{-rkFB$;O+b+LLOJ>A-7yk?Td>6oh#QNfpb|vJ;15yYVja9G-b4a$_K-fEXGc z*a{MgSTiD$9&;SlXJ_JCdK~#shFDlg(jjDw08qq`(D(;pC=Sw~34EoI3>&&6OsZWM z``7cNQ{snX7}^(3UT*3q(bxe#@S@5@vg4xYz!9q}nCQW>%$50!FFk(e=T3fi>&U%N zJ-hI@IomeoPyhB)U6bmr2vIH+&%1Qlsx1|)earF@Bo0BQkP0|C3!MS>Kh3=%_w@9O ze9c#`YneJTksDetW9ItJd*9i#VcPWW=^br#wbdgdh4*&ut7~rRYDlI$nJWQab@!6f z{`|&vB&)`9<&N14uKVog#}Dip9?O;@?jIa#s7lY6(l9cv$I2*G#=56Wc15L>%hyj? zaQZptloH92FlnU+B1i=gv1LfMjv!%;h7B1Cx(s%NjA=-1SpCZf<)5Xca0FR`X0nV* z1QAhCMqs&AMm~faV?j_!4h;M}JPX%iyu>2~q68-aLkI)Z){t>|-F>7i=3WAGWNIoi zT(*G?$%W%$N<-WXZqS8+ns|+zIqUF9-lS?#)eR&elGyn&W}c0y%Ly9q|2jRg#!bfC zI_B&h*-+3Gq~{n@Vz2>&1v8Tc!;+OO1q-1jKJ(ftf?%tJ^q4}B(&T^yLqrqyyE8Y~sMwG&X$jw5rt) z{q)Sm^X4vJ;fIwc|F&}NaAm0N?9zD11O_U*-o};`7F;1Z2d3NCb_LA3vAZQ~X>{M- znnO^_l33e`>;qn$vL#1_VcDTr4AB@1Pat6{1;Na*Gz3Grwiqx60FENS{{;bHt!7bo zI21DzB0)XH*djD8L4H?3W=htxaSN$IAxJ_NOjTWdI`(4OU4Q36JD6j&`?kkB;qM^H zT$P6HXDyLz!FU0d;G3$Lx&0e+=XTdv6I99(3#BAX$bDmB!sDrlW=edlKq}#w!{h$V zKVG+PCDuLDk7zxb=0L@$;!pIMi9GURcI%^*YT%X?i(1CM^2K9nJueJ(#4MOuiI`$X zNIx(TEQByju8@(oLLxHkNKQ!dBx#b7WwORvQHiu6Ar*&#H5#5HT*oN~S^!>BgdwUF zhDv5YylAyAQmFwsW2*+{1clK%fGPP z*XE0-ugDJNBDUphp(V+O2D3l-+{vA{E~}T(Az%FZm9dQ*#-NJG98Z%V_dNEAn=hF) zZQgHwanD6pT-ingW^iEJw*3fw)<#!~t&@(~yYJA@U~i%-WsTF>H9aWE9i_Uj{qT{& zo>6M=%8geZ{_6|#C)YVrwN34Q<>kK@%N46smz15Ity`XX!zN-pR%~)AY3a7Mbw9SY z?+2@Xx99CGkabW?VI*{9Ns{zH#-fB&8xWHm85<#`n2imY_(97sQrLZ(;M<eoE(?a`ARpqBy42j5qbZuxL)Z7oYU*n$>osXZidO-TT%P z=9tSlKa9ysxY8$w4kK2de*5|h+jG;G&fRrjWcAJ`ue$8Yr`~?=$Y?EEV_@S739DfZ zlM6u{X($B-Sxd0SumUj&_FUmB31b~50qt|7m{>Xn#EP}HZF=^e&t7@ynJZR^RCBU<()m|@_)}M0 zw$&Nk97|L}ssuQ7?)*cqKV^bfum9?KpE~uLD?j)1vKQR_oy)2megE1cU-{uC?KZGr z2m$4xe{|VW_uHRY`h$DkU%!6v55G9&mn(O@_2l4>Z(9(raz6XLEeIPBh8h$E|1A6e z%gjayfq<1&<%om5Z`$e_(K4N@rW1^HfQX?a$Py%1@wl-AzuSmlCC>u$ba>TA1?3>1Q7EJjj<%7GiU>TGROL%%=S*IMdu zv|PDzN!R)_-o5j!$I)De`q^ka4&#FiMa(P+@g%n2OR*-*xPvkn$lN*zDUf5@xfuf)wKRFgrvbvAsNhld|{p9*gA}%cJ zvM(G9AYu=;N?PkG7%(}mH?!4f_&PL%;}V|IQNJeA{@L~EO!M%E-(O3XM0wmKkCRi1 zw|?!Db+z?3|KY`Ak&i!R{*w>fclpKVWe<0sSYZ*`~&Ab^TPAD zeCp;WHs@dZ*;Cv(6Rym&SUy_gT??ktG*GGaHbAju3`0*6;+L%Ci(R0uxBA z|K%|j0DMX&OLyF|=z&-Eoi-)9^iMaYld+=fJ@8sEB%GL&udNOmYsRp z=@+aR2;DSdgZq0Xcg?xsGdF$rj~j?ugg`bI-F)qbKJ(EJl`AD3+5JbxZ~yZ3G1ish z_!F!5eDadTcRjgh-=;FE6X0?|$(>kUK)nwJ;G|!cfG+c|;Kaf?|bghX$fx#ci*a_DjlSNV6>;Mqwx7 z9(A3GkrFc_knuYI{FUu()28D1i{Uf_g0jObU7Db+dKnye67d?IeFbtO2+JK_WmM}^ zzw*-Hp@eKon6X{ufP7p=@(phaPQtT&OLuuIBmb7k=GL20>`P@7gUK==Mm4vRDJ5S84kMG^K=i^`g;&0#BH)nD487I!#y#D=6Pzr`^0H?-u6i_wa;kdhN84( z2fTjgP-h)=HMgx?zw4%@@VYt%-DUupRP5a?edX-1=Xp$kL$#%CU;pC8i!S@}!9$0Y zG*#1PedRmfe)i$Jk4<^6?kI9I!&-Q?-q`D(UX;D!2Y((I*3ocLNO|jbzVYw3mW3IL zRX2x)T)q-sbz#%tT>h~&C2b86SuxSkG@i7^f=sB0NGe28K+x7DQHrd#h@65jh`C^4 zjS#v5UzdGeeA2?cF+bB<3)Z0yB9odrV@hGwcCyUukdhn}M+S>?PCrYe8dT9(vcxtD z0=K4)gl0jhxLZ>#?s<9bn$`P0vf`wLv)f|ic~(F8()KfsZ9j9-jFL5ur-&?*WMQCn zT~oR$86V7JT20*7`VX({OvFf{)ZA6G$gkelcr6ypT6Py44d2o`1AOuzm z6Hu~C%$RKtuS9OEkO@m5%WNWa%z{c#0V)<3Y_$N*KI5Y&cXr3kbL)rKtsUf=Iy_}w-#k%tw^D963Rz7zo9-p7IoK_8cx)?R#XMxJO%N#;Ps@(+Xonm!nU=!KNHuD=}hkH;Z0cJu0t)7REsJ2u`cWPH4LUqzSD zwh*#fTL~ROkVO*1JGij9E={pEfOD zmhLHYmYx3Y`#V=YzacE=J6k6$U3PAfiXlCoE|#y_uk)3Mj_FFsKT)t zjP>l?xBKM9XJw1wyF0cF^$v{X>*k%X1c|1d2afFC-B&e3Ov+$gfQSJ z^rdvHWEi8st^i0XmMkow6H0`Y5_#!uqI2EqH2@-A@qIrTtM(FjciW-;xf+0ALspt2 zos%sOKKa1zZJX28RYr3xmP%H8kFWgezNiiwo)BqQ-uv{c_uT%Q@t(rFJ9b|C$sama z&giV$edzF(%{!$~m5O0z=ny1@Ay;wJp_|Ni?S| zMTVv8YZF8k6WR=BnxOwrv#UyS$T=G^CnmIK~3WRRdBS0>-q*-fi&2#i6#~wm?T*rZk;Veg5!L671}%V z@%E-vthz3N!>`q(Mp~0S(T@AY-bd{2hg&PJwPZHa@LDJb6hc}g6DaSC`)j7x<)-pG zUHLb35`5%^_Qw1P9pygnF5I)6=9w0h~}o~n+xaFZy!I3rfvI*g!p2}U-GBX6U%gA)Z#mF#d z+H#oBmJaP6KN7vWXV@8(-zLOumUScWyr1HeyEbj zw6xZG(pPr8JTy=&6m8DW23BPEAM6_{?j0PBq4@HKjT`q@&^s(r3vqB05A8zD6t*GQ zuoZxWAR8DklStSwgki}4W%K7B^*^E@oRF1k%jvYEgmu|^_4U_XdUku9&Oi60KmP3b z8$b4&)&2SM;3x)%Nl|rGvS+Ap@W}8n?Ny8CbhXwvizbQo@!r`DRcFoUNRVr-E`_Cd z45XY*wr$tW1NF64kRoCmkH>54Yqsq^^wyq(s7Zr}j7Ci|r_!7D4+;{V=fSd2oXJ$_ zusBk2%4O?TxlMJ6J0CxE$yJXht%gXUlwUBL7R^tfoM$$|b=;UImd+NN;!fIX-h1?0xXy$tY#vb z@Cy}8rYsugRmu^FFm^EJ<`QN{{P3$cefaEO|MW+nzwX0gbbouaeQ{?IBfCLy04SG4 zVNYjEI)31ZGp1I5@v}F4_gi1N;Ea>G=gkXe`(9-SX@X@E2_D|o*;JT<9o^x!8$Wc; z73ZBje`aTWZcoRa+fdm_m4K(5LZu2u4}7N>v(Mc+l)mj-zu2(x{eOFSbKjr>tkoL3o@E}SsA$%4L zN6P<`|K~bT0c4cTr$7JDu1zKLRG)k0_n-LNrd_|-lF!9GjssO)_qUV7Qd-?LBCSL!{D_KORTy@2dR&IIo^$nyZ5>-8tIrIPB_ukf3 z57bttTU%QbaqpgA{(RNe!<$M?sO_LA;vfK7+kN6M9^3KkgTG9tR7+cPO@a}Ie#IB+1udIINhbKP%-TB}B)D(nThXy)QWQmz6U}D&y zL_!ivShmuQ{0NYRvRN{{BR*?JabL8#`SXvDJ=^j8^OW`nW#H0QZ zLQM^_!XrwhWB;X4`^WJ`#*kKQ5E1OaYbQ^uUYr=5KX*>|%;V$f23F#w=O3@U{C@sv9eCp7r(EQV6Xv%)xN1M=32{lT%MNp>VKtFuDTt(zjtLJ`XU1*+ zyI;QUgXe$fDig2yQ0L^2-1Nl{UwlDJ!TgwKlD>>=-vEJ3+|K=^HUwl=hQWsrUbIKVPTzl5#uu_b!{5XQcaqSk!Gl)9$n)jU-jZ3AOJ~3K~($V`l`7V9WgU1`AoHwKK#xtpT6PjYd;@Q z;=)vB#pd;2y79Wj$E$7Q<&i=G36G0ot{YaD4$iI<-~QR%P2F?7RP7bl-thlE{>jqe zP0Qylf9lP~gQoU^D)uVdf{w-H7=G_@WOoBD4sL=gOf3HNsvQt<=p3q2sGE|@9Cz=_ z%{Vj(Q;xSo8;1_ji|%yV`W`x_BRh;TBZP1zw-QqA>ks5MKI6m>j`FM}uC3m^>2LcE z?TDIAK+7V|Oxt{D?UrZq9ImCVdXkfPOd)k4HonO7>fu(wh7bmkg^5E4fMiobQbLfm z*8Xq3zkjv^3^}4k#)NtJ;g=rrW(lsfC2_~UzeWoiuxTGMX-?9HJu$q!1=G7trt>G? zy_@)9u4!aP*U>b5oY*MIP*cb%Agw6?yg zcYn{?gZW(5yeKsvHUV3PE6_hg4GV@w&-?rxt7iQ1(V4T4&5mSu9_Sx-TKDT&sF_S+ zk1HgT5USGEloqwo=g;r@`Y-n~4&L(dvwyHHiXvZwl%4Rfmk|>~DT#z~*ht}P!!N`2adcZ;;*k;V<{BzdE_NciD4xRf?%*=auAn=O0+HN+FL9KL5@VL z%Czd8>qPenJoh4w?IJ*j3<1Q{ z+_Nu&=ZH8Dk1-;NgaT>E$Xdll|4X9wug3;5q3bFW`l7zEYie@Yu}y8$kE2AjNL4vr z?AlL$Vb`{sb{>upb1aAmey$X{f`DsIYCrwh*5CbN9V!a7E=B#U09lX9#A=73C~`u} zWBYV<>f>je{h<%97}W_kmfnBhNY~WamwoiZ&%N+o%puDGEJ6^3fN~fb(NTpm8_mM7 z1}uXkkOdnUDGf{E7lsaBectkOuDr1~7Ydut=F2BtaKQyD*;kTwkp2C~BJ>$u>`Fzv0uLy#KD>G_;019uW)6+Eez(?u}pk^hMK7I)8Y)tcyBR zReR-)H?4Z11nqd8q1>6*Rp6JPw&kG}Wi)^07#Si#qVlyl^jpghjAK8RQq zm3tuKwD1!40~89V6=cDw1QKyN@^>D6Pfc34oIdjVPp=>&pNw}vIYu~ET(c$4he*M0#L%kmITY2+? z4ac9=Jabm^`1yKA-^LwlbbJ{#xU2v$#DtTd4-YU|5N{a)J~E>TDXaD-YJ%Ng|y=F)j?*G@&L91_Dc}fknNTznn!4-h19=%Od7jH*V5NL?voS zAzOB}p?FfXos7`6d$%0$7WeF1r#JM)Qcb$~6jQwru_mgNnF!<}ia0+WG%PG=agu~ghipHPUJ(Q*>cyK9z?1SYa^h^(wm#?s}IV&vLUDgi=5 zW&=@8Ve^!k2g^}YP2eQ!IUfZw5y)oXn+jGx*{pqc^GH~XVd^!s_O6Rg-+B857jHf? zK9G$$@wlqtnxq@rN?elT;^L-i@6vE+&{PFS!bWfuNP>N~f{bF; z#_<2a{{WK}!d6D~x|d3}>Np%6;!F!7O`4cBtU*N9T7(wHf&!R`(-8B{w0;sh9z}T= znOdtWLTf7}q(ifAQZx(|%+ql+q216*^%pD{D0b zMNZ0CLRmw_$ueA`;ZZgGxAcX}$EzC~f?gh83p7Cquz;;V8rTRRkYr{Ij!^ehp0x;D z*1#kn1jqs*I1~U&m($G{+)BAfH=R{vDtgR*4z>dvF%hf+3lf%DAR-cS!c%QRBS9cG z6Lz``GXeI%gua56fo7HtIf5!htNjTg*uMqKYh+|#qoldOzc0j^UYUZ=1EJ3#uYn)Y{*`s zQi#7dDxQAou@zT;W;|aK;6x&^^2xuh?Hwy8V^9`0LM#4XWebN@w>i8y7}y`x zO|z4ZdFL1BD-cT>7|sWEHCNoRmTa~&*b^4CDd+Z$6>^D57hZ6}qn|maSPUJf@aOL@ zU9qt14=?Y2@a65pfm&QYcE#CUPkrO0pDx_@wf{I0AqK%93G!gd0GJr^|Ac=7Fou~4 z?C5@rff2+!um&9Fh>T{dp#UdBM2G+ZkPx1aRZ?^X(wbXZ#`hKP)fI5f;~9bGCrY`}s`MS1$UbxN0LVEAwzT)&E! ze)QI_e&wc{<}O*rF!%ocwnv^_8+2cRSeMBijzGRPh+A||6WP#?7RWM)7z6<*hgA%w z0*AThtsv@V15rC?BZ+)KKRi6!^eNi@9!q`a$PsVJZfj=v%L?zb70GLS6uzE zn`Y0Ry?yK3Kf3)3hr`UUox`yvaKw?Js!7F>y*tdLn{WO4<(`?v?T@S$#qWa#hD{jBNapvWpjwi)i&%OTmAAaRdI__{`GTdf_B`p-2 z5|8deZ5P!~PL_8)^Rq9Vv}o@4R_%Y_zCW1p(b_3Z*PeaCUEjQP#kM0WzOdmCxA;I| zFu#0B^F2SmasB3X8Cte`)6|>)xHhUeu288EC1k{?SH*W|5^Oof2j9T3Fv@eAq1O1C}!n>HR&Rgf+8V8JHeug zDx?Hb6AJ|nO9CeN{W2r=@W4Vq{wQ9h2sdz)>@W=gg6TF zk${y<4wM1}gq@JXv2?-K8VNzwHubHqZREy%Boh0F66fFW4m<}ArGXlW80(G}4rT@gZm?Ww}y7sH^J|g6&x7!iFqZFsv(S^Q#@d0MU{#l1X?0u#NrSf6$(k_hGfUyg%|ObmB<#!OaH@`jF|umiHNO*Whgm; zFozJ(5r`%P|3}flLc%hXU;;uPp>Ko#-n5y>1;o*a2(YHwlX~~P^Svk6Z|&*3=CTjA zcQzj!*!ajFf3pj-@^j9j&DK%M7?Vh#3Z`JytXb_X3jNl;@R*50z?Bdh29(U$!FBLA zh^`ysB$co*d5Ghm^Lsbl`kk)HlWmay`}QNM`w~6*0vyVTv~fsS>Ck`=|yL#1r%fKFV0Zj0S8s-o7Wqt3sJMMid^Vs9DL|V8tgYMF@ zyOdP|5*Xiu{2^|cUmi}r+3eBH+JsWH?zUbj~~guyY;(ItlYZwqj!J(hVFU$tgZ+^)Oz!#ACn&+ zPD(kYtE;K0ZTho2HsudV=S*X?g{?`&LSR-6m-{wln`chx>a0{slc!Dg(g z)*>PjA*5xJ2#L#r{K%$VSV0AF6eppWlqCVp%o=Q13Rnjs&N?^>WfD?^k##N2I~$eQ zvDGFARjD}4_B;pau{Q;?yAVH^+Wz1yksU>B(CHY@d(a^Z zE*T~g)q^`Y?8M@a;*H1IFL0tBp^Lx)$58@XK!S+aYLFn7%n`^V7ED^P)s7@BSx6WS zW5F&_JR-In{Um%z<#+MIYx5@N!AMuY zacS@0qR!Ye;Fi=2LQBn$GV?&k`g^Y!fFveN~RFIeiw~jX7&vUMW z%%J-$6^qw7N>=ue?9}GeDBO;gPTv$^JjgVyUq`XSsF}@T80#Lv{40_4xaCBXt1ZZu zRY%4o$aJLX2zclY&aR+C%5pNdq@a%e@On-dE_9>P3`;J6%? z;MJh{oczc}YMC-F0xNtr86@T+-3GE$7(o9k+rkZ-0+q1US&L0bSX=m-vE}vt{h0R+#8X6kbZ5sd1ukYor z-ypmw5qA{8xn9?)Zm6xw=j%tua&3+6r=NP_#)qC07LE`s!ipc2EvGW5jjQ&Sj@Gtr z&qgYt?R_n8-v-nW}hCxe%3w61Hd0fp{#|P}j_W;)uLBbifG#G9U+1AWl%` ze=h(0^QUkeg3D5Yd}tH*Dzyzx;77wFJ~?A;lQB4&)#W1MfR!W@EFBo298w|VVgact zQ7Tb&!i3UlV8#Wk+v)uWGtt?*iwUh2QXUSjPuo4U2~+kfm2w#5s>6H-x1Ts+6gYvr zM=Xiay%^k)j2GGy5kU=(?HU`-p!+N+4{Rif$S@p+Yse4_f@>fYq9|sh)+~ikmRPg4 zBq1bm1YryaK}13*HxZ3%p#(#7IhtG@|Jhegz5AEnE%XmG)Fw?fTdCBzlP?|4$B7I} zLg=7p4UWGI{(H`g-&mBkliF$uxKPZ4q zL=Z$0N7=e)G8nFKrxl;xkp$A$5*mg%FO> zI(wwC(Hr&jxH(7mH$VN>`q5w+;G_0f8%?H28`5BdU<709VYA$Q0cJXM;8}Q0P-#xK zajF$z9#sZb!O5^N&_!|-j=HT2gg#^vttbC~y59TG?yB1Vf33aW?esHqre~5V>5Y({ zKxm;zhtL$Hh{#nDtcV5My((Zqy`ress|bjQNbiJ@1Og-h(tBnylj(it^mp5PeSa9d z;{D#w`}C0)7mFG5=T{}R>{dY1BxG~&L(1h) z^pIe{VxI|GLKz=gB>xKqAPluhfJQ-NYTdtof9b-8nu(DG*L?rkGgsrAKmFp)yU4gaR_1^kS^3!>E=d%`mBm0Uj6pAq1sGlAXftCqf3^pT-G$Oe)GZd(c}86dWV<^ zM_+8JDApH`_&x8}88GZ*<@6;zzS_}Vq8S&e@&vSo9ic)tR@hNrIicELIB`aUV<%)y zW7anQzUN7ra;?@-1`MGA4YF8i5JMA4fwj^B!=_38=ReHMAqz{ugix?;C?a^UEg~xW z3i;wK|8~}kfB(hu=GnLW_%4}9`EKF6cYf{tv3=##iG`5>whdDv3}BB~>woy|)iZAV z!WZqz>S#su{-6Bl?LCKR%92CFVzj+3s#XpzfqnX5Sp2#FAH5f7gph>Va07aVqL6=ix8XUOLk`{jgdmo{_f3jDvTYkdQY~H_N z?TI(6g%4Q&7-s-z)*cA}5loT}7v1)Yr+@X=0m@YKWXooQv|?#-qJb)>@u8=PHgoHl zI6 zIr`X}7}`ZME@GLU}oF6Qc#B=Wup>Y||f6OeX5;#tY>` z$Bvv@)0}rp(MUX&O8B~vOjUY*Ic6rdY(Dhm&#i6foECoP^k?Zh?11KHf@XuK%_ zQG54>QIXozA5M(BYypPN>i_=ppR59wWs?eE zYbdj^mQHP|{n)*4f8xC6XYT!YQiz}Y_T}@|O#Q-VF1_`q?JyJqm>7NVr#CfbYNFBT z^CwI_?eL+`t~+ztCBKX>T=3j|*C+G&>{TCKetSj8MnaWD`$l8BT}^FgOdCDx_OHj2 zQ#L>M+EY(Ga>2)M9^E#0JljFBM!0#l;&Nzb#uz*;zVEu9f1$p4Zdd2%6My;hn(6U^ zXT5yjJyAc4nfV_Ud6HnwfQB%EkcAArte)h53I-^IFcJ7t2(1LPPvq$kP@a(5SHh~V z=j@@3h<)z1Pv_yJlFb!UGC%&^Z$EwGjU{7to0QO+R6w?#()HXKO|e_=`0hx6P-J{B z`Ni-4tZ>I?v!m|eNG#N>n8vfkPu}+NFI~Q}P$>NQo||!I%DmFWvFnAOoc{vVgmd^;)s z@?6n#{SQ@Z{-^(knMpE}Az0d0h$PGcDM4184FWTqD3pQ}kXl0rfoDYGTi*=M+V>8F zsAr552~4Si;qcI#$ai4T4H(Ij8?a;MgL18{Q)#CtmZGZ@O2d$o@^X-1lvze0NGR68 zB%xf80SXv^Gyt$^$r(k}wFkB5@vJLw=t+0u1A~`m%B@Q;xo4vq9xaab+7+2-W8-N5 zp!8KJ5Ri0>er;Ghb9@&M#^r@4lfEy`FM697&pg`x8>|u z#k@sh1u;A_MnuxGheoFT{`R|;EsUJJcwr=60Ts6I+>}V9Cd$>Y(hon>i^2d}o!frh z&OJ|Eb>68hs()~(2f}P_s2SDi!NRnz!?^GhkLpOGzEZh`;za-Oz@drsv}yTVK}3zc zZ;cfOd&_~ImCE1w$QKitx=f7a1z%lv^KXuh`Bb4;0z&>j=YQoBJkreUGOKaW-(MS> z*<_zFy}G2GKmB%nq}lzkRG^Hfq* z?lT6y7f~&YAPKS2y?W?=n7q#)qo)KM#+DAXcUzV$!*OWG5iY zObltWEFrG&-&(R9x zsa_U5BN~v6J%5i^rgi8Af&ha!&;X=XZb-6DO<63oiW&w%YaIxl^eZwTp**Bhs946G zV<>2za}75Aw%FB9a`9Vl6;y`=wZq*dQnAW-Y^0|bhD} z+F?_VYWau=UB7b!jH%RcvNmnF1oD|Zf?_j{{@pabpQ~HYbfP@ASq%nUe-fMwys=3{ z6eA=Vg(~T;4H20)937Tzw;(vvKuxRJG@vwe03*R9h$W47aAB7*I6SuMBFFsk=caay_-oJnHnG^U{?+3>L*qSNiPf3yJYPCx-mLZS_7o3yzViB;=U;kJukQrwU-<6h zTmSRXyXtM3NJfqol{2AB>DiSNPuzaTO=Vd>*nQlxEJIjVTz~!GT^%kJAuB-&Mii=q zeD}w1Seco7ddIOY%aA0EsdHwmUAwk_cr;ouB?!kEkVMe``XD9+L0G_s^U=?(Y^h7tCn7bmU<|MY z&&r5Re%XmfY9iwLdpD+o$w)NvVO+~U;SE}A&8$g>A<2oiY7DNajs;4VOQR`AhGZGS@_l!tfWg$+Y(=#~ zIV{hfZ{Bj{%w_Y_1!cT6Fh)afa`7NmeGU^@xLFu6ip075DW^QI-^WS38*S~l0?SZ2s5GHg0!4$d(h=$&Yl=d%b0DwS$ztUmh;RNi= zoSFMN_8rJYAsifks>YhxIWgs`(-t;XC%*jX&V5_od+0x|+kdFtcZ)&b2MkM!vgd}O z6HCMxNOCTbUEh4c)o*Or+tK#e)t9ZEdCKW+hY#&PyemF4#a=Lfg>ZuU9nU{;_MM-Z zbM}=#{@HJWnu#;!Rx~%YZhYg-0joLCQ!1*xpMCX`-~H;1>ehN;8ipB>V7ENs2CkMB zQ>V^!JI6HC@iFhTx>R#z1t{9uQ1koe_md`s&|nUN|7ZRO307eEkm&Ar_h$2dzT>2F zD6aeE>!;1Bx$};Th70~T?%oE|VT%xG3b-nhc<*>NH$J%H;$;#4Zmu+}oj%78Ri?IP-_GBzZ_8(+jhy$OH4s7?dq$i;z3}S( zorgdBwI7Ixw9H7hxaXNScOT6yU_a-W1_5KaTus`TXVaX|YgQ#=AWeP&@?6 zlPCuqP9_{e{4d*fInc0#U_<$SI-Xe75{`DfJv5wO-8!vdO3khVyKAPlng*-HqKCHZ z=Hm2FO+z?(&mE^-vasrlkH350gFEzr0n|+3v`=9yk76EHl#*#a^jDXJQzG0sI^JtXm}sHHklE~D6%6U8%Z0E zL-~+xgM6^kD3(Uuxuud@IKCU!pk3^DNBZ(^Ivyhx6o&`P1~}meHbPH@fFL)Zqc0|w zw8}#-+F{3;)29{+rDL5PCoNmvsVny#$x*`!R)XwmbiHMn`sCHkg}r~9-5AZG(9ttw zOIbJljNL=qy+|bs>jM^R@8(lhPmARCMo0H9pFU&T`#V$dp3hvk=HU%}?fn6oYe5pi z<|CV<8GpreucmacW@?3BF6`a&?yC7GPMy;7%7F+qE}j+*%K6~Aaen%zPi%N{{e?H4 zJ{EY{f+tv;B$Ze4tQduQ#@yD?@|XiYB$}6aQL;*KG3e9J^Y zue~+#@r7qiitFO()Zy)K4UCQK%*8pHLFmD&JxZ%9HJBIeY_-r>v>Tdk)!O@VTUr-b6&24u^W>f1`C(_*U{S{F#*e0La)M&(w7&0r>Y}H&AKbY4 zz5DLC(hJo$e*NrlZ-|HiCWeL-7%H@+=Gk`CjG74u1LnD_=YRa_3uY}`T@Lln?)~K> zk3Uf^sUY+n83OQhh^knncXXQ7^`l?>WY&UJwq^X~@h2aD^e-2kv1B5rd&(gR$tpnL zpSZYb;O&QQx_Hgm7hjpKs@=D5&sV4Wl z-<>vhiCZZC_2EDCAK&+dOV9rDuip>ZK^U+S1_i6gsC9PFSf1MP#KbJNLbj z?dcl#sc-))H7)f9i5BV3pW5kko?qBa$?<6ONeC*mpP($K-1 zZvM#pS#!OK;b>K6=f06Aw*0qteFnU~q8JOTSfr}8Y2Haor_WnH#n;h@>~fDytICWO z+_m!?PM%%)#L+#UICt?pORQhJWMj{SkX4$c(&Z2J{QuHIOVcKy0fJD7nZrYRB&&Jc zL0TeKw{_#YG~9y|Y9J&Duob98_3hty(w?`pp~CMTHbWR&pLlw(@evRn&x?9g~G-cpW3+V_-?g?>J}jwf!3BeDQ*xDf+v;cLb72=NDfF! zX((uk5QxC{p-QYHU_yZbFeI1)NZYiukggHkc+@^xX+Chr{Yg`g7Pt_;KYIGEg0{l+eD;CBC59=-VL40UbJ zV^qM5ZP^xJP#`0;;dSluk&5TS^1e4cNI})rUF`u5hA{2#|K}dk#F->a-P4hSXOb=$ zANYUthpPa9P%8=n%|dDg?j0Gw{G3y-{n)2DQ41&5FhA9_aM|I5*FQZthy|YrB9XyT zDLQ-MudZGhCM#b$mRnpM``))d^W4p^tFgRJM_@#8^a(g7&Amdu+iuQHG5`T@V)*oh z^KSqA?SA#tg0Lx+SAOy<2e-fXgQqvE%WqSqlB;<@R*7jRU%&2*qtTkn)?HBLXeQkM z`|n=)#dkQ70r_BtVI!I^$YeS2%ht?bv~6mo^Ube(rEcM>ydN|qEC2I%|Gj7LuEBvm zk~P{e0R*f`Qp3cdU)*)i31@wDw8+}zo4@j%p3dWi(Y8!|bI; z_{8V$EL&+WaMxUX%})}QH-F;V=GGOWVSx?;7!u{dM1!oM&hOm$t*ZHJ$Me~EZOv_W z-u>NMZ|XhvUdxQiqh$e@P$FJsOre4EPdk0p`5zl8gifsHvKw#D7LAAh_{*s)Z{GKo z?wxRpMfbWj^%vZ-+%d1()-lo$la8t9uU^4*tzMSEb(CbG&D`lI#^(pkf%NFHOhfpt@zzyfq)m<-#>{GE)+<@{WB?H!q#tSaa>w z7jC-y9nAp;ETjox{7c{eKcVs}&}>68Lclf<4-sK_j8Z@d5x2SMkXC?V(j*KH4ffd$ zGsg}dp?HiVQ~D0&Y3Ma%JKRMVdbtE2-bDHKGM|$$l^tQ%PxO~pe*M9tzkKX&+w@Ci zb`y)T6*H*zG*&T+SlszM!U0q*2dbVc-17cUf0b5$bd@dQwcT=#S9daWLaTlVBUAwd zQK(5MEhUtO`T*7eDNIWUg9J21!V)xr;-t$$dSnTPfT2Lpf-C@rNroh0^bCq&UefNZ zo`|0klzbE>v=t%OGrS_hB|WLkE0;z^NzNa)Rt2#&Tm<|QgvWlFh`}5N9;GUku(Xm~ znV^V+iU=$X_7OKJO<;zSl#YP|m=YB>r4tb{3~9%t6aQb6 z{|ECw1hXP3B8I`xi>FUN_nhE~_92EVsMo zoYPKeS$f)Vw(OSuzMgK=Nt}M#$+^O~W`l^B*)nXM9Y3+P_QbO<9>|w{KVQgYLmkXs zeB!%%4;Yq#gh^FN5;mYY*K@&TSNqY_crNRC-r(Tik`=33TIvt%+KE`>q_C1q!y7oZ zY-VfYlG6r;2DKlKjg3hsR@d6H>*zr;9VkF+7`E#xJ<+%Puo#IH&FD-T5N64J@(Xde|YTi`ycqzPk#Q(8FS~& zS#_>$>WYPz4fN``jftY&SUY9q>V-{HD~J30ZaDAM@vb&FtVvs@NwDIkHN7^5^xFkm3(FIP$X%;`s0uFj;ULJ`O5oUS;TDC0w4jB^snHH8mu4%Ynr5E6GFh(D%7kjP0so8ZQC9F7&4N&bgoB3f+J_b-1u3ZmEgWH3=0C6e zhpK=9f*`PvLWEiuN^UAuS0=F10Hi<|h7~pGs_OCxIUY+pV(o6vZrnd~UJ2C5>-8(*V#X2Xi3c0+5jM>&;ZXgkj zjCF5y)Tm8sS61_uSX*7pF!Q5^R}C_h(oVue@7pj4rVxhIp@qSG)H|)xS&*^%`UEd!WvvLa38qXJ|Osg7pT`%;K$)xL*s;A889~{xSHt9^Y zZT|gBJ4&(i_r7}X#h0Hmn$n3AS}WqV zW~krVv+GEAUx%qBMU&)I!jBhxUl8$Raw*WCFPDRc(L$-JZpz_fU2vw8NR&NSXmwo0 z3eoz;3cJ>d*Pgg6n+*V+shQ@a>W)3Lu{I_TzqkAHmtUNI#+mJ%y$$`HuWfmO7hH^x zK_(#n;WYc-pCKerBIS#kS{<>FEwL@2C6op$W+v&d(C|WN1}TJ^gAx!>AQ=Hd#kSx@ zmxx40Z+V%9IuNVjlCKn#@(rQAss`AAAodx`hx92G1uIrAD1aTutaC|caOg2M12nE? zih+p@3xNO&AD8O&rLgb)G@rD13yX4au5B9=K9F;)h&fZ`7v z1%V1p4TQ{!L12coIrJeUSYf0Wb!om}oja;fD3P`i1}sdW6_a4)f)rZ@G$1O_a+cXJ z>Vpfu4 zrt{@*e7_={G)VMzA9(1`e_Jwl)tdwDR&{+TU%uw-C6}KxttSlM-!pLSnM-F>JCgO5 zGC*Zw4I`=*z&>$7n1+A|3;Qb^+O%umf8O=Ik6!!9`lcq!FrR(lZ_jUfM9NMzggHy(cA5tW!b&n&y_bkJ?l}g}q5(WkWVwyJ64%AKZDz^|##K(9|d(o_pfK_Txv6 zYSUG@cx{z04a2fIH|%Tb8Xt(-z64e-p8Cr-o;}#n zX_C9@lryin^N-_!lWfe@rz8EnMCJ$EozJd2>#@H*Wt*i`Rs91mw2|M|(rBGr;m2&N zW5!`O4#)}2HGJLBtl42dp`L&7#4&9Q$mHX zGt_#~Sh~dmRoVszB}f}KAbj=<*!u?Nt;L-4Y3I{W5pI}8qdkI5HTec37z)q~t)V4M zjgWv4hGYdo$Ozpq)GGKt`+s2&G=)lOEzM9=#*W;kmxfk$H>brdXJ-pDhge^H=sB8`YbS9_|@# zy5T1Wue)?cAoZUf+lQ&=v1P$>;FVxF?2Jz6SRqjPyo?AHO;|s;=dQ;dee@%jUNkl` z`26$FtCDLtEG%;p)(}Y~5pV5xy*Jd*yPvvg?u@C;Gp4<|@r|CcldD?IwoSn}TR?ic z$d^XPu{UxBQ-ilMmh#mr`_UWE}O|r z45N9^h}eo?$rd1@$tUh(!X;)vhQiXz)pNcxR6uCkn z9kl>VZJqMmGx)>y_OIUl(RF98`orTd_l##NO#RvGFF0}e319l_-bY^Q{Onby+T*>y zcxe5=gunY}8&b=4s02)g);a|2|9$%z5C+%=6C9fXXt2i!C7GH-hUWna+Jj~&3jp$E zD9w{kiwY111pylZT0_PJSzyKF*HxvueNnP9IQA~wQB4Fc!b|`qP=o_U=n31@?7n)wl4EU^0t z_yJeV)oNHkgQbS}K)R#_j7e;pMkwI{QnE!*p@jd>6PhId@dv6Wtw4cc@n+Gs5;Xy1ahx+I!tZ4PV?y=OE@9V|In#B;yQJ2P% zKhx1Sx#1jLmDI;y81<{n`gKor9pav`#z;+0&&%dcLghS~80UZ>B=Q3kTQHoDjRe#i zPCR$;P-Qw{#%FYoR_js#W~cK@bYCgm1AYVG0Nf zDu4tLAT(=+u*tMoxvV505e6(B5Xg!$gGGeH0xYB3a~cSubGOcQ!HkdyDGq_0Qq0*= zR5xSl2|8aOU4mT5u_hgqp-uGdgx47pLMh*q66pn8F&l1~m4FfVmlHHLP%*f}*DLZhOK7^_ zfxUR$!`!u)aTWGHEe^fL!b0JCT9}EA-zn` zeX9@ktr0`V?Z|;$h5z2z_w0Q)*9nJJ!mFpNF8d?kJ%?$y<4R(3k`FvibbObw|luH=6=htQr!dFU{z404&(h% z6k~Clg!J5^7P@FBg`8OkJAJ3Juf)=;r-*@(tw=8b5*XNy@*wOM_!@dnUQynjI+Cx% z$h#2DaH=ud10GC8X2P;NwyR~Iduw{d;L)Ai+|&i{?CWit(AS@{;D*nC)B%^7I&$8X z_iugTkqxjcP3BME?u0q|(u2+I$3-gc)Kw;5*wt&LoJ+p_Y?yc1j$+QtUq8HiNBj66 ze|XKlj)5gD)rq+Eg`aF%+(`G|eD-e-j^A?YgKPm&KsnnVAG-M24OKI18yf2Rj`xjp zj=+yoMU=-5a%2Kc^Px&yF$c3&0TSC@fHr)iRw?zN{J($dN<7aCK}_-kb6TN9k#bdR zAn%24IY54hLd|xJ0}V(*I61!xGC2%6pGPHOun*(RqrDg%K-ojoqB-mORII`1P`3&I z03ZNKL_t*Wk~BUcOe5mYs!_qf?(y+%GnQ@*Y;*_VGK2=QP|IfC^V5^2!JOEeUtQBn-J=NgfLi3NrK2^(hvkA zMxJ6}0D96+$C`Wq{o`N0^~$+TBY*kzgI8a2QL?UXVyt_^6MuNQSRM)+w2TrIlRzQA za8}KV+2x`4)?ah+`KB2QMEJlT{68v6}Mcq`t1V)|MA!3g)EGygAdi|50`8qNScNnwP)3)Zoloy;i0k}leQi4 zm1Zdfu>ocsa9|h_dESDgE0xxXZ{B<4(G9)ngt51MaH3OFG7ZVhOsrw0Ftv&&@(^;^ zGopmI?!U3G4E94?3X(!86{yMZ*N~-EcD*Ta5|9&YpleXat57Tu84U43ka60cc=Nci ztEl{@0%$%esaj2vQ`NSqMXG&CFVd+VvZ&V;X$lmoL5R-%d?Ney2GLET8 z_<{1ZDinRwv<;I-$I3-5l#iCA>K!<@Bd6;t%qfXQUBeT;bhOr?GJGsEIe=!vSroOT zP+mFEskFUzZo`X5#yOKNWz9XgMk*eL`vTWq_TUqxhn{#dR>v{R$_FTq7FiL^ID-u> zEL(>{=#fGomd&i*ad@a>xRCS8Gwb5fIcu{y8%c%~lnV!({xH;2Qjv$>>Z;9%^A}bw zX^8d~f>GD!*{6zRN(Ti<1{v^Zr0kD$7GT%ngg7jR*%MM}av*^)fKAX*?0gmDU8q|m ztO_RizhE-|(3L1wV2i;(&O7hy#GO~nuSu@j(B|Ix=*}Pg{K_AG@6pcO#3Y}B4Tr3d z1Z%dPm_BDkV%@nX8lx@u?Jv)0IH5JZpn1-;AG{cJ9u_Cmz+=O0JxTU&neH5~8+z@! zi%$yV^!2ZAp6Geu(`R1$+gDx+=UuB^&8moKJ$iODXZq*L&N-?6scV{ghuwF#{rBfD z{n&$>_a4aAszg+1Wf%r)4XGgvr~rlp7%V&yLc_FT1_`Bv1_gkIjv$Z+$y=3aX8ufMqa9;>o0T|YBcRdL?==i|=rKQ(e{)`&7`p`>Q9cy?^>E5G{Q zt+zGJoom(2ubS4lbk(v8&%3m@@fh0&ZcK`aOC0)atUOuM3 z_N7y|zP10_lbVgH)K|Xn_rNh3A^wj~GqaAOJ+BQX^1a*6w?NEbf&xn>A}C-o8Oa44 z@C$uK-;7eUV((rLt`DaYsgQL@fgq`w1Px5UGAR+^`YEsN3P1IDd-K$2M9KGf=^!+X}I! z?n;9)>8Kz2mNa4pif#~u>=+_yl5fYleY7De4-hX*_LENWryeG63@iDrg|NjYC^J|0?z8XeC~ugxgsCSyVuJVS~y zSus(bQE%sb$DCGqlF9Li?9B%a>H36YgseF%#w;fceTMXv7Ep$)C~HwHl{fa}|GcY6 zc8a4!(m?aIyz_C|_E(N3p=9A`P?UldAO#%BETBVe67q$L3^&)T+Hz!cW^MA=Na+(R zn)isMfr?_-h3~gw}bH(d-o52{hfzCsGLz3nZ?ovUY>Bw(TYpn<#s}ITd*JWuUwz`nOK<$zpLffqGo&<2zDs1V zCI}57pcy1th8heZEz2~RSSS`kuw>0Xqyb699+*KIQc93p4l1YAbnSZQmdmd}qB@Ay zPn5jjw%+=td9!9_(gUMeSpi5Lct*l07Kgum>#g;zbBlHZlhJmlea8G#uDWvVoi888 zvb*w?Jp?me%45%8Z@&8{ZV;41`_|JJ-1fuAmd#9si!NNheb3wlSAOhqP1iAFy5 z@Y!qYE?c&`cO-ZHNv)fA^}c?jFP?~nTAX>st4*`iHOps^&}`(wFgLm2_!s^k10*cJ zw6yTni;o={JUGWwLDX{G&@Tr*{7^|51c9$PhENlY6;&!7-PO^T=x8&daVDwl^aQsk z-OONy2a*(q9FHKH5QFVp?2CrEhwdKGW@ss2kf9BenUyfL5|YbO3Qr3uCF@Xo9809_ zNQ_yL(wa?z&kEA8Ld_Bif(;>KWeTIQuC`g<`JRS9LWX2k2m>e}#0M*lSOVOQ{9d8P zxm03L!)ip+B~T^mcmtWmY*oU`As#_>C5k&Sup1&oEJnjwE|h5Y89ePQ2*S`72!_*u z>ez5F`k8C)W*&w1fi#j!5J{p~pjac7$8`RkRO5_N#k?@vX-({qqNHRXlu%}cO3$#O z)9jMgA^U=eH5)=o3Pk7&Ml6HAUQ>^n*>PbSdWhHvMBD_5LWX2QgA5&NX|vXXHL>!2 z!%jOjmC0W`{QB#!ZM@{dvqLhE9_iZFHth3gbwfHB%gL}1PZ#x2?>!H1erxNFPh56- zNAJXzoum1Q-2FE!>lk!9-rFL(_eOH20mZ^mp)U+ctfdiAp(mvTpj03YVquXcgaKKC ztK(V(NKK?IV>15lf8itn2rwZ8Nl1ptN4rPu6Q|cEQ@_9Wg@reqGt8=gJPT6;0)c_a zF#!$~n0#p6GoJtCH#apeX>dNe92n0o4@$}x93eQK2z=|F^|cFS&ndc<&v6DefJv!ULq`%6_VHAdfV~NJ|owc zsi|@OiGZOr7z%=*S+HQGSpX8O4X_XG8_>{NYo9?DNP|3{#Bd42&>Rx6AfYfaGSYPN zjOmM43}*eb6Ai*5v#^awT~ovOraWX71wMq(d2d=p!QJa zQ6Bza#Ltg{JDqCiy;G4pkdHj@()&NWa8^T%gH6m1{QJk(-TTNpZ&zT+ z71cag@Pdcl>%D13%TOWP);AsmWfDM8k{;!Q&=8u0TNzI#5-I%aX-yv9%;qUC|Kjt$ zN8_au>riX$c>y$oLe1p+Av7~9#SmJRz2Gw|rdro61rUZ|7|_0+zWZK$=ZJR#lSRaA z3OF{kKi4dWmp4a0vZ^JTYAKh?6^VGDNDJv$1^_RFkXlL^_=r1}Em10!0wKt-iG*ny zT99LyT5DmLf#+H#0lFd)uS`TH3g!D>*!R%3tXDCMy)0>iJr@i}hGIn0V&t8;_r{qg zHY}aH(p5o6`@qIM-Tf2qam{5s#lZMp#41Fxjx!E*{k`7Ze#(mZ3+JsI8y|gr7w_v1 zgP|>Cq&U3*VG*NkXqk`vj>O2{7tgC&xoCmw`g_}sAMD*W5UdoHGr3sMg(HZ~&dNm? z8$kctT6fK^!5OQT8kV(nU&oQ-&kZ}P-PBp^=0FBPu{2<+|Btcnjff{GeqH>MgBV~j?lrkG}W@tbCg#NJSBSP&FJkRrV-Y=H%~m%Dp+ zZ#`w^{rzzl0b}y{oqzW3J@?F+^3KdVZ+RX>!U#vHVeMdb@W#ugEtqrGpyDFm_nAo; zHUybcE8o|L8`;5d#I2tc8&tNUwnZ^)#5VHm`E`dPz%aM3pfNLazJ)a<#t zYa9Ol;_7X?o40>b&m(7|pp?3fF5bMQ=}3E-irw{{^9JP!%Vd~AhHZc~l=j(>GMbks zP2v066w(SvD-^aRkuX{N(zeJl@nomYHtqMrky`H zG*~zQ zD?_-k?5-FUu6}Ro%rl`~_El;5;8gP9+D(mVSxs)5g$)ZF@6Wi-V-Gzved@V`Y{S(Y zDi{Pa{q_f&$U0qbT~=}7G-ythOh8d0C4%pMwDZMR_I!2G^wTc>!kObnTyjQoMJ)Z$ zFO~xO=6RD2cDL2;Ds(DGH1v1;>=#eZ`PV(yE*N*kbef9iEMuyoO}8~(B5y*&lYKIPkdboHcg z`~Usm+Ie%QnxVY^@$9MAV?6*$_BkNspRLKGvrilIHO`P!w67MoT8(C{*^zO(-J-#*#gYv|%jUcRzReQsXakze0={~4#xlSTkQ ztfTc;k3IA7YumH!AET@c;gQHTq5Fd}wd!ZLEV}-x8zY4UP&(e-w(8yY?|pX55xazY z_fx?zF0MxEsEn--hdb`SapBjlzdFCD6hN}KYwd^c|Ln1sc2OZBW7*9z2^azfkQb(7 z+s73idhR!OPn$gMzqj=>|C|Wln1bs6HaNMCt)4jcvJ2+d6UYV;pul#%X$FG!vU{)E(dN9j zWtUBX>Pr^B`=@Q#{}$^Mq{XfSpO~$P%oYTqMP~a0w~bxftHzb&|Mar)vxb-bvd&?% zERjj2J^0~*p0s(O?&$n+XUF?(CXR-q?4)X2kA2b;fjt#MkkSHS57ZU!Az=pXkgq-V zGJ_(K!jj@6Tle(z%KVWLW~F>0A(#eeCLjmm=vew7@_ixiyzj?PuiDkALmVlird`Oo z7&C=?J9KkB#?K*F-@IVB<99B9Wk*k@*p2V%IJAAiS?8CO4@&kQxb=Ityk0lh)8*{D zfB^_dYEILxy}Ro-zc*vj!J1{{H^X?qq!98!M8j;IX{%tM?t~Ubkj17i?_{ zq?5^-F16*8-otH)@}c=J>}Y-P`366o8dZ?F^vua+gG+KjN;&?&9I4K69c=DGg z3pkxDnlyLXg!;yYeTPkEhSnf}B}}u-edVEhue;>ZrBWILk4bC%*fB-<)(4wDa56sf z#zKVAy>jM|_?r*^-?$0WL@tz_5sF05nKPyKaKpa(P85uR3{a*%>}`4AmP^0&&F@*k z5J5o5K%`*OwCQ2)S-)XbHshjn4l+IH-As1p&%V6iuG?-41S2_DxETmnkDD^O%zp3V z^~umAayX}LQYZ*79c)?i@*i)RJ$>@2vq_)a1$=6M93Pz%|Kz6PsaU)xzL1u^Xu-^n zb{#nEM7em7=x?qn((C?pcTrJs?p?Wgd!p$7LhLut^9&}?r@t8(9eq3;kccSOpIEl8 z$LO>W04F zAw!BQh7W$D(cizfZp7G8uWxJp%Rkn7vf#9t#>C>%hd*+hL|^@;mE#86Rb$2kLV4L# z;cli2bOsd2&FK6*-?9(9|MrAos2)EtFB*-QfxX){zWL_cE9*p$oE#{N z-h6Sz)_rQj&Q3&3FdzgmK>#Mx&@g)XW|jvH!P-y?!Y0FG1vYJ=H8erms zL>=1Fgf%@oLp>!EFnj5qrys-E8+UzJhD;}lN>;CptzOekQt;qGWO$iON<-w3nK8is zcS4d*npdA@2Ok%U|GEG3ap@RZR5)>1pw$!Hb!5tjA?M7kKK_sf#PNWM6Yu@}vi|eV z=UJFPy>s)DSubtgrn6zNhGr504tLEcE56|T#izB7YJB;fUwl ze)Xj#WkWynE;|st>9U2ZKKWOVfUrVZIn&3NedGF@j?c7#TvrBeyylC~uip2;ZVv$o zm!Q0HCH8G!x$byzCz7nryWp~m-{14Zkv1iVK>LCV%M^jXt!s#%7ClSvvr zOW5#v13>@1{{X-+Z@KEC4Ug{60`RSC7taWVLI6G!27c0|0dd?Jc52Vl$+i6Sea9K4 z0T7g81)m~=_~<4$J3I2O?0CncJ+HE8p}9+stc+3JD%PE_O5i62qT2PDGZd1o4e5us z9(#CLJ2f3a^{icuTb6&2WIuzx1Q{hIk}avJD=sR(uyIe%)wln3X7%Hx(NOcT<{e$B zzS7fFa2m@9+->EquRR2T_Gt=1mr&0W2*&^(k(;7pw%$Px@q zP?{Jlh`|GZ+M0-np>q1aWZxl{V1iNrU<6>>XxNQjKMj_1@R0bDJ(M!lbh?q=@&fMAO>{`KUMp(_E^5i6`BR;xRJO zs*1x>8%h8HiCzzg*kSv>Ny&-j9G~58kb}GY&u32390nGYAecR9E-eTJrOB*_$H`d~=- zW;hU>I&s{IthJN6Wk^|ZB!V94X$p|9rjM#L0^#FTJ>Fu#GDBl3OFr0BD~Q1%O@Zk% zh6f{s|Itbfh*6b8%~q{gK|*T@667Xlj;$1@PAdR}Q+u2KqoYpl7dmMW242P@2Lpe6 zog$!mWLY56=&&Gzrc@6*-db^TNhj|C0PtVJdrz*_$u&7~h#(LwKDL!Qck$HgQ7~R? zep(NTW6sT-mQ?dLt2T<{!;7=)Xci;^AFO~NFt}J)g_@2a96`8{iwZ?=zb>;mS|&Iv zEL)@#+Al)Y!lwShruwE3$3%2eree4XkAyK=I7uxGHW^x>y9=Wh9Xb*{wC4bj5LPM> zDNl!{p?o^hOm4vU{g7oqvHKY$s=X$}>M z=DI+#Tiao-Jeyi}!#2T&G6IPDzVhK^VEUx9u)rJ!I|P$iv#{W4awTLLyPoH!NNN@W z%8Le&59AjWQqO+g{W4}F!S@vV_myPma$k0<$6v4EzabhtJtoH0XqQ0nqGr z#~sKLAdpBVVOgIo{4=tPQ-tPJ(Gn*~3>xqzYL^F4bu^R%RyyT^d#OaGq^Ue#3kg3#w#}sr zkl&M4j)qBg7*>efq&5b;5=4@{ELdUa8F0oz_cJ3c^AReBpFui>h{0qiI1o%^Fl%N8 zYcP=|Sum3@glRCd@>!D$17Kfh8=hoV3_-$ViEPpxI|MYei0w-dR4_x(S*RSmum{U$ z4Fm;nmWuA38jlK|WFSi}Q z&et$y3C3LxO;r09Yl*7!Fi~Ou>wI(-0tQCRL)yXKWti{{VthMs@QjA^P!gby9E!g!y0?8zE+2;O(oJmqB%AXoGh#1(oYwuA< zu@(>(D3Q*%+jbwAK5^nHZvguI`D)iVI6V(-fySw!W?37o!JgS^#)SQBn2o_D}lz`}6Yh0P*Q4d}>HP zX%tTFivN#;5>B!cF!P3;N3xy)TQcFf_qKoQigShuhA@B(1jAzi zsY${xDXaKs3!zjPBuxXZ2OmU|%_40R0L~_%lO#MmDD)+~D4a5RS29%|~Q_5`;j(HcW{he)&_)q+H;=$pN6~krP4oo>aE6OY1k#`*hI-AJY>PqlKJ=k z{%U+O?^fOicRJ-|1+fV9*PruZkemwbi zpBcoXtsQ@Pay9!5M?>?++uQE@%ku;GKOe&He;wIA=Y1!A+0oPY=ciYBqvxQw0y~!@ zc?5H=XFq`L&%r%L(-w*Raw{7P&6!Mwi&+64kpYqd4DAbHK-vs~VX#sxBp`&RNs|x&w8I)Qr+2W< zWzZ;1#DW1sLgvu^Qa;0B*N0=k%Yw6zK7dFsS`_?rVKnS$H=|7L zq(xpn!^>f%k}z0FsI<-~QaTdyrD64JOFL;;5}^WW@rvfmDhq_mdv+b_Ka)mW#7g2w z4eeaXldt5Fi^&b3V=wRXG4*;(y#ae)q(jSD5GI}mBJ6w{b*sscV&vIMX0Yc8Ouhl( z5}k}8Ws6~R;|1GJ8~6Y1T`J0zn}@Jp>A$wW*=CuOTJDG(;$9Dh;hQ z=Qb_H#LCw>%25ggtYk91=|J=So8q;HL+~6Jn)|Y-I_tgtZ!Z1r@9y~8rE|uQHf@V3 zr;C2ZN)7rf7~yeq^hw(8XKa1|`V;Xtb{xHHWnW*f4XKdv0YR+DvUD<`lB4c@`-5Yh z58iae!V#6jGKu86?K}RmVc*W+Jl>W943f-(NaY>t52?dRWFy7;0C2bB#@WYcec zy!}Uie!P2s15LjQ$q3q;L7pcD-Tu3m57Zp~>a|PeOq$>*>})vp^GBav_1YF>EZ77G zP@lk4n0W3JM^>f3d-rYMyne>Gu|gOJn;ZY}+WSw`OD{2mx|0;NnZVj7X>crqq31lY zZe{k)-+lk4OJ+_SC&UTkORihAR!S+YVVP1$iQJY&46xQ(Xl9{_9!~8j>Qy*Jvf5;Gh8w8cW>1lJo1~{ue*5K#8Ht@06KSW5w7F=td$QCN5dvD zm`Q^*gzLIWgS8tB2IX=5IA6mck#RkOAWQD6Iegb2m$wv8qCqow>&r;D;G0Z={!=|BXDcFMG~??4&|mLpP5+F_-cn3UE+Li^eXlIwE39)1@DQ+O!n zS28O&9!ML20WB1?AV5I-03awwt}CFK*kI2eQf!PF6x@z@vzr`Q5-J(&Hm77qgYuOU z!mv!~WPO;D+~kPz!t+3G1Mo{i=%5fIw-D8Cp@d+Esgr_UNy zsE=flUG=@XoANS+BQbpm?`(@1MjunBr?KNn^NcGnY67c-*I0)Q4~I`*lo~vjID_te z*z*F7TgsEJWju#{FCp7a<1XZ>VeEg6w=Gw`Nu$q)G`aSl82>FqOX2izcZx=w)n7RF z!Bt0=ZG0yb@ZE?Nk_I#w0?ZJswT84=FnJCnEC^c}$}$11NK2(W1+s(ipoq!O*g-pE z5bP&Y1~W%)fXzVL*S!FM(t-d58( zVW|D5KYd3RRPWx~d34X7*LKF4gJ)D0i~g3^UwU%i#}%6ncCOgc6pzPmyL{HD;X{&6 zrtx6g+q=42;(NKZ%y;vj?QDPbrz@+=)=I&LJGd`@tWHPKkz~t&b|EB5!OZY|Br-H| z(F+H5z4g5nBPxPs)DTiiB^68!Himy~AZaiWh#RP)ejZ#3+E_wHARmlWDT2*sLw7OXTW zXr(nt86bcK6e}>Z_F*t9CT&X+FaVQ4Y`@rNg6R_r>3Q0N8Kg}1aC5UibODA<$Hy-t z-H6k_iT*S`d6c~_jJp&?Q&6)W4I4O`PmTK+Hr#%&2h${_;e!oHaUXsccXVR3Kvx{$ z6vtz5GKgBtteHVlh_G(i9n|ebc6Y|@CM%Ta54(M3s5}Q=7R)dtpvaD*w-vFCWqA~^ zyi7Jti9?<3l1E)4>^wGD3jqk07KDIS&-zokb9|-IzK{I?CSOM5mJAKQGK@EFZg9Bl0*shH z+uySPz!Pbe6qC*)7kcNTH1Vq_D&cqsVm<<8G-_x<>wcsWFna*7fX^@`d@U^KzBB|O zXpw2K@R0_zfE3Umt(ZY7z&RZ5P#8`IzC?G5GVL%taDc-F)YlEsN3ghPe5P>hUN=iI z&58g}BFmB~WU&yWZ5{~PQEY&e&ap}WK41&2G`pmUrA5AGGKdv?aH0>|h6uwjfecs! z0tTP}!(cF2BVbc+io?U>=BRkwC0lZ@M5dQvP)`r56wELIoQ}^NVLtf4{lr##Tb)WI zdc2a4-~RWPuD|5QYi%F)NU|>E>TN{Z5jMAh&l@a7a2hcUM;o%7-7KRslZ?O8{E1&?LbUf&q||X04Dv zB@vyl*G+R=Ljxpp#3%3-0Fsgo18ElkNJ2AAKrw6so(DnjJu(F6a29->(_TS}l)>5} zgOG>=Sw;lPg-mjP8otkkld>ffYn?P47lMckh7Xbi&C&-;q&zY#kk6V(dk`iw3n{hd z0#X=SOM)vPG>XF1up6ySH045+kHos?DbbF3w{UOfk`cAvyy;6u`QZ0s#ecf%RjPme zJGWm@Hsj3upNL~vA>7?)?1%3&6p@KcY|a#%HGhQH5m?*lj2}N!M2qvx=-SmawXw7? z3Zb-?QQdJcB5Nw`u26i7)R~T^)TGnrvu&)ee;;GcgPVe{C=lXA#_HNSVz3kK_$Xxg zLDL#MsEi6HJpIYLs_IJOF!{*ozQoKJAk-uXopX43o~KPi`{{ds`RrXcT@V>rSYA1@ za#(SFcXI#sn%I$p+^34g&|nZ-cO4XDoHn80z}iP{`SJ~Se*ZgxlHnSOU;p6Nw|B2^ zEFYaJJdKa`b1+IB4HL%<@2y+;r3Di&`@(`jRZ}D7CC~ix_m4fZDcE0jG+1B;EwGpE z={@cA^G=&F{&!El)?-!_o^|E*S5Ej~)rKEjFugtHFUv$>Y^L@-yv><>+4;-=?~hUT zKisn8zGWZ$^v746ReeRv;kqw=^H*Jaf>e11*x~w@F?K2PhQP~^tC@TVlSG&u1va2G z(kXZZ+orJi**B|q)wjOB)@92=e+Ho-f)+9^`jcS53NSJko|Av9tN+06epmvOo=~0r z@paR!u>ISocWwLd=vCK@x?=v&jzs1s5ABX8N>Gr;$^i^yz1waW<@t$!zT5^opZnuv z1~@+g<)b6Uo`=Fh1OmuE~n*5+Rfn0Ro*Fcpe-ss&cQtYSdr<_z~J#P&x*Iy@u80x#^9o zp3IAu&RlTmg0qVLn)i|`1L;Kb8!tX}!J?(bgU2j5dva^TehOL#cdb6SXWNo%?-(o&5*a2Cfqe}rbS|7UXK-Rb zn&kR$6D%0gAWyS8PM!@w=PXr>j7My;0cZv>JOG5OPq{SP+=MqIYa*pN7vZ55!-Gn( zG$4Zz0dDh-h-)^aNZbv{4!EUdG1$`G{W^SE_?Kz+Enq14{MZ@m9aJV|K^HYZo1~a z4XLR8a$h`#$xEqe14EMtq9=C2+^XmAIK3kV->&NW@aWQMNF1lt!@_bk2k7e$5TTQ+R@^Fx1MxOjL^SLgnC2SrM?n}QCC{vDMiJ#$0* zuDSDzL&i+)Y45JtxhK{g|JuBvkFMQ{nG*mAA)pnr0YOX>p36iKAYv9$JIc^m=i8Uh zJ?+dfBftOb&@@jQJ?QnreRp3l@2p{YBB@4?8K!~e_MY;}O5M8cnoAbXnm@OX@*Up_ zMMvNL%lmu2_miGXSF+fHX;Ib@!WCX@ZdK_uS1e76{A^^HpEhs0{YRTVxx7Bzb;L-x z#-M@2m3B1ivZ}#9{lSx{x^C4=Z!Rcn{Kn$bGmQtJiZF2r<0;f^JTE#%>Z!kcW$Oc1 zpIHl0K``oH;Jo1=0ZW1;WnDHE`GQqG{M4jz zB~=yW8@BI?*Y_-b;CnZpH{;zmA4F158(-eg-XCjMQmAP|i_1##549dXSabAWPu&0S z4?q6JJ1e8%A`v#;{QaFx^-ZaG|2scD=kc@l-MVo4N1xP99u}SR*9+z?{;R)Vu}SbF z#Hl%hmtK9=q<7xhaP&}m@}%;vSf=$*pW*e~v~>RT8DoF;=e1q+2{TGFs|#WYuc09g z3(Q#vLpdl2Q*tUw7tFj&nx^^AE6dKFdnpzy zNyU@J!$zDnZ+?Hzku59#eb(vcV(^$DLy9A1c@fJvws*tURqrqP(ru*$kxAn#YWCFF zfxw>4YjkfnAZE{+oif@#3`$(mtGK!P+YKWCpJBJKJl1q*@zYmaiS zWuMtFpqaGJk!=EkNkeHs36RdMD7kEFPqP#-1!Y_SOn@S24I+>PB>BuzLpj8Xg@kfo z$Q%wIJOL6AGt7~S~Z8yBB(*1osv5E(=y8J>{66T?lve&D|135)$idRTR) zqH4;!FE5)@lK151Hs2_NkVM4n12!?(_ecnah5{=H_K6KqS~}>w^Cy4#@zp&YQLm4; z?mXCdxVhi;!b7X7W>1qv1sV{BWx4LO@uM%i^5X84A1N$TZaUu87AYAqW<;5EV>xFy zvo8#3yPem4X;Btdc+e={b5ijbC^UY~*uG4Pqi_X-g_J^CiilQs7*IiMe)`Pn;M0G< z?e3>mKmY58(Y_sIV#;C^RV3nxvV3dl{E0EgtB+-sls8{EtudiCC&N@)hW*cR%T6A4 zHY(32OOt6a2>~Cb09kB@kZS+p7fRMXa`iv&oB!4$m*pF+&%eCQG%S^g4KG*kKXTo# z?>-at+pa#leEn0`{_PKoHa~a6JvUD~+}eN9gpqq*`qr<1_J#g<-&cRM=Ek2akH>lg zrrduxHviV;7vJ=k#v`%fh&64Nb^8tFKfSg3$G4Q0l(#&&Vh4Z_^@r^4)enE^<=@Dj+zkckCNXXfa^j?!y4 z@4e`bXCflK_qFST9IGzQy!-dXKf3jd^-o;&t*b{<^Nvfd7=PWFBYyaubEIfKZ=T-w z+7)XbyX37`uUWEqMsqCvyPtje-8X;y$PcT8Q`Z$IX09AGI2sH9*ngz8x4qTtYYha7 zfJhEUps%M_dX6o8DJA&?(js8>r@JI;!?1+rpk)JSJbIXd7D*z>P-)gaLnD_*%>srw z;EN;)NjYFuJpdt>^AQLbVTOhvHVi0Dnwcb64FGBQ4gd&4YYk~Y+CmYufM8-K*W-a0 zfm4v(0dQ`UhhU+QOIBkB8$=94LV~2wV6b525esHTLJ%>NKsH52mJNc?fL21lFqsut zv6LJxM9T)WY~aaPQ^7FoT!CaWrryA!lyT#+rs_XMAA|jLQ!r;MQxa7Qbdzx$N z>i&KEx&6;>!V8lZKm{_=dc`QHy* zF}ZTEp%L`cqoaLSUb!fnF}qsZlZkXkEP3{M=MSnFn#p!Tq*!Sd5&;M4*maBMlubCN z`AB1TZ+E}r1@a3NhK?en<7-vOQ}aC<=>>{oLB+b$9jT7Y)m1v)WO1IBbgE zU59FAV74@%m1f)aT-BEm9c}$pW2eWJH^4k%8!cUl_GFaINKk79_I(zxZP1cs zcRum-8}I)1ENNig^bs2_zu=R1HbDtYU4)TKf`z7X(jTwexMcC!MnOrC)P|k=uUK@Z zHGC$Ik!W6pnia^zF=#gHF#y1%bD0Q+CLvJJd&N}~db9j-P3sK{CY<~2Z`ZcYQT`=M4PY(V3jigs~&AK;s zj6ZkktTSdD>Pf8F(UbbP{b#@a*5uR2&$#1_>n^Uflb|3rC6R*EMB~N8dPb;k?RMKTz{-z4!73GyeGM&c(AweC3uK{<@=FP_Y&y zEW53>`SiP1+r;lpoxXy^G;s|!bsp;>o5^>*yL zOZxuyYNHpN^7Efw_Rf}$-#)amUq?ocA9cfNRo{4Ib8|=kyFa<$h1cHiYxr1*1*IjS zXizawcd*He#dp^>ojq^*q{>1|`ijtatiw&Ft#DxE@T$>e0oRSY=Fq0LxWR^#O%E>0 z(Xcd+_+DI#Nz|{8d-w?iEi`<91TpkLNRt9dcs?{kY9eBvp%qv$ z2~sW~n1CFsN-nWT2x4egi##JdGLme38-uT)qZwk>S^)%UkX9ThVoC_!E zohy)O#I);S7SOI&b)u1`UChy}IvNZ4ho6cJL__1{#wwDZ!oq1&NHy7HA=gl+<3R@3* zjtCkchNqdJbub)}w$*qf4zmIh@D&9M%uKSfyc%SZ(qsrI-!@I#477AK^*YkjLB*P& zNx7iVaj&xiB(w(!_>L_?Mq5wvy)}Eu8p}m_hj-LYzVPnyBBLoX9Mdmm9qI2q?0X0W zf_}1Z<58pUpARouu=opCU+YnRw6Nga*B{z?(2Fmcgt*7rheZgNwyO4jto*R9?(lWD z{vcXbVwvXtU2nYg>h9F6A8^LbCsqWT%vkZXU$1VlytYvJ$kgz2 zsIZOOcah9;$-)CV=m&$h-gNQNH2q`4{-LFlzj*1K`j(FV-MdgS6JZmzZ{x^1?m7VF zKo~GU+JIE-`mB6%jiI3lV+KVH9=5wFR=44Ut52UerZ8_*dduM*4MWTyj2#k<^e(SZ zMbYTg=67DGDe1j)@mDaikboj`^txB_0>MX~yJgk#_a1#J_J=#JTUeQ#d+x;VUq1Cu z&%Kvg`_?}~k<1bdGt=CD`*#>uEb?y5N{^ehpR6JpD zV#9hPW96AQ+8fS7jvZ56 zm}eNW|8TK={)`Ifx@CTzRT7#vzCfGZ>xV=y-`MHY>^U6js-0STxiIFxzoDh8Crw28 zl_Qd$Y*Kz^(T#UVcs*T*d)sTs6x~Tj8rf@p_?uwSh%I~T)^6DBYqYe-XU;nBsv#q- z$gp+q?P#j0tEebA)_8Ei7q3cpHZ$|#BaJHFiGT^pvJmi?`r@p8M2f&3QgMbxs1SJ) zJ~QXwp>rN=4NudMVnA{);Al1s;c3kb?GL!4G_zoWf=7W64Vn^d>h0CtA&$in5>Ptl z7-JYj3e3n+S!oSPP#Pvc1ZBXNpd7`m0p$alS%C)Z69b-C7FxS744q8+k)fDyF&#>= z)&n^T8i3;ba%$PhEgLcRQj|`?&S&5>VcLzb3bFqkPVUCkOL^E-eDe0Me!csgOBY&2 zmHkfJ@&}&Jba&VlBke+SHnO!Nsc>}cIKx8&H-O>y;`#aCW&;J}W5{Nta!Ll>teEx-p| z{t(Ocm0=rwN$26;?bC)0!-Z|_{4jymm6Yzs89(4NzKFfAp=~b+@9#PLj34dD&mL^s zzq>UaU0N5a9_2QD_*!pG6J}W`ABW%|_zKD)?Xs{Sh}i*4Kno7&Wa_bXonyw8R+i=c z`k9>vJMyo)`C<@_JpD9ZjyU`DaVDs0;gvPXNJ+xN#0z`NC$4JK9qI5VdpakK7=Q2I z@BHCUR*TS($9{WDKk$z&?a89*?_M{rOXKU;Twso$@cp~jcA0r7QE(uN(^uZGn3<+s zdj8fU{uNi9S7_3-OBU7E?RjONxY9KieC3+wm+!jpXzKjo`8~jo?%!`04<9i*Dv3fN zYB-!8G;H+Km(NNuuj|a-_ssTtmd;+fV0xPQ4{I9dF1m1VY2natLEwyesUyA5ZaH@O z#Z&M7QTp-a>wo%<3$I=DXPwRLs%tu+khF^Pg0jUydp950xaEaMe}CP#zTVle@5v{h z>g?)aTd#Wioh7qy`oin>t$pnek9??H&(Z!r9)9G(AKj2YeAH8qKls?2``Hj#$7`(F zHF;#v&-UJT_njZ??n2app8=Vy&0w_a=XXpQS`hj1W19;@;yYK)PG-`7e7T|NsASU` z2%cdDBS55>NFVDV(}v7}IJ=qw77#p;{l}amv4mk{T6YfauTiRnPrDXWgl#L}?8mfAP&5g<-$&bywTbc%+FGdRC?9^G zWX~V|v=(Jx&o4fEYL$&M!42cM+UC97+<}v$dP{q|ZXpJQ}o`YhIHSANUshgw|H}M`vE^VE!^`*XXguwjCy`f}%I05w+e`DO78Mo-dm55o z{_;itylHF#Tm;2W-ju~z_92+%Z$a#&OwasZK zOQ@*6b6NMpukLb$_|+d?+;XrZGPuku8o6)F9+`Nf=V${#Q0 zopmEFjaG+b!Rsp@XlV~)*eK!iaT`z!;*n!ykPN)r?37-b}}!6f8Bte*wI zhlrwmE4P1$=~qy64DVl#L?h4sI;;?OQ<%&JGeDA+1ItFLpREdi^wMXyzw^%42g^$W@RS#_+i0?r zcN%0E+@%RZ2qJ?8GZTbCO0#BwU`w#CRK(CAC`SYWnhn-cIB_lVgp@i&sQIw4P?A06 zpolOtIcfI%-c$&IDLuy$2%6|TMlU`F$6-^#3!-p{sF=n59jG`n))Rv{gGNR$sH{H_ zN^I>w+GX3!oxqrL#0D0$4-lY&ccHk*(1t83Hj2jN`K{Oxz{K<+WU{RiSh1&d526p72V%9E# zCWK2;fDMqp|ByjWk|QPpq3y4wp-qGXFwzh@6;qHvB*aJbNA-&R3`oA1A$NW51ya?03Au?!qDQs8;=#mANv4lS8_)|ujyBi0bJ z)!G*xo^CzdFt=E*+;HfTr{4VNrJt3D|yL@V4BFXjr9KS001BWNklmftf{sP78c-j(_OhN5NG`-KI zqcQ#x>gmRT73_6j_*AaG2(9&0{}E&uZJU7rK|=)KF*8AF3I{mbgCN0BAO?BN60U&u zN!pspXZEEJFNWgD9E|p-n)`H;^1>_%DLMuu;k#s*1NjSmofNF%VVCrzruHh2O%FPN z$Y=zLkVqjDdkdP7pNNFfdBzXX~)1yQ`kGmRmFY=DZG3_dhy#jTsacmD?>g! z8WxBU@>`w0)&o6AIU?Y&HG)UYhDumb-|Z8y^Pplv29=ZLKru>=21Dz~Q|Z1Q=#1q( z?~grOl}@B&Yl!-NSYB#pusL@1=z2;VsDJOHN+$)<#E~6`dk%cykxCaA7SGPhOJ*{$ zSobr_R%JbQGU@6uV|>R~$QW_sH@|+*PrB2_k6SQC>TDut*`K`k#)fR#G$q@1WnsS8 z+Y)GgSJ=_9?y=_Wt8Vz#4;L+%^uex%!a~NN9qSj+6(Ade)ffK9Tfn z+l)p^JWoMT#E$IE7H7++lFVbDMA1Z@XkkB2N+8dfH`6p?9i1Ju6w1#)rW0|gy|RM5 z*r2MTjol0hX+bM^iphdj@cS_SLMoohJC-9|i&@tJ#rWjkP|ZAfDN1K>?OJMF!(|gO z@e4?%xaLiG2^u*Q;}&zvF{*h7(txx`mN41ub(2;DhEiy_X(IZ6JiTXlUDdU={fs&1 zD!WPA>XK#4RknpYHkc4f2)$!S2qA$KLQax5?M*LV8YdzBBsu970wMHfdNH_RihH+g z%d#Y^ZFd&zm2uiq8dPI?q*hG|= z#r{lK&4L6eW`?eiPyh&y$$y%Jzj{W~&?PKOzM3dGs44@L$Q7{4cG%yL)5KFKCEE5<46i{7|ak3qy;6Q z4LBwVh6l0`9>AnSmI5Y#6d+;?NT0}I&xMW&l1&V2K?>4^0T6*g0Hk~(Sj*t)+}ma5 z(_|P^1bdJUln*wbm~{klXVE-rOI2^3pj?wNJjX^RM?l z`;+f|borvDKRvPig`LO#@r|2;QgJj_{?hNByW#e=?|<*Qra1oC=YHTT=a)bFe8K1s z|K^zs*4=!^nmGpM_b(rL_UAu(@0!Y8|J-wY6xl4;Vp$!oSwy>gd7vbg_`^rKc`D*6 z55+vjiqN2)?~E8r*1&gob}d%V!~%cY{t*zcpn*D?c<%uAjiGErIkck%2mvW*bpyY= z{qP^Z@zfkIcy7~?a!rR!WOenLbMAP`4A9IguDtQm#lo>qK6QL>V(epITUDL)9(k^- zYadgbTYi33=Q(FS@Mt$;@K^~fk*a_tEJG?NOOiSCh%FFLKOk7kjcH099D8|#wlEM< z%5f6L#-wd)Oa0;tzH)d#Ry9_F{Jwa>Y&LC52qzBe#88{)=^5*u>^Ue@!WaX@UOH9C zMb+ouCNm%4kgN+BOM(#vaD66#hz~!8;vua5Fi{J3K7^o$mt7?qmf7xYII)477og*M z6sK_b2~0!L}1eRQb#W!RBBOFd4@;Oez0rz&{&|%cKLKhJP zuo_N^MFg5|amBC#>6N_r0xY=|UF&ghJNyoKNstCIR5gzsA0`iwwlTnq@s~L|kG^ zU<2hqFtmoWFajJh`2-IXvaxJ6L=9<4p0q+@{1^(S$ONSFT&T^l$a_)r;nS_t7mi zuK(P>f4sG?bngorXViLs`@)UI(s&@bslIje;DZ!J&+ZBe8rgc;k`b-RcxelEoZ@wB z=;@vIvX!)K4*zQdl1V5nsstCyFc5~>b*ZsNm8{t|zz2r;!ujM7*H`hCtLXlXe4;|7 zGJME-2c>|RDe#DNYWu(L-w`t}e;>vtP5*lMA}*Ch9Q^tRcP;Ixd*a1S4}5dQ!*3kC zaF#f9{P5PFUOMkxU%2t&g+Knr4fnm)^}t*Acs{MW;;e?WSE>Y-rBjvi+;kM$VkM|e zi=+n~S4vZpg23zrnB21YwNaK{GNHBh+?4P7h2l6lP8lL|{PFXvQkSi{@ugQckMtay z*Ril1IHMz7?X`^?H|{K!a@Ez@a!^QlDN8ChkxLL7M~-CkG&Vd27nlzJi9igu9>Eym zAuPKS#^b~PM&$&SydQPT?8(h^@^x;SiKRD*v2pHxmdk@^UXDfUFtC?)J;)-#PKw|n zDzZ#Kvb6$Akd4`Z6%cD79m^I%LW$|{0#V2yW}#%lf(;X_hD^bAs5}WSu$zFFhB3qy zCiS1M#v#NY1t&>5vgHYo;6ybX7ZkuiNKXnu(<`ci0YTcHz6~`I3kDg1ND(Yb0ZM5s zx|+J4-~-Q~^BOFEAC5eUQo(rI0#-;6!IY>x)j7YRriw==@&i*&vEm{s!A(LbOzuHf z8S}2f>?=^{Q{GrxeAur{o+`P8pbIURkg8@Lhmj6BjJ@_vSY+zZzj0=%k0cl_f(y&md1R$^yUXC;CT9V zAxeW|h6YQpCE);IT>&M)4um3G$K=4~Aw5_N;eZ7pvP2{kTr!ztrV^Um;E+oC_dfmn zgWvw{*Y5gS*@zb(-_R~5JOBI6+kf`tmZvtCzx@$sYOH%)ZyY=8!yowE*xq*@eDR@| zw(nomRNECr<9mD0zwqpxFFsueW91<2QWSIN3^b(h#|^lAIbXOC6XTr8;EPw`x&7EZ zU>zw^E{&Be6Vg5t#|-51m=FMvNn`&29qec6fEjTFBC8-JBQ$ZoNR1ikH`Pat=OUQE z$>+Fs9um!H@OWaZpq;0;9R9)2|NYuk7rnkG`o;hG@n^qz-l1H0#-(Tf{Rg-7m*|1V zw^3Yw;krft`q6DnC@^~Za@%+8I?~;5%j0RQDU^;%tXeqllB?DU0RqN~eEDmS#4N}H zmM!Zj4kamolYSjS8t5L}zyH9*&~Sg(fuyzNAU@gOH{O(&zDn4H))5goj-x?>9BV^i zN^V;${`>U_B( zef8mM-&OA2Fn)5^OkJ@#Jym!9gfqj01qjK>B*qS+p$_S}QqD@7-I@Lu(}HA4=TzfZ zuB_+Yf-xtbXAO#>XtLP0RK_A2Ix$`PWYpDQaw_G;^$mP-NCOcsyhH524_kj}&$yl% zE@#?6hqv&l{lZJyLI4|r4U$!GESUr&02z=Aj)fsBBuEh)wncEvQb0Kz2}lSbtSM2P z!nwClL!TYkC*FOFJ+>6&pb&zHgv)}V4M@U~h%10gO0o%A5|~fJPIU;jEC?2m3X<7I zFd%49iUkoX78r|Jmx;dL%|M%~9m!sz%e(ZB!zT>WMeRR!r zUusci`uU$jZu|Z6pOOiO@pb`Tt z1W^?0_C_@LLRdST$DUqH1vFk^qVOw1INO9?OCwC0l1tV?YPHC2J3P=OsOgqJi-Nr#ja zVN^*`G2h!Sj2YVZdN4AO5~iH%k4cL1gc%GxzsgDiljph<<$^0!CY4UhTGnA^&TJHt zAWaG^2!0)oZbs6q@F=p=L+E{8)VG2-P$*Nw9}_0#-m;a!$)Nt!7MFDrp$7@EDRzfY>m*zLWx* zM1m?YrZ(2sk{H=rp6pK~z4?pJ+I!;hV&f%9FQBNz9Kw-Al1^;#xMxAO$WzDR(aJR| z-afwl$dLiGUBcFqByBAj%?5xVo@QTK2x17qO28^>tz`xXQ3%JOB{yT=1K3f)yKmxU zSGhs23)cBOoWuujy&~BC=TvFnLm$0y#+*5?ZQSt4BQL~r-@kJ}!dg<2{3_euow>OE zM)&o?%a4BGgE!4x*;yO5PZ!Wp@k~tL{|NP+tN;qw; zneW|wU|zfb^e@kMJ^9o-J>UBE;c&=lIp^{}-s(3ux8C*A;L|TG|Hv)pZ0P2bM{(6U z{r}yx>g|)GU;WF@fah>hia55m3>F~YA|OYw6>J0~U}GX?OjkR#g{3&h2exA55LS1( zYn$zXoZY!aWYgA2kb(|CAQoT`(z2Bx4OF09umqD}$C?U2tda!H#Ytk#o&!h0#>^gB z35uqP9l`{b9M}l3rP^Q6UwrM*t+%}Qg3o>aS06hUz$gFf1A(@0 zoy>jxb3a7dPp6ZSo4obQzx(KwXP?_Kd+v9>dd`_k-{~8^=C%(koYnHZ&;P8ZuKp{3 zd8wG1N2x+m(4^&*&;66wasrnu!TNo4V2FnUGmyt$U*+SIa22$%+K`f{Q#@xzW@yZe zOcffdWk;jg(krz!i`)3%h!_e)tl4E^YpN2W7)4SD*FhAPksq)<8%Fd1uX;^?&}xwTA}^XRlhg_2A&zm2)mxIeX7&5av&${4+Nk9e(x? z->o(SnQV1cB7?@dp}~G~JR+5@%GB3ohju$96Adp~ z+&r{j=7JD1DMoYInlOq~!4_TNT9zivVC2=-rc&#~)|)SFZ*05l$){dAaro&kT=%hG zJ@ab0y_Ka8T_jn{gL^V=&noZO6)TgAI?vy+tNZBjZQpwT`+oMs$$kANu-LcS3JD8< zBoV<_gfTpiz;K0Cn%O8b4Ze^9LLe-%lfsglaqwZ<{wO-HU}T9YJ?{+fgYQn&^)*(T z+rRjosu>GXO>h|o`2qo7q%Vw&CLsEc){=QxZpGQz4?djM}G44+mG!(eEs>W z2C3@qpB{opF=gTNJ&Do)qqD%{JVc|x6d5v-Lm1K7kBqpuedsYs7@a%SMu*{@2-@dW>~7N z?XOg>{rGqKHf?_P;U{Kyo{^cm_^i$Ev^c@ZlVj_j_@B47UsMh%J9Zy#?pT~jWsd|< zK1t?mmiCV!NoDzGnK5VN}@R>`=+=QXe*OdsTvGyLsbhJ7o&U%wu(gp2;keF{rims2YO&| z=3r@Iqxb!PzHDRNxw7@yCpJ9sdZuLM{Xc!Gbw<45iN8Pg+e7o}gj8)|Sc!EImP_ld zeNSC7n@D(D_8i&0=b)4Hz5JeX{_PfZe!8i7R!duJ2o~Wn>cH6mrGILLPqWkE0YisNL#Y@wE6(n>i*OXM< zaa7w-^i^iy=&Llgb^c|y<|2Q5>%HI;SbQU@&&IJW=vj}}IaqWB$`u@X3dIp_KNB72 z@z62avwr!RnH#UYaLomCf9ZVcmA(7U%@+4(t0$*=E;w)IZR;-Het7UtuMNVH5DAP2 zS6w#qOIMw@aCZCT*y_uEyuWwXq4VCqzGtXDwL;9m}ZqthVvHZh6<)H+-7hn#-q(kNoX7 zqbJ|`{LNS0araR+i`kMA48b7D%w(B~pko$<2(YYKDM?I%;YhH6B*Xz(2g^Q+{r6$t zOH->a9}e^=HHSTgcLuiJyY8|I%cNU1HhfArsmtGY`-_{toGg}EDv%^yaRrt|xkVkT zqEy;Tw-m}zZnAgo!qsQJ`<#)tCyq5!A_dEFRI%fe;rYwvCmiwC$?;!5w&w>QU#)6u zUV8HQi;s`JaNlJ`4$D&&BvTGqHik8&5=joH1}1`~nIet6e%-A(RX(}>$)DG{Wjg*C zXS1v{STGA%FjrtbQW9jK&2-%f$|Yf;D+mnFyn@@;&|(kye)N|x^F8cZierKg2#`i> zK!&HcRvb%OQXD`qlqWb~CRk=0fgPl(F=Gjhjqur>*!wEAT)@^p%^H({)ht}V!hn=y zKv-j~1z8Bei=cg9)_z~6nyyK*-=GxYDet6Wt%XRI$@anbs zu~Az%Cc>&?{e!uoeJQEVT+ldj;O+jQ30sU>&RSKjghU)05Wz&0^r;4rf{o>*M@&e0 za0QHk0kZ`O0$>6b3~MbB`HoUT`-+SrV~oQ@U}IQ-@}Ul<5i(5K>NF+lIopoPI8>6T z$Yf{&GdffEeCvvinkt*f1o>iBbz(eUo-Bn)SNz{gzfde!{`}%Wksq9`a>q`*<3h|> zw5sRCQ38TuxxS<0%A0R*7&~>myQ}$%OI~|zQ?{`h)_4dKQYp7;Y-G@PRqO1Imp1SI z+`3gAvuakJvt}yJ{_I0HKl;Fi^Kj0Z$_NfwR8x+0S2h^(Av3fAhD0`^QCB z+^}H&vfhE7e17EEL|E0HdiDqB)+_Jk&+Pg7PrkYK!t+WKQ$PC2iTgLTa{Y4jzK)a6 zQ_CElw+<7NIQb?jW7NKw=f4-D!#KK;i=$Uud)w!4U-#0!!Czf@`J=qyTen?u?VS(4 zzWIs2-+T9wL*sW{b3ygu6FaL50CymQBr$!~r9iXZ-E z>mz@A8?`H<&`^S9btF%o`0S@IIP>yP^!D~k5}8cX_y7BcKfdd$NmYRajAoJ$mhI3r zOKR4x`_%Bbh{9pVb1%E;w&(u&tD#ee8fMm(!%3kWAc8Tl8kSl8KkAuxGQ!Oy6Ay2Gry-eLv9di7l7!L4;=FgQ z?3j^y_~qT_cV3#TZ-gvVqEs#)9?gdrk=QjD?&+O8h8muK%c)Y&u0Mb4-#d?f^>>Hp zg3qxdDY7gz$f8mv0&B@+!3M?wh?HQ`Y$Cv?@(`VPhV2x$oQ2dpNXuklz&Z&ofCPjk zDHsaIf(S};%n*`X!4Rx1rmy`3!xAZpDCYVqcn!i!T02I%4lxshMGSy#nH(Pw9F+vf z3JDzp7DA#@&UpFX|M!Z^&X`@%>soy?G8I&CX-0f9u9UTug4DCG@A}GDe*VZme|`Sh z3**=%l+;EaJ$0(4+9#u>^kS%Odym}yf&VjcvRlm5lE?r8P=YKhz$srA%7%oHY=j^d z&@mDUQXw{M!LCb557VGDPg!eW*v1UUB>+|s3nl?2SptEE^pfSM%-NX)hbfr0TZ03J zYOQvbw$|H<+*OM5cLg= zE}YdgSuBm_ODu?7P%N*#a8YaH%s)K*La1rip|Nazc4qrxh`Hw-=eq3&$3A}Bx8GQQ7aPB8a3VXSsuZVgxbbI)4{Yh$^=H4X1!jN@ zvvPt+AD@V~Khtx+*Y(S>6K)`i3e-GN_Cz2i9uG^-}dS%6oStyksHJY^=6`c8Ebj z*y$A@%ODM9$Pq?c1!09y2x16gC7?AiaTE|zJm=E1GgwDd9rj{)bfP)?`rA9^E?FJN zu`p-9pxe!k8&Z95WjT z$%2sZVUma}vI|&VhZ7qxx|^iSRuO9!1jL9mIRy5YEQAXa!bVUoghW(fNe}{51tP!_ zNw!61OLMP6>l~asU`qiy7V=;LuFJ-P^yvmm9CB2IpRu}vIDnIZHPS{Vh&nnFx2~F> zD@DCyVRu*_4;`iA_69GA{h%B#u2QIlSL|xtQzf|W}9Y1(tdFzVmY;91QG;v^cYz38rKu!(4 z`0^VsZ6Du%BSeG zetP2rn{N^(=w`w6DaxYcO`4j=lsN z^X&7G=xFyi!AL|orSyTLeSOQaLV6f0cI|rkxrgrBvOWL3@2&D}BcYyT%>(bxeRDDw-fsy{UWZgK;U9N=0#52$4y7llfrRKyYf(Pq$VR zks<+USh$!j;|L~_3=4{3*&3yo1pqk20fc3S1S|+_%U~6z=jDOEWCz7VlLO^{Ja_cW zy?gKc!q?L+t^4+E_}rJicyQjQkq5$lq?=&^PSD#u-q52vW}5Y1`|MZOUUuaGq+_E1TZ@@;|B;&uRGApEhrN<-qTjbnZIYBlN&)2Zr~Y8uySO5r~OhHqL@# z$Rxr+9(xCi?qE})I0Qh%ELnhTB@fRfH_4?b_-%B?ty~&rIo$$h!J45tQ^SLMXkZ`G z)hG^-a8Q%wumTf-4aLL|AS+l~6EZUt!SVRu1K1D56{@P^y)Pn)h?v=cJqQ<4b7cTw zj)c!{R#|d$qKX;egYg$j!YJT2AG%}kD~&gIzr0f@!ZT==g+G0X4Iy`~z=}X1;ja zf8*3Rop% z`RoVI+|*}(`p>s)ZNlil7DLE1H!c6;eXp%K>#T;^ovxS8jgCF|kH2j@HrVB?!0aWY z4f`2Bb;$UczxK>t`m?X!@!9VoQOht}Hom-J^X9iETP)3p;aB2Fk_RKF$5oQkAaD!8 zAO*onk^*22NI7iFR)N^USSUqo*+fFK62cKKnlJ9vU4`RQdwRQfo%%*YWBQqwUq3$U zb5wsl^9Fbp;S`(%gqzT&inA`TMvmr7zq@Ayi7~K8H5Yy9=UwbD zR(#~g_Y6?X76w%m$q!y-8@LT&4+$quvYuoi$sSYT3c z8XzQFL#!Z}9Tzqdn6g)VoNO(R?SLmawFEt<5T2m82+NQjOx{|M@BpxgAbc{KnPFpQ zm&%jyz$PH;Kmlf)6E#?V6_qO7wU=6#SzSw0`|QvbYP*&({cJEaT1b0X|JyHDH?&ly zPQCne;w!&-`dBWnOvFr4SgORDiL2fC(ZBv;$%>T#HoS1ponQRL@f@mrnMo%dA)_c? zl}wcc8v|EysL|l!JMZIEH6n>;H)G>T5e0VjGFo*pqX4YM8;7ys7|9qPzLb_-X;HyB zC9Ho3C(1UfvF;*dI{|^(W`1-N#tbu)4z-olzV9Q_NF_L)K>tpzZbP;eZsVl&$IIoR zNcnS@zp?GDMRRl3@aB!1a!~jpRZWgpdX67b zE|43K0p&Q;cp(;KOkCa4ni!iDz8^(_<9RN$64LiYw!Y=JfBr|9A4)ei=_pQDCo-AT zOPk*;P37lwE@sjs?NlYFAmh+l%dYE|D@AF{KfiPtO^&>G?eZT!)$5eDKlac+m$kJ% zv3dK#bl?8A`8;D-wI?;Y9O%CzFzw^8cg;Qn6_L47{;>S01*IY1E(>QojOdcx1`I=qP3uXj(Cm%S?p*2M>?Xfsm_i!r&-Xc8i6p?Lv*i z8(|#i7{bI;dfaOtPqZK2UqG^5kQF;#W98cMqSLXm&Rv=u+Lk*NBT>yJ#+ZOKAj>BV z9L>Uq4pDaPfFa?X7HWnDhIoRAB;eAJVH=;;LY5rvD*=KHgEiW(z>?dr`yM)YA1}F$ ztY#fRI;fP8ode&&-~<4IV$0CeWJqF;*)oK}#6H{B0Vj=Z&tk#5Iol`>ZRV(ovuCj~ zunZzdgV^xtPSiA=LY;=*k!Dt>SJupQ!CO$1L#20ET5--*;?OYS13JBoBA3f2K{KJt z0369~%5z;mH$14r;^IYfF24HeV`JNFrncG2P%Y>6qXs`=_;ck(iQ@i8Ol$k6G^y4;S~4oM7CA5p21N8zB5rOk4%)th6m25 z^E>Cxo5)ujWtJ{mB7^%$6#^Y+jr3f(sIz19D^FSzE60i1N^;^_xERaz5klae)e+TZ|?e$zxJZO#GP_E$EGbr_A=3>md2E+Y)_)*MUg&Ak_sS_ZEAb8%<5`W{KH*m5G7hDJU=83+H4 z;MJ-isks`$9cz zAsJi%NzDvkYO2sun*>J;RHXqR(xW#fTx4Lvf`r8iX*G`?jNY7TT8b zSRape(fH)-#h1*V)!dLWhx-rz@YjFt8yU&C%2?m9h0do_zN?^`tA`2`Q>Ce@lpn-_ z0IXqcnJl}mYovr_CP)$%Fh)zInABUl4neubO*sVL_uOQrP%6t*rhl+hiI@e&VHrBq z%(=-aSeB{O;8dZev5it$VnLEp$;9GiD|T<&;-{*djtifAcIdhFe?iw%ShzN9zV?<6 z{Q~3r{e~Iw+)E({UF%Wk!HlJteJ#cZaN=>aEkVnBQI1fFKnhWWkd)&>U# zwjbk~3^^VmVp$awQWQ=h9zyPEm> zOawdaePCF?K@>v>Oxu{5AuON9$i*xanBg)aVl7|;NWol1&?KzwU60*=q$U5w%Rh;| z|AVf-amObR#blT*o&GnYL8m1s0RFQ+%rGI+b8+g0*fdk!LR5}&t`EuO9EXVa^F#?E z4dsv}MhKpc#bbyB!cah37?Mf07OsG?Y|4-fA);-OId`p2G*w=Eg>5?On*|=_(q7ED z8mIC}&oZ;gkNBQ={?Jys(}cYdMn^n+{tI%&x-FB>wm$ zOG(PXM8L5^CdDuBz{p8fu9z^^T9iwicImZUeBdBLU`!(x)>;a~SXw$~HV#^iQ$1AE ziu&0Y8{~mQm~{r~<>8!o;&^G_K(6O__eQ^TM#t=-;n6Kycln77Ol7caD(OUJqO|d; z?VYRFTz%1+7oUADkx0a06qQ3E0Fsh~VP<2AKmv+XP%Ma4ZMhiRs7xxAQOIitfsjsm zEMG21#`swn-U`5Q6mU_4B5)}&btKJ>grX*b9$rKvKGzl35x+7@Bq4H)R7!}oFfGBln?8m>_)C;&=KKIs2|z(Q&@q{irA4UWIy_Cm49Zr5twtoM zXJ2DnI~I$Hx@9Ue)4JM{LvV>Tltc_@M#5(ml8HI9h)(U};mw$RHmBwzj=%;6AO#L! zEGQwQPnM0fV1sGVh*C_`RA$1o8bF(AN62&rz+h%;g_LX!0BB?3Fvwx%>0d>H1)*4k z67Uj;G|6V3dozwdh1_1ir>M*%p=ua_DZ{wr`XB>SgmRDz(`T$ssgA_hVeHz>)kz4l zmQIh&(_&ny5JwOp*oAc<0glKjmWqS~z(x}}j0lFn8iGkW90$ynnwMbyhoB#_`~E=7 zK2A$N#ryt_Bln==cD6;qfrW&Qi5%vbnQ@v45uPSY#{m*`Xg!ZkK1%(HRR*@g<2#9b zxJkB_xWvpXLYOkxVfYXVWJyFExe&~5nrz6$JQ1^%6l_cXb`k){BNl zf9LkyU43H!ogB*#AsLs)Ri$j3*?`NDm?|0NAS~k#&#~u28=G!zYsgMb6bg%4Q_CA{ zRIY>sQC7#NlI6+#x{DX3Q8?8z;0YkxbTk)c&D2GU$OoS+BSlVbC~;!4pp=TkXe{ts z(iw_Fu9=IdjQ%}nnTJ$8SAyJF@TG75ymWYf^US6T-gQ>bu_Fzw4NWteM@Pmu)%u6u zJ^?>#Ndd{K#yRO3vxfSHv&mE;HpUo+hPFZ?)|!ZvR5}dfe1VyZ`2r;p(1tA{OO6Y~ zCT3<5ai~wHvsN01j7$)di6R)lM5H7K#v(R^cw!2rsn(9USFd~jBVT@=j=#cZoJH;L z6}@|G-?N;p=S4S>b-3#ZOc{V}%u#14M#U9R`Nk9_r_h zMrD{v*~kRQ3T7Kca0o_%47tRimNA)R3d4Ks$qkryE>iQUQfBD_26B4aM=}U(jIe-U zX{OuhESanU2_k045+WuxCRPB96~vZ>Bw`3L-2-8^z;s#$%M}8#m&MR74DFoJ>=#NR zAE!`%J|_~8^_Y7DCiX)~cqt-<{=IA{S)CLdluAi1hoZH^l8b2AlaVVNh?rc(ZUUht zE!ZPCR>WX!IjjiBwNwqkkQzDyLKZ%3ks-h?Ovn_2B?+HJM69RDMr4VPK1LCE!7bo> zvF|Uu{0mt45ghzGy6(fG+ijqQH5MQS3khpU2sQ?U=|x5&hb!Z7TY3IRQ0#%Mg%M8I_!$g=yKCxmGpYB$cM!*3l>P1wt;TR>GnCg)q zqngaFBa_$tcH28!yJrT4Sq*gyIy)iE_KjQ1tZm!!Z$EHw*&E%c;LE>%5hr(skF-F%m*)8t0#`+C&r@~m!7|7 zOwE4qPrqtdHov!UDiv4qCCp!OK}XxdNB;18jr2e+&%~n>s6BIeTMZBIeAQ%T3=j4B zDdcnJoC~fVcx6*=a6lUz9F#K`)v%DzAu+R;5`GrNDJujVD!siO2yA`TaQ~p^Ib$QE zR>w^<=M4qfV)r2I2xhe*9GjXfowI6L`SYJRwCkPYhmK?$TbzVnE|tQtl1jLSQ7TnD zUr9-hMG)zTTwe%bO)T9?5O`j~byXY$Zk4MX0dnFvj+w32(h)(ZgrgikLnaO@1(8Un zM11M$^OrANSU-2}{FbyRcA;@DW?q8+gSK})XX`NkW)zrvpQK<2Eobn|OE55kV-I4+ z8E85S_5gZBEwLwUvSP(L}^h3a|vtaDkX1FkJ_Qgr5-#_=dSJuJD64?aYDe$6ZI#Ipaw{y$OIz1;C3 z8x~=-6__?FPBWqYb8)~-7E&RcLhQ1$7#xa_;4NU*T%0^DhnFuZzZf{rZJP$J75qdW=60YHB9^S{{Av>@~4Z`|?DOHUjx`MRUKyyc$eh?UbmEa0__`18e`P-oKehJy_ta$b6;rTEwYIhII?(4hUa@bm*nJW; zEv{5j2#27BaasCOEL?HH&Nqisx-vFc(Q&+L<=l;p?#_e9Q*L>D3hj0B6E|J_&*%4- zLyQIGbW_`_2M1yKTv1H=HN838e!)i$Y;FC>XxCiX>lNDg+U+=QS^w*1dhx z@V@QcW?5~0jm^j>(^aL7BCQ%`O%6m$w{O{l@|vCdiuXOYqP%X5+f*G5OwsuaLs}$| zOH0c%T-R{(fszt!O34r^pbCkw0gJU^S-pKp0k68OqB}7hikDi#5)5Gq$8$X)Tt`O* z0#@zM+%s+)U zt_BJqB28==kQ)92Ob!boL1ZTNp++diDJIX3`ZhHMgL%e zCY=hGSQkiGtTZ4f-H)DS6_GqlOL(dzNITnp)(s~jPzivPmbPR=fFx@T5>OsYf~z4z zEXh-jA%qZyfRBRn2tNQ)AcEkc0}YTF)V-^kLR+so>lfWy-}5@QEu20fnA)|ir!A3= z4}{NT5kPK;Oq)|X?cNph51pLf{GWzmN64T~N_QsPT(j6?)xapLh}tpRHngVRLdBTO zOSes&+*J1A%Kf*$zWKGAkE)IsovHjy&-}dR+XP|}xXK6VMxZ+1OxCwClmY-;MI>1Y zXpf3{E}4O;j4exue#eu~V)F(3^f1l3iKkwSb&t^YH+bS%&?%@Q6vz;OV69nuBcYT& zC}>DPL1(~%iCE_j6wZ;1Pyh@?z9owxNCT{y0Cph-GZCABJMv0a(16Yn`=yN8|3s$g zUni=NiBAsMvj685Yc_A%+BB*ro5}6mxs$z0(lNWC+_vhI13iuN8m!V*rD*%Eoh{7` zY+=O@tC(3A5U+`i8ar;|`Zg1Y%6wxCy#-QAO{{CU;F{|;ZuxwBSH3fuA3L?hP4=F3 z$qhmkZ@T&3DPxQ?FF3h=#=_xe-v!XoukZTz>)$Lsxo`L8hH6Tsg6vSmxH(5nIrP&3P=Q8Ny;MGzFW_`k7dFKM*uArF#=OI+e(Fb?KEZ^OPz0n01MK9ubJ?uX#baAs zliW2c*VI>!I{om&AAIdCXUt+m1FSs54*3>XfDl?S5i0>x5-VocFigROk$*Zf!~x4- zO(239^jSksy2y1*nOXhDGyj-7e&VB#K7PaP554%t`%2$Y5l(cqR* zNO_O~&`9)CWENU~ ziA_&Z=O#3rC29}i)sG-w;2D>ITmfm?dcjD%j_qg!9BaU;1h8k-4_8Tt$^8MGQ zP7IuN;pz1)2kqLmLmDK&Qs_uoIaomDp*{G!CCtoJ9ty`vMNHIHmtXn&YtFj-4`*L| z`L%zzde*#S7{RdN1yoU%1fU643Dq=mMGTP;Ss@OUAR6aTgzXT5Ap}EgS`;efXbgb> zf&mH!$PU2{j5+Lt-~Q?Mzc}Z@Q!cvntlwYC!7xk{!2p6m3Pq`;4AB6hbdDs>9H+ z4+H)1B#H`yDczS8o+1e%6D*L+mDfjZzUJU-PZgyN^%NgFxm5;(L0uI2pFh6#vO~|A z)`y{Pm_c0-)wRj1FK+zh@#B!*PfkzsI0G3_G1EFT7BIl3ZAC++VcW_Mn$EV-q2$@E zgCD>5#0N`1d++sEyY{Ug8{e~Fw1d7j1jFn(geVPcp3!3dV(j3Bzg~FrZ8tu#7 zrF&Oj`Ri8h_|cWh6C#~=c&I>{$P(AT87mWK!41P8nK`AOKO9YwV zWCyD&%%~bX@r1)B%{?M()no^9@mR}cfBbXLt@mylPP7|okl;erHo4sFo8MY-@$atC zH4_qu#_PuX^{)FbKKtD9;ZzstB6GE6zkBOZyDrJq$4dr>^M_4u5mNT;>e=$cuA^?4 zckh=wmw(bvv1;~Q2nns3{d-q{G--$R0S^NqS$jg-TDj1Ql>iYZ`cX0m69jK~o~Hjs zk6T2=BCmOn=3T|p&c)iNdB=O)d@2fga&jyQeo&1x;Asek$HZXMgh`NKkI4nI2htD> z(8%T=tC8dFX_$W1P!I$#3kmJ8@|y^T&%Tf(2_7+}XGj4}ESU0zrq+^arMA#|&cXBU zzU#W=a6*KFk%Jo8ZvX%w07*naRIvSr+h1J2rK7ndv|v_F0ZLAJL=Hmgf({Gwg)36$fUYIedqbI zGV$u0D~D3w+bSK1Sgz|hPQe2SOR{FaX(A$)21zgD6_uu{>V^+{lGps{e@2ZRT@ecO z?%R{mqhV-L8W386$Yxb!S3?*egQY<-z&c0FBn(K!%pjKq0~TzXOp6OSSb{A3hi9Lg zIp(^J8#;Ec{q)cO`z7MuL|XXuCuS4oXFwT*LPWV=DbU1 zWz+iA&-##OhC@W0N}O<3>))?Ezil{o^kLrHU#kZ$KlGTZR}GAbzI@}MMyP7m;@{Jw zt6q6;2u|kyi(5{ZF>BDlqB$F&Dvn<`ciIu($Es3a-MQ$3f46<|-f~-xb`4T;Sd09j zW1RaQdZmb(Ts|}BxMLr@@9}%?ym9uNu|Ise7Zqb5B^L~-2M-%P{Ku;Sljl}J~P zZ@BT+yKef^mDB1IrBRX0rm{sfVU!p@%jwRfbA_Nb{81P1?ZenHNg7&v+VLQQ7)fLS z!DOKT$-+-^fbu-0i{mP57M^x=PqtVe3_AIAZg?;jt#y$zRf_B=EWj-&&$H8sORqkE zh>h|u}r)uy&NV=G$5MQ{1fIjj3J zfBxH#WY@Au(B#8C5R#z*K_r-&B>8lNpY))$! z&B)c~n~VBYKr@lWPyj(l|Mh<6od0@&048XVAYl|8*M+dm;Lf)0$6k87t~!>=J8j!` ztX$iM$XHh+qmj$yleuEpw6}E){o%%&%LTM)_4Ib{YVQC7dB@2+4DxvD1@jm z5?N(}%c`KYP9}Pue&in0w39ifstlXI`(V{_!-5wwxhDZF;VNiiRUGc!GyGOxpYz62 z^78Q#q;g~sTvrFYu1X8TaUlc^c_;~&n99>m5yB*R3?KJY42vO1nt^C3*`*UFPs;VT z7ZE=Dw`V>5!ly`Qg&CBF$*>s~gbD3|3^Gix0Yj22AzUpKJVhSZa3Pq$Y*>JT834d` zNM!O`Hf%e6(P_~|bG~oSI;jFe5eSP6gDJ+^5eTypgdo-yYXh-rE+%>BJ5*Z1<4>ag z9lY~>9S&jA$xvmq{awy=p}GaNCk4HIPhNHWK(2arSd4DjYL*3#ojRsOcw?)By;@zh zaB>LVl)1&5u6zs391g=Olm?1l@8REH|L~_zT(qLBw4*mGi_S@NM#bVSGtYkE+4~MT z>Cg$UzPXJ9y0xM5>bpPtX494pFJIlZe+ZdEv^3-@X6As@jDT`ILy$Bql^$Aj%nY_` zdfPi~DSAC;_T0G>#!v3?npn1l*NwC>Lep=I`(55mLLwLL?eH_~1i--ngc^ z{?OrMVK~XB&#gY?rA7CzNZ)wv52!O(SWo~HSE*wcCSF3NWAXD7q+QIs z5~=-q=WB?TLxv!TnH6iuAXot&SV0Pk0%{jxA(kE)CXoaa1TiaU9?4M~>E;1JLQ20n z_~Et(eAj41aSbiVAiq4ZfMO;vvnDMB48SU{&19Xr8hiJSb;DhI7EG!$;fZKW3#qkc zQvzC;h8`Ne|Bin)jjQV0*Vb59(K>Y;Afy$tA*4VuIh^S0iiY5MECmnek1rz_WsQ7-h8G&yZX_e;fT%YJZU0c_pGf2FGake>u~R zvauNRODg0_2A3NmdhVZ|efF`Jrp;@4{IPupExdo-)~(~lx4ipWU+YQt|Fm`cgyu@l z?V)f5h^S#qRY|x%k?n2UZwdZ#%f9WM-Ih&#iDX4wsHBrj3>n&kR}|8*4B6e;*SV`R znRDLya@9~KWf-D+M{a-LAUhyWW*jFd*$hW0oiMDBWFfR-X02QySpoAOO#-0$SF!^IiYCd-wYF@t{>(S65PQ-u^$gZR#z{ zj-5)Wq|cur(73rDcRu(``__#ild5Vet4Gy;@cwJ7H>HyebCC#zg~3vIuF2Jv8@J)u zzpT9V&F-^q`{~Zdww`pu%4{lz@&J_fj|~x#6zn7Onm{;U;7L$mK@bGN(8`Z<_0uL< zNVtkqy<9pQ%}4R3CFtIc$>*TFj@LZO%$R){(h2N%ldTAZK}66DuLuZe0t>hbc8JEz zf_6b*C?@Tv%K2~s*d2+H@pZlsBhpx70i&dGRMYr|n(Dpn2|-Fg2Ms2Y zmMu!-k$j#Cd94*W9;VizCMN32DesEm0woJ!58?0@utv@mT99pHbUDVA@ULdT zHjyqO?}WC3YMxUMoJ69Gb2R@VqpP%aD7#6$!sAgG{?T)HrMbjh^I zqd)s`{r>29RXT3z=gXVMH!L`Q`ox;5V$mfQAQNm75!mKHn8sJj*Z?)wzy%P1Fd@Pu zW6%bTZlSo1ib^&jL;)zwTy);Kmt57_R8>M{K<1}zk1Q9U$u8E z|L)o=rba8rTy^z(J*(IK{jxa?O;azw^m&xHn7#o0pK)Vd-N7dw*=)V^$R(a#9xIO= z-P$;9ZuN?tJ=He;b=%A{X18qW^#HKzFoM`&fagtC_9-)>g< z;p(b-+X|LMq9C<GPY6ZsbU%2)Zo6+$a5HMAn31;Du?Dh}G*|8da`XaD)CZ-GAMM?Z=;b@&`*l`1ga41m|78KQc?K>y?pm z4JN5s6cx$umiGdJOoKy_&aDoj5#c#nDJBW+$HQunW?{hd$RJh#3%`Me9|A9=ABVsr z&JO}`NEi&4hx-scgjy_aTLSBRw49A~&tToNn0^7~UPkL40Q0q?5hFl`AZS5Su=WTe)@lS|Um6T(5?}=_ASK{P zEtqiH!Q(f5Tz|z4cNFSpbocb!{ltq^m7}SyW=wswSoGLa>0)tiW7&*jX5aS6LB zp>o{M?YpC;Rq@%SQzkWK^F_~b>uXA3I$BdOzy%GZu(=bptq`Uav{cbmlF*Ze+K=PL z`_Kyc4wR`JR_wxs2P5l}Eyy%D@2ZAU95I%3LFIC&tc*r2qoaE$7(^@xPnp@yJ${xZ zlm{|c3TTF~@W19)`kJc0x1X+LclHZ zK!M5|F=Ub~Wl;n(8IqNUK!x6yf{a2DWQY+G#HyW z!~y^t0b-Zf)Ivj+>Fw*$`vWS*arIFcZqsc`iHN5z)>b)f`GC{=P*F|Izu>&XJKq-J zCUeY;vdYqB-|as2ka0G(FS>sEzpprH+0X5E$>4c^oq5~&$A7akQx?;`1L~Ngqu+nJ zE>||?$>&!MoHliK^MuRp-?XDAwYojsL-Ee7sdNAF(!!HZdT!;=gDhV3t|%` zv{Fh2&R+U$y} zo?97u;j63?!KpXtsmJS0z2Ji9OJ$^hYmiq!WrWGULOluxI9<@T4O2pClEexi69olk zSOyb={x8fxLo*9WM1W-N_}-@e?82mpB}0pJk1m@F&hz${N&k)~|DJX~&1;{;tgCq1 z#bVPFdd~+uei8CR@LWJZGBh73Jw(hSte_O|T==pL9|DvD{(*-e((I?Ji32iaU?f2R z05s8vW(ZmnG5gYHXh7%La6qTcYCY|fB?F0JW!OrwEp*s4rELk#T}7me94QHptFQn3 zgJ;}qR(Z0sZy*+wN|-Jo7K^RlKj3M%xw?Blb~Jdb9v2=X%R6(A!yCe z(4ITuvu>DB8jeRKmM$7P9q4wU?+XSHD??=W5$uwCv8uv z_upP641=X4(pp#qfsCz9iD(pXXvb0x)l%iL$n@~;kDxKK0H1sBMovWZvG4e(<|?)6k8_9=q+k zZ`XbCy&883f3bW`|BltW725udnxoJ(`MAqoB)1&(b6#EY^sCE*)Zc?}5-np;8h+!W z)F+?6m(QjhS+i~Rmk)nbpnY4os%73qZ*f|~v=uX%266)&tt&c5FIm2F$(Jvb#kpw2 zv&BkLK8~Zap){ajNaTjK*?^{tU;g&hmEHGGZEEQ6Pwhz*daUUxIFn?#)}7K6wV~Kw zf3q|;fAES^&vbuxa=h6=}uL%*-S}1m!|lUf2eOxNptIJ$eR}`x%QwfEw`+aH@q@lFXilv3RIZm>Q?74}6O=S%!JBT%V!3108 zT}TMYrWVYGgeGVYrbJE~=J2>lMo(WRkr2$xfeJ#Nvx61YQOn46cY--iVUryXFFY)(4`b|%HFU46sJoM)Q$&+E2l_Bao{y>9ci zeaYeEs8My@$!sc92pC?fzY7Ac>u%lBp*lNqs3^sb9?BQ!;3i7sR8Io0euIz>mNJEB z2EZ<2WwNQkOd_ZY8WM0NSq50c3L~2gID1#TyXU)AohW9|u>ob{5R8|P4o0KVy+8Lu zMaU@Fb*1i5QpUZhb8CX((5mG-T_+ARNbIre*`aLf?7E0)_N5E^_GG+l)=j4aHF2$^ zn>PVrlu!I}bN>0SKL~p1-pzY;untC$$@6cZnkK)vMW`l|1-=uf_MH5)1#_du89Ig zE~elBuE(MBRBu1a0%}4SmMHp}g+cCeQDz_~g(H+EB4V!}-4J9ohbj?if)z*JQCbug7Yn*a^zb0O zA_4)DASkUhnU?lkXb12Rsf4hgT~4`h5@Z@IP0|HRu+s4SYmbEC+a7azP{a?_%Ehkd$-IOoUWl#FVC|EbavhI53p-xKuJ_S&s?bV11(?$3 z8leSaWN3$*2N5&a_R~rg3zM|NBz+ko6i5p8ld2gbIs)*>Uhw~I1pByvuV~U5791~h z*IjFMfYHCkT(Cg(ZPj)h1)#T^qOF`Bru|>gLFaw(@up?>f6PkLK?{)@=FBif3uhkD zeCDFFJ)K|i!CSKyE?9i=;ur6`N!sQ4JZDlAj6{=O@!2)SB3Z7ZRMB%CXYXd?{apx| z#LCNS(`WsdZl64qhKQESyB`WxysUpjp^d*5Ay+wBNd^cG!<0Nwu8~2wIfyN z|9QP(vP!XGI9LAj*8eQq+V#a3zdCnr_0+Q-eR3I0qTcn~I2Bxb@)<3E`t2#He7<*J z__9kLI{UoCE9$Zr}Gs z+scibet-1r|Gjs~P5-*&>c21RTH9vS2aj&8?di)^2feFLJ^YPdI=5W^UxY0-gGgo; zo>cbWA5S6*F8%21haX>k`TzXo=t;F}eq8s!{VVT!;MP&&CcgQ~vK1eQ$Dep1ZAM>M zx^3I{A3gBG-5joc@ylHgJ^C{TVyK8=I5BHs^$XV@VQKxv-ok&k?U@y@9)0H1Tkkvj z-e-1q@92XYK;tQ352lTx370}O^YGfNG(g12iumIC!pFi^Qkb;GT>p}`h1BD?3!W5WKuET~H z@u6_ifK8?;U=BEmOK+OpT2@t1caxcG+=uKMFfvE$OJ=>Qf%8WHMGYpApjQ4iVVsAFBzuK&yf@?E!GV3$dG1G zNCQF`N((4I@>x>4aPmow^CwmO`hPz;xTSe=b@{JnHhh0>b93DM?Shu}q2f)CfBW#Y z$DVlF;LA_8qa;qOn3)JZndz_Gl8*`yeE%XMgOzV}LImjiAS#Z6QQ&pYV(PV+a1k~x z!Nw;s<$O%L0P7zU`##o9C%_bNoRKr{rv^fRhz*N82k~-tJ#rkDfaih)Ydw+_2p(Yv zl}ludL@oO`1t0ipBbqktvzb1M2^KmQBSUg;O2wk69ff!UmTw11L@Ob}Tpr|}wWvRw z%`CNjja(XIS|OdoXTT|K~x6AO4HqT}#E>+=a(nbMxJ{EXjD8d_tp7L8G>; z%qR?$mB)LMs<$Tr3P1#^%FGCIrR8NC28P|d2a@4Pw955tlZ?{RwL1p2W7owSVj<2Z z+p1#~y&T`w(}hqCB4x-pQ^uE_zVL+F1;^d__s3^8+sDssefXhw>T2kwYcBu86U&iG ziu49uHkK;q@Sg4Sr`CP*&DIAWe*S~E{&~#}r(Sf-wCbq%*DdEKhkD=rY~BCf{mAOC zo_uZknDwg%Q6dlt?fWtDhbter{ho`Sy6;0SWCN!jwDg6W@B461&$fMtmop99waxkA z?xMg4n+hMU$#5_ZgGrjuYHUNg#ARcHSB$DYWt zkDmGajTinaUj69zSv|bv=JOW*D{9~Wi9&YS6MtUx*2nFgyOM~NAR5`Uvj4$XR$O`R zk@r8jTowBter)lt=2x|4!ikO{1VT^_d0>{TvILWB#wRy@n|^IILgRSHf6;sxA|Z;F zvepm=AYhn~0pvX>3Bw|XSu(L^Wq>uAlA&P;%|*cwY_Mc#4dh9fWLjFg&_!Q7=J$^y zEdT++U^fF{F&V5qVg=8U6k9|;HWS( zgw|RYnW0z^6JVMkBE`&#G#i=)*tHCBfz1eH1UD_;qvSv$J4U z5CVc}#CBakGx=Kp0DPi>4!n6B_zul5P&1Q1dqxkGVCNvUtwiHYcJdGgjarD_uhH=h z)gHzZPNepqdHZtOv^uqNrxqo@JNvMGTUI}N$31V{zhp40Crz2#zpFhzTqFvD3>4gG z$eug7Y2L)~CP`ul+Ynr69aT1KeC50;li@fJ5Zbd1HFHwK{He`Vu?n46C>_<+)=#je zHP_Fa)RHesutB9`5g8jQAA9pZ@BC@d_~Mgg58rb|^TZYk$E!<>v6IHeYHOn5DzvZG z8WDp}>DW{z0c8Lbg(MzdGrGJD-eBomX*<_o< z%!bH$-oh!>2aT)P+n0OtrRBTZyU#uKuvNRdzI%D?J?CCId3_-@CJ{>1L>YR|XXr{Dc@YD4}1JhUR; zn`7G`21|p8;VEW^G^6p?dgCVi_zET-BL?$SOkmP1xLJ^t45%VJhGl^*I37z0MXcok zD+)!BWOxBXDlnTCSi`i)h(dX~FbGv7I|?fVR-|bpbkA3#3x-v~%$)BPxdfXwLNN#l z0&D4UkzfpNP%FMkee%)Zo}B|6jjsMNxpm!u4wxWGP=d84Ulk~PV?lq%hKR`5scDd_ zn5+mnDQbItQe?vsjeAGQ)v@$f-1{BdL69-B{iZdOgr(8(MS1>i5KLdNEr$kjmZr5^+v>`qEw!=lw(Ni4?bVaVRwc8!h{>(9W96k* zF7Nrr$v;Re4QM7JmPCAj4)i?(hc#iP$Eb7IC^U(c0_Iyp{ z({;z=)=T#|yN97?6LITvPNcUwEOi+mqcE|E@|;czCO8y-#q znvDR-(tt2x6}4q0a`u>r5srVlZjW{gMG;uBJHM@MAhTx;N=H-q5y)vK5+X=&kDO8S ztJ7vzSCr&UoYAPyY%e$;gZvHgAH_5qS4EJ+lkfBPdE5=rr7t+JC zPp-NAHz$6!v-`g5Pbe8($^}9B#3{#*`SRVrEPeH=wjZ88X7L10W!O_}MWED#s8`om zbMt+FcM5Lj#vhk{z4kvpY<=sNljl!PK6meF=lo{zIafY0<&dfiFP-+;`yV+*psL<| z;L(L={o?4G|MroSAPgnY)r+Atgi}!$A75P}g*SG7;FN{4yE28V&TKWKf?Q@2@Q?+F z_W%GO07*naR2>S0MbhSCmSBn*m%=Iu*M%c9CUGv$efvZ_2HR9nkcPk74st-6%m84( z@ZdkmU(??AF|b|)!XO9>rZl{wM$|w>7!^SdXqLBg9{ zq}BattmmW3;ZLiu+RS|kQ-Y!{q-n4rT~+`qD9uu^WX-8bH6{Q0-4Qv*VOB@C*7Obx z4=0LqCX`PdRlfSs3$=+)zUe|R%&ed^q#*x)!Ay#or0?dzN|QF2393knp*<+gKFtmg zDP$6;S;%$Mv1tisGMIcR42g9w63TeeImqln`-c=LV`fMK#DOkDKu8+QVA34fJXU9t zfS;zMG?)p#h=BdJY@`i=_7r?-K>N)I4ixVZ2!KgKyCemqp!5)x%*Xgkx#be#dZdQQ zW6cUqMxz1EXL8?a-t)C6ok1(&%^~VcNOAieUcC}x0#z9kBMsudvIsTR5#G7_=}VL;Fqf?z2#&43;U8E0`|Y3ZeskUT z+f$s5zqM-M*&jMDdUVZQ*S+7iqI=xo^>^IT`mbB2Uv}LbikQRc&=boOsg$mnHv8!> zx=*>_)wLNaX{<(GM=Okf+y4&$@|ZL`0YRccv7(5gs?#lI+p&_qkr+hj?=Gs zp}ZnG`;hr(FFx_&MGHUruBW!P^t6jF=}z+fw=Ejipl`Y6R~KJ(;pgkx8)i2A_Kc(5 zqI=gpCx$2JV~;Y=KfC&{Lj#7&CSB{tKIIK|&OfAKTTkfd-@np4wQfvn6Q|Q7tfwJh z5Gz+evMOpfgR&XZ)M};5x(#L_`Ha20M8H1__~xBm}`EWogHQ z=Mq6k3z-5sKd&eos?a;4iLc{@l?x^&$_C%U;3kBkP~OP?iwN?r&*I*XbL*2QO>h8t zK!(3hY*i;saHe3j-t{?T2udrZ$j^ar98wN6L1}1DD8O?yv*#2HB9f%RCg2lV7}*45 zCe}h4fKbBXj&BY+s#15YY~=pyt~j@Ga?2-Q{P(FP|7|F(Tx*QxNF65!DHzp#Kh@Pl zt^D5c-nQTT<)Vg`sck#g-gWPz!=|xEk1s?Tbk2n~SbHP^A($C1+ad4z^AG)cYwx}x zA#KZ!ly?mnXDs^V_xpxPigdE;m`N4u2NL_YB@wEF)FZBY+5?0?P!lUn5<izGD(Wh`>h&BAB z0FVpA;O;DEgRTMOT!;hR2M&A*8bL$+j@}n9c?vWF4UQ0mtRO%TBdTHLV-||ZL?Ja& zafm@COHE2MYdBfhjTmSW$WP_g@U0u=4pp zG??wk00x=+Q8(qK2Yv(?Qle=zr!&D=xT0xtfZSZhAah@LyYuYdKBJORAHUP1(_0a& zyZxF^5jGL932sR^P~s(m>77xh&In45lv6Urd)~*G<_}jy^w1jYdVA6Ooqd7kx7L0) zBcA1)i;x`zP=PX_{&R|>YPML7=RFl_T6-a$;>2dPWDjsWG(Vo@fcnWuz3~a2b^(Ke*&zrBB z>ZYw(zhnQviYrb%?V)#mNQXy(Oelw~GV0h?Sw8Tq`L(ku)6I2_9i7APFa7+2V~>CL z`=KBDw_sG66q?B2KoJKF?*JCsQ&0rf9-9UcX(K?=AK{689SayluneLi0N3pemh0ls zo~lsx=Ij4v)r>Ra)mI;KdN6Xudv9;6ccypPbwm={lR6y^XG?p&x&0r1i;SCVM5`w) zI4uwf|MRw|f@9~eb;1JG^1xdeaT)Yn!$f^q=&w(`{n~TOsj5^5O!iE{1(v4eQZSqU zjy%Rj%!(=NoM^RV%0$S=6zIOO`l3}OfYXapp3MQzxSLDmk0pZV*bZ3g5> zQGjGpU}o)6&}1pub>S~ygFzD7W5K?GAVMLQ7^%&UK_nOs3lg5kBq0Hag}OJ%ohFstfkoPGarN84LZ{Q1f|pF8D{d9S>-m+g{%Vm!_SaNa@7a?Fd@R3hZ2$Aw#m8F@oZ#bKX{P!)A7DZDfxK>&}9x z@|r8Cy(3?cVP{{r2*(hQL3u1CNT8^YO0fch2Et+P+D|oexnexFzOBb3sbUhguI5-2 zRTg&Jl*w@-4ffDrG6#{$vTXo@Qdu~fb)^+GSx7h0VT1<8itRUEaKy2vT}uLmfxcUA zytRGXkEb1W@JrvXqwz;_&LLrOanG31*>mSM&O7N3N(ISvM@^pj%#)9vc<`~SU)k<8 z%+X3nL&Nv|CF!@@1opRSpanr2%#5PT%JOYLAq6DhXh^{Y~Mx^v9z_WX`zqn(B(QQs1mtmn+H%Q|HEvIU}4I z1Z%}aU0)gV8bJrdYNv$ zSZsPxZ+?cRU&u4A(CZ&0rFqoRC=P)&!Dc8{AcFu8+E*EjT>JpYknFcxQm|GaO=Q9r ztn=_(*d-u^qJ}?KC<*@ow@i&3c@FFt*kMV2S{eNOV$DP#X|wCVAab(^Hlz7W-th{v ziE$^e)7zEMY>&brhdFM3_du4U(NVzug!=uhkF8(!@Qi_EF<(ez(?z3MA(%*{NQ9D! zj5LFeOSz&WE9`LfC>rP<-B@2p5A^0dQt0RzW|n2;5ouVSr-MNofaiH643?Hqq?M-( zMj(KUDGaHFh6uun0*;mzQHa4{4{XA)0m0<&Q%fd>WkM-P;k!ZtAf-53!r>S(L2K4U z2qGcaQ)HN|JwH4Lf&mw`E%)F1?vgjwo8_a;#ID}VC=4v4(i)z;7z6#-`6^6B6VKqt zXxj1t2G@zPqqunyqm;M5K$Rw%7PCVXC~`0g2-1pUl373mHKdm;R@G--zvtw}+RBZ4 z(ziXZ^v{V5NEql|~-v99*EIg^qL2 zY-)&>z5n?p6BR=R_E<;k#P#PKa@?=3*}u1sSjA$oKm6%0cl_-}&l@7Mgxw;@gqI2g zlb0S+v*4JMJNq>i`^dBwEI9J3uf9t4?QUvl*u&kh0)FftG_wFfvTgcub!Z2MB4G#x z)+Udb1pCKBff$ei>@kD_NJ}r5o7d7(Id-CN_QK3X?Fb$e=2}c|BtEnjIQcBxBlm|)-Ib(giC|A&3Z`{xr3#?a6>(q8*n&z$o&LtK^Ph*cH{BtV7;q$6nt+e9)$Bqd9O z-7z*BY3gM>ycPRi!m(XEwhP1CaPS>*bPGoJ($G%w)WSyVf!nWn>dh~=ZP-#>8Sn2K z$cz>Y(^guruxrOxL@Vk#y3^_5RII`zlGW99F~c4nNvB7$5F%L>C)4n>3Rz*-Eky(Y za7ra;0zz8YkYNZDnh;8|N3c!U!K{@C#8zkm8IT4L=p#~y+K$9HJ>?=s4R${U%R-UUtdyB@^q;SyInhL-`OUMp8exeBwWETXW{3=0|_C@`4MSKKsXo zt+iDs4*cn#x1Dm~X^-80&Pg|2LD3vCMb`8`*G;|g)I~R+-~Q5Xmp%8Fuf2QglImP$ z#)8VfeP_)XCry0*PZ!UbGPC3WVc4bN`HSY3a!TovG>|J6LXpti_L;+(BAa1SK7?Qr zQI$RS%q6fYyh0|pvlj}*nyPUfy*+FT?RfA&hU9>D$BLnjJLMR{5E7D#f?$xcpgm|1 z16l?Cp8!x{NCv>+nqtA)+LQY5^Dk^+z;z|4uAyPifnEK_yu{?$JXQdFSTUyfa7jG( z_GhLD3CTjL#)b)p5AWOd<$kK02NC8{NlHoV2O${}29%cUnzk6u<}W#W_57vFQP+Mn z!-o$Kx3ryl`<=h8stH?$r6C|}_zw9Rnn){R0bdh?T?dvxt4FPQgcMvKT0?18VCBR2 zppI|y{=I=y!CyUO2QcwGT{~6m{yQ>Ro^>50W5;7;*J1wGFuV;%KS8ttEXuqW<$^Sr z!2wyZti`bMK>-s+YrmWqAgz!WNKA!aV$!TMf)r4hup${6o{gqO@Jp9GO7VE(ZkpBM68*?698#kFjai+WrGSxi&Io>fOJ(N2Ujgg~I%{ z>Ep&XAL;4MWD9m>)67{Xban4vw){jPtp5J7W8FuSiOOVUMQLpKwAH7M4W-;dmX#BW z)OK}t)YQ~ODx3Y1lT|(hks(15up~`j3HHb&5qR&R0I-lu222wo1R|0$*zz!lb+7{? zW(I*cC{Q-YG{l5vRF5O&9oMyt;4Z+@AZe5G!3yC7=_2+%hH+Cd=>&NFKo+&rG3#o| z5Apt&z+*V!3WVEf-+CV2j95KSI}bXJ?f1ZBOumraBD^9XgFcJ^DFtBy3ar424XfxV zc~LF^c$Y~$zRqr z*Cs2fYQes!u1JsIz=6I{EG&csU`Y`Ui>(K`_xBHzu*nFcRG@fr#EU-q(x))(P&lfE zl#*gGqfjawPCH$hydAD5D1!olJ&?%*$;l%IeAb?C+om99c3mP9BIx`$E>=l^g&|2m z`y!+gGhhC)c*g^;KmG87$q==)w(Q#V{vZDPe!KmOp_&#-kCHS1h~%t;gWI{E6s?)P`naX%K^02XaF=Vht%W!_^m^d0NRx$VkNV z3(`REk)yNcFP%DfnrkcDHkGGgmZy)v+anB_4)1xGj7gaNH5%TCzK=wt62Y+{D9}g1 zf`kFhfwEBkLnbu+`(Lby9G6mKaC|Dah7w4ZF@da@8Qo*pc9=3gJO#so71d@Gu_T#c zgcGpiY{d|Yb0mRK40eKJwP3}O8k%|;w_ZstXQKIBv|PrmSJKo=xnWh0Ogy%4?CS5l zUrH>>DeLpEwk*HkGFj6)Jem=9%t@#9XhwROQ!l={XEb;4P?v4Td$Rc8z|jd4n--pR zUgyz6ojqMpenBKQZ{0LyZd{_*#})+Vi*MBHZM)mPqq>CJbK`E}Z?Co{~X zJ>Ln=T+)KIPts(POafAaq|nNM1f<0p&`g@yG)XIlfF_}p&+tLQEup%7sKBnv>%Ka) zF zdc_Ki9x);lG!(l&2xOY@7{1Rj(^qOrP2I%lHL1MzecuQybrPPZj~(o4TWS`I4wXE% z3?dbvcZgUk2f=J(8R#x(a$wu=J!U2ZubuzjJ0B9lVC@0|rX^H>7B$%S!9|QagYY32 z4}SpYD!8%_ycaLplBKA8k!RylZztuR3{JPO&FgtBWnNov%Z;qoH?>%=xG0e zf#=gH7xBjL-@kcP^&sN)L;3!#AAW*(?an=fP*D^LkUk(FEV97x8JZQ5w7?o#lX8lF^!Igsi7Uyui)Me+WQ>pr}MNcIhCRVPeE#)elZf0vHK+++J=gH zOu864ihU2mBuu!J^EnEKQ85weeqznOhfEn9$x!j51qH<-3sWf+jedpETyCE9G(fQhO-U~6X`LkYj*@Fm! ziG$(_W`IcxCU}YkCX;x+x_*!cu+c?j*7^R%0==P{Bdk3W@1`+_+fnwTX7 z1?-C;@EbTfgoM@_hJ^1yXlN6xn9AP<2++sjf`$PmxFxb;EH&+at~#2Z*EX&uZjOwV zlu|KMD@mSjnz|TCBuif21S<`v=rDv~DQUQ_>xX0E^k~Y0sI06+HdAQOIiyT26-|Rz zWN9H8WhXzswM{g&9Hr{6-ZYP7%!oC4yuDzWt!tZyL$!W(BsVym4vky1W>tMLJvy4s z6&zm`Vj(-*)7Lh+(y|A`zVFRDX^^5bLY`=u+E>gsCKA2oh-<}_Vf2TF?aG26R@%sp zxo*}(I0{w>(t%zu)LYC1p;#EKnU3$KpcMe7Ala$P{%A-b;4mR$0r=Zo~%-9K3V*`C9nz0$YiwT=@{ul(`3^M88U#L}3P z9qIeo_a~cS^I*rwlk2>HzTF?MtXj0_q+1`^vwiEpo2M2A5;e{U-gtBG6)R7E^!?%A zzmQ@-kCCkycl!Ulmj2CE%_S#!){ovjYf1R+Ln^I=U040?p+bNE;5p}?sjmx7 zC+VV8QYa9FVkrrNeN9pZNj13nV2`GRHpdoY)Co ztG+r;+LZ7Zfl-gkc06Xy%z=X_i0*4Jh?yithe;$jT4x>pSEPNdxA@HZ{`D&T;t{z5 z&6o4B=Y_C!?P3(u97KRA=mH}^v#-kgJZ2q8`mBh-0RkB1k(NRDw}n${Xu;ZpVKHg! zet~PNAARVKv!>S+7)syyq$?A3;e81e1hzLCj>7ef3Zz3|5*<1A)Az6(ooR zBnPx#G9+s)AhZ-hKubx!&xS;akJn++sEwZz_Qp2#rhdKd z$XD)Jy8l(8BG;`zAyuyWgJNNnFBu%{xd^NXk|}_Ki-21AZ{|OrzROH6!RKpG;A0wNGVxS->2^s!?r{`9!+Ik&v&XrhG8l#jM0&t4Y$6&ek3xkKds}1W3@HWqhoMgO1S_4AOJ~3 zK~$kxY!vcd#LVCGy_KgeYu&P8JF5tSLaHZv?G9Nw32~V_NukFct-)k7$hJ+cJ zf2t{r%*F>{N2vA8h|U*tc}SrO z5CWlEj>M7e!NHd>^-Qikg%7@k(jI7y2*a)bTL@c-RcmQONhHFMRZ)@mmDc2wVX-$% z$!7HJV|N7ELmZz(eu8xd6jVAA6G7N0jf!xSmIewvkVOg`93BrR3u$TCzSgD-QeY|I zYYC~e2dS9^41*+V3K@!Z`JOBVghW86Vy%5mB*8)gYzbyXWW$WXcj5XF5@rM@!OemN z3$W5cNG%uuTM6+6T(qRQ zHW`v3)9M;Y`K%T#S-gD3NkH=av*-PDdx})>6a|l&f(~lT@b8)B{{?Iz01u+>)QLb zzw_qBeDFyqO%1ELI235wLDrCj)(Q|BUVDxi@q6kUSMK~H>36+!CPQuB-pmMCx2w~_jxJV&` znV4BAhalN4z)B!e1$F=*%!mWAFbZ8reTfOD!>r!FN8!-(u91I_}&U&h5d`d`+w}Ukati{Cp<&MeS<;f~9?RJ}WD})Q?BziW&HpwLCj1-!xn>setOuUM5t6SfA-+PxicHZgs*Gq5z%N-k%X=!X@o*~ z@BR(hCqL<783r@77DjoYM?_2k7u4iHehc3GPy$jzGixxB7C})Dd=HX927Dr6a9-1B z-+612KmYD3&*$|U1|J{ox$&IVDqD^g-H0s=NlwWh&Qfh6blvK4@4cVbvu>dMk24u) zSb@SISVAiX%JUNi<9+a9>T=m4%j4dPGAjhESdx$yNb-S4QP-kdFT~MJ_VCB1T$>jW zo_RjycT$x*p;C+v9nenRu1$<_Rf!@Pw+cQ3T4+ayBa}HN^gvBrH91E)JDl}Bu4^so zI2z_6Tn**H04WKRc<-xGTh!RaQhq>56IR@(#&o*GhC#J4#3EE%iHHYH(TLqxsdCw& z;Y@!dk|3)o<5Y0nN?y91~sCw9qP!hD^(K zJtz%fuu>325U`13A+X7gM=r6_)$u{&(}BHbnDutw#nzt zYW&e(KR$C&-EVH5cgJ&uAFiCacmLrpOPjA)HK{%nd1Z5Fp6tG^;_@kBADG;fc>1B6 zCe+!IqR^)u+k%#r7|la? zU|(3amdxw}0=7-Q1|UpBn-XjrWEepi2w(@RX%Ls`0)pWCQV;_yfN&KbdaJFzyMAgo zUhEql$m|)RoY(0Yry(*4g^UJ6d1NMdc&F`d8Q);rV|}uePH}Y9AI|r>7`K!~zvnoH zT_G$f28xhlE?I~s*~zZ^$A)J}vak?~Li!LEvBOZL1jM(Wu-O2l<*jWS^KaJ_Lxe{#UkJ#thpqGH}>P(X8io>rQdvL+Y|S9axOuk zj!Tv|jGs`O_mt!5nn&{_&5t9eC#z?pD-(70#SXe-$mm}l(O2iDRYdEeNb6r*hgNp+_Y`m$fR7kuYLa79fR+< zRclx?SR)eW&UfNfI*~nC+_SN^E@4EXJ)PU;%v;(UoqXWHC|4HYx$r$wDw>SWuG4Ps zCw5_^Qj6iPZ1v=})~5EYUGM4oH9~;dgA~-Wsd>EV9(l#<+9-q>GVJJZbl!>Qe7xt2 zQQZj36yT7M5EgT=&y!3{@d&b=ka3FC!Yx5c5Q6J}@L7@66pF(s@%|^drU^5zRa-wh z^l5L$>}k2ejFoNE2C~lWzkOo)1@oS}U}c5w${*RpjTJQRd{a0{av$5=b^kN(Tz|{z z`e?jAQ>siN5tbI)o8RyH{EB`OtPR6)W%K03iUm_uq4Z?kRuU$Finy_I>5}UDN!l$* zD-P(G9oCs*OOn05u;|-xLc|Ue2+WB}9NVFCJH+&J^~gauyB4orx$mV%$A)VWn?;H_ z00wXwnGMHh0H$PLLHi)j62dT;gl4dZz=L>+uQGDM!2#I^)N#0m)orQwKJ;MO5X9OBG;2amLD`UD z(gxC5O+YL}whT7>3>AE{Wke^KHA4ttAUGaCQZTf~aL1;%;>6jtlgCBs8!C?Uj8w&N z>p2TA{`YW`EG!Gjg(!_ef^a+n7(faE$Y7ccoIHZO5*tRjR!B++OBaUV7clc040ZFN z7pQfGs+_8zP)dV`>f<`p`{CU7iRYeudNdmQWb=+E9((%K=`*s(A8}H!B4k+H-xZ2e zsq@XL6{%}(ysml5jLz-@fBoB|G`L~Ol$9TM9YOUhxCIo3g(%j9ipik^XI**PqGiiH z&wF|Oho67>@yX{*Iof9xnV=L28=#uFId=Gy1#L}doO)e6UirmmpFi=;OA979h{=sx z278cbgaBoZR3ufbaJ1U*o_q0`b#)C|(WWiidpkZ~bHbWuHty!eHb4jw@K1tWtN@r2 zHq1D?7DEvUKno!?j+0SHaioGB2m7BzWg|_yl827r!1FmicTibe7>bYCS$_)EEI_=a z21t5GdJGfOui`>gb?SMyu;hk|7JcWM`8|d3L+^ZW&rPf5ESg^5V5i5t{GijF%9w^p zM)cm-55BP}_xh8cJ^nwZ{^I+mJ^bcp9%HzFV0fgF!ftUaQ`;EL6)2a>fwWuVp^Wrp zrhg#CWLH(1SyVb4)*sQ18-@>}I)`wS3VGH;RJ6H(h#6ucwi4*uYSA$nHd{J=RLQx0&kfC8d((pR z=RN+;)0lMwJ0*gKVbjMIWXu_kvgmCZLAr=5TO+TY*z*4V@vZJT9)O*v(( z!3MEnXfQ(&h^3(oCTOjpiH$&XMVW798nA4wOalB;kqi6gE|}E$)!SFBSu=ats$|o+ zuMg~h^5Og5|LX97KAgAPP|T7kDSNnSQl;Mb>~&|KaK%kGRZX1Je{ARf`OZxr9{J2_ zsdRU2tCTkz4mZ*M7yk3gzP7Wvztw@wO~`N!SMYnvbJLIADL1(C|T$r3JSb=;T@gqotG2pYgb5pd>TYrYY-5G5s1Jng3dK5SZOvb03-x} zvV0%_GeJek!<$e$jvE*1V;vw<7jsC+($TL@8sD(?va4jIqEH+=d(COmFMY9P$F#PV zBL~OGtPsU9?K@#P+E$VO#tk<#&Rj53$hFT|c;~O0et+kmrdPY0y9-5Mvk~T0S0W;7 z3y04>lt&q4i50dRTwH^+r4V?SanU^#*XakuXerg-r($Mg_;Wc z?)%=j@yym!R;`Y<7$-DDQ-eNpv7$0IEm7KC>$lWKzS_fn(J_F0toohZhwBdw`5xum zolz@(bg%~#PaYjjY}m42i%y%uoxPd<(cEk6w=Q2)XOd{I8vf|BKb?N%f@@AWA?u4j zJ@-kfbKvylv)8}B3#H<9S1eu9HutTM!Y^z&%;VP>qX&O^b7ZoJrg-ol9&Tz*wPJTW_vs~flEj(h)p@mc2% zi?8X4?PkdI4O3P$n3nwEeJ@3NbN}`CTdw=LaY zd;9S9zsXOT99=rAqP@|ow#@;bg`o9!oPTU!_=Fh~YNL_<)R`<6kx5SOxzW<#)gJU`~>MOV88HPibG=(cfoED1aL|x~w7g}l4VRvG z&c}NXg@svAu0_t-=bZfZM?1WdhP1(w$YL)WLi*?b_XmAr>d29UU?Vq@T{Lgz$De=I zH=H4(4nDJ?0iQ>XU4GH3IkV?~vT3gs4(0RN#k0pPm_KdTp{!{pSr^EVS_l#bE3lOC zeSld@%6lw`nV=OL;@_JpVI^7l*!w7I8!+Q~O7-!9M=2T;ODku zpAS6t!_zv3^>sgcDlu#B4VNx%qdq5f+M_#5FYF$<=dryz*LNWnI#L_nIZ}G%o|~BH z*1v6^FkwP-Q}Yx8swxhAHTctCt-1b!1$&3|?f-b|g4v!)*q*6)=EKd^?%vel!?8qt zek7Aog2GhP^rPQB?s;Cx)0H*Jtm5?cV+-e8qrp2zYBA%~U;p-6(+j7vWA`jrwzaeK zCl@Z8dBw}o$?DGEuHCe0{{xqw+57v>FJ9=JRlD)l>;Cko^6LCFc5JxkoxfbOY2Tru<4c`ZYH-b@(O>`muZ}ULm>pex(dGZ+S%0|mmrGV& z{^@(&sBZ%Vxg;%fhO_DR@0>g5oNo>G56?Vl>Ro>r_uX&aJm2a~*65;>HUw!MFzm{i zR3d{t1!&UD$ZNI?CM^sJ5+DguPz)giLz5;}wtxm)Ple&FoY)5&mihA81?gGj-TP0 zp^TF;6S0QcT6TWO%~?3rFGiPb zegB)M)L(VV^xr&q*y~q1Qm)V-5;|~n2Wec*kOmR4(kzHT2pc1*;s?Ej51#McuoC}! z_nE5X`dUfGr0QgAZDp?D^f@^O)hDb^268w4^aCzbv70-8O?ct7WEo3HB6} z1~ChAa|NCEQ-a2|&K^)Zj`s9tGwCIBXZU0nvtzxzgNRj-^4SQn56g2R;fAJ(lRA!d zc``&Q*Hm9OQgpxS-j}am4Lb@a&tA$&PAK?$#!s0mw(Tq!R=THm(e$Rnec^*gGku`~ z2@hJa&xX{j4d0BKp`ue#B`2G(sG_NTI6s#5Gi-z)B&0!BtaHd?v$nalt@PmrGZHG~ zN9yb68Eoz9*pjPm6;=b3ZvJ*4`Dh#1UsaS}*?YZIAw;${ijP`F#ESD`)>;MdPSDAs-39nm_oh zZ@f>*IA%71sdHap)h+*9nGBVRJaoh*+n@RE_i`D5SY+#0xy4t#TveACNK3W(ZA@?R zffZBhdp8&JOtD!DU5%=iDSpY!7c|!`=qrVrCO8#VI9u|i7R@W0mMxkIri?a3q(yN! zmCE-F4bPo5chAO-QP-=VICJB^!S+k3zx�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%0AXiuNkPdm|{deKtps66aRZ&&~}acdx5DKch0 zcy#)8zy8|4T=?m}{g1dJf8Pf`e#?W#R?|U|tBt|b?JiZ4s;44OfIM$!#ooR5u3Rx` zIBU&ye9|<{RmYDUX$)6x{n6IzUi0#oTs^fkJ1DZH*S+?NXFvbNKe}Tfy~OkeE-(6N zdOBh3@~+a;zO<9ih2=aEJ?UAV(Fl<^Nb$vU(~0bdXE3qf=NH~!!!T4pV3Y;`0DHe4zTKw(cjJ-u>qvx%2k#Kj+!!UGuWHf9<M8*+lkHilRC^Pi`MB5e)|2K_F10vCq7Mw{CV;JFWN8Kzqp-P zKdaShZ?KRiNNf~U?ZUDBpZ>~s;r!6>(ONTeEs}Y3bO9KmJHu&|`bs`(_>*9@14)D?L=bWJR9m zd8JbM-~Af?zutZ^{(sT_wOUw_y4|j4v5844aeJxT?H_&ibE-%8J~A>+gYNeE#omgM zhP6bd(&;%7sZ=Ua8XY>kl=qin?zg)8YgM~;!>YNtxm6p-`U8gOmUEtU^!SmH$rZ!N zeY+mITQ?s)xHrlsS9()0Gm#;MG3J?MXZ{awB~Jer?HBD|sqNjj=kX&4XBPVV4<9VD zZeo~-I<4a#ChL;-S~yLj)W%V})#Zq-OA9C>IE14?|$_EAGBYL|6jC!m3AUg zrHWqW4<4WEcUuq#w*A~ouA+rVo@K?LI~er(X`@Dl7Zw(}tv+EeJW{jP_IkZEsX5{H z(n3eqUl5wQ=z9OkyKPeze)R@a*$VJh6F0V{$ZoCPknB!`uH0 Xs)Ovs^Mr8l00000NkvXXu0mjfN2Mxt literal 0 HcmV?d00001 diff --git a/bsp/ht32/ht32f12366/project.uvoptx b/bsp/ht32/ht32f12366/project.uvoptx new file mode 100644 index 0000000000..b6ec60944b --- /dev/null +++ b/bsp/ht32/ht32f12366/project.uvoptx @@ -0,0 +1,1219 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + rt-thread + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\build\keil\List\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 2 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + CMSIS_AGDI + -X"Any" -UAny -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN2 -FF0HT32F.FLM -FS00 -FL0100000 -FP0($$Device:HT32F12366$ARM\Flash\HT32F.FLM) -FF1HT32F_OPT.FLM -FS11FF00000 -FL11000 -FP1($$Device:HT32F12366$ARM\Flash\HT32F_OPT.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F12366$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F12366$ARM\Flash\HT32F_OPT.FLM)) + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + Applications + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + applications\main.c + main.c + 0 + 0 + + + + + Compiler + 0 + 0 + 0 + 0 + + 2 + 2 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c + syscall_mem.c + 0 + 0 + + + 2 + 3 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\armlibc\syscalls.c + syscalls.c + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cctype.c + cctype.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cstdlib.c + cstdlib.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cstring.c + cstring.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\ctime.c + ctime.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cunistd.c + cunistd.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cwchar.c + cwchar.c + 0 + 0 + + + + + DeviceDrivers + 0 + 0 + 0 + 0 + + 3 + 10 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\core\device.c + device.c + 0 + 0 + + + 3 + 11 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\i2c\i2c-bit-ops.c + i2c-bit-ops.c + 0 + 0 + + + 3 + 12 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\i2c\i2c_core.c + i2c_core.c + 0 + 0 + + + 3 + 13 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\i2c\i2c_dev.c + i2c_dev.c + 0 + 0 + + + 3 + 14 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\completion.c + completion.c + 0 + 0 + + + 3 + 15 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\condvar.c + condvar.c + 0 + 0 + + + 3 + 16 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\dataqueue.c + dataqueue.c + 0 + 0 + + + 3 + 17 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\pipe.c + pipe.c + 0 + 0 + + + 3 + 18 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\ringblk_buf.c + ringblk_buf.c + 0 + 0 + + + 3 + 19 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\ringbuffer.c + ringbuffer.c + 0 + 0 + + + 3 + 20 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\waitqueue.c + waitqueue.c + 0 + 0 + + + 3 + 21 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\workqueue.c + workqueue.c + 0 + 0 + + + 3 + 22 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\pin\pin.c + pin.c + 0 + 0 + + + 3 + 23 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\serial\serial.c + serial.c + 0 + 0 + + + 3 + 24 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\spi\spi_core.c + spi_core.c + 0 + 0 + + + 3 + 25 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\spi\spi_dev.c + spi_dev.c + 0 + 0 + + + + + Drivers + 1 + 0 + 0 + 0 + + 4 + 26 + 1 + 0 + 0 + 0 + board\src\board.c + board.c + 0 + 0 + + + 4 + 27 + 1 + 0 + 0 + 0 + board\src\ht32_msp.c + ht32_msp.c + 0 + 0 + + + 4 + 28 + 2 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\Device\Holtek\HT32F1xxxx\Source\ARM\startup_ht32f1xxxx_01.s + startup_ht32f1xxxx_01.s + 0 + 0 + + + 4 + 29 + 1 + 0 + 0 + 0 + ..\libraries\ht32_drivers\drv_common.c + drv_common.c + 0 + 0 + + + 4 + 30 + 1 + 0 + 0 + 0 + ..\libraries\ht32_drivers\drv_gpio.c + drv_gpio.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\libraries\ht32_drivers\drv_usart.c + drv_usart.c + 0 + 0 + + + + + Finsh + 0 + 0 + 0 + 0 + + 5 + 32 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\shell.c + shell.c + 0 + 0 + + + 5 + 33 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\msh.c + msh.c + 0 + 0 + + + 5 + 34 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\msh_parse.c + msh_parse.c + 0 + 0 + + + 5 + 35 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\cmd.c + cmd.c + 0 + 0 + + + + + Kernel + 0 + 0 + 0 + 0 + + 6 + 36 + 1 + 0 + 0 + 0 + ..\..\..\src\clock.c + clock.c + 0 + 0 + + + 6 + 37 + 1 + 0 + 0 + 0 + ..\..\..\src\components.c + components.c + 0 + 0 + + + 6 + 38 + 1 + 0 + 0 + 0 + ..\..\..\src\idle.c + idle.c + 0 + 0 + + + 6 + 39 + 1 + 0 + 0 + 0 + ..\..\..\src\ipc.c + ipc.c + 0 + 0 + + + 6 + 40 + 1 + 0 + 0 + 0 + ..\..\..\src\irq.c + irq.c + 0 + 0 + + + 6 + 41 + 1 + 0 + 0 + 0 + ..\..\..\src\klibc\kstdio.c + kstdio.c + 0 + 0 + + + 6 + 42 + 1 + 0 + 0 + 0 + ..\..\..\src\klibc\kstring.c + kstring.c + 0 + 0 + + + 6 + 43 + 1 + 0 + 0 + 0 + ..\..\..\src\kservice.c + kservice.c + 0 + 0 + + + 6 + 44 + 1 + 0 + 0 + 0 + ..\..\..\src\mem.c + mem.c + 0 + 0 + + + 6 + 45 + 1 + 0 + 0 + 0 + ..\..\..\src\memheap.c + memheap.c + 0 + 0 + + + 6 + 46 + 1 + 0 + 0 + 0 + ..\..\..\src\mempool.c + mempool.c + 0 + 0 + + + 6 + 47 + 1 + 0 + 0 + 0 + ..\..\..\src\object.c + object.c + 0 + 0 + + + 6 + 48 + 1 + 0 + 0 + 0 + ..\..\..\src\scheduler_comm.c + scheduler_comm.c + 0 + 0 + + + 6 + 49 + 1 + 0 + 0 + 0 + ..\..\..\src\scheduler_up.c + scheduler_up.c + 0 + 0 + + + 6 + 50 + 1 + 0 + 0 + 0 + ..\..\..\src\thread.c + thread.c + 0 + 0 + + + 6 + 51 + 1 + 0 + 0 + 0 + ..\..\..\src\timer.c + timer.c + 0 + 0 + + + + + libcpu + 0 + 0 + 0 + 0 + + 7 + 52 + 1 + 0 + 0 + 0 + ..\..\..\libcpu\arm\common\atomic_arm.c + atomic_arm.c + 0 + 0 + + + 7 + 53 + 1 + 0 + 0 + 0 + ..\..\..\libcpu\arm\common\div0.c + div0.c + 0 + 0 + + + 7 + 54 + 1 + 0 + 0 + 0 + ..\..\..\libcpu\arm\common\showmem.c + showmem.c + 0 + 0 + + + 7 + 55 + 2 + 0 + 0 + 0 + ..\..\..\libcpu\arm\cortex-m3\context_rvds.S + context_rvds.S + 0 + 0 + + + 7 + 56 + 1 + 0 + 0 + 0 + ..\..\..\libcpu\arm\cortex-m3\cpuport.c + cpuport.c + 0 + 0 + + + + + Libraries + 0 + 0 + 0 + 0 + + 8 + 57 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_wdt.c + ht32f1xxxx_wdt.c + 0 + 0 + + + 8 + 58 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_sci.c + ht32f1xxxx_sci.c + 0 + 0 + + + 8 + 59 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_rstcu.c + ht32f1xxxx_rstcu.c + 0 + 0 + + + 8 + 60 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_usbd.c + ht32f1xxxx_usbd.c + 0 + 0 + + + 8 + 61 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_tm.c + ht32f1xxxx_tm.c + 0 + 0 + + + 8 + 62 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_ckcu.c + ht32f1xxxx_ckcu.c + 0 + 0 + + + 8 + 63 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_usart.c + ht32f1xxxx_usart.c + 0 + 0 + + + 8 + 64 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_aes.c + ht32f1xxxx_aes.c + 0 + 0 + + + 8 + 65 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_flash.c + ht32f1xxxx_flash.c + 0 + 0 + + + 8 + 66 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_gpio.c + ht32f1xxxx_gpio.c + 0 + 0 + + + 8 + 67 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32_cm3_misc.c + ht32_cm3_misc.c + 0 + 0 + + + 8 + 68 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_crc.c + ht32f1xxxx_crc.c + 0 + 0 + + + 8 + 69 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_sdio.c + ht32f1xxxx_sdio.c + 0 + 0 + + + 8 + 70 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_ebi.c + ht32f1xxxx_ebi.c + 0 + 0 + + + 8 + 71 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_cmp.c + ht32f1xxxx_cmp.c + 0 + 0 + + + 8 + 72 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_i2c.c + ht32f1xxxx_i2c.c + 0 + 0 + + + 8 + 73 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_adc.c + ht32f1xxxx_adc.c + 0 + 0 + + + 8 + 74 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_pwrcu.c + ht32f1xxxx_pwrcu.c + 0 + 0 + + + 8 + 75 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_pdma.c + ht32f1xxxx_pdma.c + 0 + 0 + + + 8 + 76 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\Device\Holtek\HT32F1xxxx\Source\system_ht32f1xxxx_02.c + system_ht32f1xxxx_02.c + 0 + 0 + + + 8 + 77 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_mctm.c + ht32f1xxxx_mctm.c + 0 + 0 + + + 8 + 78 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_spi.c + ht32f1xxxx_spi.c + 0 + 0 + + + 8 + 79 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_bftm.c + ht32f1xxxx_bftm.c + 0 + 0 + + + 8 + 80 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_i2s.c + ht32f1xxxx_i2s.c + 0 + 0 + + + 8 + 81 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_exti.c + ht32f1xxxx_exti.c + 0 + 0 + + + 8 + 82 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_rtc.c + ht32f1xxxx_rtc.c + 0 + 0 + + + +
diff --git a/bsp/ht32/ht32f12366/project.uvprojx b/bsp/ht32/ht32f12366/project.uvprojx new file mode 100644 index 0000000000..0e9ceaea2f --- /dev/null +++ b/bsp/ht32/ht32f12366/project.uvprojx @@ -0,0 +1,2439 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + rt-thread + 0x4 + ARM-ADS + 5060422::V5.06 update 4 (build 422)::ARMCC + + + HT32F12366 + Holtek + Holtek.HT32_DFP.1.0.19 + http://mcu.holtek.com.tw/pack + IRAM(0x20000000,0x20000) IROM(0x00000000,0x3FC00) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F12366$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F12366$ARM\Flash\HT32F_OPT.FLM)) + 0 + $$Device:HT32F12366$ARM\INC\Holtek\HT32F1xxxx\ht32f1xxxx_01.h + + + + + + + + + + $$Device:HT32F12366$SVD\HT32F12365_66.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\build\keil\Obj\ + rt-thread + 1 + 0 + 0 + 1 + 1 + .\build\keil\List\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DCM.DLL + -pCM3 + SARMCM3.DLL + + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 1 + 0x0 + 0x3fc00 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x3fc00 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + __STDC_LIMIT_MACROS, RT_USING_ARMLIBC, RT_USING_LIBC, USE_HT32F12366_SK, USE_HT32F12365_66, USE_MEM_HT32F12366, __CLK_TCK=RT_TICK_PER_SECOND, USE_HT32_DRIVER, __RTTHREAD__ + + ..\libraries\HT32_STD_1xxxx_FWLib\library\Device\Holtek\HT32F1xxxx\Include;..\..\..\include;..\libraries\ht32_drivers;..\..\..\components\drivers\include;.;..\libraries\HT32_STD_1xxxx_FWLib\library\CMSIS\Include;..\..\..\components\drivers\include;..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\inc;..\..\..\components\libc\compilers\common\extension;applications;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\epoll;..\..\..\components\libc\compilers\common\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\libc\posix\io\poll;..\..\..\components\finsh;..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m3;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board\inc;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\spi;..\..\..\libcpu\arm\common + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + USE_HT32_CHIP=2 + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + .\board\linker_scripts\link.sct + + + + + + + + + + + Applications + + + main.c + 1 + applications\main.c + + + + + Compiler + + + syscall_mem.c + 1 + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c + + + syscalls.c + 1 + ..\..\..\components\libc\compilers\armlibc\syscalls.c + + + cctype.c + 1 + ..\..\..\components\libc\compilers\common\cctype.c + + + cstdlib.c + 1 + ..\..\..\components\libc\compilers\common\cstdlib.c + + + cstring.c + 1 + ..\..\..\components\libc\compilers\common\cstring.c + + + ctime.c + 1 + ..\..\..\components\libc\compilers\common\ctime.c + + + cunistd.c + 1 + ..\..\..\components\libc\compilers\common\cunistd.c + + + cwchar.c + 1 + ..\..\..\components\libc\compilers\common\cwchar.c + + + + + DeviceDrivers + + + device.c + 1 + ..\..\..\components\drivers\core\device.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + i2c-bit-ops.c + 1 + ..\..\..\components\drivers\i2c\i2c-bit-ops.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + i2c_core.c + 1 + ..\..\..\components\drivers\i2c\i2c_core.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + i2c_dev.c + 1 + ..\..\..\components\drivers\i2c\i2c_dev.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + completion.c + 1 + ..\..\..\components\drivers\ipc\completion.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + condvar.c + 1 + ..\..\..\components\drivers\ipc\condvar.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + dataqueue.c + 1 + ..\..\..\components\drivers\ipc\dataqueue.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + pipe.c + 1 + ..\..\..\components\drivers\ipc\pipe.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + ringblk_buf.c + 1 + ..\..\..\components\drivers\ipc\ringblk_buf.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + ringbuffer.c + 1 + ..\..\..\components\drivers\ipc\ringbuffer.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + waitqueue.c + 1 + ..\..\..\components\drivers\ipc\waitqueue.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + workqueue.c + 1 + ..\..\..\components\drivers\ipc\workqueue.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + pin.c + 1 + ..\..\..\components\drivers\pin\pin.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + serial.c + 1 + ..\..\..\components\drivers\serial\serial.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + spi_core.c + 1 + ..\..\..\components\drivers\spi\spi_core.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + spi_dev.c + 1 + ..\..\..\components\drivers\spi\spi_dev.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + + + Drivers + + + board.c + 1 + board\src\board.c + + + ht32_msp.c + 1 + board\src\ht32_msp.c + + + startup_ht32f1xxxx_01.s + 2 + ..\libraries\HT32_STD_1xxxx_FWLib\library\Device\Holtek\HT32F1xxxx\Source\ARM\startup_ht32f1xxxx_01.s + + + drv_common.c + 1 + ..\libraries\ht32_drivers\drv_common.c + + + drv_gpio.c + 1 + ..\libraries\ht32_drivers\drv_gpio.c + + + drv_usart.c + 1 + ..\libraries\ht32_drivers\drv_usart.c + + + + + Finsh + + + shell.c + 1 + ..\..\..\components\finsh\shell.c + + + msh.c + 1 + ..\..\..\components\finsh\msh.c + + + msh_parse.c + 1 + ..\..\..\components\finsh\msh_parse.c + + + cmd.c + 1 + ..\..\..\components\finsh\cmd.c + + + + + Kernel + + + clock.c + 1 + ..\..\..\src\clock.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + components.c + 1 + ..\..\..\src\components.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + idle.c + 1 + ..\..\..\src\idle.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + ipc.c + 1 + ..\..\..\src\ipc.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + irq.c + 1 + ..\..\..\src\irq.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + kstdio.c + 1 + ..\..\..\src\klibc\kstdio.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + kstring.c + 1 + ..\..\..\src\klibc\kstring.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + kservice.c + 1 + ..\..\..\src\kservice.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + mem.c + 1 + ..\..\..\src\mem.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + memheap.c + 1 + ..\..\..\src\memheap.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + mempool.c + 1 + ..\..\..\src\mempool.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + object.c + 1 + ..\..\..\src\object.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + scheduler_comm.c + 1 + ..\..\..\src\scheduler_comm.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + scheduler_up.c + 1 + ..\..\..\src\scheduler_up.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + thread.c + 1 + ..\..\..\src\thread.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + timer.c + 1 + ..\..\..\src\timer.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + + + libcpu + + + atomic_arm.c + 1 + ..\..\..\libcpu\arm\common\atomic_arm.c + + + div0.c + 1 + ..\..\..\libcpu\arm\common\div0.c + + + showmem.c + 1 + ..\..\..\libcpu\arm\common\showmem.c + + + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m3\context_rvds.S + + + cpuport.c + 1 + ..\..\..\libcpu\arm\cortex-m3\cpuport.c + + + + + Libraries + + + ht32f1xxxx_wdt.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_wdt.c + + + ht32f1xxxx_sci.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_sci.c + + + ht32f1xxxx_rstcu.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_rstcu.c + + + ht32f1xxxx_usbd.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_usbd.c + + + ht32f1xxxx_tm.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_tm.c + + + ht32f1xxxx_ckcu.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_ckcu.c + + + ht32f1xxxx_usart.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_usart.c + + + ht32f1xxxx_aes.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_aes.c + + + ht32f1xxxx_flash.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_flash.c + + + ht32f1xxxx_gpio.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_gpio.c + + + ht32_cm3_misc.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32_cm3_misc.c + + + ht32f1xxxx_crc.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_crc.c + + + ht32f1xxxx_sdio.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_sdio.c + + + ht32f1xxxx_ebi.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_ebi.c + + + ht32f1xxxx_cmp.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_cmp.c + + + ht32f1xxxx_i2c.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_i2c.c + + + ht32f1xxxx_adc.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_adc.c + + + ht32f1xxxx_pwrcu.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_pwrcu.c + + + ht32f1xxxx_pdma.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_pdma.c + + + system_ht32f1xxxx_02.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\Device\Holtek\HT32F1xxxx\Source\system_ht32f1xxxx_02.c + + + ht32f1xxxx_mctm.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_mctm.c + + + ht32f1xxxx_spi.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_spi.c + + + ht32f1xxxx_bftm.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_bftm.c + + + ht32f1xxxx_i2s.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_i2s.c + + + ht32f1xxxx_exti.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_exti.c + + + ht32f1xxxx_rtc.c + 1 + ..\libraries\HT32_STD_1xxxx_FWLib\library\HT32F1xxxx_Driver\src\ht32f1xxxx_rtc.c + + + + + + + + + + + + + +
diff --git a/bsp/ht32/ht32f12366/rtconfig.h b/bsp/ht32/ht32f12366/rtconfig.h new file mode 100644 index 0000000000..42fd7c23e0 --- /dev/null +++ b/bsp/ht32/ht32f12366/rtconfig.h @@ -0,0 +1,273 @@ +#ifndef RT_CONFIG_H__ +#define RT_CONFIG_H__ + +/* Automatically generated file; DO NOT EDIT. */ +/* RT-Thread Configuration */ + +/* RT-Thread Kernel */ + +#define RT_NAME_MAX 8 +#define RT_CPUS_NR 1 +#define RT_ALIGN_SIZE 4 +#define RT_THREAD_PRIORITY_32 +#define RT_THREAD_PRIORITY_MAX 32 +#define RT_TICK_PER_SECOND 1000 +#define RT_USING_OVERFLOW_CHECK +#define RT_USING_HOOK +#define RT_HOOK_USING_FUNC_PTR +#define RT_USING_IDLE_HOOK +#define RT_IDLE_HOOK_LIST_SIZE 4 +#define IDLE_THREAD_STACK_SIZE 256 + +/* kservice optimization */ + +#define RT_USING_DEBUG +#define RT_DEBUGING_COLOR +#define RT_DEBUGING_CONTEXT + +/* Inter-Thread communication */ + +#define RT_USING_SEMAPHORE +#define RT_USING_MUTEX +#define RT_USING_EVENT +#define RT_USING_MAILBOX +#define RT_USING_MESSAGEQUEUE + +/* Memory Management */ + +#define RT_USING_MEMPOOL +#define RT_USING_SMALL_MEM +#define RT_USING_MEMHEAP +#define RT_MEMHEAP_FAST_MODE +#define RT_USING_SMALL_MEM_AS_HEAP +#define RT_USING_HEAP +#define RT_USING_DEVICE +#define RT_USING_CONSOLE +#define RT_CONSOLEBUF_SIZE 128 +#define RT_CONSOLE_DEVICE_NAME "usart0" +#define RT_VER_NUM 0x50100 +#define RT_BACKTRACE_LEVEL_MAX_NR 32 +#define RT_USING_HW_ATOMIC +#define RT_USING_CPU_FFS +#define ARCH_ARM +#define ARCH_ARM_CORTEX_M +#define ARCH_ARM_CORTEX_M3 + +/* RT-Thread Components */ + +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 2048 +#define RT_MAIN_THREAD_PRIORITY 10 +#define RT_USING_MSH +#define RT_USING_FINSH +#define FINSH_USING_MSH +#define FINSH_THREAD_NAME "tshell" +#define FINSH_THREAD_PRIORITY 20 +#define FINSH_THREAD_STACK_SIZE 4096 +#define FINSH_USING_HISTORY +#define FINSH_HISTORY_LINES 5 +#define FINSH_USING_SYMTAB +#define FINSH_CMD_SIZE 80 +#define MSH_USING_BUILT_IN_COMMANDS +#define FINSH_USING_DESCRIPTION +#define FINSH_ARG_MAX 10 +#define FINSH_USING_OPTION_COMPLETION + +/* DFS: device virtual file system */ + + +/* Device Drivers */ + +#define RT_USING_DEVICE_IPC +#define RT_UNAMED_PIPE_NUMBER 64 +#define RT_USING_SERIAL +#define RT_USING_SERIAL_V1 +#define RT_SERIAL_USING_DMA +#define RT_SERIAL_RB_BUFSZ 64 +#define RT_USING_I2C +#define RT_USING_I2C_BITOPS +#define RT_USING_SPI +#define RT_USING_PIN + +/* Using USB */ + + +/* C/C++ and POSIX layer */ + +/* ISO-ANSI C layer */ + +/* Timezone and Daylight Saving Time */ + +#define RT_LIBC_USING_LIGHT_TZ_DST +#define RT_LIBC_TZ_DEFAULT_HOUR 8 +#define RT_LIBC_TZ_DEFAULT_MIN 0 +#define RT_LIBC_TZ_DEFAULT_SEC 0 + +/* POSIX (Portable Operating System Interface) layer */ + + +/* Interprocess Communication (IPC) */ + + +/* Socket is in the 'Network' category */ + + +/* Network */ + + +/* Memory protection */ + + +/* Utilities */ + + +/* RT-Thread Utestcases */ + + +/* RT-Thread online packages */ + +/* IoT - internet of things */ + + +/* Wi-Fi */ + +/* Marvell WiFi */ + + +/* Wiced WiFi */ + + +/* CYW43012 WiFi */ + + +/* BL808 WiFi */ + + +/* CYW43439 WiFi */ + + +/* IoT Cloud */ + + +/* security packages */ + + +/* language packages */ + +/* JSON: JavaScript Object Notation, a lightweight data-interchange format */ + + +/* XML: Extensible Markup Language */ + + +/* multimedia packages */ + +/* LVGL: powerful and easy-to-use embedded GUI library */ + + +/* u8g2: a monochrome graphic library */ + + +/* tools packages */ + + +/* system packages */ + +/* enhanced kernel services */ + + +/* acceleration: Assembly language or algorithmic acceleration packages */ + + +/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */ + + +/* Micrium: Micrium software products porting for RT-Thread */ + + +/* peripheral libraries and drivers */ + +/* HAL & SDK Drivers */ + +/* STM32 HAL & SDK Drivers */ + + +/* Kendryte SDK */ + + +/* sensors drivers */ + + +/* touch drivers */ + + +/* AI packages */ + + +/* Signal Processing and Control Algorithm Packages */ + + +/* miscellaneous packages */ + +/* project laboratory */ + +/* samples: kernel and components samples */ + + +/* entertainment: terminal games and other interesting software packages */ + + +/* Arduino libraries */ + + +/* Projects and Demos */ + + +/* Sensors */ + + +/* Display */ + + +/* Timing */ + + +/* Data Processing */ + + +/* Data Storage */ + +/* Communication */ + + +/* Device Control */ + + +/* Other */ + + +/* Signal IO */ + + +/* Uncategorized */ + +#define SOC_FAMILY_HT32 +#define SOC_SERIES_HT32F1 + +/* Hardware Drivers Config */ + +#define SOC_HT32F12366 + +/* Onboard Peripheral Drivers */ + +/* On-chip Peripheral Drivers */ + +#define BSP_USING_GPIO +#define BSP_USING_UART +#define BSP_USING_USART0 + +/* Board extended module Drivers */ + + +#endif diff --git a/bsp/ht32/ht32f12366/rtconfig.py b/bsp/ht32/ht32f12366/rtconfig.py new file mode 100644 index 0000000000..1c3077b6cf --- /dev/null +++ b/bsp/ht32/ht32f12366/rtconfig.py @@ -0,0 +1,152 @@ +import os + +# toolchains options +ARCH='arm' +CPU='cortex-m3' +CROSS_TOOL='keil' + +# bsp lib config +BSP_LIBRARY_TYPE = None + +if os.getenv('RTT_CC'): + CROSS_TOOL = os.getenv('RTT_CC') +if os.getenv('RTT_ROOT'): + RTT_ROOT = os.getenv('RTT_ROOT') + +# cross_tool provides the cross compiler +# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR +if CROSS_TOOL == 'gcc': + PLATFORM = 'gcc' + EXEC_PATH = r'C:\Users\XXYYZZ' +elif CROSS_TOOL == 'keil': + PLATFORM = 'armcc' +# EXEC_PATH = r'D:\keil5\keil_v532\UV4' + EXEC_PATH = r'C:/Keil_v5' +elif CROSS_TOOL == 'iar': + PLATFORM = 'iar' + EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0' + +if os.getenv('RTT_EXEC_PATH'): + EXEC_PATH = os.getenv('RTT_EXEC_PATH') + +BUILD = 'debug' + +if PLATFORM == 'gcc': + # toolchains + PREFIX = 'arm-none-eabi-' + CC = PREFIX + 'gcc' + AS = PREFIX + 'gcc' + AR = PREFIX + 'ar' + CXX = PREFIX + 'g++' + LINK = PREFIX + 'gcc' + TARGET_EXT = 'elf' + SIZE = PREFIX + 'size' + OBJDUMP = PREFIX + 'objdump' + OBJCPY = PREFIX + 'objcopy' + + DEVICE = ' -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections' + CFLAGS = DEVICE + ' -Dgcc' + AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' + + CPATH = '' + LPATH = '' + + if BUILD == 'debug': + CFLAGS += ' -O0 -gdwarf-2 -g' + AFLAGS += ' -gdwarf-2' + else: + CFLAGS += ' -O2' + + CXXFLAGS = CFLAGS + + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' + +elif PLATFORM == 'armcc': + # toolchains + CC = 'armcc' + CXX = 'armcc' + AS = 'armasm' + AR = 'armar' + LINK = 'armlink' + TARGET_EXT = 'axf' + + DEVICE = ' --cpu Cortex-M3 ' + CFLAGS = '-c ' + DEVICE + ' --apcs=interwork --c99' + AFLAGS = DEVICE + ' --apcs=interwork ' + LFLAGS = DEVICE + ' --scatter "board\linker_scripts\link.sct" --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict' + CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCC/include' + LFLAGS += ' --libpath=' + EXEC_PATH + '/ARM/ARMCC/lib' + + CFLAGS += ' -D__MICROLIB ' + AFLAGS += ' --pd "__MICROLIB SETA 1" ' + LFLAGS += ' --library_type=microlib ' + EXEC_PATH += '/ARM/ARMCC/bin/' + + if BUILD == 'debug': + CFLAGS += ' -g -O0' + AFLAGS += ' -g' + else: + CFLAGS += ' -O2' + + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' + +elif PLATFORM == 'iar': + # toolchains + CC = 'iccarm' + CXX = 'iccarm' + AS = 'iasmarm' + AR = 'iarchive' + LINK = 'ilinkarm' + TARGET_EXT = 'out' + + DEVICE = '-Dewarm' + + CFLAGS = DEVICE + CFLAGS += ' --diag_suppress Pa050' + CFLAGS += ' --no_cse' + CFLAGS += ' --no_unroll' + CFLAGS += ' --no_inline' + CFLAGS += ' --no_code_motion' + CFLAGS += ' --no_tbaa' + CFLAGS += ' --no_clustering' + CFLAGS += ' --no_scheduling' + CFLAGS += ' --endian=little' + CFLAGS += ' --cpu=Cortex-M3' + CFLAGS += ' -e' + CFLAGS += ' --fpu=None' + CFLAGS += ' --dlib_config "' + EXEC_PATH + '/arm/INC/c/DLib_Config_Normal.h"' + CFLAGS += ' --silent' + + AFLAGS = DEVICE + AFLAGS += ' -s+' + AFLAGS += ' -w+' + AFLAGS += ' -r' + AFLAGS += ' --cpu Cortex-M3' + AFLAGS += ' --fpu None' + AFLAGS += ' -S' + + if BUILD == 'debug': + CFLAGS += ' --debug' + CFLAGS += ' -On' + else: + CFLAGS += ' -Oh' + + LFLAGS = ' --config "board/linker_scripts/link.icf"' + LFLAGS += ' --entry __iar_program_start' + + CXXFLAGS = CFLAGS + + EXEC_PATH = EXEC_PATH + '/arm/bin/' + POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' + +def dist_handle(BSP_ROOT, dist_dir): + import sys + cwd_path = os.getcwd() + sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools')) + from sdk_dist import dist_do_building + dist_do_building(BSP_ROOT, dist_dir) + diff --git a/bsp/ht32/ht32f12366/template.uvoptx b/bsp/ht32/ht32f12366/template.uvoptx new file mode 100644 index 0000000000..4c6655f9dd --- /dev/null +++ b/bsp/ht32/ht32f12366/template.uvoptx @@ -0,0 +1,179 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + rt-thread + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\build\keil\List\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 2 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + CMSIS_AGDI + -X"Any" -UAny -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN2 -FF0HT32F.FLM -FS00 -FL0100000 -FP0($$Device:HT32F12366$ARM\Flash\HT32F.FLM) -FF1HT32F_OPT.FLM -FS11FF00000 -FL11000 -FP1($$Device:HT32F12366$ARM\Flash\HT32F_OPT.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F12366$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F12366$ARM\Flash\HT32F_OPT.FLM)) + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + Source Group 1 + 0 + 0 + 0 + 0 + + +
diff --git a/bsp/ht32/ht32f12366/template.uvprojx b/bsp/ht32/ht32f12366/template.uvprojx new file mode 100644 index 0000000000..9b24487b53 --- /dev/null +++ b/bsp/ht32/ht32f12366/template.uvprojx @@ -0,0 +1,392 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + rt-thread + 0x4 + ARM-ADS + 5060422::V5.06 update 4 (build 422)::ARMCC + + + HT32F12366 + Holtek + Holtek.HT32_DFP.1.0.19 + http://mcu.holtek.com.tw/pack + IRAM(0x20000000,0x20000) IROM(0x00000000,0x3FC00) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F12366$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F12366$ARM\Flash\HT32F_OPT.FLM)) + 0 + $$Device:HT32F12366$ARM\INC\Holtek\HT32F1xxxx\ht32f1xxxx_01.h + + + + + + + + + + $$Device:HT32F12366$SVD\HT32F12365_66.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\build\keil\Obj\ + rt-thread + 1 + 0 + 0 + 1 + 1 + .\build\keil\List\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DCM.DLL + -pCM3 + SARMCM3.DLL + + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 1 + 0x0 + 0x3fc00 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x3fc00 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x20000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + USE_HT32_CHIP=2 + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + .\board\linker_scripts\link.sct + + + + + + + + + + + Source Group 1 + + + + + + + + + + + +
diff --git a/bsp/ht32/ht32f52352/.config b/bsp/ht32/ht32f52352/.config new file mode 100644 index 0000000000..cb70b2f90b --- /dev/null +++ b/bsp/ht32/ht32f52352/.config @@ -0,0 +1,1094 @@ +# +# Automatically generated file; DO NOT EDIT. +# RT-Thread Configuration +# + +# +# RT-Thread Kernel +# +CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_ARCH_DATA_TYPE is not set +# CONFIG_RT_USING_SMART is not set +# CONFIG_RT_USING_NANO is not set +# CONFIG_RT_USING_AMP is not set +# CONFIG_RT_USING_SMP is not set +CONFIG_RT_CPUS_NR=1 +CONFIG_RT_ALIGN_SIZE=4 +# CONFIG_RT_THREAD_PRIORITY_8 is not set +CONFIG_RT_THREAD_PRIORITY_32=y +# CONFIG_RT_THREAD_PRIORITY_256 is not set +CONFIG_RT_THREAD_PRIORITY_MAX=32 +CONFIG_RT_TICK_PER_SECOND=1000 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_HOOK_USING_FUNC_PTR=y +# CONFIG_RT_USING_HOOKLIST is not set +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=256 +# CONFIG_RT_USING_TIMER_SOFT is not set + +# +# kservice optimization +# +# CONFIG_RT_KSERVICE_USING_STDLIB is not set +# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set +# CONFIG_RT_USING_TINY_FFS is not set +# CONFIG_RT_KPRINTF_USING_LONGLONG is not set +CONFIG_RT_USING_DEBUG=y +CONFIG_RT_DEBUGING_COLOR=y +CONFIG_RT_DEBUGING_CONTEXT=y +# CONFIG_RT_DEBUGING_AUTO_INIT is not set + +# +# Inter-Thread communication +# +CONFIG_RT_USING_SEMAPHORE=y +CONFIG_RT_USING_MUTEX=y +CONFIG_RT_USING_EVENT=y +CONFIG_RT_USING_MAILBOX=y +CONFIG_RT_USING_MESSAGEQUEUE=y +# CONFIG_RT_USING_MESSAGEQUEUE_PRIORITY is not set +# CONFIG_RT_USING_SIGNALS is not set + +# +# Memory Management +# +CONFIG_RT_USING_MEMPOOL=y +CONFIG_RT_USING_SMALL_MEM=y +# CONFIG_RT_USING_SLAB is not set +CONFIG_RT_USING_MEMHEAP=y +CONFIG_RT_MEMHEAP_FAST_MODE=y +# CONFIG_RT_MEMHEAP_BEST_MODE is not set +CONFIG_RT_USING_SMALL_MEM_AS_HEAP=y +# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set +# CONFIG_RT_USING_SLAB_AS_HEAP is not set +# CONFIG_RT_USING_USERHEAP is not set +# CONFIG_RT_USING_NOHEAP is not set +# CONFIG_RT_USING_MEMTRACE is not set +# CONFIG_RT_USING_HEAP_ISR is not set +CONFIG_RT_USING_HEAP=y +CONFIG_RT_USING_DEVICE=y +# CONFIG_RT_USING_DEVICE_OPS is not set +# CONFIG_RT_USING_INTERRUPT_INFO is not set +# CONFIG_RT_USING_THREADSAFE_PRINTF is not set +# CONFIG_RT_USING_SCHED_THREAD_CTX is not set +CONFIG_RT_USING_CONSOLE=y +CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLE_DEVICE_NAME="usart1" +CONFIG_RT_VER_NUM=0x50100 +# CONFIG_RT_USING_STDC_ATOMIC is not set +CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32 +# CONFIG_RT_USING_CACHE is not set +# CONFIG_RT_USING_HW_ATOMIC is not set +# CONFIG_ARCH_ARM_BOOTWITH_FLUSH_CACHE is not set +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set +# CONFIG_RT_USING_CPU_FFS is not set +CONFIG_ARCH_ARM=y +CONFIG_ARCH_ARM_CORTEX_M=y +CONFIG_ARCH_ARM_CORTEX_M0=y + +# +# RT-Thread Components +# +CONFIG_RT_USING_COMPONENTS_INIT=y +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 +# CONFIG_RT_USING_LEGACY is not set +CONFIG_RT_USING_MSH=y +CONFIG_RT_USING_FINSH=y +CONFIG_FINSH_USING_MSH=y +CONFIG_FINSH_THREAD_NAME="tshell" +CONFIG_FINSH_THREAD_PRIORITY=20 +CONFIG_FINSH_THREAD_STACK_SIZE=4096 +CONFIG_FINSH_USING_HISTORY=y +CONFIG_FINSH_HISTORY_LINES=5 +CONFIG_FINSH_USING_SYMTAB=y +CONFIG_FINSH_CMD_SIZE=80 +CONFIG_MSH_USING_BUILT_IN_COMMANDS=y +CONFIG_FINSH_USING_DESCRIPTION=y +# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set +# CONFIG_FINSH_USING_AUTH is not set +CONFIG_FINSH_ARG_MAX=10 +CONFIG_FINSH_USING_OPTION_COMPLETION=y + +# +# DFS: device virtual file system +# +# CONFIG_RT_USING_DFS is not set +# CONFIG_RT_USING_FAL is not set + +# +# Device Drivers +# +# CONFIG_RT_USING_DM is not set +CONFIG_RT_USING_DEVICE_IPC=y +CONFIG_RT_UNAMED_PIPE_NUMBER=64 +# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set +CONFIG_RT_USING_SERIAL=y +CONFIG_RT_USING_SERIAL_V1=y +# CONFIG_RT_USING_SERIAL_V2 is not set +CONFIG_RT_SERIAL_USING_DMA=y +CONFIG_RT_SERIAL_RB_BUFSZ=64 +# CONFIG_RT_USING_CAN is not set +# CONFIG_RT_USING_CPUTIME is not set +CONFIG_RT_USING_I2C=y +# CONFIG_RT_I2C_DEBUG is not set +CONFIG_RT_USING_I2C_BITOPS=y +# CONFIG_RT_I2C_BITOPS_DEBUG is not set +# CONFIG_RT_USING_SOFT_I2C is not set +# CONFIG_RT_USING_PHY is not set +# CONFIG_RT_USING_ADC is not set +# CONFIG_RT_USING_DAC is not set +# CONFIG_RT_USING_NULL is not set +# CONFIG_RT_USING_ZERO is not set +# CONFIG_RT_USING_RANDOM is not set +# CONFIG_RT_USING_PWM is not set +# CONFIG_RT_USING_MTD_NOR is not set +# CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_PM is not set +# CONFIG_RT_USING_RTC is not set +# CONFIG_RT_USING_SDIO is not set +CONFIG_RT_USING_SPI=y +# CONFIG_RT_USING_SPI_BITOPS is not set +# CONFIG_RT_USING_QSPI is not set +# CONFIG_RT_USING_SPI_MSD is not set +# CONFIG_RT_USING_SFUD is not set +# CONFIG_RT_USING_ENC28J60 is not set +# CONFIG_RT_USING_SPI_WIFI is not set +# CONFIG_RT_USING_WDT is not set +# CONFIG_RT_USING_AUDIO is not set +# CONFIG_RT_USING_SENSOR is not set +# CONFIG_RT_USING_TOUCH is not set +# CONFIG_RT_USING_LCD is not set +# CONFIG_RT_USING_HWCRYPTO is not set +# CONFIG_RT_USING_PULSE_ENCODER is not set +# CONFIG_RT_USING_INPUT_CAPTURE is not set +# CONFIG_RT_USING_DEV_BUS is not set +# CONFIG_RT_USING_WIFI is not set +# CONFIG_RT_USING_VIRTIO is not set +CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_KTIME is not set +# CONFIG_RT_USING_HWTIMER is not set + +# +# Using USB +# +# CONFIG_RT_USING_USB is not set +# CONFIG_RT_USING_USB_HOST is not set +# CONFIG_RT_USING_USB_DEVICE is not set + +# +# C/C++ and POSIX layer +# + +# +# ISO-ANSI C layer +# + +# +# Timezone and Daylight Saving Time +# +# CONFIG_RT_LIBC_USING_FULL_TZ_DST is not set +CONFIG_RT_LIBC_USING_LIGHT_TZ_DST=y +CONFIG_RT_LIBC_TZ_DEFAULT_HOUR=8 +CONFIG_RT_LIBC_TZ_DEFAULT_MIN=0 +CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 + +# +# POSIX (Portable Operating System Interface) layer +# +# CONFIG_RT_USING_POSIX_FS is not set +# CONFIG_RT_USING_POSIX_DELAY is not set +# CONFIG_RT_USING_POSIX_CLOCK is not set +# CONFIG_RT_USING_POSIX_TIMER is not set +# CONFIG_RT_USING_PTHREADS is not set +# CONFIG_RT_USING_MODULE is not set + +# +# Interprocess Communication (IPC) +# +# CONFIG_RT_USING_POSIX_PIPE is not set +# CONFIG_RT_USING_POSIX_MESSAGE_QUEUE is not set +# CONFIG_RT_USING_POSIX_MESSAGE_SEMAPHORE is not set + +# +# Socket is in the 'Network' category +# +# CONFIG_RT_USING_CPLUSPLUS is not set + +# +# Network +# +# CONFIG_RT_USING_SAL is not set +# CONFIG_RT_USING_NETDEV is not set +# CONFIG_RT_USING_LWIP is not set +# CONFIG_RT_USING_AT is not set + +# +# Memory protection +# +# CONFIG_RT_USING_MEM_PROTECTION is not set +# CONFIG_RT_USING_HW_STACK_GUARD is not set + +# +# Utilities +# +# CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set +# CONFIG_RT_USING_UTEST is not set +# CONFIG_RT_USING_VAR_EXPORT is not set +# CONFIG_RT_USING_RESOURCE_ID is not set +# CONFIG_RT_USING_ADT is not set +# CONFIG_RT_USING_RT_LINK is not set +# CONFIG_RT_USING_VBUS is not set + +# +# RT-Thread Utestcases +# +# CONFIG_RT_USING_UTESTCASES is not set + +# +# RT-Thread online packages +# + +# +# IoT - internet of things +# +# CONFIG_PKG_USING_LWIP is not set +# CONFIG_PKG_USING_LORAWAN_DRIVER is not set +# CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_UMQTT is not set +# CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_WEBNET is not set +# CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_MYMQTT is not set +# CONFIG_PKG_USING_KAWAII_MQTT is not set +# CONFIG_PKG_USING_BC28_MQTT is not set +# CONFIG_PKG_USING_WEBTERMINAL is not set +# CONFIG_PKG_USING_FREEMODBUS is not set +# CONFIG_PKG_USING_NANOPB is not set + +# +# Wi-Fi +# + +# +# Marvell WiFi +# +# CONFIG_PKG_USING_WLANMARVELL is not set + +# +# Wiced WiFi +# +# CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_RW007 is not set + +# +# CYW43012 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43012 is not set + +# +# BL808 WiFi +# +# CONFIG_PKG_USING_WLAN_BL808 is not set + +# +# CYW43439 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43439 is not set +# CONFIG_PKG_USING_COAP is not set +# CONFIG_PKG_USING_NOPOLL is not set +# CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_CMUX is not set +# CONFIG_PKG_USING_PPP_DEVICE is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_ATSRV_SOCKET is not set +# CONFIG_PKG_USING_WIZNET is not set +# CONFIG_PKG_USING_ZB_COORDINATOR is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set +# CONFIG_PKG_USING_JIOT-C-SDK is not set +# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set +# CONFIG_PKG_USING_JOYLINK is not set +# CONFIG_PKG_USING_IOTSHARP_SDK is not set +# CONFIG_PKG_USING_NIMBLE is not set +# CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set +# CONFIG_PKG_USING_OTA_DOWNLOADER is not set +# CONFIG_PKG_USING_IPMSG is not set +# CONFIG_PKG_USING_LSSDP is not set +# CONFIG_PKG_USING_AIRKISS_OPEN is not set +# CONFIG_PKG_USING_LIBRWS is not set +# CONFIG_PKG_USING_TCPSERVER is not set +# CONFIG_PKG_USING_PROTOBUF_C is not set +# CONFIG_PKG_USING_DLT645 is not set +# CONFIG_PKG_USING_QXWZ is not set +# CONFIG_PKG_USING_SMTP_CLIENT is not set +# CONFIG_PKG_USING_ABUP_FOTA is not set +# CONFIG_PKG_USING_LIBCURL2RTT is not set +# CONFIG_PKG_USING_CAPNP is not set +# CONFIG_PKG_USING_AGILE_TELNET is not set +# CONFIG_PKG_USING_NMEALIB is not set +# CONFIG_PKG_USING_PDULIB is not set +# CONFIG_PKG_USING_BTSTACK is not set +# CONFIG_PKG_USING_BT_CYW43012 is not set +# CONFIG_PKG_USING_CYW43XX is not set +# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set +# CONFIG_PKG_USING_WAYZ_IOTKIT is not set +# CONFIG_PKG_USING_MAVLINK is not set +# CONFIG_PKG_USING_BSAL is not set +# CONFIG_PKG_USING_AGILE_MODBUS is not set +# CONFIG_PKG_USING_AGILE_FTP is not set +# CONFIG_PKG_USING_EMBEDDEDPROTO is not set +# CONFIG_PKG_USING_RT_LINK_HW is not set +# CONFIG_PKG_USING_RYANMQTT is not set +# CONFIG_PKG_USING_RYANW5500 is not set +# CONFIG_PKG_USING_LORA_PKT_FWD is not set +# CONFIG_PKG_USING_LORA_GW_DRIVER_LIB is not set +# CONFIG_PKG_USING_LORA_PKT_SNIFFER is not set +# CONFIG_PKG_USING_HM is not set +# CONFIG_PKG_USING_SMALL_MODBUS is not set +# CONFIG_PKG_USING_NET_SERVER is not set +# CONFIG_PKG_USING_ZFTP is not set +# CONFIG_PKG_USING_WOL is not set +# CONFIG_PKG_USING_ZEPHYR_POLLING is not set +# CONFIG_PKG_USING_MATTER_ADAPTATION_LAYER is not set +# CONFIG_PKG_USING_LHC_MODBUS is not set + +# +# security packages +# +# CONFIG_PKG_USING_MBEDTLS is not set +# CONFIG_PKG_USING_LIBSODIUM is not set +# CONFIG_PKG_USING_LIBHYDROGEN is not set +# CONFIG_PKG_USING_TINYCRYPT is not set +# CONFIG_PKG_USING_TFM is not set +# CONFIG_PKG_USING_YD_CRYPTO is not set + +# +# language packages +# + +# +# JSON: JavaScript Object Notation, a lightweight data-interchange format +# +# CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_LJSON is not set +# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set +# CONFIG_PKG_USING_RAPIDJSON is not set +# CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_AGILE_JSMN is not set +# CONFIG_PKG_USING_PARSON is not set + +# +# XML: Extensible Markup Language +# +# CONFIG_PKG_USING_SIMPLE_XML is not set +# CONFIG_PKG_USING_EZXML is not set +# CONFIG_PKG_USING_LUATOS_SOC is not set +# CONFIG_PKG_USING_LUA is not set +# CONFIG_PKG_USING_JERRYSCRIPT is not set +# CONFIG_PKG_USING_MICROPYTHON is not set +# CONFIG_PKG_USING_PIKASCRIPT is not set +# CONFIG_PKG_USING_RTT_RUST is not set + +# +# multimedia packages +# + +# +# LVGL: powerful and easy-to-use embedded GUI library +# +# CONFIG_PKG_USING_LVGL is not set +# CONFIG_PKG_USING_LV_MUSIC_DEMO is not set +# CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set + +# +# u8g2: a monochrome graphic library +# +# CONFIG_PKG_USING_U8G2_OFFICIAL is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set +# CONFIG_PKG_USING_STEMWIN is not set +# CONFIG_PKG_USING_WAVPLAYER is not set +# CONFIG_PKG_USING_TJPGD is not set +# CONFIG_PKG_USING_PDFGEN is not set +# CONFIG_PKG_USING_HELIX is not set +# CONFIG_PKG_USING_AZUREGUIX is not set +# CONFIG_PKG_USING_TOUCHGFX2RTT is not set +# CONFIG_PKG_USING_NUEMWIN is not set +# CONFIG_PKG_USING_MP3PLAYER is not set +# CONFIG_PKG_USING_TINYJPEG is not set +# CONFIG_PKG_USING_UGUI is not set +# CONFIG_PKG_USING_MCURSES is not set +# CONFIG_PKG_USING_TERMBOX is not set +# CONFIG_PKG_USING_VT100 is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_GUIENGINE is not set +# CONFIG_PKG_USING_3GPP_AMRNB is not set + +# +# tools packages +# +# CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set +# CONFIG_PKG_USING_EASYLOGGER is not set +# CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_SEGGER_RTT is not set +# CONFIG_PKG_USING_RTT_AUTO_EXE_CMD is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set +# CONFIG_PKG_USING_LOGMGR is not set +# CONFIG_PKG_USING_ADBD is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_DHRYSTONE is not set +# CONFIG_PKG_USING_MEMORYPERF is not set +# CONFIG_PKG_USING_NR_MICRO_SHELL is not set +# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set +# CONFIG_PKG_USING_LUNAR_CALENDAR is not set +# CONFIG_PKG_USING_BS8116A is not set +# CONFIG_PKG_USING_GPS_RMC is not set +# CONFIG_PKG_USING_URLENCODE is not set +# CONFIG_PKG_USING_UMCN is not set +# CONFIG_PKG_USING_LWRB2RTT is not set +# CONFIG_PKG_USING_CPU_USAGE is not set +# CONFIG_PKG_USING_GBK2UTF8 is not set +# CONFIG_PKG_USING_VCONSOLE is not set +# CONFIG_PKG_USING_KDB is not set +# CONFIG_PKG_USING_WAMR is not set +# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set +# CONFIG_PKG_USING_LWLOG is not set +# CONFIG_PKG_USING_ANV_TRACE is not set +# CONFIG_PKG_USING_ANV_MEMLEAK is not set +# CONFIG_PKG_USING_ANV_TESTSUIT is not set +# CONFIG_PKG_USING_ANV_BENCH is not set +# CONFIG_PKG_USING_DEVMEM is not set +# CONFIG_PKG_USING_REGEX is not set +# CONFIG_PKG_USING_MEM_SANDBOX is not set +# CONFIG_PKG_USING_SOLAR_TERMS is not set +# CONFIG_PKG_USING_GAN_ZHI is not set +# CONFIG_PKG_USING_FDT is not set +# CONFIG_PKG_USING_CBOX is not set +# CONFIG_PKG_USING_SNOWFLAKE is not set +# CONFIG_PKG_USING_HASH_MATCH is not set +# CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set +# CONFIG_PKG_USING_VOFA_PLUS is not set +# CONFIG_PKG_USING_RT_TRACE is not set +# CONFIG_PKG_USING_ZDEBUG is not set + +# +# system packages +# + +# +# enhanced kernel services +# +# CONFIG_PKG_USING_RT_MEMCPY_CM is not set +# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set +# CONFIG_PKG_USING_RT_VSNPRINTF_FULL is not set + +# +# acceleration: Assembly language or algorithmic acceleration packages +# +# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set +# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set +# CONFIG_PKG_USING_QFPLIB_M3 is not set + +# +# CMSIS: ARM Cortex-M Microcontroller Software Interface Standard +# +# CONFIG_PKG_USING_CMSIS_5 is not set +# CONFIG_PKG_USING_CMSIS_CORE is not set +# CONFIG_PKG_USING_CMSIS_DSP is not set +# CONFIG_PKG_USING_CMSIS_NN is not set +# CONFIG_PKG_USING_CMSIS_RTOS1 is not set +# CONFIG_PKG_USING_CMSIS_RTOS2 is not set + +# +# Micrium: Micrium software products porting for RT-Thread +# +# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set +# CONFIG_PKG_USING_UCOSII_WRAPPER is not set +# CONFIG_PKG_USING_UC_CRC is not set +# CONFIG_PKG_USING_UC_CLK is not set +# CONFIG_PKG_USING_UC_COMMON is not set +# CONFIG_PKG_USING_UC_MODBUS is not set +# CONFIG_PKG_USING_FREERTOS_WRAPPER is not set +# CONFIG_PKG_USING_LITEOS_SDK is not set +# CONFIG_PKG_USING_TZ_DATABASE is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_PERF_COUNTER is not set +# CONFIG_PKG_USING_FILEX is not set +# CONFIG_PKG_USING_LEVELX is not set +# CONFIG_PKG_USING_FLASHDB is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_LITTLEFS is not set +# CONFIG_PKG_USING_DFS_JFFS2 is not set +# CONFIG_PKG_USING_DFS_UFFS is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_THREAD_POOL is not set +# CONFIG_PKG_USING_ROBOTS is not set +# CONFIG_PKG_USING_EV is not set +# CONFIG_PKG_USING_SYSWATCH is not set +# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set +# CONFIG_PKG_USING_PLCCORE is not set +# CONFIG_PKG_USING_RAMDISK is not set +# CONFIG_PKG_USING_MININI is not set +# CONFIG_PKG_USING_QBOOT is not set +# CONFIG_PKG_USING_PPOOL is not set +# CONFIG_PKG_USING_OPENAMP is not set +# CONFIG_PKG_USING_RPMSG_LITE is not set +# CONFIG_PKG_USING_LPM is not set +# CONFIG_PKG_USING_TLSF is not set +# CONFIG_PKG_USING_EVENT_RECORDER is not set +# CONFIG_PKG_USING_ARM_2D is not set +# CONFIG_PKG_USING_MCUBOOT is not set +# CONFIG_PKG_USING_TINYUSB is not set +# CONFIG_PKG_USING_CHERRYUSB is not set +# CONFIG_PKG_USING_KMULTI_RTIMER is not set +# CONFIG_PKG_USING_TFDB is not set +# CONFIG_PKG_USING_QPC is not set +# CONFIG_PKG_USING_AGILE_UPGRADE is not set +# CONFIG_PKG_USING_FLASH_BLOB is not set +# CONFIG_PKG_USING_MLIBC is not set +# CONFIG_PKG_USING_TASK_MSG_BUS is not set +# CONFIG_PKG_USING_SFDB is not set +# CONFIG_PKG_USING_RTP is not set +# CONFIG_PKG_USING_REB is not set +# CONFIG_PKG_USING_R_RHEALSTONE is not set + +# +# peripheral libraries and drivers +# + +# +# HAL & SDK Drivers +# + +# +# STM32 HAL & SDK Drivers +# +# CONFIG_PKG_USING_STM32L4XX_HAL_DRIVER is not set +# CONFIG_PKG_USING_STM32WB55_SDK is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_BLUETRUM_SDK is not set +# CONFIG_PKG_USING_EMBARC_BSP is not set +# CONFIG_PKG_USING_ESP_IDF is not set + +# +# Kendryte SDK +# +# CONFIG_PKG_USING_K210_SDK is not set +# CONFIG_PKG_USING_KENDRYTE_SDK is not set +# CONFIG_PKG_USING_NRF5X_SDK is not set +# CONFIG_PKG_USING_NRFX is not set +# CONFIG_PKG_USING_RASPBERRYPI_PICO_SDK is not set + +# +# sensors drivers +# +# CONFIG_PKG_USING_LSM6DSM is not set +# CONFIG_PKG_USING_LSM6DSL is not set +# CONFIG_PKG_USING_LPS22HB is not set +# CONFIG_PKG_USING_HTS221 is not set +# CONFIG_PKG_USING_LSM303AGR is not set +# CONFIG_PKG_USING_BME280 is not set +# CONFIG_PKG_USING_BME680 is not set +# CONFIG_PKG_USING_BMA400 is not set +# CONFIG_PKG_USING_BMI160_BMX160 is not set +# CONFIG_PKG_USING_SPL0601 is not set +# CONFIG_PKG_USING_MS5805 is not set +# CONFIG_PKG_USING_DA270 is not set +# CONFIG_PKG_USING_DF220 is not set +# CONFIG_PKG_USING_HSHCAL001 is not set +# CONFIG_PKG_USING_BH1750 is not set +# CONFIG_PKG_USING_MPU6XXX is not set +# CONFIG_PKG_USING_AHT10 is not set +# CONFIG_PKG_USING_AP3216C is not set +# CONFIG_PKG_USING_TSL4531 is not set +# CONFIG_PKG_USING_DS18B20 is not set +# CONFIG_PKG_USING_DHT11 is not set +# CONFIG_PKG_USING_DHTXX is not set +# CONFIG_PKG_USING_GY271 is not set +# CONFIG_PKG_USING_GP2Y10 is not set +# CONFIG_PKG_USING_SGP30 is not set +# CONFIG_PKG_USING_HDC1000 is not set +# CONFIG_PKG_USING_BMP180 is not set +# CONFIG_PKG_USING_BMP280 is not set +# CONFIG_PKG_USING_SHTC1 is not set +# CONFIG_PKG_USING_BMI088 is not set +# CONFIG_PKG_USING_HMC5883 is not set +# CONFIG_PKG_USING_MAX6675 is not set +# CONFIG_PKG_USING_TMP1075 is not set +# CONFIG_PKG_USING_SR04 is not set +# CONFIG_PKG_USING_CCS811 is not set +# CONFIG_PKG_USING_PMSXX is not set +# CONFIG_PKG_USING_RT3020 is not set +# CONFIG_PKG_USING_MLX90632 is not set +# CONFIG_PKG_USING_MLX90393 is not set +# CONFIG_PKG_USING_MLX90392 is not set +# CONFIG_PKG_USING_MLX90397 is not set +# CONFIG_PKG_USING_MS5611 is not set +# CONFIG_PKG_USING_MAX31865 is not set +# CONFIG_PKG_USING_VL53L0X is not set +# CONFIG_PKG_USING_INA260 is not set +# CONFIG_PKG_USING_MAX30102 is not set +# CONFIG_PKG_USING_INA226 is not set +# CONFIG_PKG_USING_LIS2DH12 is not set +# CONFIG_PKG_USING_HS300X is not set +# CONFIG_PKG_USING_ZMOD4410 is not set +# CONFIG_PKG_USING_ISL29035 is not set +# CONFIG_PKG_USING_MMC3680KJ is not set +# CONFIG_PKG_USING_QMP6989 is not set +# CONFIG_PKG_USING_BALANCE is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_SHT3X is not set +# CONFIG_PKG_USING_SHT4X is not set +# CONFIG_PKG_USING_AD7746 is not set +# CONFIG_PKG_USING_ADT74XX is not set +# CONFIG_PKG_USING_MAX17048 is not set +# CONFIG_PKG_USING_AS7341 is not set +# CONFIG_PKG_USING_CW2015 is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_PAJ7620 is not set +# CONFIG_PKG_USING_STHS34PF80 is not set + +# +# touch drivers +# +# CONFIG_PKG_USING_GT9147 is not set +# CONFIG_PKG_USING_GT1151 is not set +# CONFIG_PKG_USING_GT917S is not set +# CONFIG_PKG_USING_GT911 is not set +# CONFIG_PKG_USING_FT6206 is not set +# CONFIG_PKG_USING_FT5426 is not set +# CONFIG_PKG_USING_FT6236 is not set +# CONFIG_PKG_USING_XPT2046_TOUCH is not set +# CONFIG_PKG_USING_CST816X is not set +# CONFIG_PKG_USING_CST812T is not set +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_SX12XX is not set +# CONFIG_PKG_USING_SIGNAL_LED is not set +# CONFIG_PKG_USING_LEDBLINK is not set +# CONFIG_PKG_USING_LITTLED is not set +# CONFIG_PKG_USING_LKDGUI is not set +# CONFIG_PKG_USING_INFRARED is not set +# CONFIG_PKG_USING_MULTI_INFRARED is not set +# CONFIG_PKG_USING_AGILE_BUTTON is not set +# CONFIG_PKG_USING_AGILE_LED is not set +# CONFIG_PKG_USING_AT24CXX is not set +# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set +# CONFIG_PKG_USING_PCA9685 is not set +# CONFIG_PKG_USING_ILI9341 is not set +# CONFIG_PKG_USING_I2C_TOOLS is not set +# CONFIG_PKG_USING_NRF24L01 is not set +# CONFIG_PKG_USING_RPLIDAR is not set +# CONFIG_PKG_USING_AS608 is not set +# CONFIG_PKG_USING_RC522 is not set +# CONFIG_PKG_USING_WS2812B is not set +# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set +# CONFIG_PKG_USING_MULTI_RTIMER is not set +# CONFIG_PKG_USING_MAX7219 is not set +# CONFIG_PKG_USING_BEEP is not set +# CONFIG_PKG_USING_EASYBLINK is not set +# CONFIG_PKG_USING_PMS_SERIES is not set +# CONFIG_PKG_USING_CAN_YMODEM is not set +# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set +# CONFIG_PKG_USING_QLED is not set +# CONFIG_PKG_USING_AGILE_CONSOLE is not set +# CONFIG_PKG_USING_LD3320 is not set +# CONFIG_PKG_USING_WK2124 is not set +# CONFIG_PKG_USING_LY68L6400 is not set +# CONFIG_PKG_USING_DM9051 is not set +# CONFIG_PKG_USING_SSD1306 is not set +# CONFIG_PKG_USING_QKEY is not set +# CONFIG_PKG_USING_RS485 is not set +# CONFIG_PKG_USING_RS232 is not set +# CONFIG_PKG_USING_NES is not set +# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set +# CONFIG_PKG_USING_VDEVICE is not set +# CONFIG_PKG_USING_SGM706 is not set +# CONFIG_PKG_USING_RDA58XX is not set +# CONFIG_PKG_USING_LIBNFC is not set +# CONFIG_PKG_USING_MFOC is not set +# CONFIG_PKG_USING_TMC51XX is not set +# CONFIG_PKG_USING_TCA9534 is not set +# CONFIG_PKG_USING_KOBUKI is not set +# CONFIG_PKG_USING_ROSSERIAL is not set +# CONFIG_PKG_USING_MICRO_ROS is not set +# CONFIG_PKG_USING_MCP23008 is not set +# CONFIG_PKG_USING_MISAKA_AT24CXX is not set +# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set +# CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set +# CONFIG_PKG_USING_SOFT_SERIAL is not set +# CONFIG_PKG_USING_MB85RS16 is not set +# CONFIG_PKG_USING_RFM300 is not set +# CONFIG_PKG_USING_IO_INPUT_FILTER is not set +# CONFIG_PKG_USING_LRF_NV7LIDAR is not set +# CONFIG_PKG_USING_AIP650 is not set +# CONFIG_PKG_USING_FINGERPRINT is not set +# CONFIG_PKG_USING_BT_ECB02C is not set +# CONFIG_PKG_USING_UAT is not set +# CONFIG_PKG_USING_ST7789 is not set +# CONFIG_PKG_USING_VS1003 is not set +# CONFIG_PKG_USING_X9555 is not set +# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set +# CONFIG_PKG_USING_BT_MX01 is not set +# CONFIG_PKG_USING_RGPOWER is not set +# CONFIG_PKG_USING_SPI_TOOLS is not set + +# +# AI packages +# +# CONFIG_PKG_USING_LIBANN is not set +# CONFIG_PKG_USING_NNOM is not set +# CONFIG_PKG_USING_ONNX_BACKEND is not set +# CONFIG_PKG_USING_ONNX_PARSER is not set +# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set +# CONFIG_PKG_USING_ELAPACK is not set +# CONFIG_PKG_USING_ULAPACK is not set +# CONFIG_PKG_USING_QUEST is not set +# CONFIG_PKG_USING_NAXOS is not set +# CONFIG_PKG_USING_R_TINYMAIX is not set + +# +# Signal Processing and Control Algorithm Packages +# +# CONFIG_PKG_USING_FIRE_PID_CURVE is not set +# CONFIG_PKG_USING_QPID is not set +# CONFIG_PKG_USING_UKAL is not set +# CONFIG_PKG_USING_DIGITALCTRL is not set +# CONFIG_PKG_USING_KISSFFT is not set + +# +# miscellaneous packages +# + +# +# project laboratory +# + +# +# samples: kernel and components samples +# +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set + +# +# entertainment: terminal games and other interesting software packages +# +# CONFIG_PKG_USING_CMATRIX is not set +# CONFIG_PKG_USING_SL is not set +# CONFIG_PKG_USING_CAL is not set +# CONFIG_PKG_USING_ACLOCK is not set +# CONFIG_PKG_USING_THREES is not set +# CONFIG_PKG_USING_2048 is not set +# CONFIG_PKG_USING_SNAKE is not set +# CONFIG_PKG_USING_TETRIS is not set +# CONFIG_PKG_USING_DONUT is not set +# CONFIG_PKG_USING_COWSAY is not set +# CONFIG_PKG_USING_MORSE is not set +# CONFIG_PKG_USING_TINYSQUARE is not set +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set +# CONFIG_PKG_USING_FASTLZ is not set +# CONFIG_PKG_USING_MINILZO is not set +# CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_LZMA is not set +# CONFIG_PKG_USING_RALARAM is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_MINIZIP is not set +# CONFIG_PKG_USING_HEATSHRINK is not set +# CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set +# CONFIG_PKG_USING_KENDRYTE_DEMO is not set +# CONFIG_PKG_USING_UPACKER is not set +# CONFIG_PKG_USING_UPARAM is not set +# CONFIG_PKG_USING_HELLO is not set +# CONFIG_PKG_USING_VI is not set +# CONFIG_PKG_USING_KI is not set +# CONFIG_PKG_USING_ARMv7M_DWT is not set +# CONFIG_PKG_USING_CRCLIB is not set +# CONFIG_PKG_USING_LWGPS is not set +# CONFIG_PKG_USING_STATE_MACHINE is not set +# CONFIG_PKG_USING_DESIGN_PATTERN is not set +# CONFIG_PKG_USING_CONTROLLER is not set +# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set +# CONFIG_PKG_USING_MFBD is not set +# CONFIG_PKG_USING_SLCAN2RTT is not set +# CONFIG_PKG_USING_SOEM is not set +# CONFIG_PKG_USING_QPARAM is not set +# CONFIG_PKG_USING_CorevMCU_CLI is not set + +# +# Arduino libraries +# +# CONFIG_PKG_USING_RTDUINO is not set + +# +# Projects and Demos +# +# CONFIG_PKG_USING_ARDUINO_MSGQ_C_CPP_DEMO is not set +# CONFIG_PKG_USING_ARDUINO_SKETCH_LOADER_DEMO is not set +# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set +# CONFIG_PKG_USING_ARDUINO_NINEINONE_SENSOR_SHIELD is not set +# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set +# CONFIG_PKG_USING_ARDUINO_MATLAB_SUPPORT is not set + +# +# Sensors +# +# CONFIG_PKG_USING_ARDUINO_SENSOR_DEVICE_DRIVERS is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SENSOR is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SENSORLAB is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL375 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VL53L0X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VL53L1X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VL6180X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX31855 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX31865 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX31856 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX6675 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90614 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM9DS1 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AHTX0 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM9DS0 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP280 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADT7410 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP085 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BME680 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP9808 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP4728 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_INA219 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LTR390 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL345 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DHT is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP9600 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM6DS is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO055 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX1704X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MMC56X3 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90393 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90395 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ICM20X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DPS310 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HTS221 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT4X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT31 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL343 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BME280 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AS726X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AMG88XX is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AM2320 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AM2315 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LTR329_LTR303 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP085_UNIFIED is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP183 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP183_UNIFIED is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP3XX is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MS8607 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS3MDL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MLX90640 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MMA8451 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MSA301 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPL115A2 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO08X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BNO08X_RVC is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS2MDL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM303DLH_MAG is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LC709203F is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_CAP1188 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_CCS811 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_NAU7802 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS331 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LPS2X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LPS35HW is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LSM303_ACCEL is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_LIS3DH is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCF8591 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPL3115A2 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPR121 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPRLS is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MPU6050 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCT2075 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PM25AQI is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_EMC2101 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_FXAS21002C is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SCD30 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_FXOS8700 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HMC5883_UNIFIED is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SGP30 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TMP006 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TLA202X is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TCS34725 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI7021 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI1145 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SGP40 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHTC3 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HDC1000 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HTU21DF is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AS7341 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_HTU31D is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_INA260 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TMP007_LIBRARY is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_L3GD20 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TMP117 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TSC2007 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TSL2561 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TSL2591_LIBRARY is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VCNL4040 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VEML6070 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VEML6075 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_VEML7700 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LIS3DHTR is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_DHT is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_ADXL335 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_ADXL345 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BME280 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BMP280 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_H3LIS331DL is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_MMA7660 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_TSL2561 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_PAJ7620 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_VL53L0X is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_ITG3200 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_SHT31 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HP20X is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_DRV2605L is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BBM150 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HMC5883L is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LSM303DLH is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_TCS3414CS is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_MP503 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_BMP085 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HIGHTEMP is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_VEML6070 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_SI1145 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_SHT35 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_AT42QT1070 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LSM6DS3 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HDC1000 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_HM3301 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_MCP9600 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LTC2941 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_LDC1612 is not set +# CONFIG_PKG_USING_ARDUINO_CAPACITIVESENSOR is not set +# CONFIG_PKG_USING_ARDUINO_JARZEBSKI_MPU6050 is not set + +# +# Display +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set +# CONFIG_PKG_USING_ARDUINO_U8G2 is not set +# CONFIG_PKG_USING_ARDUINO_TFT_ESPI is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set +# CONFIG_PKG_USING_SEEED_TM1637 is not set + +# +# Timing +# +# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set +# CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set +# CONFIG_PKG_USING_ARDUINO_TICKER is not set +# CONFIG_PKG_USING_ARDUINO_TASKSCHEDULER is not set + +# +# Data Processing +# +# CONFIG_PKG_USING_ARDUINO_KALMANFILTER is not set +# CONFIG_PKG_USING_ARDUINO_ARDUINOJSON is not set +# CONFIG_PKG_USING_ARDUINO_TENSORFLOW_LITE_MICRO is not set +# CONFIG_PKG_USING_ARDUINO_RUNNINGMEDIAN is not set + +# +# Data Storage +# + +# +# Communication +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PN532 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI4713 is not set + +# +# Device Control +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCF8574 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_PCA9685 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TPA2016 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DRV2605 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DS1841 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DS3502 is not set +# CONFIG_PKG_USING_ARDUINO_SEEED_PCF85063TP is not set + +# +# Other +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set + +# +# Signal IO +# +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BUSIO is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TCA8418 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP23017 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADS1X15 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AW9523 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP3008 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MCP4725 is not set +# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BD3491FS is not set + +# +# Uncategorized +# +CONFIG_SOC_FAMILY_HT32=y +CONFIG_SOC_SERIES_HT32F5=y + +# +# Hardware Drivers Config +# +CONFIG_SOC_HT32F52352=y + +# +# Onboard Peripheral Drivers +# + +# +# On-chip Peripheral Drivers +# +CONFIG_BSP_USING_GPIO=y +CONFIG_BSP_USING_UART=y +# CONFIG_BSP_USING_USART0 is not set +CONFIG_BSP_USING_USART1=y +# CONFIG_BSP_USING_UART0 is not set +# CONFIG_BSP_USING_UART1 is not set +# CONFIG_BSP_USING_SPI is not set +# CONFIG_BSP_USING_I2C is not set + +# +# Board extended module Drivers +# diff --git a/bsp/ht32/ht32f52352/Kconfig b/bsp/ht32/ht32f52352/Kconfig new file mode 100644 index 0000000000..79b160b856 --- /dev/null +++ b/bsp/ht32/ht32f52352/Kconfig @@ -0,0 +1,21 @@ +mainmenu "RT-Thread Configuration" + +config BSP_DIR + string + option env="BSP_ROOT" + default "." + +config RTT_DIR + string + option env="RTT_ROOT" + default "../../.." + +config PKGS_DIR + string + option env="PKGS_ROOT" + default "packages" + +source "$RTT_DIR/Kconfig" +source "$PKGS_DIR/Kconfig" +source "../libraries/Kconfig" +source "board/Kconfig" diff --git a/bsp/ht32/ht32f52352/README.md b/bsp/ht32/ht32f52352/README.md new file mode 100644 index 0000000000..10644a76a4 --- /dev/null +++ b/bsp/ht32/ht32f52352/README.md @@ -0,0 +1,108 @@ +# HT32F52352 BSP 说明 + +## 简介 + +ESK32-30501是合泰基于HT32F52352芯片并针对Cortex®-M0+入门而设计的评估板。本文档是为ESK32-30501开发板提供的BSP(板级支持包)说明。 + +主要内容如下: + +- 开发板资源介绍 +- BSP 快速上手 +- 进阶使用方法 + +通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。 + +## 开发板介绍 + +ESK32-30501使用32位Arm® Cortex®-M0+高性能、低功耗单片机HT32F52352,针对Cortex®-M0+入门而设计。开发板外观如下图所示: + +![board.png](figures/board.png) + +该开发板常用 **板载资源** 如下: + +- MCU:HT32F52352,主频 48MHz,128KB FLASH ,16KB SRAM +- 常用外设 + - LED:2个,(绿色,PC14、PC15) +- 常用接口:USB 转串口 、USB SLAVE +- 调试接口:板载的 e-Link32 Lite SWD 下载 + +开发板更多详细信息请参考合泰官网的相关文档[ESK32-30501](https://www.holtek.com.cn/page/detail/dev_kit/ESK32-30501)。 + +## 外设支持 + +本 BSP 目前对外设的支持情况如下: + +| **板载外设** | **支持情况** | **备注** | +| :--- | :---: | :--- | +| USB 转串口 | 支持 | 使用 USART1 | +| **片上外设** | **支持情况** | **备注** | +| GPIO | 支持 | PA0, PA1...PD3 ---> PIN: 0, 1...51 | +| USART | 支持 | USART0/1 | +| UART | 支持 | UART0/1 | +| SPI | 支持 | SPI0/1 | +| I2C | 支持 | 硬件 I2C0/1 | +| ADC | 暂不支持 | | +| WDT | 暂不支持 | | + +## 使用说明 + +使用说明分为如下两个章节: + +- 快速上手 + + 本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。 + +- 进阶使用 + + 本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多片上资源,实现更多高级功能。 + + +### 快速上手 + +本 BSP 为仅为开发者提供MDK5的工程。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。 + +#### 硬件连接 + +使用数据线通过板载的 e-Link32 Lite将芯片连接到 PC。 + +#### 编译下载 + +双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。 + +> 注:工程默认配置使用CMSIS-DAP下载方式,在通过 e-Link32 Lite 连接开发板的基础上,点击下载按钮即可下载程序到开发板。 + +#### 运行结果 + +下载程序成功之后,系统会自动运行,观察开发板上 LED 的运行效果,LED1和LED2交替闪烁。 + +连接开发板对应串口到 PC(也可以通过e-Link32 Lite的模拟串口将开发板连接到PC), 在终端工具里调整好串口配置(115200-8-1-N)并打开相应的串口,复位设备后,可以看到 RT-Thread 的输出信息: + +> 注:由于RT-Thread的finsh控制台使用的是命令行的输入形式,推荐使用串口调试工具如:Tabby terminal 或者 Tera Term。 + +```bash + \ | / +- RT - Thread Operating System + / | \ 5.1.0 build Apr 10 2024 14:39:43 + 2006 - 2024 Copyright by RT-Thread team +msh > +``` + +### 进阶使用 + +此 BSP 默认只开启了 GPIO 和 USART1 的功能,如果需使用更多的片上资源,需要利用 ENV 工具对BSP 进行配置,步骤如下: + +1. 在 bsp 下打开 env 工具。 + +2. 输入`menuconfig`命令配置工程,配置好之后保存退出。 + +3. 输入`scons --target=mdk5` 命令重新生成工程。 + +## 注意事项 + +开发板和芯片的相关资料可以在[合泰官网](https://www.holtek.com.cn/page/index)进行查找和下载,如芯片的数据手册和开发使用手册、开发板的原理图、Keil_v5的pack安装包等。 + +## 联系人信息 + +维护人: + +- [QT-one](https://github.com/QT-one) \ No newline at end of file diff --git a/bsp/ht32/ht32f52352/SConscript b/bsp/ht32/ht32f52352/SConscript new file mode 100644 index 0000000000..682f94215c --- /dev/null +++ b/bsp/ht32/ht32f52352/SConscript @@ -0,0 +1,15 @@ +# for module compiling +import os #包含os库 +Import('RTT_ROOT') #导入RTT_ROOT对象(RTT_ROOT代表的是RT-Thread源码包) +from building import * #把building模块的所有内容都导入到当前模块中 + +cwd = GetCurrentDir() #获取当前路径,并将该路径信息保存到变量cwd中 +objs = [] #创建一个list型变量objs +list = os.listdir(cwd) #得到当前目录下的所有子目录,并保存到变量list中 + +for d in list: #for循环用d记录循环的次数,直到寻遍所有路径 + path = os.path.join(cwd, d) #根据d获取到不同的路径 + if os.path.isfile(os.path.join(path, 'SConscript')): #如果该路径下存在名为SConscript的文件 + objs = objs + SConscript(os.path.join(d, 'SConscript')) #将路径中SConscript文件内的源码读取到objs中 + +Return('objs') #将objs返回出去 diff --git a/bsp/ht32/ht32f52352/SConstruct b/bsp/ht32/ht32f52352/SConstruct new file mode 100644 index 0000000000..9f16ec63d2 --- /dev/null +++ b/bsp/ht32/ht32f52352/SConstruct @@ -0,0 +1,60 @@ +import os +import sys +import rtconfig + +if os.getenv('RTT_ROOT'): + RTT_ROOT = os.getenv('RTT_ROOT') +else: + RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') + +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +try: + from building import * +except: + print('Cannot found RT-Thread root directory, please check RTT_ROOT') + print(RTT_ROOT) + exit(-1) + +TARGET = 'rt-thread.' + rtconfig.TARGET_EXT + +DefaultEnvironment(tools=[]) +env = Environment(tools = ['mingw'], + AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, + CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, + AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, + LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) +env.PrependENVPath('PATH', rtconfig.EXEC_PATH) + +if rtconfig.PLATFORM == 'iar': + env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES']) + env.Replace(ARFLAGS = ['']) + env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map') + +Export('RTT_ROOT') +Export('rtconfig') + +SDK_ROOT = os.path.abspath('./') + +if os.path.exists(SDK_ROOT + '/libraries'): + libraries_path_prefix = SDK_ROOT + '/libraries' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) + +ht32_library = 'HT32_STD_5xxxx_FWLib' +rtconfig.BSP_LIBRARY_TYPE = ht32_library + +# include libraries +objs.extend(SConscript(os.path.join(libraries_path_prefix, ht32_library, 'SConscript'))) + +# include drivers +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'ht32_drivers', 'SConscript'))) + +# make a building +DoBuilding(TARGET, objs) diff --git a/bsp/ht32/ht32f52352/applications/SConscript b/bsp/ht32/ht32f52352/applications/SConscript new file mode 100644 index 0000000000..9023be657a --- /dev/null +++ b/bsp/ht32/ht32f52352/applications/SConscript @@ -0,0 +1,21 @@ +#导入其他模块的变量 +Import('RTT_ROOT') +Import('rtconfig') + +#导入使用到的模块 +from building import * + +#获取当前目录的路径 +cwd = GetCurrentDir() + +#创建一个列表,用于保存需要使用到的C文件路径 +src = Glob('*c') + +#创建一个列表,用于保存需要包含的H文件路径 +path = [cwd] + +#创建一个组别 +group = DefineGroup('Applications', src, depend = [''], CPPPATH = path) + +#返回创建好的组别 +Return('group') \ No newline at end of file diff --git a/bsp/ht32/ht32f52352/applications/main.c b/bsp/ht32/ht32f52352/applications/main.c new file mode 100644 index 0000000000..3bcf7a1215 --- /dev/null +++ b/bsp/ht32/ht32f52352/applications/main.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include +#include +#include "board.h" + +/* defined the led2 pin: pc14 */ +#define LED1_PIN GET_PIN(C, 14) +/* defined the led3 pin: pc15 */ +#define LED2_PIN GET_PIN(C, 15) + +int main(void) +{ + rt_uint32_t speed = 200; + /* set led1 pin mode to output */ + rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT); + /* set led2 pin mode to output */ + rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT); + + while (1) + { + rt_pin_write(LED1_PIN, PIN_LOW); + rt_pin_write(LED2_PIN, PIN_HIGH); + rt_thread_mdelay(speed); + rt_pin_write(LED1_PIN, PIN_HIGH); + rt_pin_write(LED2_PIN, PIN_LOW); + rt_thread_mdelay(speed); + } +} diff --git a/bsp/ht32/ht32f52352/board/Kconfig b/bsp/ht32/ht32f52352/board/Kconfig new file mode 100644 index 0000000000..b12d8e5626 --- /dev/null +++ b/bsp/ht32/ht32f52352/board/Kconfig @@ -0,0 +1,77 @@ +menu "Hardware Drivers Config" + +config SOC_HT32F52352 + bool + select SOC_SERIES_HT32F5 + select RT_USING_COMPONENTS_INIT + select RT_USING_USER_MAIN + default y + +menu "Onboard Peripheral Drivers" + +endmenu + +menu "On-chip Peripheral Drivers" + + config BSP_USING_GPIO + bool "Enable GPIO" + select RT_USING_PIN + default n + +    menuconfig BSP_USING_UART + bool "Enable UART" + default n + select RT_USING_SERIAL + if BSP_USING_UART + config BSP_USING_USART0 + bool "Enable USART0" + default n + + config BSP_USING_USART1 + bool "Enable USART1" + default n + + config BSP_USING_UART0 + bool "Enable UART0" + default n + + config BSP_USING_UART1 + bool "Enable UART1" + default n +        endif + + menuconfig BSP_USING_SPI + bool "Enable SPI Bus" + default n + select RT_USING_SPI + if BSP_USING_SPI + config BSP_USING_SPI0 + bool "Enable SPI0 Bus" + default n + + config BSP_USING_SPI1 + bool "Enable SPI1 Bus" + default n + endif + + menuconfig BSP_USING_I2C + bool "Enable I2C Bus" + default n + select RT_USING_I2C + if BSP_USING_I2C + config BSP_USING_I2C0 + bool "Enable I2C0 Bus" + default n + + config BSP_USING_I2C1 + bool "Enable I2C1 Bus" + default n + endif + +endmenu + +menu "Board extended module Drivers" + +endmenu + +endmenu diff --git a/bsp/ht32/ht32f52352/board/SConscript b/bsp/ht32/ht32f52352/board/SConscript new file mode 100644 index 0000000000..79eab7eced --- /dev/null +++ b/bsp/ht32/ht32f52352/board/SConscript @@ -0,0 +1,27 @@ + +import os +import rtconfig +from building import * + +Import('SDK_LIB') + +cwd = GetCurrentDir() + +src = Glob('src/*.c') + +startup_path_prefix = SDK_LIB +if rtconfig.CROSS_TOOL == 'gcc': + src += [startup_path_prefix + '/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_01.s'] +elif rtconfig.CROSS_TOOL == 'keil': + src += [startup_path_prefix + '/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_01.s'] +elif rtconfig.CROSS_TOOL == 'iar': + src += [startup_path_prefix + '/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_01.s'] + +path = [cwd] +path = [cwd + '/inc'] + +CPPDEFINES = ['USE_HT32F52352_SK, USE_HT32F52342_52, USE_MEM_HT32F52352'] + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) + +Return('group') \ No newline at end of file diff --git a/bsp/ht32/ht32f52352/board/inc/board.h b/bsp/ht32/ht32f52352/board/inc/board.h new file mode 100644 index 0000000000..91d5c2d0a5 --- /dev/null +++ b/bsp/ht32/ht32f52352/board/inc/board.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __BOARD_H__ +#define __BOARD_H__ + +#include +#include "ht32.h" +#include "ht32_msp.h" + +#ifdef BSP_USING_GPIO + #include "drv_gpio.h" +#endif + +#ifdef BSP_USING_UART + #include "drv_usart.h" +#endif + +#ifdef BSP_USING_SPI + #include "drv_spi.h" +#endif + +#ifdef BSP_USING_I2C + #include "drv_i2c.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* whether use board external SRAM memory */ +#define HT32_EXT_SRAM 0 +#define HT32_EXT_SRAM_BEGIN 0x68000000 +#define HT32_EXT_SRAM_END (HT32_EXT_SRAM_BEGIN + HT32_EXT_SRAM*1024) + +/* internal sram memory size */ +#define HT32_SRAM_END (0x20000000 + LIBCFG_RAM_SIZE) + +#ifdef __CC_ARM +extern int Image$$RW_IRAM1$$ZI$$Limit; +#define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit) +#elif __ICCARM__ +#pragma section="HEAP" +#define HEAP_BEGIN (__segment_end("HEAP")) +#else +extern int __bss_end; +#define HEAP_BEGIN ((void *)&__bss_end) +#endif +#define HEAP_END HT32_SRAM_END + +void rt_hw_board_clock_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __BOARD_H__ */ diff --git a/bsp/ht32/ht32f52352/board/inc/ht32_msp.h b/bsp/ht32/ht32f52352/board/inc/ht32_msp.h new file mode 100644 index 0000000000..066add8d56 --- /dev/null +++ b/bsp/ht32/ht32f52352/board/inc/ht32_msp.h @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __HT32_MSP_H__ +#define __HT32_MSP_H__ + +#include +#include "ht32.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* UART gpio */ +#ifdef BSP_USING_UART +#ifdef BSP_USING_USART0 +#define HTCFG_USART0_IPN USART0 + +#define _HTCFG_USART0_TX_GPIOX A +#define _HTCFG_USART0_TX_GPION 2 +#define _HTCFG_USART0_RX_GPIOX A +#define _HTCFG_USART0_RX_GPION 3 + +#define HTCFG_USART0_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART0_TX_GPIOX) +#define HTCFG_USART0_TX_GPIO_CLK STRCAT2(P, _HTCFG_USART0_TX_GPIOX) +#define HTCFG_USART0_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART0_TX_GPIOX) +#define HTCFG_USART0_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART0_TX_GPION) + +#define HTCFG_USART0_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART0_RX_GPIOX) +#define HTCFG_USART0_RX_GPIO_CLK STRCAT2(P, _HTCFG_USART0_RX_GPIOX) +#define HTCFG_USART0_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART0_RX_GPIOX) +#define HTCFG_USART0_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART0_RX_GPION) + +#endif +#ifdef BSP_USING_USART1 + +#define HTCFG_USART1_IPN USART1 + +#define _HTCFG_USART1_TX_GPIOX A +#define _HTCFG_USART1_TX_GPION 4 +#define _HTCFG_USART1_RX_GPIOX A +#define _HTCFG_USART1_RX_GPION 5 + +#define HTCFG_USART1_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART1_TX_GPIOX) +#define HTCFG_USART1_TX_GPIO_CLK STRCAT2(P, _HTCFG_USART1_TX_GPIOX) +#define HTCFG_USART1_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART1_TX_GPIOX) +#define HTCFG_USART1_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART1_TX_GPION) + +#define HTCFG_USART1_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_USART1_RX_GPIOX) +#define HTCFG_USART1_RX_GPIO_CLK STRCAT2(P, _HTCFG_USART1_RX_GPIOX) +#define HTCFG_USART1_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_USART1_RX_GPIOX) +#define HTCFG_USART1_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_USART1_RX_GPION) + +#endif +#ifdef BSP_USING_UART0 + +#define HTCFG_UART0_IPN UART0 + +#define _HTCFG_UART0_TX_GPIOX B +#define _HTCFG_UART0_TX_GPION 2 +#define _HTCFG_UART0_RX_GPIOX B +#define _HTCFG_UART0_RX_GPION 3 + +#define HTCFG_UART0_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART0_TX_GPIOX) +#define HTCFG_UART0_TX_GPIO_CLK STRCAT2(P, _HTCFG_UART0_TX_GPIOX) +#define HTCFG_UART0_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART0_TX_GPIOX) +#define HTCFG_UART0_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART0_TX_GPION) + +#define HTCFG_UART0_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART0_RX_GPIOX) +#define HTCFG_UART0_RX_GPIO_CLK STRCAT2(P, _HTCFG_UART0_RX_GPIOX) +#define HTCFG_UART0_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART0_RX_GPIOX) +#define HTCFG_UART0_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART0_RX_GPION) + +#endif +#ifdef BSP_USING_UART1 + +#define HTCFG_UART1_IPN UART1 + +#define _HTCFG_UART1_TX_GPIOX B +#define _HTCFG_UART1_TX_GPION 4 +#define _HTCFG_UART1_RX_GPIOX B +#define _HTCFG_UART1_RX_GPION 5 + +#define HTCFG_UART1_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART1_TX_GPIOX) +#define HTCFG_UART1_TX_GPIO_CLK STRCAT2(P, _HTCFG_UART1_TX_GPIOX) +#define HTCFG_UART1_TX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART1_TX_GPIOX) +#define HTCFG_UART1_TX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART1_TX_GPION) + +#define HTCFG_UART1_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART1_RX_GPIOX) +#define HTCFG_UART1_RX_GPIO_CLK STRCAT2(P, _HTCFG_UART1_RX_GPIOX) +#define HTCFG_UART1_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART1_RX_GPIOX) +#define HTCFG_UART1_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART1_RX_GPION) + +#endif +#endif + +/* SPI gpio */ +#ifdef BSP_USING_SPI +#ifdef BSP_USING_SPI0 + +#define HTCFG_SPI0_IPN SPI0 + +#define _HTCFG_SPI0_SCK_GPIOX C +#define _HTCFG_SPI0_SCK_GPION 0 + +#define _HTCFG_SPI0_MISO_GPIOX A +#define _HTCFG_SPI0_MISO_GPION 11 + +#define _HTCFG_SPI0_MOSI_GPIOX A +#define _HTCFG_SPI0_MOSI_GPION 9 + +#define HTCFG_SPI0_SCK_GPIO_CLK STRCAT2(P, _HTCFG_SPI0_SCK_GPIOX) +#define HTCFG_SPI0_SCK_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI0_SCK_GPIOX) +#define HTCFG_SPI0_SCK_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI0_SCK_GPION) + +#define HTCFG_SPI0_MISO_GPIO_CLK STRCAT2(P, _HTCFG_SPI0_MISO_GPIOX) +#define HTCFG_SPI0_MISO_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI0_MISO_GPIOX) +#define HTCFG_SPI0_MISO_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI0_MISO_GPION) + +#define HTCFG_SPI0_MOSI_GPIO_CLK STRCAT2(P, _HTCFG_SPI0_MOSI_GPIOX) +#define HTCFG_SPI0_MOSI_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI0_MOSI_GPIOX) +#define HTCFG_SPI0_MOSI_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI0_MOSI_GPION) + +#endif +#ifdef BSP_USING_SPI1 + +#define HTCFG_SPI1_IPN SPI1 + +#define _HTCFG_SPI1_SCK_GPIOX A +#define _HTCFG_SPI1_SCK_GPION 15 + +#define _HTCFG_SPI1_MISO_GPIOX B +#define _HTCFG_SPI1_MISO_GPION 1 + +#define _HTCFG_SPI1_MOSI_GPIOX B +#define _HTCFG_SPI1_MOSI_GPION 0 + +#define HTCFG_SPI1_SCK_GPIO_CLK STRCAT2(P, _HTCFG_SPI1_SCK_GPIOX) +#define HTCFG_SPI1_SCK_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI1_SCK_GPIOX) +#define HTCFG_SPI1_SCK_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI1_SCK_GPION) + +#define HTCFG_SPI1_MISO_GPIO_CLK STRCAT2(P, _HTCFG_SPI1_MISO_GPIOX) +#define HTCFG_SPI1_MISO_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI1_MISO_GPIOX) +#define HTCFG_SPI1_MISO_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI1_MISO_GPION) + +#define HTCFG_SPI1_MOSI_GPIO_CLK STRCAT2(P, _HTCFG_SPI1_MOSI_GPIOX) +#define HTCFG_SPI1_MOSI_GPIO_ID STRCAT2(GPIO_P, _HTCFG_SPI1_MOSI_GPIOX) +#define HTCFG_SPI1_MOSI_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_SPI1_MOSI_GPION) + +#endif +#endif + +/* I2C gpio */ +#ifdef BSP_USING_I2C +#ifdef BSP_USING_I2C0 + +#define HTCFG_I2C0_IPN I2C0 + +#define _HTCFG_I2C0_SCL_GPIOX C +#define _HTCFG_I2C0_SCL_GPION 12 + +#define _HTCFG_I2C0_SDA_GPIOX C +#define _HTCFG_I2C0_SDA_GPION 13 + +#define HTCFG_I2C0_SCL_GPIO_CLK STRCAT2(P, _HTCFG_I2C0_SCL_GPIOX) +#define HTCFG_I2C0_SCL_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C0_SCL_GPIOX) +#define HTCFG_I2C0_SCL_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C0_SCL_GPION) + +#define HTCFG_I2C0_SDA_GPIO_CLK STRCAT2(P, _HTCFG_I2C0_SDA_GPIOX) +#define HTCFG_I2C0_SDA_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C0_SDA_GPIOX) +#define HTCFG_I2C0_SDA_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C0_SDA_GPION) + +#endif +#ifdef BSP_USING_I2C1 + +#define HTCFG_I2C1_IPN I2C1 + +#define _HTCFG_I2C1_SCL_GPIOX A +#define _HTCFG_I2C1_SCL_GPION 0 + +#define _HTCFG_I2C1_SDA_GPIOX A +#define _HTCFG_I2C1_SDA_GPION 1 + +#define HTCFG_I2C1_SCL_GPIO_CLK STRCAT2(P, _HTCFG_I2C1_SCL_GPIOX) +#define HTCFG_I2C1_SCL_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C1_SCL_GPIOX) +#define HTCFG_I2C1_SCL_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C1_SCL_GPION) + +#define HTCFG_I2C1_SDA_GPIO_CLK STRCAT2(P, _HTCFG_I2C1_SDA_GPIOX) +#define HTCFG_I2C1_SDA_GPIO_ID STRCAT2(GPIO_P, _HTCFG_I2C1_SDA_GPIOX) +#define HTCFG_I2C1_SDA_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_I2C1_SDA_GPION) + +#endif +#endif + +void ht32_usart_gpio_init(void *instance); +void ht32_spi_gpio_init(void *instance); +void ht32_i2c_gpio_init(void *instance); + +#ifdef __cplusplus +} +#endif + +#endif /* __HT32_MSP_H__ */ diff --git a/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_01_usbdconf.h b/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_01_usbdconf.h new file mode 100644 index 0000000000..a512579519 --- /dev/null +++ b/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_01_usbdconf.h @@ -0,0 +1,453 @@ +/*********************************************************************************************************//** + * @file IP/Example/ht32f5xxxx_01_usbdconf.h + * @version $Rev:: 2390 $ + * @date $Date:: 2017-12-21 #$ + * @brief The configuration file of USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_01_USBDCONF_H +#define __HT32F5XXXX_01_USBDCONF_H + +// Enter Low Power mode when Suspended +#define USBDCORE_ENABLE_LOW_POWER (0) +// + +#if (USBDCORE_ENABLE_LOW_POWER == 1) + #define USBDCore_LowPower() PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_WFE) +#else + #define USBDCore_LowPower(...) +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Interrupt Enable */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Interrupt Setting (UIER) +// USB Global Interrupt Enable (UGIE) (Default) +// Start Of Frame Interrupt Enable (SOFIE) +// USB Reset Interrupt Enable (URSTIE) (Default) +// Resume Interrupt Enable (RSMIE) (Default) +// Suspend Interrupt Enable (SUSPIE) (Default) +// Expected Start of Frame Interrupt Enable (ESOFE) +// Control Endpoint Interrupt Enable (EP0IE) (Default) +// Endpoint1 Interrupt Enable (EP1IE) +// Endpoint2 Interrupt Enable (EP2IE) +// Endpoint3 Interrupt Enable (EP3IE) +// Endpoint4 Interrupt Enable (EP4IE) +// Endpoint5 Interrupt Enable (EP5IE) +// Endpoint6 Interrupt Enable (EP6IE) +// Endpoint7 Interrupt Enable (EP7IE) +#define _UIER (0x011D) +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Control Endpoint0 Configuration +// Endpoint Buffer Length (EPLEN) +// <8=> 8 bytes +// <16=> 16 bytes +// <32=> 32 bytes +// <64=> 64 bytes + /* Maximum: 64 Bytes */ +#define _EP0LEN (64) + + +// Control Endpoint0 Interrupt Enable Settings (EP0IER) +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) (Default) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) (Default) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +// SETUP Token Packet Received Interrupt Enable (STRXIE) +// SETUP Data Packet Received Interrupt Enable (SDRXIE) (Default) +// SETUP Data Error Interrupt Enable (SDERIE) +// Zero Length Data Packet Received Interrupt Enable (ZLRXIE) +#define _EP0_IER (0x212) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint1 Configuration +#define _EP1_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP1_CFG_EPADR (1) + +// Endpoint Enable (EPEN) +#define _EP1_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP1_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP1_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP1LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP1_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint2 Configuration +#define _EP2_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP2_CFG_EPADR (2) + +// Endpoint Enable (EPEN) +#define _EP2_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP2_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP2_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP2LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP2_IER (0x002) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint3 Configuration +#define _EP3_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP3_CFG_EPADR (3) + +// Endpoint Enable (EPEN) +#define _EP3_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP3_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP3_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP3LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP3_IER (0x10) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint4 Configuration +#define _EP4_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP4_CFG_EPADR (4) + +// Endpoint Enable (EPEN) +#define _EP4_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP4_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP4_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP4LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP4_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP4_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint5 Configuration +#define _EP5_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP5_CFG_EPADR (5) + +// Endpoint Enable (EPEN) +#define _EP5_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP5_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP5_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP5LEN_TMP (8) + + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP5_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP5_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint6 Configuration +#define _EP6_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP6_CFG_EPADR (6) + +// Endpoint Enable (EPEN) +#define _EP6_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP6_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP6_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP6LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP6_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP6_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint7 Configuration +#define _EP7_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP7_CFG_EPADR (7) + +// Endpoint Enable (EPEN) +#define _EP7_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP7_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP7_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP7LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP7_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP7_IER (0x10) +// +// + +#endif diff --git a/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_02_usbdconf.h b/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_02_usbdconf.h new file mode 100644 index 0000000000..272e8cd127 --- /dev/null +++ b/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_02_usbdconf.h @@ -0,0 +1,569 @@ +/*********************************************************************************************************//** + * @file IP/Example/ht32f5xxxx_02_usbdconf.h + * @version $Rev:: 5656 $ + * @date $Date:: 2021-11-24 #$ + * @brief The configuration file of USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_02_USBDCONF_H +#define __HT32F5XXXX_02_USBDCONF_H + +// Enter Low Power mode when Suspended +#define USBDCORE_ENABLE_LOW_POWER (0) +// + +#if (USBDCORE_ENABLE_LOW_POWER == 1) + #define USBDCore_LowPower() PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_WFE) +#else + #define USBDCore_LowPower(...) +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Interrupt Enable */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Interrupt Setting (UIER) +// USB Global Interrupt Enable (UGIE) (Default) +// Start Of Frame Interrupt Enable (SOFIE) +// USB Reset Interrupt Enable (URSTIE) (Default) +// Resume Interrupt Enable (RSMIE) (Default) +// Suspend Interrupt Enable (SUSPIE) (Default) +// Expected Start of Frame Interrupt Enable (ESOFE) +// Control Endpoint Interrupt Enable (EP0IE) (Default) +// Endpoint1 Interrupt Enable (EP1IE) +// Endpoint2 Interrupt Enable (EP2IE) +// Endpoint3 Interrupt Enable (EP3IE) +// Endpoint4 Interrupt Enable (EP4IE) +// Endpoint5 Interrupt Enable (EP5IE) +// Endpoint6 Interrupt Enable (EP6IE) +// Endpoint7 Interrupt Enable (EP7IE) +// Endpoint8 Interrupt Enable (EP8IE) +// Endpoint9 Interrupt Enable (EP9IE) +#define _UIER (0x011D) +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Control Endpoint0 Configuration +// Endpoint Buffer Length (EPLEN) +// <8=> 8 bytes +// <16=> 16 bytes +// <32=> 32 bytes +// <64=> 64 bytes + /* Maximum: 64 Bytes */ +#define _EP0LEN (64) + + +// Control Endpoint0 Interrupt Enable Settings (EP0IER) +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) (Default) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) (Default) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +// SETUP Token Packet Received Interrupt Enable (STRXIE) +// SETUP Data Packet Received Interrupt Enable (SDRXIE) (Default) +// SETUP Data Error Interrupt Enable (SDERIE) +// Zero Length Data Packet Received Interrupt Enable (ZLRXIE) +#define _EP0_IER (0x212) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint1 Configuration +#define _EP1_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP1_CFG_EPADR (1) + +// Endpoint Enable (EPEN) +#define _EP1_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP1_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP1_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP1LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP1_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint2 Configuration +#define _EP2_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP2_CFG_EPADR (2) + +// Endpoint Enable (EPEN) +#define _EP2_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP2_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP2_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP2LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP2_IER (0x002) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint3 Configuration +#define _EP3_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP3_CFG_EPADR (3) + +// Endpoint Enable (EPEN) +#define _EP3_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP3_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP3_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP3LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP3_IER (0x10) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint4 Configuration +#define _EP4_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP4_CFG_EPADR (4) + +// Endpoint Enable (EPEN) +#define _EP4_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP4_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP4_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP4LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP4_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP4_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint5 Configuration +#define _EP5_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP5_CFG_EPADR (5) + +// Endpoint Enable (EPEN) +#define _EP5_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP5_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP5_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP5LEN_TMP (8) + + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP5_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP5_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint6 Configuration +#define _EP6_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP6_CFG_EPADR (6) + +// Endpoint Enable (EPEN) +#define _EP6_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP6_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP6_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP6LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP6_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP6_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint7 Configuration +#define _EP7_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP7_CFG_EPADR (7) + +// Endpoint Enable (EPEN) +#define _EP7_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP7_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP7_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP7LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP7_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP7_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint8 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint8 Configuration +#define _EP8_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP8_CFG_EPADR (8) + +// Endpoint Enable (EPEN) +#define _EP8_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP8_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP8_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP8LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP8_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint9 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint9 Configuration +#define _EP9_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +// <8=> 8 +// <9=> 9 +#define _EP9_CFG_EPADR (9) + +// Endpoint Enable (EPEN) +#define _EP9_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP9_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP9_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP9LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP9_IER (0x10) +// +// + +#endif diff --git a/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_conf.h b/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_conf.h new file mode 100644 index 0000000000..c78b9bb75d --- /dev/null +++ b/bsp/ht32/ht32f52352/board/inc/ht32f5xxxx_conf.h @@ -0,0 +1,556 @@ +/*********************************************************************************************************//** + * @file IP/Example/ht32f5xxxx_conf.h + * @version $Rev:: 7109 $ + * @date $Date:: 2023-08-10 #$ + * @brief Library configuration file. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +//-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_CONF_H +#define __HT32F5XXXX_CONF_H + +/* Exported constants --------------------------------------------------------------------------------------*/ + +#define RETARGET_USB 1 +#define RETARGET_SYSLOG 2 +#define RETARGET_COM1 10 +#define RETARGET_COM2 11 +#define RETARGET_USART0 12 +#define RETARGET_USART1 13 +#define RETARGET_UART0 14 +#define RETARGET_UART1 15 +#define RETARGET_UART2 16 +#define RETARGET_UART3 17 + + +/* Retarget settings of the C standard I/O library functions (printf, scanf, getchar, ...etc.) */ +/* +// Enable Retarget +// Retarget Port +// <1=> USB Virtual COM +// <2=> Syslog +// <10=> COM1 +// <11=> COM2 +// <12=> USART0 +// <13=> USART1 +// <14=> UART0 +// <15=> UART1 +// <16=> UART2 +// <17=> UART3 +// Enable Auto Return +// Auto Return function adds "\r" before "\n" automatically when print message by Retarget. +*/ +#define _RETARGET 1 +#define RETARGET_PORT 10 +#define _AUTO_RETURN 0 + +#ifndef AUTO_RETURN +#if (_AUTO_RETURN == 1) +#define AUTO_RETURN +#endif +#endif + +/* Enable Interrupt Mode for UxART Retarget +// Retarget COM/UxART Setting +// UxART Baudrate +// Enable Interrupt Mode for UxART Tx Retarget +// Define UxARTn_IRQHandler By Retarget (ht32_serial.c) +// Disable (RETARGET_DEFINE_HANDLER = 0) if application already have UxARTn_IRQHandler. +// RETARGET_UART_IRQHandler() shall be called by UxARTn_IRQHandler when disable. +// Tx Buffer Length (in byte) +// +*/ +#define RETARGET_UxART_BAUDRATE 115200 +#define RETARGET_INT_MODE 0 +#define RETARGET_DEFINE_HANDLER 1 +#define RETARGET_INT_BUFFER_SIZE 64 + +#if (_RETARGET == 1) +#if (RETARGET_PORT == RETARGET_USB) + #define RETARGET_IS_USB +// Retarget USB Virtual COM Setting +// Communication (Interrupt IN) +// <1=> Endpoint 1 +// <2=> Endpoint 2 +// <3=> Endpoint 3 +// <4=> Endpoint 4 +// <5=> Endpoint 5 +// <6=> Endpoint 6 +// <7=> Endpoint 7 +// Data Rx (Bulk OUT) +// <1=> Endpoint 1 +// <2=> Endpoint 2 +// <3=> Endpoint 3 +// <4=> Endpoint 4 +// <5=> Endpoint 5 +// <6=> Endpoint 6 +// <7=> Endpoint 7 +// Data Tx (Bulk IN) +// <1=> Endpoint 1 +// <2=> Endpoint 2 +// <3=> Endpoint 3 +// <4=> Endpoint 4 +// <5=> Endpoint 5 +// <6=> Endpoint 6 +// <7=> Endpoint 7 +// Communication Endpoint Buffer Length (in byte) <4-64:4> +// Data Rx Endpoint Buffer Length (in byte) <4-64:4> +// Data Tx Endpoint Buffer Length (in byte) <4-64:4> +// Rx Buffer Length (in byte) <64-1024:4> +// Tx Buffer Length (in byte) <1-63:1> +// Please use "SERIAL_Flush()" to sent out the buffer data immediately when Tx Buffer Length > 1. +// USB Tx Mode (BULK IN) +// <0=> Block Mode (Wait until both USB and terminal software are ready) +// <1=> Non-Block Mode (Drop data if USB or terminal software is not ready) +// Enable HSI Auto Trim By USB Function +// Need turn on if the USB clock source is from HSI (PLL USBPLL clock Source). + #define RETARGET_CTRL_EPT (5) + #define RETARGET_RX_EPT (6) + #define RETARGET_TX_EPT (7) + #define RETARGET_CTRL_EPTLEN (8) + #define RETARGET_RX_EPTLEN (64) + #define RETARGET_TX_EPTLEN (64) + #define RETARGET_BUFFER_SIZE (64) + #define RETARGET_TXBUFFER_SIZE (1) // Use "SERIAL_Flush()" to sent out the buffer data immediately when Tx Buffer Length > 1. + #define RETARGET_USB_MODE (0) + #define RETARGET_HSI_ATM (1) +// +#elif (RETARGET_PORT == RETARGET_COM1) + #define RETARGET_COM_PORT COM1 + #define RETARGET_USART_PORT COM1_PORT + #define RETARGET_UART_IRQn COM1_IRQn + #define RETARGET_UART_IRQHandler COM1_IRQHandler + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_COM2) + #define RETARGET_COM_PORT COM2 + #define RETARGET_USART_PORT COM2_PORT + #define RETARGET_UART_IRQn COM2_IRQn + #define RETARGET_UART_IRQHandler COM2_IRQHandler + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_USART0) + #define RETARGET_UxART_IPN USART0 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_USART1) + #define RETARGET_UxART_IPN USART1 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_UART0) + #define RETARGET_UxART_IPN UART0 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_UART1) + #define RETARGET_UxART_IPN UART1 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_UART2) + #define RETARGET_UxART_IPN UART2 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#elif (RETARGET_PORT == RETARGET_UART3) + #define RETARGET_UxART_IPN UART3 + #define RETARGET_USART_PORT STRCAT2(HT_, RETARGET_UxART_IPN) + #define RETARGET_UART_IRQn STRCAT2(RETARGET_UxART_IPN, _IRQn) + #define RETARGET_UART_IRQHandler STRCAT2(RETARGET_UxART_IPN, _IRQHandler) + #define RETARGET_IS_UART +#endif + extern void RETARGET_Configuration(void); +#else + #define RETARGET_Configuration(...) + #undef printf + #undef getchar + #define printf(...) + #define getchar() (0) +#endif + +#if (RETARGET_DEFINE_HANDLER == 0) +#undef RETARGET_UART_IRQHandler +#endif + +/* +// Enable HT32 Time Function +// Provide "Time_GetTick()" and "Time_Dealy()" functions. + +// Timer Selection +// <0=> BFTM0 +// <1=> BFTM1 +// <2=> SCTM0 +// <3=> SCTM1 +// <4=> SCTM2 +// <5=> SCTM3 +// <6=> PWM0 +// <7=> PWM1 +// <8=> PWM2 +// <9=> GPTM0 +// <10=> GPTM1 +// <11=> MCTM0 + +// Timer Clock Setting +// +// Timer Clock = (Core Clock) / (APB Peripheral Clock Prescaler) +// HTCFG_TIME_CLKSRC = _HTCFG_TIME_CORECLK / (2^HTCFG_TIME_PCLK_DIV) +// _HTCFG_TIME_CORECLK = LIBCFG_MAX_SPEED or HTCFG_TIME_CLK_MANUAL (selected by HTCFG_TIME_CLKSEL) + +// -- Core Clock Setting (CK_AHB) +// HTCFG_TIME_CLKSEL +// 0 = Default Maximum (LIBCFG_MAX_SPEED) +// 1 = Manual Input (HTCFG_TIME_CLK_MANUAL) +// <0=> Default Maximum (LIBCFG_MAX_SPEED) +// <1=> Manual Input (HTCFG_TIME_CLK_MANUAL) + +// -- Core Clock Manual Input (Hz) +// HTCFG_TIME_CLK_MANUAL +// Only meaningful when Core Clock Setting (HTCFG_TIME_CLKSEL) = Manual Input (1) + +// -- APB Peripheral Clock Prescaler +// HTCFG_TIME_PCLK_DIV +// <0=> /1 +// <1=> /2 +// <2=> /4 +// <3=> /8 + +// Time Tick (Hz, not applicable for BFTM) <1-1000000:100> +// Not applicable for BFTM, fixed TICKHZ to HTCFG_TIME_CLKSRC for BFTM. +*/ +#if (0) // Enable HT32 Time Function +#define HTCFG_TIME_IPSEL (0) +#define HTCFG_TIME_CLKSEL (0) // 0 = Default Maximum (LIBCFG_MAX_SPEED), 1 = Manual Input (HTCFG_TIME_CLKSRC) +#define HTCFG_TIME_CLK_MANUAL (20000000) // Only meaningful when HTCFG_TIME_CLKSEL = 1 (Manual Input) +#define HTCFG_TIME_PCLK_DIV (0) // 0 ~ 3. (/1, /2, /4, /8) +#define HTCFG_TIME_TICKHZ (1000) // Hz, not applicable for BFTM, fixed TICKHZ to HTCFG_TIME_CLKSRC for BFTM +#define HTCFG_TIME_MULTIPLE (1) // MUST be 1, 2, 4, 8. TICK = COUNT / MULTIPLE. Not applicable for BFTM. +/* + + Timer Clock = (Core Clock) / (APB Peripheral Clock Prescaler) + HTCFG_TIME_CLKSRC = (_HTCFG_TIME_CORECLK) / (2^HTCFG_TIME_PCLK_DIV) + where _HTCFG_TIME_CORECLK can be LIBCFG_MAX_SPEED or HTCFG_TIME_CLK_MANUAL (selected by HTCFG_TIME_CLKSEL) + + Tick Range: 0 ~ 2^32 / HTCFG_TIME_TICKHZ (maximum tick time) + Interrupt Time: _HTCFG_TIME_OVERFLOW_VALUE / (HTCFG_TIME_TICKHZ * HTCFG_TIME_MULTIPLE) Second + (Interrupt Time is not applicable for BFTM) + + Example: 32-bit BFTM with 48 MHz Timer Clock + HTCFG_TIME_TICKHZ = HTCFG_TIME_CLKSRC = 48000000 + Tick Range: 0 ~ 2^32 / 48000000 = 0 ~ 89.478485 Second (maximum tick time, return to 0 every 89.478485 Second) + BFTM do not use interrupt + + Example: 16-bit GPTM with 1 ms tick + HTCFG_TIME_TICKHZ = 1000 (Hz) + HTCFG_TIME_MULTIPLE = 1 (1 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 1000 = 0 ~ 4294967 Second = 0 ~ 49.7 Day (maximum tick time, return to 0 every 49.7 Day) + Interrupt Time: 65536 / (1000 * 1) = 65.536 Second (Trigger interrupt every 65.536 Second) +*/ +#endif +/* +// +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file (this file). +*/ +/* +// Enable User Define HSE Value +// Enable user define HSE value to overwrite default "HSE_VALUE" define in "ht32fxxxxx_nn.h". +// HSE Value (Hz) +*/ +#if (0) +#define HSE_VALUE 16000000 +#endif +/* +// +*/ + +/* +// Enable CKOUT Function +*/ +#define ENABLE_CKOUT 0 + +/* +// Enable Get CK_ADC of "CKCU_GetClocksFrequency()" +// Enable ADC0_Freq and ADC1_Freq of the "CKCU_GetClocksFrequency()" function. It required the division calculation (by C Library) and increased the code size. +*/ +#define HT32_LIB_ENABLE_GET_CK_ADC 0 + +/* The DEBUG definition to enter debug mode for library */ +/* +// Library Debug Mode +*/ +#define HT32_LIB_DEBUG 0 + + +/* Enable/disable the specific peripheral inclusion */ + +// Library Inclusion Configuration +/* ADC -----------------------------------------------------------------------------------------------------*/ +/* +// ADC Library +*/ +#define _ADC 1 + +/* AES -----------------------------------------------------------------------------------------------------*/ +/* +// AES Library +*/ +#define _AES 1 + +/* BFTM ----------------------------------------------------------------------------------------------------*/ +/* +// BFTM Library +*/ +#define _BFTM 1 + +/* CAN -----------------------------------------------------------------------------------------------------*/ +/* +// CAN Library +*/ +#define _CAN 1 + +/* Clock Control -------------------------------------------------------------------------------------------*/ +/* +// Clock Control Library +*/ +#define _CKCU 1 + +/* Comparator ----------------------------------------------------------------------------------------------*/ +/* +// Comparator Library +*/ +#define _CMP 1 + +/* CRC -----------------------------------------------------------------------------------------------------*/ +/* +// CRC Library +*/ +#define _CRC 1 + +/* DAC -----------------------------------------------------------------------------------------------------*/ +/* +// DAC Library +*/ +#define _DAC 1 + +/* DAC Dual 16-bit -----------------------------------------------------------------------------------------*/ +/* +// DAC_Dual16 Library +*/ +#define _DAC_DUAL16 1 + +/* DIV -----------------------------------------------------------------------------------------------------*/ +/* +// DIV Library +*/ +#define _DIV 1 + +/* EBI -----------------------------------------------------------------------------------------------------*/ +/* +// EBI Library +*/ +#define _EBI 1 + +/* EXTI ----------------------------------------------------------------------------------------------------*/ +/* +// EXTI Library +*/ +#define _EXTI 1 + +/* Flash ---------------------------------------------------------------------------------------------------*/ +/* +// Flash Library +*/ +#define _FLASH 1 + +/* GPIO ----------------------------------------------------------------------------------------------------*/ +/* +// GPIO Library +*/ +#define _GPIO 1 + +/* GPTM ----------------------------------------------------------------------------------------------------*/ +/* +// GPTM Library +*/ +#define _GPTM 1 + +/* I2C -----------------------------------------------------------------------------------------------------*/ +/* +// I2C Library +*/ +#define _I2C 1 + +/* I2S -----------------------------------------------------------------------------------------------------*/ +/* +// I2S Library +*/ +#define _I2S 1 + +/* LCD -----------------------------------------------------------------------------------------------------*/ +/* +// LCD Library +*/ +#define _LCD 1 + +/* LEDC ----------------------------------------------------------------------------------------------------*/ +/* +// LEDC Library +*/ +#define _LEDC 1 + +/* MCTM ----------------------------------------------------------------------------------------------------*/ +/* +// MCTM Library +*/ +#define _MCTM 1 + +/* MIDI ----------------------------------------------------------------------------------------------------*/ +/* +// MIDI Library +*/ +#define _MIDI 1 + +/* OPA -----------------------------------------------------------------------------------------------------*/ +/* +// OPA +*/ +#define _OPA 1 + +/* PDMA ----------------------------------------------------------------------------------------------------*/ +/* +// PDMA Library +*/ +#define _PDMA 1 + +/* PWM -----------------------------------------------------------------------------------------------------*/ +/* +// PWM Library +*/ +#define _PWM 1 + +/* PWRCU ---------------------------------------------------------------------------------------------------*/ +/* +// PWRCU Library +*/ +#define _PWRCU 1 + +/* RSTCU ---------------------------------------------------------------------------------------------------*/ +/* +// RSTCU Library +*/ +#define _RSTCU 1 + +/* RTC -----------------------------------------------------------------------------------------------------*/ +/* +// RTC Library +*/ +#define _RTC 1 + +/* SCI -----------------------------------------------------------------------------------------------------*/ +/* +// SCI Library +*/ +#define _SCI 1 + +/* SCTM ----------------------------------------------------------------------------------------------------*/ +/* +// SCTM Library +*/ +#define _SCTM 1 + +/* SLED ----------------------------------------------------------------------------------------------------*/ +/* +// SLED Library +*/ +#define _SLED 1 + +/* SPI -----------------------------------------------------------------------------------------------------*/ +/* +// SPI Library +*/ +#define _SPI 1 + +/* TKEY ----------------------------------------------------------------------------------------------------*/ +/* +// TKEY Library +*/ +#define _TKEY 1 + +/* USART ---------------------------------------------------------------------------------------------------*/ +/* +// USART/UART Library +*/ +#define _USART 1 + +/* USBD ----------------------------------------------------------------------------------------------------*/ +/* +// USB Library +*/ +#define _USB 1 + +/* WDT -----------------------------------------------------------------------------------------------------*/ +/* +// WDT Library +*/ +#define _WDT 1 + +/* Misc ----------------------------------------------------------------------------------------------------*/ +/* +// Misc Library +*/ +#define _MISC 1 + +/* Serial --------------------------------------------------------------------------------------------------*/ +/* +// Serial Library +*/ +#define _SERIAL 1 + +/* Software DIV --------------------------------------------------------------------------------------------*/ +/* +// Software Divider Library +*/ +#define _SWDIV 1 + +/* Software Random Number ----------------------------------------------------------------------------------*/ +/* +// Software Random Number Library +*/ +#define _SWRAND 1 + + +// + +#endif diff --git a/bsp/ht32/ht32f52352/board/linker_scripts/link.icf b/bsp/ht32/ht32f52352/board/linker_scripts/link.icf new file mode 100644 index 0000000000..65c2bfc8b7 --- /dev/null +++ b/bsp/ht32/ht32f52352/board/linker_scripts/link.icf @@ -0,0 +1,28 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x08000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x08000000; +define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF; +define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM_end__ = 0x20017FFF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x0400; +define symbol __ICFEDIT_size_heap__ = 0x0000; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_region { readonly }; +place in RAM_region { readwrite, last block CSTACK}; \ No newline at end of file diff --git a/bsp/ht32/ht32f52352/board/linker_scripts/link.lds b/bsp/ht32/ht32f52352/board/linker_scripts/link.lds new file mode 100644 index 0000000000..27269dd77e --- /dev/null +++ b/bsp/ht32/ht32f52352/board/linker_scripts/link.lds @@ -0,0 +1,156 @@ +/* + * linker script for AT32 with GNU ld + */ + +/* Program Entry, set to mark it as "used" and avoid gc */ +MEMORY +{ + ROM (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */ + RAM (rw) : ORIGIN = 0x20000000, LENGTH = 96k /* 96K sram */ +} +ENTRY(Reset_Handler) +_system_stack_size = 0x200; + +SECTIONS +{ + .text : + { + . = ALIGN(4); + _stext = .; + KEEP(*(.isr_vector)) /* Startup code */ + + . = ALIGN(4); + *(.text) /* remaining code */ + *(.text.*) /* remaining code */ + *(.rodata) /* read-only data (constants) */ + *(.rodata*) + *(.glue_7) + *(.glue_7t) + *(.gnu.linkonce.t*) + + /* section information for finsh shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + + /* section information for initial. */ + . = ALIGN(4); + __rt_init_start = .; + KEEP(*(SORT(.rti_fn*))) + __rt_init_end = .; + + . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + + _etext = .; + } > ROM = 0 + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + + /* This is used by the startup in order to initialize the .data secion */ + _sidata = .; + } > ROM + __exidx_end = .; + + /* .data section which is used for initialized data */ + + .data : AT (_sidata) + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _sdata = . ; + + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _edata = . ; + } >RAM + + .stack : + { + . = ALIGN(4); + _sstack = .; + . = . + _system_stack_size; + . = ALIGN(4); + _estack = .; + } >RAM + + __bss_start = .; + .bss : + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; + + *(.bss) + *(.bss.*) + *(COMMON) + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _ebss = . ; + + *(.bss.init) + } > RAM + __bss_end = .; + + _end = .; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to the beginning + * of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} diff --git a/bsp/ht32/ht32f52352/board/linker_scripts/link.sct b/bsp/ht32/ht32f52352/board/linker_scripts/link.sct new file mode 100644 index 0000000000..ece577cb3e --- /dev/null +++ b/bsp/ht32/ht32f52352/board/linker_scripts/link.sct @@ -0,0 +1,15 @@ +; ************************************************************* +; *** Scatter-Loading Description File generated by uVision *** +; ************************************************************* + +LR_IROM1 0x00000000 0x0001FE00 { ; load region size_region + ER_IROM1 0x00000000 0x0001FE00 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + RW_IRAM1 0x20000000 0x00004000 { ; RW data + .ANY (+RW +ZI) + } +} + diff --git a/bsp/ht32/ht32f52352/board/src/board.c b/bsp/ht32/ht32f52352/board/src/board.c new file mode 100644 index 0000000000..e0160468e9 --- /dev/null +++ b/bsp/ht32/ht32f52352/board/src/board.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include "board.h" + +/* This feature will initialize the HT32 chip clock */ +void rt_hw_board_clock_init(void) +{ + +} diff --git a/bsp/ht32/ht32f52352/board/src/ht32_msp.c b/bsp/ht32/ht32f52352/board/src/ht32_msp.c new file mode 100644 index 0000000000..1315b9723f --- /dev/null +++ b/bsp/ht32/ht32f52352/board/src/ht32_msp.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include "ht32_msp.h" + +/* GPIO configuration for UART */ +#ifdef BSP_USING_UART +void ht32_usart_gpio_init(void *instance) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + HT_USART_TypeDef *usart_x = (HT_USART_TypeDef *)instance; +#ifdef BSP_USING_USART0 + if (HT_USART0 == usart_x) + { + CKCUClock.Bit.HTCFG_USART0_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_USART0_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_USART0_RX_GPIO_PORT, HTCFG_USART0_RX_GPIO_PIN, GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_USART0_TX_GPIO_ID, HTCFG_USART0_TX_GPIO_PIN, AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_USART0_RX_GPIO_ID, HTCFG_USART0_RX_GPIO_PIN, AFIO_FUN_USART_UART); + } +#endif +#ifdef BSP_USING_USART1 + if (HT_USART1 == usart_x) + { + CKCUClock.Bit.HTCFG_USART1_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_USART1_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_USART1_RX_GPIO_PORT, HTCFG_USART1_RX_GPIO_PIN, GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_USART1_TX_GPIO_ID, HTCFG_USART1_TX_GPIO_PIN, AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_USART1_RX_GPIO_ID, HTCFG_USART1_RX_GPIO_PIN, AFIO_FUN_USART_UART); + } +#endif +#ifdef BSP_USING_UART0 + if (HT_UART0 == usart_x) + { + CKCUClock.Bit.HTCFG_UART0_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_UART0_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_UART0_RX_GPIO_PORT, HTCFG_UART0_RX_GPIO_PIN, GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_UART0_TX_GPIO_ID, HTCFG_UART0_TX_GPIO_PIN, AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_UART0_RX_GPIO_ID, HTCFG_UART0_RX_GPIO_PIN, AFIO_FUN_USART_UART); + } +#endif +#ifdef BSP_USING_UART1 + if (HT_UART1 == usart_x) + { + CKCUClock.Bit.HTCFG_UART1_TX_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_UART1_RX_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + /* Turn on UxART Rx internal pull up resistor to prevent unknow state */ + GPIO_PullResistorConfig(HTCFG_UART1_RX_GPIO_PORT, HTCFG_UART1_RX_GPIO_PIN, GPIO_PR_UP); + /* Config AFIO mode as UxART function */ + AFIO_GPxConfig(HTCFG_UART1_TX_GPIO_ID, HTCFG_UART1_TX_GPIO_PIN, AFIO_FUN_USART_UART); + AFIO_GPxConfig(HTCFG_UART1_RX_GPIO_ID, HTCFG_UART1_RX_GPIO_PIN, AFIO_FUN_USART_UART); + } +#endif +} +#endif + +/* GPIO configuration for SPI */ +#ifdef BSP_USING_SPI +void ht32_spi_gpio_init(void *instance) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + HT_SPI_TypeDef *spi_x = (HT_SPI_TypeDef *)instance; +#ifdef BSP_USING_SPI0 + if (HT_SPI0 == spi_x) + { + CKCUClock.Bit.HTCFG_SPI0_SCK_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI0_MISO_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI0_MOSI_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + AFIO_GPxConfig(HTCFG_SPI0_SCK_GPIO_ID, HTCFG_SPI0_SCK_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI0_MISO_GPIO_ID, HTCFG_SPI0_MISO_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI0_MOSI_GPIO_ID, HTCFG_SPI0_MOSI_GPIO_PIN, AFIO_FUN_SPI); + } +#endif +#ifdef BSP_USING_SPI1 + if (HT_SPI1 == spi_x) + { + CKCUClock.Bit.HTCFG_SPI1_SCK_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI1_MISO_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_SPI1_MOSI_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + AFIO_GPxConfig(HTCFG_SPI1_SCK_GPIO_ID, HTCFG_SPI1_SCK_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI1_MISO_GPIO_ID, HTCFG_SPI1_MISO_GPIO_PIN, AFIO_FUN_SPI); + AFIO_GPxConfig(HTCFG_SPI1_MOSI_GPIO_ID, HTCFG_SPI1_MOSI_GPIO_PIN, AFIO_FUN_SPI); + } +#endif +} +#endif + +/* GPIO configuration for I2C */ +#ifdef BSP_USING_I2C +void ht32_i2c_gpio_init(void *instance) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + HT_I2C_TypeDef *i2c_x = (HT_I2C_TypeDef *)instance; +#ifdef BSP_USING_I2C0 + if (HT_I2C0 == i2c_x) + { + CKCUClock.Bit.HTCFG_I2C0_SCL_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_I2C0_SDA_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + /* Configure GPIO to I2C mode */ + AFIO_GPxConfig(HTCFG_I2C0_SCL_GPIO_ID, HTCFG_I2C0_SCL_GPIO_PIN, AFIO_FUN_I2C); + AFIO_GPxConfig(HTCFG_I2C0_SDA_GPIO_ID, HTCFG_I2C0_SDA_GPIO_PIN, AFIO_FUN_I2C); + } +#endif +#ifdef BSP_USING_I2C1 + if (HT_I2C1 == i2c_x) + { + CKCUClock.Bit.HTCFG_I2C1_SCL_GPIO_CLK = 1; + CKCUClock.Bit.HTCFG_I2C1_SDA_GPIO_CLK = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + /* Configure GPIO to I2C mode */ + AFIO_GPxConfig(HTCFG_I2C1_SCL_GPIO_ID, HTCFG_I2C1_SCL_GPIO_PIN, AFIO_FUN_I2C); + AFIO_GPxConfig(HTCFG_I2C1_SDA_GPIO_ID, HTCFG_I2C1_SDA_GPIO_PIN, AFIO_FUN_I2C); + } +#endif +} +#endif diff --git a/bsp/ht32/ht32f52352/figures/board.png b/bsp/ht32/ht32f52352/figures/board.png new file mode 100644 index 0000000000000000000000000000000000000000..2e7fb71882bb38b3b83a7d3560e6fc54a6d382fe GIT binary patch literal 381664 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 &oy+7PVtJmYumB+3_bIg#$;1U0tbBW0ZRCiL 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

5Llu_!pc}>TqhgD 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 FV1i_FtWN*{ literal 0 HcmV?d00001 diff --git a/bsp/ht32/ht32f52352/project.uvoptx b/bsp/ht32/ht32f52352/project.uvoptx new file mode 100644 index 0000000000..9668fa37f7 --- /dev/null +++ b/bsp/ht32/ht32f52352/project.uvoptx @@ -0,0 +1,1183 @@ + + + + 1.0 + +

### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + rt-thread + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\build\keil\List\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 2 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + CMSIS_AGDI + -X"Any" -UAny -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN2 -FF0HT32F.FLM -FS00 -FL0100000 -FP0($$Device:HT32F52352$ARM\Flash\HT32F.FLM) -FF1HT32F_OPT.FLM -FS11FF00000 -FL11000 -FP1($$Device:HT32F52352$ARM\Flash\HT32F_OPT.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F52352$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F52352$ARM\Flash\HT32F_OPT.FLM)) + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + Applications + 0 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + applications\main.c + main.c + 0 + 0 + + + + + Compiler + 0 + 0 + 0 + 0 + + 2 + 2 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c + syscall_mem.c + 0 + 0 + + + 2 + 3 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\armlibc\syscalls.c + syscalls.c + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cctype.c + cctype.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cstdlib.c + cstdlib.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cstring.c + cstring.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\ctime.c + ctime.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cunistd.c + cunistd.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\..\components\libc\compilers\common\cwchar.c + cwchar.c + 0 + 0 + + + + + DeviceDrivers + 0 + 0 + 0 + 0 + + 3 + 10 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\core\device.c + device.c + 0 + 0 + + + 3 + 11 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\i2c\i2c-bit-ops.c + i2c-bit-ops.c + 0 + 0 + + + 3 + 12 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\i2c\i2c_core.c + i2c_core.c + 0 + 0 + + + 3 + 13 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\i2c\i2c_dev.c + i2c_dev.c + 0 + 0 + + + 3 + 14 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\completion.c + completion.c + 0 + 0 + + + 3 + 15 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\condvar.c + condvar.c + 0 + 0 + + + 3 + 16 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\dataqueue.c + dataqueue.c + 0 + 0 + + + 3 + 17 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\pipe.c + pipe.c + 0 + 0 + + + 3 + 18 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\ringblk_buf.c + ringblk_buf.c + 0 + 0 + + + 3 + 19 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\ringbuffer.c + ringbuffer.c + 0 + 0 + + + 3 + 20 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\waitqueue.c + waitqueue.c + 0 + 0 + + + 3 + 21 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\ipc\workqueue.c + workqueue.c + 0 + 0 + + + 3 + 22 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\pin\pin.c + pin.c + 0 + 0 + + + 3 + 23 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\serial\serial.c + serial.c + 0 + 0 + + + 3 + 24 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\spi\spi_core.c + spi_core.c + 0 + 0 + + + 3 + 25 + 1 + 0 + 0 + 0 + ..\..\..\components\drivers\spi\spi_dev.c + spi_dev.c + 0 + 0 + + + + + Drivers + 0 + 0 + 0 + 0 + + 4 + 26 + 1 + 0 + 0 + 0 + board\src\board.c + board.c + 0 + 0 + + + 4 + 27 + 1 + 0 + 0 + 0 + board\src\ht32_msp.c + ht32_msp.c + 0 + 0 + + + 4 + 28 + 2 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\Device\Holtek\HT32F5xxxx\Source\ARM\startup_ht32f5xxxx_01.s + startup_ht32f5xxxx_01.s + 0 + 0 + + + 4 + 29 + 1 + 0 + 0 + 0 + ..\libraries\ht32_drivers\drv_common.c + drv_common.c + 0 + 0 + + + 4 + 30 + 1 + 0 + 0 + 0 + ..\libraries\ht32_drivers\drv_gpio.c + drv_gpio.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\libraries\ht32_drivers\drv_usart.c + drv_usart.c + 0 + 0 + + + + + Finsh + 0 + 0 + 0 + 0 + + 5 + 32 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\shell.c + shell.c + 0 + 0 + + + 5 + 33 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\msh.c + msh.c + 0 + 0 + + + 5 + 34 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\msh_parse.c + msh_parse.c + 0 + 0 + + + 5 + 35 + 1 + 0 + 0 + 0 + ..\..\..\components\finsh\cmd.c + cmd.c + 0 + 0 + + + + + Kernel + 0 + 0 + 0 + 0 + + 6 + 36 + 1 + 0 + 0 + 0 + ..\..\..\src\clock.c + clock.c + 0 + 0 + + + 6 + 37 + 1 + 0 + 0 + 0 + ..\..\..\src\components.c + components.c + 0 + 0 + + + 6 + 38 + 1 + 0 + 0 + 0 + ..\..\..\src\idle.c + idle.c + 0 + 0 + + + 6 + 39 + 1 + 0 + 0 + 0 + ..\..\..\src\ipc.c + ipc.c + 0 + 0 + + + 6 + 40 + 1 + 0 + 0 + 0 + ..\..\..\src\irq.c + irq.c + 0 + 0 + + + 6 + 41 + 1 + 0 + 0 + 0 + ..\..\..\src\klibc\kstdio.c + kstdio.c + 0 + 0 + + + 6 + 42 + 1 + 0 + 0 + 0 + ..\..\..\src\klibc\kstring.c + kstring.c + 0 + 0 + + + 6 + 43 + 1 + 0 + 0 + 0 + ..\..\..\src\kservice.c + kservice.c + 0 + 0 + + + 6 + 44 + 1 + 0 + 0 + 0 + ..\..\..\src\mem.c + mem.c + 0 + 0 + + + 6 + 45 + 1 + 0 + 0 + 0 + ..\..\..\src\memheap.c + memheap.c + 0 + 0 + + + 6 + 46 + 1 + 0 + 0 + 0 + ..\..\..\src\mempool.c + mempool.c + 0 + 0 + + + 6 + 47 + 1 + 0 + 0 + 0 + ..\..\..\src\object.c + object.c + 0 + 0 + + + 6 + 48 + 1 + 0 + 0 + 0 + ..\..\..\src\scheduler_comm.c + scheduler_comm.c + 0 + 0 + + + 6 + 49 + 1 + 0 + 0 + 0 + ..\..\..\src\scheduler_up.c + scheduler_up.c + 0 + 0 + + + 6 + 50 + 1 + 0 + 0 + 0 + ..\..\..\src\thread.c + thread.c + 0 + 0 + + + 6 + 51 + 1 + 0 + 0 + 0 + ..\..\..\src\timer.c + timer.c + 0 + 0 + + + + + libcpu + 0 + 0 + 0 + 0 + + 7 + 52 + 1 + 0 + 0 + 0 + ..\..\..\libcpu\arm\common\div0.c + div0.c + 0 + 0 + + + 7 + 53 + 1 + 0 + 0 + 0 + ..\..\..\libcpu\arm\common\showmem.c + showmem.c + 0 + 0 + + + 7 + 54 + 2 + 0 + 0 + 0 + ..\..\..\libcpu\arm\cortex-m0\context_rvds.S + context_rvds.S + 0 + 0 + + + 7 + 55 + 1 + 0 + 0 + 0 + ..\..\..\libcpu\arm\cortex-m0\cpuport.c + cpuport.c + 0 + 0 + + + + + Libraries + 0 + 0 + 0 + 0 + + 8 + 56 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_sci.c + ht32f5xxxx_sci.c + 0 + 0 + + + 8 + 57 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_rstcu.c + ht32f5xxxx_rstcu.c + 0 + 0 + + + 8 + 58 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_adc.c + ht32f5xxxx_adc.c + 0 + 0 + + + 8 + 59 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_cmp.c + ht32f5xxxx_cmp.c + 0 + 0 + + + 8 + 60 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32_cm0plus_misc.c + ht32_cm0plus_misc.c + 0 + 0 + + + 8 + 61 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_crc.c + ht32f5xxxx_crc.c + 0 + 0 + + + 8 + 62 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_spi.c + ht32f5xxxx_spi.c + 0 + 0 + + + 8 + 63 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_pwrcu.c + ht32f5xxxx_pwrcu.c + 0 + 0 + + + 8 + 64 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_pdma.c + ht32f5xxxx_pdma.c + 0 + 0 + + + 8 + 65 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_mctm.c + ht32f5xxxx_mctm.c + 0 + 0 + + + 8 + 66 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_rtc.c + ht32f5xxxx_rtc.c + 0 + 0 + + + 8 + 67 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_i2s.c + ht32f5xxxx_i2s.c + 0 + 0 + + + 8 + 68 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_usbd.c + ht32f5xxxx_usbd.c + 0 + 0 + + + 8 + 69 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_wdt.c + ht32f5xxxx_wdt.c + 0 + 0 + + + 8 + 70 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_ebi.c + ht32f5xxxx_ebi.c + 0 + 0 + + + 8 + 71 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_tm.c + ht32f5xxxx_tm.c + 0 + 0 + + + 8 + 72 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_ckcu.c + ht32f5xxxx_ckcu.c + 0 + 0 + + + 8 + 73 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_gpio.c + ht32f5xxxx_gpio.c + 0 + 0 + + + 8 + 74 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_exti.c + ht32f5xxxx_exti.c + 0 + 0 + + + 8 + 75 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_bftm.c + ht32f5xxxx_bftm.c + 0 + 0 + + + 8 + 76 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_usart.c + ht32f5xxxx_usart.c + 0 + 0 + + + 8 + 77 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_i2c.c + ht32f5xxxx_i2c.c + 0 + 0 + + + 8 + 78 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_flash.c + ht32f5xxxx_flash.c + 0 + 0 + + + 8 + 79 + 1 + 0 + 0 + 0 + ..\libraries\HT32_STD_5xxxx_FWLib\library\Device\Holtek\HT32F5xxxx\Source\system_ht32f5xxxx_01.c + system_ht32f5xxxx_01.c + 0 + 0 + + + + diff --git a/bsp/ht32/ht32f52352/project.uvprojx b/bsp/ht32/ht32f52352/project.uvprojx new file mode 100644 index 0000000000..0c3f47fd02 --- /dev/null +++ b/bsp/ht32/ht32f52352/project.uvprojx @@ -0,0 +1,2424 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + rt-thread + 0x4 + ARM-ADS + 5060422::V5.06 update 4 (build 422)::ARMCC + + + HT32F52352 + Holtek + Holtek.HT32_DFP.1.0.19 + http://mcu.holtek.com.tw/pack + IRAM(0x20000000,0x4000) IROM(0x00000000,0x1FE00) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F52352$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F52352$ARM\Flash\HT32F_OPT.FLM)) + 0 + $$Device:HT32F52352$ARM\INC\Holtek\HT32F5xxxx\ht32f5xxxx_01.h + + + + + + + + + + $$Device:HT32F52352$SVD\HT32F52342_52.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\build\keil\Obj\ + rt-thread + 1 + 0 + 0 + 1 + 1 + .\build\keil\List\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 0 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 1 + 0x0 + 0x1fe00 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x1fe00 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + __STDC_LIMIT_MACROS, RT_USING_ARMLIBC, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, USE_HT32_DRIVER, __RTTHREAD__, USE_HT32F52352_SK, USE_HT32F52342_52, USE_MEM_HT32F52352 + + ..\libraries\HT32_STD_5xxxx_FWLib\library\Device\Holtek\HT32F5xxxx\Include;..\..\..\include;..\libraries\ht32_drivers;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\epoll;..\libraries\HT32_STD_5xxxx_FWLib\library\CMSIS\Include;..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\inc;..\..\..\components\drivers\include;.;board\inc;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include;applications;..\..\..\components\libc\compilers\common\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\libc\posix\io\poll;..\..\..\components\finsh;..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m0;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\spi;..\..\..\libcpu\arm\common + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + USE_HT32_CHIP=4 + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + .\board\linker_scripts\link.sct + + + + + + + + + + + Applications + + + main.c + 1 + applications\main.c + + + + + Compiler + + + syscall_mem.c + 1 + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c + + + syscalls.c + 1 + ..\..\..\components\libc\compilers\armlibc\syscalls.c + + + cctype.c + 1 + ..\..\..\components\libc\compilers\common\cctype.c + + + cstdlib.c + 1 + ..\..\..\components\libc\compilers\common\cstdlib.c + + + cstring.c + 1 + ..\..\..\components\libc\compilers\common\cstring.c + + + ctime.c + 1 + ..\..\..\components\libc\compilers\common\ctime.c + + + cunistd.c + 1 + ..\..\..\components\libc\compilers\common\cunistd.c + + + cwchar.c + 1 + ..\..\..\components\libc\compilers\common\cwchar.c + + + + + DeviceDrivers + + + device.c + 1 + ..\..\..\components\drivers\core\device.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + i2c-bit-ops.c + 1 + ..\..\..\components\drivers\i2c\i2c-bit-ops.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + i2c_core.c + 1 + ..\..\..\components\drivers\i2c\i2c_core.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + i2c_dev.c + 1 + ..\..\..\components\drivers\i2c\i2c_dev.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + completion.c + 1 + ..\..\..\components\drivers\ipc\completion.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + condvar.c + 1 + ..\..\..\components\drivers\ipc\condvar.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + dataqueue.c + 1 + ..\..\..\components\drivers\ipc\dataqueue.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + pipe.c + 1 + ..\..\..\components\drivers\ipc\pipe.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + ringblk_buf.c + 1 + ..\..\..\components\drivers\ipc\ringblk_buf.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + ringbuffer.c + 1 + ..\..\..\components\drivers\ipc\ringbuffer.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + waitqueue.c + 1 + ..\..\..\components\drivers\ipc\waitqueue.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + workqueue.c + 1 + ..\..\..\components\drivers\ipc\workqueue.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + pin.c + 1 + ..\..\..\components\drivers\pin\pin.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + serial.c + 1 + ..\..\..\components\drivers\serial\serial.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + spi_core.c + 1 + ..\..\..\components\drivers\spi\spi_core.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + spi_dev.c + 1 + ..\..\..\components\drivers\spi\spi_dev.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + + + + + Drivers + + + board.c + 1 + board\src\board.c + + + ht32_msp.c + 1 + board\src\ht32_msp.c + + + startup_ht32f5xxxx_01.s + 2 + ..\libraries\HT32_STD_5xxxx_FWLib\library\Device\Holtek\HT32F5xxxx\Source\ARM\startup_ht32f5xxxx_01.s + + + drv_common.c + 1 + ..\libraries\ht32_drivers\drv_common.c + + + drv_gpio.c + 1 + ..\libraries\ht32_drivers\drv_gpio.c + + + drv_usart.c + 1 + ..\libraries\ht32_drivers\drv_usart.c + + + + + Finsh + + + shell.c + 1 + ..\..\..\components\finsh\shell.c + + + msh.c + 1 + ..\..\..\components\finsh\msh.c + + + msh_parse.c + 1 + ..\..\..\components\finsh\msh_parse.c + + + cmd.c + 1 + ..\..\..\components\finsh\cmd.c + + + + + Kernel + + + clock.c + 1 + ..\..\..\src\clock.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + components.c + 1 + ..\..\..\src\components.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + idle.c + 1 + ..\..\..\src\idle.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + ipc.c + 1 + ..\..\..\src\ipc.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + irq.c + 1 + ..\..\..\src\irq.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + kstdio.c + 1 + ..\..\..\src\klibc\kstdio.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + kstring.c + 1 + ..\..\..\src\klibc\kstring.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + kservice.c + 1 + ..\..\..\src\kservice.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + mem.c + 1 + ..\..\..\src\mem.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + memheap.c + 1 + ..\..\..\src\memheap.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + mempool.c + 1 + ..\..\..\src\mempool.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + object.c + 1 + ..\..\..\src\object.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + scheduler_comm.c + 1 + ..\..\..\src\scheduler_comm.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + scheduler_up.c + 1 + ..\..\..\src\scheduler_up.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + thread.c + 1 + ..\..\..\src\thread.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + timer.c + 1 + ..\..\..\src\timer.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_KERNEL_SOURCE__ + + + + + + + + + + + libcpu + + + div0.c + 1 + ..\..\..\libcpu\arm\common\div0.c + + + showmem.c + 1 + ..\..\..\libcpu\arm\common\showmem.c + + + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m0\context_rvds.S + + + cpuport.c + 1 + ..\..\..\libcpu\arm\cortex-m0\cpuport.c + + + + + Libraries + + + ht32f5xxxx_sci.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_sci.c + + + ht32f5xxxx_rstcu.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_rstcu.c + + + ht32f5xxxx_adc.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_adc.c + + + ht32f5xxxx_cmp.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_cmp.c + + + ht32_cm0plus_misc.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32_cm0plus_misc.c + + + ht32f5xxxx_crc.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_crc.c + + + ht32f5xxxx_spi.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_spi.c + + + ht32f5xxxx_pwrcu.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_pwrcu.c + + + ht32f5xxxx_pdma.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_pdma.c + + + ht32f5xxxx_mctm.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_mctm.c + + + ht32f5xxxx_rtc.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_rtc.c + + + ht32f5xxxx_i2s.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_i2s.c + + + ht32f5xxxx_usbd.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_usbd.c + + + ht32f5xxxx_wdt.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_wdt.c + + + ht32f5xxxx_ebi.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_ebi.c + + + ht32f5xxxx_tm.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_tm.c + + + ht32f5xxxx_ckcu.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_ckcu.c + + + ht32f5xxxx_gpio.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_gpio.c + + + ht32f5xxxx_exti.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_exti.c + + + ht32f5xxxx_bftm.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_bftm.c + + + ht32f5xxxx_usart.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_usart.c + + + ht32f5xxxx_i2c.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_i2c.c + + + ht32f5xxxx_flash.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\HT32F5xxxx_Driver\src\ht32f5xxxx_flash.c + + + system_ht32f5xxxx_01.c + 1 + ..\libraries\HT32_STD_5xxxx_FWLib\library\Device\Holtek\HT32F5xxxx\Source\system_ht32f5xxxx_01.c + + + + + + + + + + + + + +
diff --git a/bsp/ht32/ht32f52352/rtconfig.h b/bsp/ht32/ht32f52352/rtconfig.h new file mode 100644 index 0000000000..3caf5a5be0 --- /dev/null +++ b/bsp/ht32/ht32f52352/rtconfig.h @@ -0,0 +1,271 @@ +#ifndef RT_CONFIG_H__ +#define RT_CONFIG_H__ + +/* Automatically generated file; DO NOT EDIT. */ +/* RT-Thread Configuration */ + +/* RT-Thread Kernel */ + +#define RT_NAME_MAX 8 +#define RT_CPUS_NR 1 +#define RT_ALIGN_SIZE 4 +#define RT_THREAD_PRIORITY_32 +#define RT_THREAD_PRIORITY_MAX 32 +#define RT_TICK_PER_SECOND 1000 +#define RT_USING_OVERFLOW_CHECK +#define RT_USING_HOOK +#define RT_HOOK_USING_FUNC_PTR +#define RT_USING_IDLE_HOOK +#define RT_IDLE_HOOK_LIST_SIZE 4 +#define IDLE_THREAD_STACK_SIZE 256 + +/* kservice optimization */ + +#define RT_USING_DEBUG +#define RT_DEBUGING_COLOR +#define RT_DEBUGING_CONTEXT + +/* Inter-Thread communication */ + +#define RT_USING_SEMAPHORE +#define RT_USING_MUTEX +#define RT_USING_EVENT +#define RT_USING_MAILBOX +#define RT_USING_MESSAGEQUEUE + +/* Memory Management */ + +#define RT_USING_MEMPOOL +#define RT_USING_SMALL_MEM +#define RT_USING_MEMHEAP +#define RT_MEMHEAP_FAST_MODE +#define RT_USING_SMALL_MEM_AS_HEAP +#define RT_USING_HEAP +#define RT_USING_DEVICE +#define RT_USING_CONSOLE +#define RT_CONSOLEBUF_SIZE 128 +#define RT_CONSOLE_DEVICE_NAME "usart1" +#define RT_VER_NUM 0x50100 +#define RT_BACKTRACE_LEVEL_MAX_NR 32 +#define ARCH_ARM +#define ARCH_ARM_CORTEX_M +#define ARCH_ARM_CORTEX_M0 + +/* RT-Thread Components */ + +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 2048 +#define RT_MAIN_THREAD_PRIORITY 10 +#define RT_USING_MSH +#define RT_USING_FINSH +#define FINSH_USING_MSH +#define FINSH_THREAD_NAME "tshell" +#define FINSH_THREAD_PRIORITY 20 +#define FINSH_THREAD_STACK_SIZE 4096 +#define FINSH_USING_HISTORY +#define FINSH_HISTORY_LINES 5 +#define FINSH_USING_SYMTAB +#define FINSH_CMD_SIZE 80 +#define MSH_USING_BUILT_IN_COMMANDS +#define FINSH_USING_DESCRIPTION +#define FINSH_ARG_MAX 10 +#define FINSH_USING_OPTION_COMPLETION + +/* DFS: device virtual file system */ + + +/* Device Drivers */ + +#define RT_USING_DEVICE_IPC +#define RT_UNAMED_PIPE_NUMBER 64 +#define RT_USING_SERIAL +#define RT_USING_SERIAL_V1 +#define RT_SERIAL_USING_DMA +#define RT_SERIAL_RB_BUFSZ 64 +#define RT_USING_I2C +#define RT_USING_I2C_BITOPS +#define RT_USING_SPI +#define RT_USING_PIN + +/* Using USB */ + + +/* C/C++ and POSIX layer */ + +/* ISO-ANSI C layer */ + +/* Timezone and Daylight Saving Time */ + +#define RT_LIBC_USING_LIGHT_TZ_DST +#define RT_LIBC_TZ_DEFAULT_HOUR 8 +#define RT_LIBC_TZ_DEFAULT_MIN 0 +#define RT_LIBC_TZ_DEFAULT_SEC 0 + +/* POSIX (Portable Operating System Interface) layer */ + + +/* Interprocess Communication (IPC) */ + + +/* Socket is in the 'Network' category */ + + +/* Network */ + + +/* Memory protection */ + + +/* Utilities */ + + +/* RT-Thread Utestcases */ + + +/* RT-Thread online packages */ + +/* IoT - internet of things */ + + +/* Wi-Fi */ + +/* Marvell WiFi */ + + +/* Wiced WiFi */ + + +/* CYW43012 WiFi */ + + +/* BL808 WiFi */ + + +/* CYW43439 WiFi */ + + +/* IoT Cloud */ + + +/* security packages */ + + +/* language packages */ + +/* JSON: JavaScript Object Notation, a lightweight data-interchange format */ + + +/* XML: Extensible Markup Language */ + + +/* multimedia packages */ + +/* LVGL: powerful and easy-to-use embedded GUI library */ + + +/* u8g2: a monochrome graphic library */ + + +/* tools packages */ + + +/* system packages */ + +/* enhanced kernel services */ + + +/* acceleration: Assembly language or algorithmic acceleration packages */ + + +/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */ + + +/* Micrium: Micrium software products porting for RT-Thread */ + + +/* peripheral libraries and drivers */ + +/* HAL & SDK Drivers */ + +/* STM32 HAL & SDK Drivers */ + + +/* Kendryte SDK */ + + +/* sensors drivers */ + + +/* touch drivers */ + + +/* AI packages */ + + +/* Signal Processing and Control Algorithm Packages */ + + +/* miscellaneous packages */ + +/* project laboratory */ + +/* samples: kernel and components samples */ + + +/* entertainment: terminal games and other interesting software packages */ + + +/* Arduino libraries */ + + +/* Projects and Demos */ + + +/* Sensors */ + + +/* Display */ + + +/* Timing */ + + +/* Data Processing */ + + +/* Data Storage */ + +/* Communication */ + + +/* Device Control */ + + +/* Other */ + + +/* Signal IO */ + + +/* Uncategorized */ + +#define SOC_FAMILY_HT32 +#define SOC_SERIES_HT32F5 + +/* Hardware Drivers Config */ + +#define SOC_HT32F52352 + +/* Onboard Peripheral Drivers */ + +/* On-chip Peripheral Drivers */ + +#define BSP_USING_GPIO +#define BSP_USING_UART +#define BSP_USING_USART1 + +/* Board extended module Drivers */ + + +#endif diff --git a/bsp/ht32/ht32f52352/rtconfig.py b/bsp/ht32/ht32f52352/rtconfig.py new file mode 100644 index 0000000000..964fa9313e --- /dev/null +++ b/bsp/ht32/ht32f52352/rtconfig.py @@ -0,0 +1,152 @@ +import os + +# toolchains options +ARCH='arm' +CPU='cortex-m0' +CROSS_TOOL='keil' + +# bsp lib config +BSP_LIBRARY_TYPE = None + +if os.getenv('RTT_CC'): + CROSS_TOOL = os.getenv('RTT_CC') +if os.getenv('RTT_ROOT'): + RTT_ROOT = os.getenv('RTT_ROOT') + +# cross_tool provides the cross compiler +# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR +if CROSS_TOOL == 'gcc': + PLATFORM = 'gcc' + EXEC_PATH = r'C:\Users\XXYYZZ' +elif CROSS_TOOL == 'keil': + PLATFORM = 'armcc' +# EXEC_PATH = r'D:\keil5\keil_v532\UV4' + EXEC_PATH = r'C:/Keil_v5' +elif CROSS_TOOL == 'iar': + PLATFORM = 'iar' + EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0' + +if os.getenv('RTT_EXEC_PATH'): + EXEC_PATH = os.getenv('RTT_EXEC_PATH') + +BUILD = 'debug' + +if PLATFORM == 'gcc': + # toolchains + PREFIX = 'arm-none-eabi-' + CC = PREFIX + 'gcc' + AS = PREFIX + 'gcc' + AR = PREFIX + 'ar' + CXX = PREFIX + 'g++' + LINK = PREFIX + 'gcc' + TARGET_EXT = 'elf' + SIZE = PREFIX + 'size' + OBJDUMP = PREFIX + 'objdump' + OBJCPY = PREFIX + 'objcopy' + + DEVICE = ' -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections' + CFLAGS = DEVICE + ' -Dgcc' + AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' + + CPATH = '' + LPATH = '' + + if BUILD == 'debug': + CFLAGS += ' -O0 -gdwarf-2 -g' + AFLAGS += ' -gdwarf-2' + else: + CFLAGS += ' -O2' + + CXXFLAGS = CFLAGS + + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' + +elif PLATFORM == 'armcc': + # toolchains + CC = 'armcc' + CXX = 'armcc' + AS = 'armasm' + AR = 'armar' + LINK = 'armlink' + TARGET_EXT = 'axf' + + DEVICE = ' --cpu Cortex-M0 ' + CFLAGS = '-c ' + DEVICE + ' --apcs=interwork --c99' + AFLAGS = DEVICE + ' --apcs=interwork ' + LFLAGS = DEVICE + ' --scatter "board\linker_scripts\link.sct" --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict' + CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCC/include' + LFLAGS += ' --libpath=' + EXEC_PATH + '/ARM/ARMCC/lib' + + CFLAGS += ' -D__MICROLIB ' + AFLAGS += ' --pd "__MICROLIB SETA 1" ' + LFLAGS += ' --library_type=microlib ' + EXEC_PATH += '/ARM/ARMCC/bin/' + + if BUILD == 'debug': + CFLAGS += ' -g -O0' + AFLAGS += ' -g' + else: + CFLAGS += ' -O2' + + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' + +elif PLATFORM == 'iar': + # toolchains + CC = 'iccarm' + CXX = 'iccarm' + AS = 'iasmarm' + AR = 'iarchive' + LINK = 'ilinkarm' + TARGET_EXT = 'out' + + DEVICE = '-Dewarm' + + CFLAGS = DEVICE + CFLAGS += ' --diag_suppress Pa050' + CFLAGS += ' --no_cse' + CFLAGS += ' --no_unroll' + CFLAGS += ' --no_inline' + CFLAGS += ' --no_code_motion' + CFLAGS += ' --no_tbaa' + CFLAGS += ' --no_clustering' + CFLAGS += ' --no_scheduling' + CFLAGS += ' --endian=little' + CFLAGS += ' --cpu=Cortex-M0' + CFLAGS += ' -e' + CFLAGS += ' --fpu=None' + CFLAGS += ' --dlib_config "' + EXEC_PATH + '/arm/INC/c/DLib_Config_Normal.h"' + CFLAGS += ' --silent' + + AFLAGS = DEVICE + AFLAGS += ' -s+' + AFLAGS += ' -w+' + AFLAGS += ' -r' + AFLAGS += ' --cpu Cortex-M0' + AFLAGS += ' --fpu None' + AFLAGS += ' -S' + + if BUILD == 'debug': + CFLAGS += ' --debug' + CFLAGS += ' -On' + else: + CFLAGS += ' -Oh' + + LFLAGS = ' --config "board/linker_scripts/link.icf"' + LFLAGS += ' --entry __iar_program_start' + + CXXFLAGS = CFLAGS + + EXEC_PATH = EXEC_PATH + '/arm/bin/' + POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' + +def dist_handle(BSP_ROOT, dist_dir): + import sys + cwd_path = os.getcwd() + sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools')) + from sdk_dist import dist_do_building + dist_do_building(BSP_ROOT, dist_dir) + diff --git a/bsp/ht32/ht32f52352/template.uvoptx b/bsp/ht32/ht32f52352/template.uvoptx new file mode 100644 index 0000000000..eaed3566ca --- /dev/null +++ b/bsp/ht32/ht32f52352/template.uvoptx @@ -0,0 +1,179 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + rt-thread + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\build\keil\List\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 2 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + CMSIS_AGDI + -X"Any" -UAny -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN2 -FF0HT32F.FLM -FS00 -FL0100000 -FP0($$Device:HT32F52352$ARM\Flash\HT32F.FLM) -FF1HT32F_OPT.FLM -FS11FF00000 -FL11000 -FP1($$Device:HT32F52352$ARM\Flash\HT32F_OPT.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F52352$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F52352$ARM\Flash\HT32F_OPT.FLM)) + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + Source Group 1 + 0 + 0 + 0 + 0 + + +
diff --git a/bsp/ht32/ht32f52352/template.uvprojx b/bsp/ht32/ht32f52352/template.uvprojx new file mode 100644 index 0000000000..2530ad2a7e --- /dev/null +++ b/bsp/ht32/ht32f52352/template.uvprojx @@ -0,0 +1,392 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + rt-thread + 0x4 + ARM-ADS + 5060422::V5.06 update 4 (build 422)::ARMCC + + + HT32F52352 + Holtek + Holtek.HT32_DFP.1.0.19 + http://mcu.holtek.com.tw/pack + IRAM(0x20000000,0x4000) IROM(0x00000000,0x1FE00) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN2 -FF0HT32F -FS00 -FL0100000 -FF1HT32F_OPT -FS11FF00000 -FL11000 -FP0($$Device:HT32F52352$ARM\Flash\HT32F.FLM) -FP1($$Device:HT32F52352$ARM\Flash\HT32F_OPT.FLM)) + 0 + $$Device:HT32F52352$ARM\INC\Holtek\HT32F5xxxx\ht32f5xxxx_01.h + + + + + + + + + + $$Device:HT32F52352$SVD\HT32F52342_52.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\build\keil\Obj\ + rt-thread + 1 + 0 + 0 + 1 + 1 + .\build\keil\List\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DARMCM1.DLL + -pCM0+ + SARMCM3.DLL + + TARMCM1.DLL + -pCM0+ + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 0 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M0+" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 1 + 0x0 + 0x1fe00 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x1fe00 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + USE_HT32_CHIP=4 + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + .\board\linker_scripts\link.sct + + + + + + + + + + + Source Group 1 + + + + + + + + + + + +
diff --git a/bsp/ht32/libraries/.ignore_format.yml b/bsp/ht32/libraries/.ignore_format.yml new file mode 100644 index 0000000000..65b2f1a156 --- /dev/null +++ b/bsp/ht32/libraries/.ignore_format.yml @@ -0,0 +1,7 @@ +# files format check exclude path, please follow the instructions below to modify; +# If you need to exclude an entire folder, add the folder path in dir_path; +# If you need to exclude a file, add the path to the file in file_path. + +dir_path: +- HT32_STD_1xxxx_FWLib +- HT32_STD_5xxxx_FWLib diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/Release_Notes.txt b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/Release_Notes.txt new file mode 100644 index 0000000000..20ad57f3fc --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/Release_Notes.txt @@ -0,0 +1,876 @@ +/*********************************************************************************************************//** + * @file Release_Notes.txt + * @version V1.4.1 + * @date 2023-10-31 + * @brief The Release notes of HT32 Firmware Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +// Supported Device +// ======================================== +// HT32F1653, HT32F1654 +// HT32F1655, HT32F1656 +// HT32F12345 +// HT32F12364 +// HT32F12365, HT32F12366 +// HT32F22366 + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.4.1_2982 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-10-31 + + Main Changes + + Add new example. + - "GPIO/PinLock" + + Modify examples below, add volatile qualifiers on some variables (in the for loop usage) + to fix the Arm Compiler Version 6 optimization issue. + ("u32" to "vu32", unsigned int to volatile unsigned int). + - “PWRCU/PowerDown_WAKEUPPin” + - “PWRCU/PowerDown_RTC” + - “TM/PWM” + + Modify examples below, use separate "if" statements instead of "if-else" to avoid double-entry ISR. + - "PWRCU/DeepSleepMode1" + - "PWRCU/DeepSleepMode2" + + Modify "ht32_time.h", "ht32f1xxxx_conf.h" and "ht32_time_conf.h" for "LIBCFG_CKCU_NO_APB_PRESCALER" series. + - To ensure the correct configuration of the timer clock, the "HTCFG_TIME_PCLK_DIV" is redefined as 0. + + Add "Project or Target File Clearing" functions ("_ClearProject.bat" and "_ClearTarget.bat"). + + Modify "syscall.c" to prevent redundant initialization of the heap index. + + Modify "ht32f1xxxx_01.h" to add below definition. + - "sc64", "vs64", "vsc64", "uc64", "vu64", "vuc64" + + Modify PWRCU related define (The left side old one is still kept for backward compatible). + - PWRCU_FLAG_BAKPOR -> PWRCU_FLAG_PWRPOR + + Modify "RETARGET_Configuration()", add the operation of UxARTn peripheral clock enable. + + Update and sync "ht32f1xxxx_conf.h", modify related define of UxARTn retarget port. + + Update "ht32_op.c" and "ht32_op.s" to support new version of bootloader waiting time setting address. + (The setting address is changed from 0x1FF0002C to 0x1FF0004C) + + Add "ht32_op_V107.c" and "ht32_op_V107.s" to support the use of older versions of bootloader. + + Add "CKCU_ATCInit()" API for HSI Auto Trim initial function. + + Update "ht32f1xxxx_adc.c" and "ht32f1xxxx_adc_02.c", modify the ADC enable related flow. + + Add the below folder, For the BMduino shield/module Keil Driver. + - "BestModules" + + Others + + Update comment, format, typing error, and coding style. + + Adjust "LIBCFG_xxxxx" definition below. + - "LIBCFG_CKCU_APBCLKFIX" rename to "LIBCFG_CKCU_NO_APB_PRESCALER" + + Modify the Sourcery G++ Lite toolchain project. + - Set C99 mode to fix issues after updating CMSIS v5.9.0 ("for" loop initial declarations). + + Update e-Link32 Pro/Lite Command line tool as "V1.19" ("utilities/elink32pro/eLink32pro.exe"). + + Modify "_ProjectConfigScript.bat" to prevent the creation of project that copy unused system/startup files. + + Update "project_template/Script" for adding project C++ source files and setting the chip model mechanism. + - The updated files are as follows: + "Script/_ProjectSource.bat" + "Script/_ProjectSource.ini" + + Update "project_template/Script" for improving script mechanism. + - The updated files are as follows: + "Script/_CreateProjectConfScript.bat" + "Script/_CreateProjectScript.bat" + "Script/_ht32_ic_name.ini" + + Modify and check the example supportability of each IC. + + Add the below file, for the BMduino shield. + - "ht32_undef_IP.h" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.3.2_2858 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-02-02 + + Main Changes + + Add new examples: + - "SRAM_Overwrite/Watchpoint_Heap" + - "SRAM_Overwrite/Watchpoint_Stack" + + Update "ht32f1xxxx_conf.h" for user layer HSE_VALUE setting. + + Others + + Update comment, format, typing error, and coding style. + + Modify "system_ht32fxxxxx_nn.c", add HSE_VALUE notice and update PLL Out formula. + + Update and sync system.c files. + + Update EEPROM Emulation middleware, improve efficacy and reduce resource usage. + "utilities/middleware/eeprom_emulation.c" + "utilities/middleware/ht32_eeprom_config_templet.h" + + Update I2C Master middleware, improve setting way and fix minor errors. + "utilities/middleware/i2c_master.c/.h" + "utilities/middleware/i2c_master_config_templet.h" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.3.1_2808 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-12-01 + + Main Changes + + Update "ht32_time.h", fix a formula error of "TIME_TICK2US()" and "TIME_TICK2MS()" macro. + + Modify "ht32_retarget.c", fix retarget can't work when the MicroLIB is not used in Keil's V6 compiler. + + Modify "ht32_serial.c/.h" and "ht32_retarget.c", fix ITM setting issue. + + Update "ht32fxxxx_sk.h", add TRACESWO pin assignment for ITM. + + Update "SPI/PDMA" example, change the order of API execution (SPI_SELOutputCmd() execution before SPI_Cmd()). + + Update "CSIF/Init" example, modify the datatype form and add comments to explain the length of the Rx buffer. + + Update following I2C example. (sync. with M0+) + - I2C/7_bit_mode + - I2C/10_bit_mode + - I2C/EEPROM_Simulate + - I2C/Interrupt + - I2C/PDMA + + GPIO + - Add new define "GPIO_PIN_NUM_n" for GPIO pin number (n = 0 ~ 15). + + EXTI + - Add "gEXTIn_IRQn[]" and "EXTI_GetIRQn()" macro to map GPIO pin number (0 ~ 15) to "EXTIn_IRQn". + - Add "GPIO2EXTI()" macro to map GPIO pin to EXTI Channel. + - Change "AFIO_EXTISourceConfig()" API, remove "AFIO_EXTI_CH_Enum" and "AFIO_ESS_Enum". + Old: void AFIO_EXTISourceConfig(AFIO_EXTI_CH_Enum AFIO_EXTI_CH_n, AFIO_ESS_Enum AFIO_ESS_Px) + New: void AFIO_EXTISourceConfig(u32 GPIO_PIN_NUM_n, u32 GPIO_Px) + + Others + + Update comment, format, typing error, and coding style. + + Update "ht32_op.s/.c", allow "Bootloader Waiting Time" function for all series. + + Update "CKCU/HSI_AutoTrim_By_USB" example, add the following define to "ht32_board_config.h". + - "CKCU_PLL_CFG" + - "CKCU_SYSCLK_DIV_CFG" + + Upgrade CMSIS to v5.9.0. + + Modify API parameter check macro of Library Debug Mode, fix parameter check error. + + Modify variable declaration of "PDMACH_InitTypeDef" to reduce memory size. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.2.1_2753 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-10-11 + + Main Changes + + Add new examples: + - "I2C/7_bit_mode_master" + - "I2C/7_bit_mode_slave" + + Add the following API for PDMA. + - "PDMA_DeInit()" + - "PDMA_AddrConfig()" + - "PDMA_SrcAddrConfig()" + - "PDMA_DstAddrConfig()" + - "PDMA_GetRemainBlkCnt()" + + Add the following API for ADC. + - "ADC_ChannelDataAlign()" + - "ADC_ChannelOffsetValue()" + - "ADC_ChannelOffsetCmd()" + + Update "ht32_retarget.c", modify the retarget related functions for SEGGER Embedded Studio. + + Update "FLASH_SetWaitState()" function, disable Pre-fetch and Branch Cache function before change + wait state. + + Update following middleware. + "utilities/middleware/i2c_master.c/h" + "utilities/middleware/uart_module.c" + + Others + + Update comment, format, typing error, and coding style. + + Update "BFTM/OneShot" example, fix the register access sequence and time calculation formula. + + Update "TM/PWM/main.c" + - Add "HTCFG_PWM_TM_RELOAD" check. + - Add PWM channel initial function. + - Remove "_ht32_project_source.h" (Use "_ProjectSource.ini" to add "pwm.c" into project compiling list). + + Fix the upper/lower case error of #include file name. + + Update e-Link32 Pro/Lite Command line tool as "V1.18" ("utilities/elink32pro/eLink32pro.exe"). + + Change the project recommended minimum version of SEGGER Embedded Studio from V4.12 to V6.20. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.1.1_2647 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-06-10 + + Main Changes + + Add following middleware. + "utilities/middleware/spi_module.c" + "utilities/middleware/spi_module.h" + "utilities/middleware/spi_module_config_templet.h" + + Fixed FW library compatibility with ARM compiler version 6 of MDK-ARM V5.37. + - Add MDK-ARMv537 project template for MDK-ARM V5.37. + - Update "project_template/Script". Those MDK-ARMv537 project templates will be added for use if choose + the target IDE is "Keil MDK-ARMv5". The fixed files are as follows: + "Script/_CreateProjectScript.bat" + "Script/_ProjectConfig.bat" + "Script/_ProjectSource.bat" + - Update "core_cm3.h", fix compiler error. + - Update "FMC/FLASH_OperationNoHalt", fix the compiler issue of Arm Compiler Version V6.18 and the + compiler warning of linker script file. The fixed files are as follows: + "FLASH_OperationNoHalt/main.c" + "FLASH_OperationNoHalt/linker.lin" + - Update following middleware, remove STRCAT3 usage to fix compiler error. + "utilities/middleware/uart_module.c" + "utilities/middleware/i2c_master.c" + "utilities/middleware/spi_module.c" + + Update "ht32_retarget.c". Implement __write function to fix compiler error in IAR EWARM Version 9.20 + or later. + + Update GNU Arm makefile in the project_template, fix the compatibility issue that the makefile of GNU Arm + Version 11 cannot be compiled. + + Update EWARM in the project_template, fix the compiler error that header file path doesn't exist in + the file list of Workspace of IAR EWARM Version 7. + + Fix SPI initial PDMA parameter in the "utilities/common/spi_flash.c". + + Sync M0+ I2C/EEPROM to fix compiler warning of the GNU compiler. + + Sync M0+ library\HT32F1xxxx_Driver\inc\ht32_dependency.h. + + Others + + Update comment, format, typing error, and coding style. + + Update e-Link32 Pro/Lite Command line tool as "V1.16" ("utilities/elink32pro/eLink32pro.exe"). + + Update the following examples to remove compiler warning of the IAR EWARM. + "BFTM\TimeMeasure" + "TM\PWMInput\ht32f1xxxx_01_it.c" + "USBD\HID_Keyboard_Virtual_COM\ht32_usbd_class.c" + "USBD\Mass_Storage_SDIO\sd_disk.c" + "USBD\USB_UAC_Sound\ht32_usbd_class.c" + "USBD\Virtual_COM\ht32_usbd_class.c" + + Update and sync create project related files ("_ProjectConfig.bat"、"_ProjectConfig.ini"). + + Update content of "project_template/IP/Example/readme.txt", add MDK-ARM V5.37 related information. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.0.10_2585 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-04-14 + + Main Changes + + Update EEPROM Basic and EEPROM Emulation middleware, fix the include and define sequence. + "utilities/middleware/eeprom_basic.h" + "utilities/middleware/eeprom_emulation.h" + + Update UART Module middleware, add the "UARTM_IsTxFinished()" API. + "utilities/middleware/uart_module.c" + "utilities/middleware/uart_module.h" + + Others + + Update e-Link32 Pro/Lite Command line tool as "V1.0.15" ("utilities/elink32pro/eLink32pro.exe"). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.0.10_2585 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-04-14 + + Main Changes + + Update EEPROM Basic and EEPROM Emulation middleware, fix the include and define sequence. + "utilities/middleware/eeprom_basic.h" + "utilities/middleware/eeprom_emulation.h" + + Update UART Module middleware, add the "UARTM_IsTxFinished()" API. + "utilities/middleware/uart_module.c" + "utilities/middleware/uart_module.h" + + Others + + Update e-Link32 Pro/Lite Command line tool as "V1.0.15" ("utilities/elink32pro/eLink32pro.exe"). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_V1.0.9_2556 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-03-15 + + Main Changes + + Change to the new Holtek version format (Vm.n.r). + + Add new "FMC/FLASH_OperationNoHalt" example. + + Modify "utilities/common/ring_buffer.c", fix the thread-safe issue of "Buffer_GetLength()". + + Update "GNU_ARM/linker.ld", fix the heap/stack area overlap problem. + + Add "ADC_SamplingTimeConfig()" function for the "ht32f1xxxx_adc_02.c". + + Others + + Update comment, format, typing error, and coding style. + + Modify "bool, TRUE, FALSE" define way for C++/.cpp applications. + + Update "startup_ht32fxxxxx_nn.s", support "USE_HT32_CHIP" define exist at startup.s and project Asm + setting in the same time (project's Asm Define has the higher priority). + + Remove unuse global variable "DelayTime" of "ebi_lcd.c" and "spi_lcd.c". + + Update "spi_lcd.c/.h", fix the GPIO Chip SEL define mistake. + + Add following middleware. + "utilities/middleware/uart_module.c" + "utilities/middleware/uart_module.h" + + Update related middleware (eeprom_basic and eeprom_emulation). + + Update e-Link32 Pro/Lite Command line tool as "V1.0.14" ("utilities/elink32pro/eLink32pro.exe"). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_v008_2470 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-08-19 + + Main Changes + + Add "ht32_time.c/.h" to support following new functions for delay, time measure, and timeout. + "Time_Init()" + "Time_Delay()" + "Time_GetTick()" + + Add new examples: + - "ADC/OneShot_SWTrigger_ByTM" + - "GPIO/Input" + - "GPIO/Output" + - "Time/TimeFun" + - "Time/TimeFun_UserConf" + - "USART/RS485_NMM_Slave" + + Add new definition, "FLASH_WAITSTATE_MAX". + + Add "USART_PARITY_MARK" and "USART_PARITY_SPACE" for the UART parity mode. + + Update "ADC_RegularTrigConfig()" and "AC_TRIG_XXXX" define to support all the trigger source of ADC. + + Add "CKCU_ADCPRE_DIV1" parameter of "CKCU_SetADCnPrescaler()" for the HT32F12364. + + Modified "SDIO_ClearFlag()", disable Status Enable Register (SER) to clear SDIO_FLAG_BUF_OVERFLOW and + SDIO_FLAG_BUF_UNDERFLOW. + + Fix the result mistake of the marco below of HT32F12364 (LIBCFG_FLASH_2PAGE_PER_WPBIT is missing). + "#define FLASH_WP_PAGE_SET(OP, PAGE)" + "#define FLASH_WP_PAGE_CLEAR(OP, PAGE)" + "#define FLASH_IS_WP_PAGE(OP, PAGE)" + + Update following example, modify the default value of "gIsINEmpty" from TRUE to FALSE. The default value + TRUE may cause the F/W to not send CSW after the first Inquiry CBW Command in a specific condition. + "example/USBD/HID_Keyboard_Mass_Storage" + "example/USBD/Mass_Storage" + "example/USBD/Mass_Storage_IAP" + "example/USBD/Mass_Storage_SDIO" + + Others + + Update comment, format, typing error, and coding style. + + Fix compile error when turn on Library debug mode (HT32_LIB_DEBUG = 1). + + Update e-Link32 Pro Commander to V1.10. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_v007_2414 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-05-11 + + Main Changes + + Add new examples: + - "EXTI/GPIO_Interrupt" + - "CKCU/HSI_AutoTrim_By_LSE" + + Update the IAP example of HT32F12364 project: + - IAR EWARM v6/v7/v8: + 1. Modify "startup_ht32f1xxxx_03.s" to "startup_ht32f1xxxx_iar_03.s". + 2. Modify "ht32f1xxxx_adc.c" to "ht32f1xxxx_adc_02.c". + - Keil MDK-ARM v4/v5: Modify "ht32f1xxxx_adc.c" to "ht32f1xxxx_adc_02.c". + + Fix the system stuck in CKCU_HSIAutoTrimCmd() because of the misjudgment of CKCU_HSIAutoTrimIsReady(). + + Fix the CHIP ID error. Fixed "USE_HT32_CHIP=3" to "USE_HT32_CHIP=16". The fixed files are as follows: + - IAP/IAP_Text_RAM/EWARM/Project_12364_IAP.ewp + - IAP/IAP_UI/EWARM/Project_12364_IAP.ewp + + Fix the syntax error on the "IAP/IAP_Text_RAM/EWARM/startup_ht32f1xxxx_iar_03_iap.s". + + Others + + Update comment, format, typing error, and coding style. + + Update the version of eLink32pro.exe to 1.0.1.1. + + Update the following project setting: + - IAR EWARM v6/v7: Modify "_ht32_project_source.c" to "_ht32_project_source.h". + - SEGGER Embedded Studio: Add the new definition "arm_compiler_variant="SEGGER"". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_1xxxx_FWLib_v006_2361 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-02-26 + + Main Changes + + Add "Create Project Configuration Menu" to choose the target IDE and Device when the first time to do the + create project operation of the example. The configuration file, "_CreateProjectConfig.bat" is saved to + the root path of the HT32 Firmware Library. You can reset the create project IDE/IC configuration anytime + by deleting the configuration file. + Target IDE/Compiler: + - Keil MDK-ARM v5 + - Keil MDK-ARM v4 + - IAR EWARM v8 + - IAR EWARM v6/v7 + - SEGGER Embedded Studio + - GNU [with Keil and GNU make] + - SourceryG++Lite [with Keil] + Target Device: + - xxxxx: Single Device + - xxx*: Series + + Add new examples: + - "NVIC/Disable_Interrupt" + - "TM/InternalTrigger" + - "TM/PWM_Buzzer" + - "WDT/Auto_Enable" + + Add Flash programming function of GNU Maker (via e-Link32 Pro/Lite Commander). + "make IC=xxxxx eraseall" + "make IC=xxxxx program" + "make IC=xxxxx run" + + Update "CKCU_HSIAutoTrimCmd()" and "CKCU_HSIAutoTrimIsReady()" function to improve clock stability. + + Fix the cache address problem of "SDDISK_Read()" function. + "USBD/Mass_Storage/sd_disk.c", "USBD/Mass_Storage_SDIO/sd_disk.c" + + Update GNU project (*.uvprojx), fix the compile error when use new GNU Arm version + ("gcc-arm-none-eabi-10-2020-q2-preview-win32" or above). + + Fix Keil compiling error when disable both retarget and MicroLib. + + Update "ht32f1xxxx_01.h", fix the compatibility issue when user include "stdbool.h". + + Modify GNU compiler settings, output text file (disassembly) after building the code. + + Add "HT32_FWLIB_VER" and "HT32_FWLIB_SVN" in "ht32f1xxxx_lib.h" for the version information of + HT32 Firmware Library. + Example: + "#define HT32_FWLIB_VER (006)" + "#define HT32_FWLIB_VER (2361)" + + Add new AFIO define in "ht32f1xxxx_gpio.h". + - "AFIO_FUN_MCTM1" + - "AFIO_FUN_PWM" + - "AFIO_FUN_PWM0", "AFIO_FUN_PWM1", "AFIO_FUN_PWM2", "AFIO_FUN_PWM3" + + Add following alias of MCTM IRQ handler + "#define MCTM0_IRQn MCTM0UP_IRQn" + "#define MCTM0_IRQHandler MCTM0UP_IRQHandler" + "#define MCTM1_IRQn MCTM1UP_IRQn" + "#define MCTM1_IRQHandler MCTM1UP_IRQHandler" + + Others + + Update comment, format, typing error, and coding style. + + Update "SPI/FIFO_SEL_Hardware" example, add Rx FIFO Timeout function and fix data loss issue. + + Update "USBD/Mass_Storage" example, add "HTCFG_SD_MAXSPEED" define for different board. + + Update "utilities/common/spi_lcd.c". + - Remove duplicate SPI parameter setting of "LCD_Init()". + - Update SPI chip select define and SPI configuration by "LCD_SPI_SEL_AFIO_MODE". + - Swap the "GPIO_DirectionConfig()" and "GPIO_SetOutBits()" function to prevent transient state + of SPI_SEL pin. + + Update "_ProjectConfig*.bat" files. + + Add "Project Source File Setting" functions ("_ProjectSource.ini" and "_ProjectSource.bat"). + + Rename "_CreateProjectUSB.bat" as "_CreateProject.bat". + + Add dummy xxTM C files, to notify the user that SCTM/PWM/GPTM/MCTM timer use the "ht32f1xxxx_tm.c" driver. + "ht32f1xxxx_gptm.c", "ht32f1xxxx_pwm.c", "ht32f1xxxx_sctm.c" + + Add "IS_IPN_MCTM()" and "IS_IPN_GPTM" macro, for use to confirm the xxTMn is GPTM or MCTM. + + Update comment and board/pin configuration of "ADC/OneShot_TMTrigger_PDMA" example. + + Update and sync startup.s/system.c files. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v005_2207 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2020-08-11 + + Main Changes + + Add the following files to use e-Link32 Pro with SEGGER Embedded Studio. Refer to the + "readme e-Link32 Pro.txt" for how to use it. + "emStudiov4/readme e-Link32 Pro.txt" + "emStudiov4/Project_xxxxx.bat" + "emStudiov4/_MassErase.bat" + + Fix the "I2S_FIFOTrigLevelConfig()" error which did not clear the field of I2S FCR correctly. + + Fix "RPRE_MASK" define error for "RTC_SetPrescaler()" function. + + Add "SPI_FLASH_WaitForWriteEnd()" function in the end of the write status operation + ("SPI_FLASH_WriteStatus()"). + + Modify "SPI_FLASH_WaitForWriteEnd()" function to return value of status register. + + Add below notice of examples to inform the user to check the local structure variable without a + default value. + "Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below this function." + + Add "LIBCFG_MAX_SPEED" in the file "ht32fxxxxx_libcfg.h" which indicate the maximum core speed. + + Add the following definition for convenience. + PDMACH0_IRQn ~ PDMACH5_IRQn + AFIO_FUN_MCTM0 + AFIO_FUN_GPTM0 ~ AFIO_FUN_GPTM3 + AFIO_FUN_PWM0 + AFIO_FUN_SCTM0 ~ AFIO_FUN_SCTM2 + + Add new examples. + "TM/PWM" + "TM/UpdateEvent" + + Add "s64/u64" definition. + + Others + + Update comment, format, typing error, and coding style. + + Add below notice in the "FMC/FLASH_Security" example. + "The Option Byte will be write protected (cannot be changed again) after the + Security Protection is enabled. Refer to the user manual for details." + + Remove HSI disable setting of Configuration Wizard and add notice in the "system_xxxxx_nn.c". + + Update the following examples to remove compiler warning of the GNU compiler. + "USBD/Mass_Storage" + "USART/PDMA" + "USART/Interrupt" + + Add "-Waddress-of-packed-member" #pragma of below examples to remove compiler warning of the + GNU compiler. + "USBD/Mass_Storage" + "USBD/Mass_Storage_IAP" + "USBD/Mass_Storage_SDIO" + "USBD/HID_Keyboard" + "USBD/HID_Keyboard_Joystick" + "USBD/HID_Keyboard_Mass_Storage" + "USBD/HID_Keyboard_Virtual_COM" + "USBD/HID_Mouse" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v004_2103 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2020-04-25 + + Main Changes + + Remove the "I2C_Cmd()" in the "I2C_Init()" function since it shall be called after the I2C related + settings. User shall call the "I2C_Cmd()" by themself after the "I2C_Init()". + + Update "system_ht32f1xxxx_02.c", modify the LDO related setting. + + Add "USART_GetIntStatus()" function to get the enabled interrupt source. + + Add "RETARGET_HSI_ATM" setting to turn on/off the auto-trim function of HSI ("ht32f1xxxx_conf.h"). + + Add "USBDClass_Reset()" into the "USBD/*" example to reset related flag for the self-power application. + + Modify "ht32f5xxxx_aes.c", fix "AES_SetKeyTable()" and "_AES_CryptData()" functions who did not clear + related fields before set it. + + Rename examples as below. + IP Old Name New Name + -------- -------- -------- + ADC EXTITrigger_DiscontinuousMode Discontinuous_EXTITrigger + ADC PDMA_ADCResult OneShot_TMTrigger_PDMA + ADC Potentiometer_ContinuousMode Continuous_Potentiometer + ADC TM_Trigger OneShot_PWMTrigger + ADC TM_Trigger_with_Delay OneShot_PWMTrigger_with_Delay + USART HyperTerminal_TxRx Retarget + USART HyperTerminal_TxRx_Interrupt Interrupt + USART HyperTerminal_TxRx_Interrupt_FIFO Interrupt_FIFO + + Update the following example to improve readability. + "ADC/AnalogWatchdog" + "ADC/Continuous_Potentiometer" + "ADC/Discontinuous_EXTITrigger" + "ADC/InternalReferenceVoltage" + "ADC/OneShot_PWMTrigger" + "ADC/OneShot_PWMTrigger_with_Delay" + "ADC/OneShot_TMTrigger_PDMA" + "ADC/Two_Group_MaxCH" + "USART/Interrupt" + "USART/Interrupt_FIFO" + "USART/PDMA" + "USART/Polling" + "USART/Retarget" + "USBD/HID_Demo" + "USBD/HID_DemoVendorReport" + + Update UxART related example, turn on internal pull up to prevent unknown state. + + Add new examples. + "BFTM/OneShot" + "BFTM/TimeMeasure" + + Remove unnecessary RTC compare match restart setting of the RTC example + (which cause the time not correct after entering the low power mode). + + ADC to ADC0 related modification (to compatible with M0+ and ADC1). + Modify "HT_ADC" and "ADC_IRQn" to "HT_ADC0" and "ADC0_IRQn". + Modify "AFIO_FUN_ADC" as "AFIO_FUN_ADC0". + Modify "CKCU_SetADCPrescaler()" to "CKCU_SetADCnPrescaler()". + Add "CKCU_ADCPRE_ADCn_TypeDef". + Modify "ADC_Freq" to "ADC0_Freq" of "CKCU_ClocksTypeDef". + Modify "ADC" to "ADC0" of "RSTCU_PeripReset_TypeDef". + Add "HT_ADC", "ADC_IRQn", "AFIO_FUN_ADC" define for backward compatibility. + + Fix "HT_GPIOF" define error of HT32F12364. + + Others + + Update "SPI/FIFO_SEL_Hardware" example, change the code location of the IP enable ("SPI_Cmd()"). + + Update "system_ht32fxxxxx_nn.c" (coding style). + + Update "ht32_series.c/h" and "ht32_retarget_usbdconf.h" to improve the compatibly of the + terminal software. + + Update comment, format, typing error, and coding style. + + Fix interrupt mode of UxART retarget, remove unnecessary FIFO/interrupt configuration of the + retarget function. + + Update format of "CKCU_PeripClockConfig_TypeDef" and "RSTCU_PeripReset_TypeDef". + + Update and modify naming rule of the "HTCFG_xxxx" configuration define in the "ht32_board_config.h". + + Update settings of project files. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v004_1946 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-11-28 + + Main Changes + + Move the "common/*.h" include from the begin to the end (after the pin define) in the file + "HT32_Board/ht32fxxxx_sk/dvb.h". The original include way leads to the pin define lost when you + use the EBI_LCD->EBI_LCD_RAM outside the "ebi_lcd.c". + + Fix error of "_CreateProjectScript.bat" which cause the stack size and RW base can not be set by the + "_ProjectConfig.bat" of the emStudiov4 project. + + Add "GPIO_GetID()" function to convert HT_GPIOx to GPIO_Px. + + Update "HID_Demo_UI.exe" to support HID Report ID. + + Add "USBD/HID_DemoVendorReport" example. + + Modify "SPI_Init()" function, fix SPIx Clock Prescaler setting of HT32F12364. + + Modify "system_ht32f1xxxx_03.c", fix PLLCFGR initiation error which cause the "PLL_CLK_SRC_DIV" setting + is not work. + + Add "RETARGET_UxART_BAUDRATE" setting to change the retarget UART baudrate in "ht32f1xxxx_conf.h". + + Add "RETARGET_HSI_ATM" setting to turn on/off the auto-trim function of HSI. + + Add "RETARGET_DEFINE_HANDLER" setting to remove the UxARTn_IRQHandler() define of the retarget. + This setting is used for the model who grouping two UART Interrupt into one vector. + + Add non-block mode of USB Virtual-COM retarget function ((Drop data if USB or terminal software is + not ready). + + Modify "PWRCU_SetLDOFTRM()" function, fix the error which cause the LDO output voltage fine trim is + not work. + + Update "PWRCU_DeepSleep2()" to restore the LDO output voltage fine trim after system wakeup. + + Add SWCLK toggle of "GPIO_DisableDebugPort()" function. + + Others + + Add "utilities/common/lcd.h" to put the lcd related register together. + + Update format and coding style. + + Add PLL Output frequency comment of "system_ht32f1xxxx_nn.c". + + Update project files. + .c and .h files order. + Project format. + Include path order. + + Add "USAGE_PAGE_L" define of "USB/HID_Demo" example. + + Fix typing error of "ht32f1xxxx_conf.h". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v004_1812 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-09-11 + + Main Changes + + Add new device support. + HT32F12364 + + Update "ebi_lcd.c/h", fix LCD_SPI_BL_GPIO_XXX define error (shall be LCD_EBI_BL_GPIO_XXX). + + Update USB example, use USB PLL by default (if USB PLL exist). + + Fix function name typing error + SPI_GUADTCmd() -> SPI_GUARDTCmd() + SPI_GUADTConfig -> SPI_GUARDTConfig() + + Update "ADC_RegularGroupConfig()" and "ADC_HPGroupConfig()", prevent to enable the ADC directly after + the above function call. User shall use the "ADC_Cmd(HT_ADC, ENABLE);" to enable the ADC. + + Rename following files. + "IAR/startup_ht32f1xxxx_01.s" to "IARstartup_ht32f1xxxx_iar_01.s" + "IAR/startup_ht32f1xxxx_03.s" to "IARstartup_ht32f1xxxx_iar_03.s" + + Others + + Update comment and coding style. + + Update "USART/HyperTerminal_TxRx_Interrupt" example, remove unnecessary configuration of LED. + + Update readme file of "EBI/LCD" example. + + Add "PWRCU/PowerDown_RTC" example. + + Add "PWRCU/PWRCU_PowerDown_WAKEUPPin" example. + + Add "RTC/Time" example. + + Update and sync "ht32f1xxxx_conf.h". + + Update and sync "HT32F1xxxx_01_DebugSupport.ini". + + Update "ht32f1xxxx_tm.c", remove unnecessary variable initialization. + + Update "ht32_op.c" and "ht32_op.s", edit comment of WDT Enable function. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v003_1679 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-04-19 + + Main Changes + + Fix error of "CKCU_HSIAutoTrimClkConfig()" function which cause the HSI auto-trim not work. + + Modify following define of ADC. + ADC_CH_GNDREF -> ADC_CH_GND_VREF + ADC_CH_VREF -> ADC_CH_VDD_VREF + + Others + + None. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v003_1673 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-04-09 + + Main Changes + + Add SEGGER Embedded Studio IDE support (beta version). + + Update "ht32f1xxxx_usbd.c" and "ht32_usbd_core.c", add Force USB Reset Control function (apply to specific + model only). + + Update Create Project script, add Script folder in project_template. + + Add "TM/TriggerCounter" example. + + Add "USBD/HID_Keyboard_Mass_Storage" example. + + Others + + Update comment of example code. + + Update define of "USBD/Mass_Storage" example. + + Update "EXTI/WakeUp_DeepSleepMode1" Example, add LED3 (for some SK have only LED2 and LED3 on board). + + Update/sync startup.s/system.c files. + + Update/sync "HT32F1xxxx_01_DebugSupport.ini". + + Update/sync "ht32_op.s" and "ht32_op.c". + + Update "BootProcess" function. + + Update/sync "FlashMacro.mac". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v002_1496 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-12-17 + + Main Changes + + Modify Control IN/OUT method of USB Core, to fix USB transfer problem when CPU in the lower speed or late + USB interrupt case. + + Add workaround for PDMA CH3 issue (Interrupt Enable bit of CH3 is not work). + + Others + + Add "USBD_DisableDefaultPull()" function to disable pull resistance when the USB is not use. + + Rename RTC example as below. + "Calendar" -> "Time_BackupDomain" + + Add new example. + "RTC/Calendar_BackupDomain" + "FMC/EnableProtectionByFW" + + Update "EXTI/WakeUp_DeepSleepMode1" example. + + Update coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v002_1406 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-09-30 + + Main Changes + + Update HardFault_Handler of "ht32f1xxxx_01_it.c",add the debug instruction and system reset. + + Add "RAND/Random_Number" example and update "ht32_rand.c". + + Add "__HT_check_sp" and "__HT_check_heap" symbol into startup.s and watchpoint command into + "HT32F1xxxx_01_DebugSupport.ini" for debug stack/heap underflow, overflow, and overwrite. + + Update "USBD/HID_Keyboard_Joystick" and "USBD/HID_Mouse" example, change the set flag sequence + (before USBDCore_EPTWriteINData). + + Add GNU Make support of GNU Arm compiler. + + Others + + Add "objcooy.txt" which shows how to use obj tools of GNU Arm compiler. + + Update format and coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v002_1367 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-08-02 + + Main Changes + + Add GNU Arm compiler support. + - Add project_template related files + - "startup_ht32f5xxxx_gcc_nn.s" + - "linker.ld" (link script) + + Update "ht32f5xxxx_tm.c/.h", add following functions which have TM_CH_n parameter. + void TM_ForcedOREF(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, TM_OM_Enum ForcedAction) + void TM_SetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) + void TM_SetAsymmetricCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) + u32 TM_GetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n) + + Others + + Add "USBD/HID_Keyboard_Virtual_COM" example. + + Fix compile error when turn on Library debug mode (HT32_LIB_DEBUG = 1). + + Modify "example/NVIC/Vector_Table_Offset" example code to support GUN compiler. + + Simplify "example/USART/HyperTerminal_TxRx_Interrupt" example. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_1302 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-06-11 + + Main Changes + + Add SourceryG++Lite compiler support. + - Add project_template related files + - "startup_ht32f1xxxx_cs3_nn.s" + - "linker.ld" (link script) + + Add DMA support of "utilities/common/spi_flash.c". + + Add "EXTI_GetEdgeFlag()" function. + + Add LIBCFG_AES_SWAP function to process endian issue of AES. + + Others + + Update "ht32f1xxxx_conf.h" for AUTO_RETURN (\r) option. + + Update format of IAR "startup_ht32f1xxxx_01.s". + + Fix "LIBCFC_CKCU_USB_PLL" typing error of ht32fxxxx_libcfg.h and example code (shall be LIBCFG_CKCU_USB_PLL). + + Fix IAP_PPBIT define error of "IAP/IAP_UI" example. + + Update "ht32f1xxxx_ckcu.c" to remove unnecessary register write of PLL. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_1153 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-02-28 + + Main Changes + + Add "USBD/USB_UAC_Sound_RateControl" Example. + + Add "I2C_SpeedOffset" parameter of I2C_InitTypeDef to reach real I2C speed. + Note: Related examples are also updated. + + Change EBI timing of "ebi_lcd.c" to fix LCD display problem on HT32F12345 with ESK32-A2A31. + + Add "CKCU/HSI_AutoTrim_By_USB" Example. + + Update "CKCU_HSIAutoTrimIsReady" function of "ht32f5xxxx_ckcu.c". + + Others + + Update format and coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_1023 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-12-30 + + Main Changes + + Update boot related functions of "startup_ht32f1xxxx_nn.s" and "system_ht32f1xxxx_nn.c". + + Update "ht32_op.c" and "ht32_op.s" to support enable WDT function by Flash Option byte (Apply to specific + model only). + + Add "GPIO_DisableDebugPort()"" function to disable SWD function. + + Others + + Fix IAR Project setting error of IAP Example. + + Add "RTC_LSILoadTrimData()" function. + + Add "LIBCFG_RTC_LSI_LOAD_TRIM" define of HT32F165x. + + Remove useless "RTC_LSICmd()"" function. + + Update following examples, remove LSI enable code (LSI default on). + "PWRCU/DeepSleepMode1" + "PWRCU/BackupData" + "PWRCU/DeepSleepMode2" + "PWRCU/PowerDownMode" + "RTC/Calendar" + + Update I2S and USB UAC related examples (Coding style and remove unuse define). + + Update USB Example, remove invalid remote wakeup configuration by define (Only HID class support Remote + Wakeup). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_933 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-11-17 + + Main Changes + + Fix AES typing error of "ht32f1xxxx_aes.c/.h" (EBC to ECB). + + Fix TM define error of "ht32f1xxxx_tm.c/.h". + + Others + + Update "ht32_virtual_com.inf" file, add Digital Signature. + + Update typing error of example code. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_899 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-10-19 + + Main Changes + + Update "SDIO/SDCard" Example code. Fix read Card SCR problem which causes SDIO working on 1-bit mode + abnormally. + + Others + + Update project setting. + + Remove some project files. Use "CreateProject.bat" to copy project files automatically. + + Add "LIBCFG_CHIPNAME" define. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_785 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-08-31 + + Main Changes + + Fix "ht32f1xxxx_conf.h" typing error ("_ADC" to "_AES"). + + Fix AES typing error (EBC to ECB). + + Others + + Update "ht32_usbd_core.c" to support vendor function. + + Add "USE_MEM_HT32F1xxxx" define into project. + + Add "USE_MEM_HT32F1xxxx" default define into "ht32f1xxxx_xx_libcfg.h". + + Rename "system_ht32f1xxxx.h" to "system_ht32f1xxxx_01.h" for PACK requirement. + + Update IAP examples. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_671 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-07-27 + + Main Changes + + None + + Others + + Update "ht32_op.c", add CK_CODE/CK_DATA/CK_CODEOP in Option Bytes (same format with e-Writer32). + + Modify USB/Mass_Storage example for WIN10 compatibility issue. + + Add "USE_MEM_HT32F1xxxx" support for memory size define (LIBCFG_FLASH_SIZE/LIBCFG_RAM_SIZE). + + Add IAR EWARMv8 project template (create by IAR EWARM v8.11). + + Upgrade the version of IAR EWARM project template from v6.20 to v6.50. + Note: + 1. Supported CMSIS-DAP: IAR EWARM v6.50 and above. + 2. RDI/e-Link32 is not supported anymore from the v8.xx of IAR EWARM. + + Known Issue: + + IAP example is not ready, will be update in next release. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_552 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-07-17 + + Main Changes + + Add example code. + + Update TM for PDMA support. + + Fix "USART_RXTL_01/04/08/14" define error. + + Fix "HT32F_DVB_BuzzerFun()" define error of "ht32f1xxxx_board_01.c". + + Fix pin assignment error of "ht32f12366_sk.h" + + Others + + Add BUTTON_MODE_WAKE_UP support for "ht32f1xxxx_sk.c/.h". + + Update typing error and coding style. + + Remove warning on old MDK-ARM version. + + Update project setting. + + Add DEINIT_ENABLE setting of "ht32f1xxxx_system_nn.c". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F1xxxx_FWLib_v001_167 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-06-14 + + Main Changes + + Initial version. + + Others + + diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/SConscript b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/SConscript new file mode 100644 index 0000000000..bae7234da6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/SConscript @@ -0,0 +1,48 @@ +import rtconfig +from building import * + +cwd = GetCurrentDir() + +src = Split(""" + library/HT32F1xxxx_Driver/src/ht32_cm3_misc.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_aes.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_bftm.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_ckcu.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_crc.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_ebi.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_exti.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_flash.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_gpio.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2c.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2s.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_mctm.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_pdma.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwrcu.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_rstcu.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_rtc.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_sci.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_sdio.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_spi.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_tm.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_usart.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_usbd.c + library/HT32F1xxxx_Driver/src/ht32f1xxxx_wdt.c + + library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_02.c +""") +#HT32F1xxxx_Driver/src/ht32f1xxxx_csif.c + +path = [ + cwd + '/library/HT32F1xxxx_Driver/inc', + cwd + '/library/CMSIS/Include', + cwd + '/library/Device/Holtek/HT32F1xxxx/Include' +] + +CPPDEFINES = ['USE_HT32_DRIVER'] + +group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) + +Return('group') + diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc new file mode 100644 index 0000000000..96775d502a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc @@ -0,0 +1,3271 @@ + + + + CMSIS + CMSIS (Common Microcontroller Software Interface Standard) + ARM + + http://www.keil.com/pack/ + + + + CMSIS-Core(M): 5.6.0 + - Arm Cortex-M85 cpu support + - Arm China STAR-MC1 cpu support + - Updated system_ARMCM55.c + CMSIS-DSP: 1.10.0 (see revision history for details) + CMSIS-NN: 3.1.0 (see revision history for details) + - Support for int16 convolution and fully connected for reference implementation + - Support for DSP extension optimization for int16 convolution and fully connected + - Support dilation for int8 convolution + - Support dilation for int8 depthwise convolution + - Support for int16 depthwise conv for reference implementation including dilation + - Support for int16 average and max pooling for reference implementation + - Support for elementwise add and mul int16 scalar version + - Support for softmax int16 scalar version + - Support for SVDF with 8 bit state tensor + CMSIS-RTOS2: 2.1.3 (unchanged) + - RTX 5.5.4 (see revision history for details) + CMSIS-Pack: deprecated (moved to Open-CMSIS-Pack) + CMSIS-SVD: 1.3.9 (see revision history for details) + CMSIS-DAP: 2.1.1 (see revision history for details) + - Allow default clock frequency to use fast clock mode + Devices + - Support for Cortex-M85 + Utilities + - SVDConv 3.3.42 + - PackChk 1.3.95 + + + CMSIS-Core(M): 5.5.0 (see revision history for details) + - Updated GCC LinkerDescription, GCC Assembler startup + - Added Armv8-M Stack Sealing (to linker, startup) for toolchain ARM, GCC + - Changed C-Startup to default Startup. + - Updated Armv8-M Assembler startup to use GAS syntax + Note: Updating existing projects may need manual user interaction! + CMSIS-Core(A): 1.2.1 (see revision history for details) + - Bugfixes for Cortex-A32 + CMSIS-DAP: 2.1.0 (see revision history for details) + - Enhanced DAP_Info + - Added extra UART support + CMSIS-DSP: 1.9.0 (see revision history for details) + - Purged pre-built libs from Git + - Enhanced support for f16 datatype + - Fixed couple of GCC issues + CMSIS-NN: 3.0.0 (see revision history for details including version 2.0.0) + - Major interface change for functions compatible with TensorFlow Lite for Microcontroller + - Added optimization for SVDF kernel + - Improved MVE performance for fully Connected and max pool operator + - NULL bias support for fully connected operator in non-MVE case(Can affect performance) + - Expanded existing unit test suite along with support for FVP + - Removed Examples folder + CMSIS-RTOS2: + - RTX 5.5.3 (see revision history for details) + - CVE-2021-27431 vulnerability mitigation. + - Enhanced stack overrun checking. + - Various bug fixes and improvements. + CMSIS-Pack: 1.7.2 (see revision history for details) + - Support for Microchip XC32 compiler + - Support for Custom Datapath Extension + + + CMSIS-Build: 0.9.0 (beta) + - Draft for CMSIS Project description (CPRJ) + CMSIS-Core(M): 5.4.0 (see revision history for details) + - Cortex-M55 cpu support + - Enhanced MVE support for Armv8.1-MML + - Fixed device config define checks. + - L1 Cache functions for Armv7-M and later + CMSIS-Core(A): 1.2.0 (see revision history for details) + - Fixed GIC_SetPendingIRQ to use GICD_SGIR + - Added missing DSP intrinsics + - Reworked assembly intrinsics: volatile, barriers and clobber + CMSIS-DSP: 1.8.0 (see revision history for details) + - Added new functions and function groups + - Added MVE support + CMSIS-NN: 1.3.0 (see revision history for details) + - Added MVE support + - Further optimizations for kernels using DSP extension + CMSIS-RTOS2: + - RTX 5.5.2 (see revision history for details) + CMSIS-Driver: 2.8.0 + - Added VIO API 0.1.0 (Preview) + - removed volatile from status related typedefs in APIs + - enhanced WiFi Interface API with support for polling Socket Receive/Send + CMSIS-Pack: 1.6.3 (see revision history for details) + - deprecating all types specific to cpdsc format. Cpdsc is replaced by Cprj with dedicated schema. + Devices: + - ARMCM55 device + - ARMv81MML startup code recognizing __MVE_USED macro + - Refactored vector table references for all Cortex-M devices + - Reworked ARMCM* C-StartUp files. + - Include L1 Cache functions in ARMv8MML/ARMv81MML devices + Utilities: + Attention: Linux binaries moved to Linux64 folder! + - SVDConv 3.3.35 + - PackChk 1.3.89 + + + CMSIS-Core(M): 5.3.0 (see revision history for details) + - Added provisions for compiler-independent C startup code. + CMSIS-Core(A): 1.1.4 (see revision history for details) + - Fixed __FPU_Enable. + CMSIS-DSP: 1.7.0 (see revision history for details) + - New Neon versions of f32 functions + - Python wrapper + - Preliminary cmake build + - Compilation flags for FFTs + - Changes to arm_math.h + CMSIS-NN: 1.2.0 (see revision history for details) + - New function for depthwise convolution with asymmetric quantization. + - New support functions for requantization. + CMSIS-RTOS: + - RTX 4.82.0 (updated provisions for Arm Compiler 6 when using Cortex-M0/M0+) + CMSIS-RTOS2: + - RTX 5.5.1 (see revision history for details) + CMSIS-Driver: 2.7.1 + - WiFi Interface API 1.0.0 + Devices: + - Generalized C startup code for all Cortex-M family devices. + - Updated Cortex-A default memory regions and MMU configurations + - Moved Cortex-A memory and system config files to avoid include path issues + + + The following folders are deprecated + - CMSIS/Include/ (superseded by CMSIS/DSP/Include/ and CMSIS/Core/Include/) + + CMSIS-Core(M): 5.2.1 (see revision history for details) + - Fixed compilation issue in cmsis_armclang_ltm.h + + + The following folders have been removed: + - CMSIS/Lib/ (superseded by CMSIS/DSP/Lib/) + - CMSIS/DSP_Lib/ (superseded by CMSIS/DSP/) + The following folders are deprecated + - CMSIS/Include/ (superseded by CMSIS/DSP/Include/ and CMSIS/Core/Include/) + + CMSIS-Core(M): 5.2.0 (see revision history for details) + - Reworked Stack/Heap configuration for ARM startup files. + - Added Cortex-M35P device support. + - Added generic Armv8.1-M Mainline device support. + CMSIS-Core(A): 1.1.3 (see revision history for details) + CMSIS-DSP: 1.6.0 (see revision history for details) + - reworked DSP library source files + - reworked DSP library documentation + - Changed DSP folder structure + - moved DSP libraries to folder ./DSP/Lib + - ARM DSP Libraries are built with ARMCLANG + - Added DSP Libraries Source variant + CMSIS-RTOS2: + - RTX 5.5.0 (see revision history for details) + CMSIS-Driver: 2.7.0 + - Added WiFi Interface API 1.0.0-beta + - Added components for project specific driver implementations + CMSIS-Pack: 1.6.0 (see revision history for details) + Devices: + - Added Cortex-M35P and ARMv81MML device templates. + - Fixed C-Startup Code for GCC (aligned with other compilers) + Utilities: + - SVDConv 3.3.25 + - PackChk 1.3.82 + + + Aligned pack structure with repository. + The following folders are deprecated: + - CMSIS/Include/ + - CMSIS/DSP_Lib/ + + CMSIS-Core(M): 5.1.2 (see revision history for details) + - Added Cortex-M1 support (beta). + CMSIS-Core(A): 1.1.2 (see revision history for details) + CMSIS-NN: 1.1.0 + - Added new math functions. + CMSIS-RTOS2: + - API 2.1.3 (see revision history for details) + - RTX 5.4.0 (see revision history for details) + * Updated exception handling on Cortex-A + CMSIS-Driver: + - Flash Driver API V2.2.0 + Utilities: + - SVDConv 3.3.21 + - PackChk 1.3.71 + + + Updated Arm company brand. + CMSIS-Core(M): 5.1.1 (see revision history for details) + CMSIS-Core(A): 1.1.1 (see revision history for details) + CMSIS-DAP: 2.0.0 (see revision history for details) + CMSIS-NN: 1.0.0 + - Initial contribution of the bare metal Neural Network Library. + CMSIS-RTOS2: + - RTX 5.3.0 (see revision history for details) + - OS Tick API 1.0.1 + + + CMSIS-Core(M): 5.1.0 (see revision history for details) + - Added MPU Functions for ARMv8-M for Cortex-M23/M33. + - Added compiler_iccarm.h to replace compiler_iar.h shipped with the compiler. + CMSIS-Core(A): 1.1.0 (see revision history for details) + - Added compiler_iccarm.h. + - Added additional access functions for physical timer. + CMSIS-DAP: 1.2.0 (see revision history for details) + CMSIS-DSP: 1.5.2 (see revision history for details) + CMSIS-Driver: 2.6.0 (see revision history for details) + - CAN Driver API V1.2.0 + - NAND Driver API V2.3.0 + CMSIS-RTOS: + - RTX: added variant for Infineon XMC4 series affected by PMU_CM.001 errata. + CMSIS-RTOS2: + - API 2.1.2 (see revision history for details) + - RTX 5.2.3 (see revision history for details) + Devices: + - Added GCC startup and linker script for Cortex-A9. + - Added device ARMCM0plus_MPU for Cortex-M0+ with MPU. + - Added IAR startup code for Cortex-A9 + + + CMSIS-RTOS2: + - RTX 5.2.1 (see revision history for details) + + + CMSIS-Core(M): 5.0.2 (see revision history for details) + - Changed Version Control macros to be core agnostic. + - Added MPU Functions for ARMv7-M for Cortex-M0+/M3/M4/M7. + CMSIS-Core(A): 1.0.0 (see revision history for details) + - Initial release + - IRQ Controller API 1.0.0 + CMSIS-Driver: 2.05 (see revision history for details) + - All typedefs related to status have been made volatile. + CMSIS-RTOS2: + - API 2.1.1 (see revision history for details) + - RTX 5.2.0 (see revision history for details) + - OS Tick API 1.0.0 + CMSIS-DSP: 1.5.2 (see revision history for details) + - Fixed GNU Compiler specific diagnostics. + CMSIS-Pack: 1.5.0 (see revision history for details) + - added System Description File (*.SDF) Format + CMSIS-Zone: 0.0.1 (Preview) + - Initial specification draft + + + Package Description: + - added taxonomy for Cclass RTOS + CMSIS-RTOS2: + - API 2.1 (see revision history for details) + - RTX 5.1.0 (see revision history for details) + CMSIS-Core: 5.0.1 (see revision history for details) + - Added __PACKED_STRUCT macro + - Added uVisior support + - Updated cmsis_armcc.h: corrected macro __ARM_ARCH_6M__ + - Updated template for secure main function (main_s.c) + - Updated template for Context Management for ARMv8-M TrustZone (tz_context.c) + CMSIS-DSP: 1.5.1 (see revision history for details) + - added ARMv8M DSP libraries. + CMSIS-Pack:1.4.9 (see revision history for details) + - added Pack Index File specification and schema file + + + Changed open source license to Apache 2.0 + CMSIS_Core: + - Added support for Cortex-M23 and Cortex-M33. + - Added ARMv8-M device configurations for mainline and baseline. + - Added CMSE support and thread context management for TrustZone for ARMv8-M + - Added cmsis_compiler.h to unify compiler behaviour. + - Updated function SCB_EnableICache (for Cortex-M7). + - Added functions: NVIC_GetEnableIRQ, SCB_GetFPUType + CMSIS-RTOS: + - bug fix in RTX 4.82 (see revision history for details) + CMSIS-RTOS2: + - new API including compatibility layer to CMSIS-RTOS + - reference implementation based on RTX5 + - supports all Cortex-M variants including TrustZone for ARMv8-M + CMSIS-SVD: + - reworked SVD format documentation + - removed SVD file database documentation as SVD files are distributed in packs + - updated SVDConv for Win32 and Linux + CMSIS-DSP: + - Moved DSP libraries from CMSIS/DSP/Lib to CMSIS/Lib. + - Added DSP libraries build projects to CMSIS pack. + + + - CMSIS-Core 4.30.0 (see revision history for details) + - CMSIS-DAP 1.1.0 (unchanged) + - CMSIS-Driver 2.04.0 (see revision history for details) + - CMSIS-DSP 1.4.7 (no source code change [still labeled 1.4.5], see revision history for details) + - CMSIS-Pack 1.4.1 (see revision history for details) + - CMSIS-RTOS 4.80.0 Restored time delay parameter 'millisec' old behavior (prior V4.79) for software compatibility. (see revision history for details) + - CMSIS-SVD 1.3.1 (see revision history for details) + + + - CMSIS-Core 4.20 (see revision history for details) + - CMSIS-DSP 1.4.6 (no source code change [still labeled 1.4.5], see revision history for details) + - CMSIS-Pack 1.4.0 (adding memory attributes, algorithm style) + - CMSIS-Driver 2.03.0 (adding CAN [Controller Area Network] API) + - CMSIS-RTOS + -- API 1.02 (unchanged) + -- RTX 4.79 (see revision history for details) + - CMSIS-SVD 1.3.0 (see revision history for details) + - CMSIS-DAP 1.1.0 (extended with SWO support) + + + - CMSIS-Core 4.10 (Cortex-M7 extended Cache Maintenance functions) + - CMSIS-DSP 1.4.5 (see revision history for details) + - CMSIS-Driver 2.02 (adding SAI (Serial Audio Interface) API) + - CMSIS-Pack 1.3.3 (Semantic Versioning, Generator extensions) + - CMSIS-RTOS + -- API 1.02 (unchanged) + -- RTX 4.78 (see revision history for details) + - CMSIS-SVD 1.2 (unchanged) + + + Adding Cortex-M7 support + - CMSIS-Core 4.00 (Cortex-M7 support, corrected C++ include guards in core header files) + - CMSIS-DSP 1.4.4 (Cortex-M7 support and corrected out of bound issues) + - CMSIS-Pack 1.3.1 (Cortex-M7 updates, clarification, corrected batch files in Tutorial) + - CMSIS-SVD 1.2 (Cortex-M7 extensions) + - CMSIS-RTOS RTX 4.75 (see revision history for details) + + + - fixed conditions preventing the inclusion of the DSP library in projects for Infineon XMC4000 series devices + + + - CMSIS-Driver 2.02 (incompatible update) + - CMSIS-Pack 1.3 (see revision history for details) + - CMSIS-DSP 1.4.2 (unchanged) + - CMSIS-Core 3.30 (unchanged) + - CMSIS-RTOS RTX 4.74 (unchanged) + - CMSIS-RTOS API 1.02 (unchanged) + - CMSIS-SVD 1.10 (unchanged) + PACK: + - removed G++ specific files from PACK + - added Component Startup variant "C Startup" + - added Pack Checking Utility + - updated conditions to reflect tool-chain dependency + - added Taxonomy for Graphics + - updated Taxonomy for unified drivers from "Drivers" to "CMSIS Drivers" + + + + - CMSIS-RTOS 4.74 (see revision history for details) + - PACK Extensions (Boards, Device Features, Flash Programming, Generators, Configuration Wizard). Schema version 1.1. + + + + + + + + + Software components for audio processing + Generic Interfaces for Evaluation and Development Boards + Drivers that support an external component available on an evaluation board + Compiler Software Extensions + Cortex Microcontroller Software Interface Components + Unified Device Drivers compliant to CMSIS-Driver Specifications + Startup, System Setup + Data exchange or data formatter + Drivers that support an extension board or shield + File Drive Support and File System + IoT cloud client connector + IoT specific services + IoT specific software utility + Graphical User Interface + Network Stack using Internet Protocols + Real-time Operating System + Encryption for secure communication or storage + Universal Serial Bus Stack + Generic software utility components + + + + + + + +The Cortex-M0 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + +The Cortex-M0+ processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + + + + + + +The ARM Cortex-M1 FPGA processor is intended for deeply embedded applications that require a small processor integrated into an FPGA. +The ARM Cortex-M1 processor implements the ARMv6-M architecture profile. + + + + + + + + + + + + + + + + +The Cortex-M3 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + +The Cortex-M4 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + + + + + + +The Cortex-M7 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + + + + + + + + + + + +The Arm Cortex-M23 is based on the Armv8-M baseline architecture. +It is the smallest and most energy efficient Arm processor with Arm TrustZone technology. +Cortex-M23 is the ideal processor for constrained embedded applications requiring efficient security. + + + + + + + + + + + + + + + + + + + + + + + +The Arm Cortex-M33 is the most configurable of all Cortex-M processors. It is a full featured microcontroller +class processor based on the Armv8-M mainline architecture with Arm TrustZone security. + + + + + + + + + + + + no DSP Instructions, no Floating Point Unit, no TrustZone + + + + + + + + no DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, no TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-M35P is the most configurable of all Cortex-M processors. It is a full featured microcontroller +class processor based on the Armv8-M mainline architecture with Arm TrustZone security designed for a broad range of secure embedded applications. + + + + + + + + + + + + + no DSP Instructions, no Floating Point Unit, no TrustZone + + + + + + + + no DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, no TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-M55 processor is a fully synthesizable, mid-range, microcontroller-class processor that implements the Armv8.1-M mainline architecture and includes support for the M-profile Vector Extension (MVE), also known as Arm Helium technology. +It is Arm's most AI-capable Cortex-M processor, delivering enhanced, energy-efficient digital signal processing (DSP) and machine learning (ML) performance. +The Cortex-M55 processor achieves high compute performance across scalar and vector operations, while maintaining low energy consumption. + + + + + + + + + + + + + Floating Point Vector Extensions, DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-M85 processor is a fully synthesizable high-performance microcontroller class processor that implements the Armv8.1-M Mainline architecture which includes support for the M-profile Vector Extension (MVE). +The processor also supports previous Armv8-M architectural features. +The design is focused on compute applications such as Digital Signal Processing (DSP) and machine learning. +The Arm Cortex-M85 processor is energy efficient and achieves high compute performance across scalar and vector operations while maintaining low power consumption. + + + + + + + + + + + + + Floating Point Vector Extensions, DSP Instructions, Double Precision Floating Point Unit, TrustZone, PACBTI + + + + + + + + +The Arm SC000 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of secure embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling + + + + + + + + + + + + + + + +The ARM SC300 processor is an entry-level 32-bit ARM Cortex processor designed for a broad range of secure embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling + + + + + + + + + + + + + + + + +Armv8-M Baseline based device with TrustZone + + + + + + + + + + + + + + + + + + +Armv8-M Mainline based device with TrustZone + + + + + + + + + + + + no DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + no DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + no DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + + +Armv8.1-M Mainline based device with TrustZone and MVE + + + + + + + + + + + + + Double Precision Vector Extensions, DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-A5 processor is a high-performance, low-power, Arm macrocell with an L1 cache subsystem that provides full +virtual memory capabilities. The Cortex-A5 processor implements the Armv7-A architecture profile and can execute 32-bit +Arm instructions and 16-bit and 32-bit Thumb instructions. The Cortex-A5 is the smallest member of the Cortex-A processor family. + + + + + + + + + + + + + + + + + +The Cortex-A7 MPCore processor is a high-performance, low-power processor that implements the Armv7-A architecture. +The Cortex-A7 MPCore processor has one to four processors in a single multiprocessor device with a L1 cache subsystem, +an optional integrated GIC, and an optional L2 cache controller. + + + + + + + + + + + + + + + + + +The Cortex-A9 processor is a high-performance, low-power, Arm macrocell with an L1 cache subsystem that provides full virtual memory capabilities. +The Cortex-A9 processor implements the Armv7-A architecture and runs 32-bit Arm instructions, 16-bit and 32-bit Thumb instructions, +and 8-bit Java bytecodes in Jazelle state. + + + + + + + + + + + + + + + + + + + Device interrupt controller interface + + + + + + RTOS Kernel system tick timer interface + + + + + + + CMSIS-RTOS API for Cortex-M, SC000, and SC300 + + + + + + CMSIS-RTOS API for Cortex-M, SC000, and SC300 + + + + + + + + USART Driver API for Cortex-M + + + + + + + SPI Driver API for Cortex-M + + + + + + + SAI Driver API for Cortex-M + + + + + + + I2C Driver API for Cortex-M + + + + + + + CAN Driver API for Cortex-M + + + + + + + Flash Driver API for Cortex-M + + + + + + + MCI Driver API for Cortex-M + + + + + + + NAND Flash Driver API for Cortex-M + + + + + + + Ethernet MAC and PHY Driver API for Cortex-M + + + + + + + + Ethernet MAC Driver API for Cortex-M + + + + + + + Ethernet PHY Driver API for Cortex-M + + + + + + + USB Device Driver API for Cortex-M + + + + + + + USB Host Driver API for Cortex-M + + + + + + + WiFi driver + + + + + + + Virtual I/O + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Armv6-M architecture based device + + + + + + + Armv7-M architecture based device + + + + + + + Armv8-M base line architecture based device + + + + + Armv8-M main line architecture based device + + + + + + + Armv8.1-M main line architecture based device + + + + + + Armv8-M/Armv8.1-M architecture based device + + + + + Armv8-M architecture based device + + + + + + Armv6_7-M architecture based device + + + + + Armv6_7_8-M architecture based device + + + + + + Armv7-A architecture based device + + + + + + + TrustZone + + + + TrustZone (Secure) + + + + + TrustZone (Non-secure) + + + + + + + + Startup files for Arm Compiler 6 targeting TrustZone secure mode + + + + + Startup files for Arm Compiler 6 targeting non-TrustZone or TrustZone non-secure mode + + + + + + + Generic Arm Cortex-M0 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M0+ device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M1 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M3 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M4 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M7 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M23 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M33 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M35P device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M55 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M85 device startup and depends on CMSIS Core + + + + + + Generic Arm SC000 device startup and depends on CMSIS Core + + + + + + Generic Arm SC300 device startup and depends on CMSIS Core + + + + + + Generic Armv8-M Baseline device startup and depends on CMSIS Core + + + + + + Generic Armv8-M Mainline device startup and depends on CMSIS Core + + + + + + Generic Armv8.1-M Mainline device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-A5 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-A7 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-A9 device startup and depends on CMSIS Core + + + + + + + Components required for DSP + + + + + + + + Components required for NN + + + + + + Components required for RTOS RTX + + + + + + + Components required for RTOS RTX IFX + + + + + + + + Components required for RTOS RTX5 + + + + + + Components required for RTOS2 RTX5 + + + + + + + Components required for RTOS2 RTX5 on Armv7-A + + + + + + + + + Components required for RTOS2 RTX5 in Non-Secure Domain + + + + + + + + + Arm Compiler for Armv6-M architecture (little endian) + + + + + + Arm Compiler for Armv6-M architecture (big endian) + + + + + + Arm Compiler for Armv7-M architecture without FPU (little endian) + + + + + + + Arm Compiler for Armv7-M architecture without FPU (big endian) + + + + + + + Arm Compiler for Armv7-M architecture with FPU (little endian) + + + + + + + + Arm Compiler for Armv7-M architecture with FPU (big endian) + + + + + + + + Arm Compiler for Armv8-M base line architecture (little endian) + + + + + + Arm Compiler for Armv8-M/Armv8.1-M main line architecture without FPU/MVE (little endian) + + + + + + + + Arm Compiler for Armv8-M/Armv8.1-M main line architecture with FPU/MVE (little endian) + + + + + + + + + + + GNU Compiler for Armv6-M architecture (little endian) + + + + + + GNU Compiler for Armv6-M architecture (big endian) + + + + + + GNU Compiler for Armv7-M architecture without FPU (little endian) + + + + + + + GNU Compiler for Armv7-M architecture without FPU (big endian) + + + + + + + GNU Compiler for Armv7-M architecture with FPU (little endian) + + + + + + + + GNU Compiler for Armv7-M architecture with FPU (big endian) + + + + + + + + GNU Compiler for Armv8-M base line architecture (little endian) + + + + + + GNU Compiler for Armv8-M/Armv8.1-M main line architecture without FPU/MVE (little endian) + + + + + + + + GNU Compiler for Armv8-M/Armv8.1-M main line architecture with FPU/MVE (little endian) + + + + + + + + + + + IAR Compiler for Armv6-M architecture (little endian) + + + + + + IAR Compiler for Armv6-M architecture (big endian) + + + + + + IAR Compiler for Armv7-M architecture without FPU (little endian) + + + + + + + IAR Compiler for Armv7-M architecture without FPU (big endian) + + + + + + + IAR Compiler for Armv7-M architecture with FPU (little endian) + + + + + + + + IAR Compiler for Armv7-M architecture with FPU (big endian) + + + + + + + + IAR Compiler for Armv8-M base line architecture (little endian) + + + + + + IAR Compiler for Armv8-M main line architecture without FPU (little endian) + + + + + + + IAR Compiler for Armv8-M main line architecture with FPU (little endian) + + + + + + + + IAR Compiler for Armv8.1-M main line architecture without FPU/MVE (little endian) + + + + + + + + IAR Compiler for Armv8.1-M main line architecture with FPU/MVE (little endian) + + + + + + + + + + + Arm Assembler for Armv6-M architecture + + + + + GNU Assembler for Armv6-M architecture + + + + + + IAR Assembler for Armv6-M architecture + + + + + + Arm Assembler for Armv7-M architecture + + + + + GNU Assembler for Armv7-M architecture + + + + + + IAR Assembler for Armv7-M architecture + + + + + + GNU Assembler for Armv8-M base line architecture + + + + + GNU Assembler for Armv8-M/Armv8.1-M main line architecture + + + + + IAR Assembler for Armv8-M base line architecture + + + + + IAR Assembler for Armv8-M main line architecture + + + + + + Arm Assembler for Armv7-A architecture + + + + + GNU Assembler for Armv7-A architecture + + + + + + IAR Assembler for Armv7-A architecture + + + + + + + Components required for OS Tick Private Timer + + + + + + + Components required for OS Tick Generic Physical Timer + + + + + + + + + + CMSIS-CORE for Cortex-M, SC000, SC300, Star-MC1, ARMv8-M, ARMv8.1-M + + + + + + + + + + + + + CMSIS-CORE for Cortex-A + + + + + + + + + + + System and Startup for Generic Arm Cortex-M0 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M0 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M0+ device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M0+ device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M1 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M1 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M3 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M3 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M4 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M4 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M7 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M7 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M23 device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M23 device + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M33 device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M33 device + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M35P device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M35P device + + + + + + + + + + + + + + + + + + + System and Startup for Generic Cortex-M55 device + + + + + + + + + + + + + + + + + System and Startup for Generic Cortex-M85 device + + + + + + + + + + + + + + + + + System and Startup for Generic Arm SC000 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm SC000 device + + + + + + + + + + + + + + + System and Startup for Generic Arm SC300 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm SC300 device + + + + + + + + + + + + + + + System and Startup for Generic Armv8-M Baseline device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Armv8-M Baseline device + + + + + + + + + + + + + + + + + + System and Startup for Generic Armv8-M Mainline device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Armv8-M Mainline device + + + + + + + + + + + + + + + + + + System and Startup for Generic Armv8.1-M Mainline device + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-A5 device + + + + + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-A7 device + + + + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-A9 device + + + + + + + + + + + + + + + + + + + + + + IRQ Controller implementation using GIC + + + + + + + + OS Tick implementation using Private Timer + + + + + + + OS Tick implementation using Generic Physical Timer + + + + + + + + CMSIS-DSP Library for Cortex-M, SC000, and SC300 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-NN Neural Network Library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS RTX implementation for Cortex-M, SC000, and SC300 + + + #define RTE_CMSIS_RTOS /* CMSIS-RTOS */ + #define RTE_CMSIS_RTOS_RTX /* CMSIS-RTOS Keil RTX */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS RTX implementation for Infineon XMC4 series affected by PMU_CM.001 errata + + + #define RTE_CMSIS_RTOS /* CMSIS-RTOS */ + #define RTE_CMSIS_RTOS_RTX /* CMSIS-RTOS Keil RTX */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS RTX5 implementation for Cortex-M, SC000, and SC300 + + + #define RTE_CMSIS_RTOS /* CMSIS-RTOS */ + #define RTE_CMSIS_RTOS_RTX5 /* CMSIS-RTOS Keil RTX5 */ + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Cortex-M, SC000, SC300, ARMv8-M, ARMv8.1-M (Library) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Armv8-M/Armv8.1-M Non-Secure Domain (Library) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_ARMV8M_NS /* CMSIS-RTOS2 Keil RTX5 Armv8-M Non-secure domain */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Cortex-M, SC000, SC300, ARMv8-M, ARMv8.1-M (Source) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Armv7-A (Source) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Armv8-M/Armv8.1-M Non-Secure Domain (Source) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */ + #define RTE_CMSIS_RTOS2_RTX5_ARMV8M_NS /* CMSIS-RTOS2 Keil RTX5 Armv8-M Non-secure domain */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Access to #include Driver_USART.h file and code template for custom implementation + + + + + + + Access to #include Driver_SPI.h file and code template for custom implementation + + + + + + + Access to #include Driver_SAI.h file and code template for custom implementation + + + + + + + Access to #include Driver_I2C.h file and code template for custom implementation + + + + + + + Access to #include Driver_CAN.h file and code template for custom implementation + + + + + + + Access to #include Driver_Flash.h file and code template for custom implementation + + + + + + + Access to #include Driver_MCI.h file and code template for custom implementation + + + + + + + Access to #include Driver_NAND.h file and code template for custom implementation + + + + + + + Access to #include Driver_ETH_PHY/MAC.h files and code templates for custom implementation + + + + + + + + + Access to #include Driver_ETH_MAC.h file and code template for custom implementation + + + + + + + Access to #include Driver_ETH_PHY.h file and code template for custom implementation + + + + + + + Access to #include Driver_USBD.h file and code template for custom implementation + + + + + + + Access to #include Driver_USBH.h file and code template for custom implementation + + + + + + + Access to #include Driver_WiFi.h file + + + + + + + + + Virtual I/O custom implementation template + + + + + + Virtual I/O implementation using memory only + + + + + + + + + + uVision Simulator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EWARM Simulator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DSP_Lib Bayes example + + + + + + + + + Getting Started + + + + + DSP_Lib Class Marks example + + + + + + + + + Getting Started + + + + + DSP_Lib Convolution example + + + + + + + + + Getting Started + + + + + DSP_Lib Dotproduct example + + + + + + + + + Getting Started + + + + + DSP_Lib FFT Bin example + + + + + + + + + Getting Started + + + + + DSP_Lib FIR example + + + + + + + + + Getting Started + + + + + DSP_Lib Graphic Equalizer example + + + + + + + + + Getting Started + + + + + DSP_Lib Linear Interpolation example + + + + + + + + + Getting Started + + + + + DSP_Lib Matrix example + + + + + + + + + Getting Started + + + + + DSP_Lib Signal Convergence example + + + + + + + + + Getting Started + + + + + DSP_Lib Sinus/Cosinus example + + + + + + + + + Getting Started + + + + + DSP_Lib SVM example + + + + + + + + + Getting Started + + + + + DSP_Lib Variance example + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Blinky example + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 mixed API v1 and v2 + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Message Queue Example + + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Memory Pool Example + + + + + + + + + + Getting Started + + + + + Bare-metal secure/non-secure example without RTOS + + + + + + + + + Getting Started + + + + + Secure/non-secure RTOS example with thread context management + + + + + + + + + Getting Started + + + + + Secure/non-secure RTOS example with security test cases and system recovery + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Blinky example + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Message Queue Example + + + + + + + + + Getting Started + + + + + + diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h new file mode 100644 index 0000000000..abebc95f94 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h @@ -0,0 +1,411 @@ +/****************************************************************************** + * @file cachel1_armv7.h + * @brief CMSIS Level 1 Cache API for Armv7-M and later + * @version V1.0.1 + * @date 19. April 2021 + ******************************************************************************/ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_CACHEL1_ARMV7_H +#define ARM_CACHEL1_ARMV7_H + +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_CacheFunctions Cache Functions + \brief Functions that configure Instruction and Data cache. + @{ + */ + +/* Cache Size ID Register Macros */ +#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) +#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) + +#ifndef __SCB_DCACHE_LINE_SIZE +#define __SCB_DCACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#endif + +#ifndef __SCB_ICACHE_LINE_SIZE +#define __SCB_ICACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#endif + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */ + + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate I-Cache + \details Invalidates I-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief I-Cache Invalidate by address + \details Invalidates I-Cache for the given address. + I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + I-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] isize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (volatile void *addr, int32_t isize) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if ( isize > 0 ) { + int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_ICACHE_LINE_SIZE; + op_size -= __SCB_ICACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */ + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + __DSB(); + + SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable D-Cache + \details Turns off D-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | + ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address. + D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (volatile void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (volatile void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned and invalidated. + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (volatile void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + +/*@} end of CMSIS_Core_CacheFunctions */ + +#endif /* ARM_CACHEL1_ARMV7_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h new file mode 100644 index 0000000000..a955d47139 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h @@ -0,0 +1,888 @@ +/**************************************************************************//** + * @file cmsis_armcc.h + * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file + * @version V5.3.2 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_ARMCC_H +#define __CMSIS_ARMCC_H + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) + #error "Please use Arm Compiler Toolchain V4.0.677 or later!" +#endif + +/* CMSIS compiler control architecture macros */ +#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \ + (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) ) + #define __ARM_ARCH_6M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1)) + #define __ARM_ARCH_7M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1)) + #define __ARM_ARCH_7EM__ 1 +#endif + + /* __ARM_ARCH_8M_BASE__ not applicable */ + /* __ARM_ARCH_8M_MAIN__ not applicable */ + /* __ARM_ARCH_8_1M_MAIN__ not applicable */ + +/* CMSIS compiler control DSP macros */ +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __ARM_FEATURE_DSP 1 +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE static __forceinline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __declspec(noreturn) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed)) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT __packed struct +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION __packed union +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x))) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr))) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __memory_changed() +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __nop + + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __dsb(0xF) + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) +{ + rev16 r0, r0 + bx lr +} +#endif + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value) +{ + revsh r0, r0 + bx lr +} +#endif + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +#define __ROR __ror + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __breakpoint(value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __RBIT __rbit +#else +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ + return result; +} +#endif + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __clz + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) +#else + #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) +#else + #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) +#else + #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXB(value, ptr) __strex(value, ptr) +#else + #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXH(value, ptr) __strex(value, ptr) +#else + #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXW(value, ptr) __strex(value, ptr) +#else + #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __clrex + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) +{ + rrx r0, r0 + bx lr +} +#endif + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRBT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRHT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRT(value, ptr) __strt(value, ptr) + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __enable_irq(); */ + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __disable_irq(); */ + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; + __ISB(); +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_INLINE uint32_t __get_IPSR(void) +{ + register uint32_t __regIPSR __ASM("ipsr"); + return(__regIPSR); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_INLINE uint32_t __get_APSR(void) +{ + register uint32_t __regAPSR __ASM("apsr"); + return(__regAPSR); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_INLINE uint32_t __get_xPSR(void) +{ + register uint32_t __regXPSR __ASM("xpsr"); + return(__regXPSR); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + return(__regProcessStackPointer); +} + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + __regProcessStackPointer = topOfProcStack; +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + return(__regMainStackPointer); +} + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + __regMainStackPointer = topOfMainStack; +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xFFU); +} + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + register uint32_t __regBasePriMax __ASM("basepri_max"); + __regBasePriMax = (basePri & 0xFFU); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & (uint32_t)1U); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + return(__regfpscr); +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +#define __SADD8 __sadd8 +#define __QADD8 __qadd8 +#define __SHADD8 __shadd8 +#define __UADD8 __uadd8 +#define __UQADD8 __uqadd8 +#define __UHADD8 __uhadd8 +#define __SSUB8 __ssub8 +#define __QSUB8 __qsub8 +#define __SHSUB8 __shsub8 +#define __USUB8 __usub8 +#define __UQSUB8 __uqsub8 +#define __UHSUB8 __uhsub8 +#define __SADD16 __sadd16 +#define __QADD16 __qadd16 +#define __SHADD16 __shadd16 +#define __UADD16 __uadd16 +#define __UQADD16 __uqadd16 +#define __UHADD16 __uhadd16 +#define __SSUB16 __ssub16 +#define __QSUB16 __qsub16 +#define __SHSUB16 __shsub16 +#define __USUB16 __usub16 +#define __UQSUB16 __uqsub16 +#define __UHSUB16 __uhsub16 +#define __SASX __sasx +#define __QASX __qasx +#define __SHASX __shasx +#define __UASX __uasx +#define __UQASX __uqasx +#define __UHASX __uhasx +#define __SSAX __ssax +#define __QSAX __qsax +#define __SHSAX __shsax +#define __USAX __usax +#define __UQSAX __uqsax +#define __UHSAX __uhsax +#define __USAD8 __usad8 +#define __USADA8 __usada8 +#define __SSAT16 __ssat16 +#define __USAT16 __usat16 +#define __UXTB16 __uxtb16 +#define __UXTAB16 __uxtab16 +#define __SXTB16 __sxtb16 +#define __SXTAB16 __sxtab16 +#define __SMUAD __smuad +#define __SMUADX __smuadx +#define __SMLAD __smlad +#define __SMLADX __smladx +#define __SMLALD __smlald +#define __SMLALDX __smlaldx +#define __SMUSD __smusd +#define __SMUSDX __smusdx +#define __SMLSD __smlsd +#define __SMLSDX __smlsdx +#define __SMLSLD __smlsld +#define __SMLSLDX __smlsldx +#define __SEL __sel +#define __QADD __qadd +#define __QSUB __qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ + ((int64_t)(ARG3) << 32U) ) >> 32U)) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h new file mode 100644 index 0000000000..6911417747 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h @@ -0,0 +1,1503 @@ +/**************************************************************************//** + * @file cmsis_armclang.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V5.4.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +#define __SADD8 __builtin_arm_sadd8 +#define __QADD8 __builtin_arm_qadd8 +#define __SHADD8 __builtin_arm_shadd8 +#define __UADD8 __builtin_arm_uadd8 +#define __UQADD8 __builtin_arm_uqadd8 +#define __UHADD8 __builtin_arm_uhadd8 +#define __SSUB8 __builtin_arm_ssub8 +#define __QSUB8 __builtin_arm_qsub8 +#define __SHSUB8 __builtin_arm_shsub8 +#define __USUB8 __builtin_arm_usub8 +#define __UQSUB8 __builtin_arm_uqsub8 +#define __UHSUB8 __builtin_arm_uhsub8 +#define __SADD16 __builtin_arm_sadd16 +#define __QADD16 __builtin_arm_qadd16 +#define __SHADD16 __builtin_arm_shadd16 +#define __UADD16 __builtin_arm_uadd16 +#define __UQADD16 __builtin_arm_uqadd16 +#define __UHADD16 __builtin_arm_uhadd16 +#define __SSUB16 __builtin_arm_ssub16 +#define __QSUB16 __builtin_arm_qsub16 +#define __SHSUB16 __builtin_arm_shsub16 +#define __USUB16 __builtin_arm_usub16 +#define __UQSUB16 __builtin_arm_uqsub16 +#define __UHSUB16 __builtin_arm_uhsub16 +#define __SASX __builtin_arm_sasx +#define __QASX __builtin_arm_qasx +#define __SHASX __builtin_arm_shasx +#define __UASX __builtin_arm_uasx +#define __UQASX __builtin_arm_uqasx +#define __UHASX __builtin_arm_uhasx +#define __SSAX __builtin_arm_ssax +#define __QSAX __builtin_arm_qsax +#define __SHSAX __builtin_arm_shsax +#define __USAX __builtin_arm_usax +#define __UQSAX __builtin_arm_uqsax +#define __UHSAX __builtin_arm_uhsax +#define __USAD8 __builtin_arm_usad8 +#define __USADA8 __builtin_arm_usada8 +#define __SSAT16 __builtin_arm_ssat16 +#define __USAT16 __builtin_arm_usat16 +#define __UXTB16 __builtin_arm_uxtb16 +#define __UXTAB16 __builtin_arm_uxtab16 +#define __SXTB16 __builtin_arm_sxtb16 +#define __SXTAB16 __builtin_arm_sxtab16 +#define __SMUAD __builtin_arm_smuad +#define __SMUADX __builtin_arm_smuadx +#define __SMLAD __builtin_arm_smlad +#define __SMLADX __builtin_arm_smladx +#define __SMLALD __builtin_arm_smlald +#define __SMLALDX __builtin_arm_smlaldx +#define __SMUSD __builtin_arm_smusd +#define __SMUSDX __builtin_arm_smusdx +#define __SMLSD __builtin_arm_smlsd +#define __SMLSDX __builtin_arm_smlsdx +#define __SMLSLD __builtin_arm_smlsld +#define __SMLSLDX __builtin_arm_smlsldx +#define __SEL __builtin_arm_sel +#define __QADD __builtin_arm_qadd +#define __QSUB __builtin_arm_qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h new file mode 100644 index 0000000000..1e255d5907 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h @@ -0,0 +1,1928 @@ +/**************************************************************************//** + * @file cmsis_armclang_ltm.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V1.5.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h new file mode 100644 index 0000000000..adbf296f15 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h @@ -0,0 +1,283 @@ +/**************************************************************************//** + * @file cmsis_compiler.h + * @brief CMSIS compiler generic header file + * @version V5.1.0 + * @date 09. October 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_COMPILER_H +#define __CMSIS_COMPILER_H + +#include + +/* + * Arm Compiler 4/5 + */ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + + +/* + * Arm Compiler 6.6 LTM (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) + #include "cmsis_armclang_ltm.h" + + /* + * Arm Compiler above 6.10.1 (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) + #include "cmsis_armclang.h" + + +/* + * GNU Compiler + */ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + + +/* + * IAR Compiler + */ +#elif defined ( __ICCARM__ ) + #include + + +/* + * TI Arm Compiler + */ +#elif defined ( __TI_ARM__ ) + #include + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __attribute__((packed)) + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed)) + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed)) + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) + #endif + #ifndef __RESTRICT + #define __RESTRICT __restrict + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * TASKING Compiler + */ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __packed__ + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __packed__ + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __packed__ + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __packed__ T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __align(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * COSMIC Compiler + */ +#elif defined ( __CSMC__ ) + #include + + #ifndef __ASM + #define __ASM _asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + // NO RETURN is automatically detected hence no warning here + #define __NO_RETURN + #endif + #ifndef __USED + #warning No compiler specific solution for __USED. __USED is ignored. + #define __USED + #endif + #ifndef __WEAK + #define __WEAK __weak + #endif + #ifndef __PACKED + #define __PACKED @packed + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT @packed struct + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION @packed union + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + @packed struct T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. + #define __ALIGNED(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +#else + #error Unknown compiler. +#endif + + +#endif /* __CMSIS_COMPILER_H */ + diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h new file mode 100644 index 0000000000..67bda4ef3c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h @@ -0,0 +1,2211 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS compiler GCC header file + * @version V5.4.1 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" + +/* Fallback for __has_builtin */ +#ifndef __has_builtin + #define __has_builtin(x) (0) +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START + +/** + \brief Initializes data and bss sections + \details This default implementations initialized all data and additional bss + sections relying on .copy.table and .zero.table specified properly + in the used linker script. + + */ +__STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) +{ + extern void _start(void) __NO_RETURN; + + typedef struct { + uint32_t const* src; + uint32_t* dest; + uint32_t wlen; + } __copy_table_t; + + typedef struct { + uint32_t* dest; + uint32_t wlen; + } __zero_table_t; + + extern const __copy_table_t __copy_table_start__; + extern const __copy_table_t __copy_table_end__; + extern const __zero_table_t __zero_table_start__; + extern const __zero_table_t __zero_table_end__; + + for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = pTable->src[i]; + } + } + + for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = 0u; + } + } + + _start(); +} + +#define __PROGRAM_START __cmsis_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP __StackTop +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT __StackLimit +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section(".vectors"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL __StackSeal +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP() __ASM volatile ("nop") + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI() __ASM volatile ("wfi":::"memory") + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE() __ASM volatile ("wfe":::"memory") + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV() __ASM volatile ("sev") + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__STATIC_FORCEINLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__STATIC_FORCEINLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__STATIC_FORCEINLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (int16_t)__builtin_bswap16(value); +#else + int16_t result; + + __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + __ASM ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return result; +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__STATIC_FORCEINLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_FORCEINLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_get_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + return __builtin_arm_get_fpscr(); +#else + uint32_t result; + + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + return(result); +#endif +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_set_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + __builtin_arm_set_fpscr(fpscr); +#else + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); +#endif +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +#define __USAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16_RORn(uint32_t op1, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtb16 %0, %1, ROR %2" : "=r" (result) : "r" (op1), "i" (rotate) ); + } else { + result = __SXTB16(__ROR(op1, rotate)) ; + } + return result; +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16_RORn(uint32_t op1, uint32_t op2, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtab16 %0, %1, %2, ROR %3" : "=r" (result) : "r" (op1) , "r" (op2) , "i" (rotate)); + } else { + result = __SXTAB16(op1, __ROR(op2, rotate)); + } + return result; +} + + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +#define __PKHBT(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#pragma GCC diagnostic pop + +#endif /* __CMSIS_GCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h new file mode 100644 index 0000000000..65b824b009 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h @@ -0,0 +1,1002 @@ +/**************************************************************************//** + * @file cmsis_iccarm.h + * @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file + * @version V5.3.0 + * @date 14. April 2021 + ******************************************************************************/ + +//------------------------------------------------------------------------------ +// +// Copyright (c) 2017-2021 IAR Systems +// Copyright (c) 2017-2021 Arm Limited. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//------------------------------------------------------------------------------ + + +#ifndef __CMSIS_ICCARM_H__ +#define __CMSIS_ICCARM_H__ + +#ifndef __ICCARM__ + #error This file should only be compiled by ICCARM +#endif + +#pragma system_include + +#define __IAR_FT _Pragma("inline=forced") __intrinsic + +#if (__VER__ >= 8000000) + #define __ICCARM_V8 1 +#else + #define __ICCARM_V8 0 +#endif + +#ifndef __ALIGNED + #if __ICCARM_V8 + #define __ALIGNED(x) __attribute__((aligned(x))) + #elif (__VER__ >= 7080000) + /* Needs IAR language extensions */ + #define __ALIGNED(x) __attribute__((aligned(x))) + #else + #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored. + #define __ALIGNED(x) + #endif +#endif + + +/* Define compiler macros for CPU architecture, used in CMSIS 5. + */ +#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__ +/* Macros already defined */ +#else + #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M' + #if __ARM_ARCH == 6 + #define __ARM_ARCH_6M__ 1 + #elif __ARM_ARCH == 7 + #if __ARM_FEATURE_DSP + #define __ARM_ARCH_7EM__ 1 + #else + #define __ARM_ARCH_7M__ 1 + #endif + #endif /* __ARM_ARCH */ + #endif /* __ARM_ARCH_PROFILE == 'M' */ +#endif + +/* Alternativ core deduction for older ICCARM's */ +#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \ + !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__) + #if defined(__ARM6M__) && (__CORE__ == __ARM6M__) + #define __ARM_ARCH_6M__ 1 + #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__) + #define __ARM_ARCH_7M__ 1 + #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__) + #define __ARM_ARCH_7EM__ 1 + #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #else + #error "Unknown target." + #endif +#endif + + + +#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1 + #define __IAR_M0_FAMILY 1 +#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1 + #define __IAR_M0_FAMILY 1 +#else + #define __IAR_M0_FAMILY 0 +#endif + + +#ifndef __ASM + #define __ASM __asm +#endif + +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +#ifndef __INLINE + #define __INLINE inline +#endif + +#ifndef __NO_RETURN + #if __ICCARM_V8 + #define __NO_RETURN __attribute__((__noreturn__)) + #else + #define __NO_RETURN _Pragma("object_attribute=__noreturn") + #endif +#endif + +#ifndef __PACKED + #if __ICCARM_V8 + #define __PACKED __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED __packed + #endif +#endif + +#ifndef __PACKED_STRUCT + #if __ICCARM_V8 + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_STRUCT __packed struct + #endif +#endif + +#ifndef __PACKED_UNION + #if __ICCARM_V8 + #define __PACKED_UNION union __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_UNION __packed union + #endif +#endif + +#ifndef __RESTRICT + #if __ICCARM_V8 + #define __RESTRICT __restrict + #else + /* Needs IAR language extensions */ + #define __RESTRICT restrict + #endif +#endif + +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif + +#ifndef __FORCEINLINE + #define __FORCEINLINE _Pragma("inline=forced") +#endif + +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE +#endif + +#ifndef __UNALIGNED_UINT16_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint16_t __iar_uint16_read(void const *ptr) +{ + return *(__packed uint16_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR) +#endif + + +#ifndef __UNALIGNED_UINT16_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val) +{ + *(__packed uint16_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint32_t __iar_uint32_read(void const *ptr) +{ + return *(__packed uint32_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR) +#endif + +#ifndef __UNALIGNED_UINT32_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val) +{ + *(__packed uint32_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32 /* deprecated */ +#pragma language=save +#pragma language=extended +__packed struct __iar_u32 { uint32_t v; }; +#pragma language=restore +#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v) +#endif + +#ifndef __USED + #if __ICCARM_V8 + #define __USED __attribute__((used)) + #else + #define __USED _Pragma("__root") + #endif +#endif + +#undef __WEAK /* undo the definition from DLib_Defaults.h */ +#ifndef __WEAK + #if __ICCARM_V8 + #define __WEAK __attribute__((weak)) + #else + #define __WEAK _Pragma("__weak") + #endif +#endif + +#ifndef __PROGRAM_START +#define __PROGRAM_START __iar_program_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP CSTACK$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT CSTACK$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __vector_table +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE @".intvec" +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL STACKSEAL$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + +#ifndef __ICCARM_INTRINSICS_VERSION__ + #define __ICCARM_INTRINSICS_VERSION__ 0 +#endif + +#if __ICCARM_INTRINSICS_VERSION__ == 2 + + #if defined(__CLZ) + #undef __CLZ + #endif + #if defined(__REVSH) + #undef __REVSH + #endif + #if defined(__RBIT) + #undef __RBIT + #endif + #if defined(__SSAT) + #undef __SSAT + #endif + #if defined(__USAT) + #undef __USAT + #endif + + #include "iccarm_builtin.h" + + #define __disable_fault_irq __iar_builtin_disable_fiq + #define __disable_irq __iar_builtin_disable_interrupt + #define __enable_fault_irq __iar_builtin_enable_fiq + #define __enable_irq __iar_builtin_enable_interrupt + #define __arm_rsr __iar_builtin_rsr + #define __arm_wsr __iar_builtin_wsr + + + #define __get_APSR() (__arm_rsr("APSR")) + #define __get_BASEPRI() (__arm_rsr("BASEPRI")) + #define __get_CONTROL() (__arm_rsr("CONTROL")) + #define __get_FAULTMASK() (__arm_rsr("FAULTMASK")) + + #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + #define __get_FPSCR() (__arm_rsr("FPSCR")) + #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE))) + #else + #define __get_FPSCR() ( 0 ) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #define __get_IPSR() (__arm_rsr("IPSR")) + #define __get_MSP() (__arm_rsr("MSP")) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __get_MSPLIM() (0U) + #else + #define __get_MSPLIM() (__arm_rsr("MSPLIM")) + #endif + #define __get_PRIMASK() (__arm_rsr("PRIMASK")) + #define __get_PSP() (__arm_rsr("PSP")) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __get_PSPLIM() (0U) + #else + #define __get_PSPLIM() (__arm_rsr("PSPLIM")) + #endif + + #define __get_xPSR() (__arm_rsr("xPSR")) + + #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE))) + #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE))) + +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __arm_wsr("CONTROL", control); + __iar_builtin_ISB(); +} + + #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE))) + #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __set_MSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE))) + #endif + #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE))) + #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE))) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __set_PSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE))) + #endif + + #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS")) + +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __arm_wsr("CONTROL_NS", control); + __iar_builtin_ISB(); +} + + #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS")) + #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE))) + #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS")) + #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE))) + #define __TZ_get_SP_NS() (__arm_rsr("SP_NS")) + #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE))) + #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS")) + #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE))) + #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS")) + #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE))) + #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS")) + #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __TZ_get_PSPLIM_NS() (0U) + #define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE)) + #else + #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS")) + #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE))) + #endif + + #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS")) + #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE))) + + #define __NOP __iar_builtin_no_operation + + #define __CLZ __iar_builtin_CLZ + #define __CLREX __iar_builtin_CLREX + + #define __DMB __iar_builtin_DMB + #define __DSB __iar_builtin_DSB + #define __ISB __iar_builtin_ISB + + #define __LDREXB __iar_builtin_LDREXB + #define __LDREXH __iar_builtin_LDREXH + #define __LDREXW __iar_builtin_LDREX + + #define __RBIT __iar_builtin_RBIT + #define __REV __iar_builtin_REV + #define __REV16 __iar_builtin_REV16 + + __IAR_FT int16_t __REVSH(int16_t val) + { + return (int16_t) __iar_builtin_REVSH(val); + } + + #define __ROR __iar_builtin_ROR + #define __RRX __iar_builtin_RRX + + #define __SEV __iar_builtin_SEV + + #if !__IAR_M0_FAMILY + #define __SSAT __iar_builtin_SSAT + #endif + + #define __STREXB __iar_builtin_STREXB + #define __STREXH __iar_builtin_STREXH + #define __STREXW __iar_builtin_STREX + + #if !__IAR_M0_FAMILY + #define __USAT __iar_builtin_USAT + #endif + + #define __WFE __iar_builtin_WFE + #define __WFI __iar_builtin_WFI + + #if __ARM_MEDIA__ + #define __SADD8 __iar_builtin_SADD8 + #define __QADD8 __iar_builtin_QADD8 + #define __SHADD8 __iar_builtin_SHADD8 + #define __UADD8 __iar_builtin_UADD8 + #define __UQADD8 __iar_builtin_UQADD8 + #define __UHADD8 __iar_builtin_UHADD8 + #define __SSUB8 __iar_builtin_SSUB8 + #define __QSUB8 __iar_builtin_QSUB8 + #define __SHSUB8 __iar_builtin_SHSUB8 + #define __USUB8 __iar_builtin_USUB8 + #define __UQSUB8 __iar_builtin_UQSUB8 + #define __UHSUB8 __iar_builtin_UHSUB8 + #define __SADD16 __iar_builtin_SADD16 + #define __QADD16 __iar_builtin_QADD16 + #define __SHADD16 __iar_builtin_SHADD16 + #define __UADD16 __iar_builtin_UADD16 + #define __UQADD16 __iar_builtin_UQADD16 + #define __UHADD16 __iar_builtin_UHADD16 + #define __SSUB16 __iar_builtin_SSUB16 + #define __QSUB16 __iar_builtin_QSUB16 + #define __SHSUB16 __iar_builtin_SHSUB16 + #define __USUB16 __iar_builtin_USUB16 + #define __UQSUB16 __iar_builtin_UQSUB16 + #define __UHSUB16 __iar_builtin_UHSUB16 + #define __SASX __iar_builtin_SASX + #define __QASX __iar_builtin_QASX + #define __SHASX __iar_builtin_SHASX + #define __UASX __iar_builtin_UASX + #define __UQASX __iar_builtin_UQASX + #define __UHASX __iar_builtin_UHASX + #define __SSAX __iar_builtin_SSAX + #define __QSAX __iar_builtin_QSAX + #define __SHSAX __iar_builtin_SHSAX + #define __USAX __iar_builtin_USAX + #define __UQSAX __iar_builtin_UQSAX + #define __UHSAX __iar_builtin_UHSAX + #define __USAD8 __iar_builtin_USAD8 + #define __USADA8 __iar_builtin_USADA8 + #define __SSAT16 __iar_builtin_SSAT16 + #define __USAT16 __iar_builtin_USAT16 + #define __UXTB16 __iar_builtin_UXTB16 + #define __UXTAB16 __iar_builtin_UXTAB16 + #define __SXTB16 __iar_builtin_SXTB16 + #define __SXTAB16 __iar_builtin_SXTAB16 + #define __SMUAD __iar_builtin_SMUAD + #define __SMUADX __iar_builtin_SMUADX + #define __SMMLA __iar_builtin_SMMLA + #define __SMLAD __iar_builtin_SMLAD + #define __SMLADX __iar_builtin_SMLADX + #define __SMLALD __iar_builtin_SMLALD + #define __SMLALDX __iar_builtin_SMLALDX + #define __SMUSD __iar_builtin_SMUSD + #define __SMUSDX __iar_builtin_SMUSDX + #define __SMLSD __iar_builtin_SMLSD + #define __SMLSDX __iar_builtin_SMLSDX + #define __SMLSLD __iar_builtin_SMLSLD + #define __SMLSLDX __iar_builtin_SMLSLDX + #define __SEL __iar_builtin_SEL + #define __QADD __iar_builtin_QADD + #define __QSUB __iar_builtin_QSUB + #define __PKHBT __iar_builtin_PKHBT + #define __PKHTB __iar_builtin_PKHTB + #endif + +#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #define __CLZ __cmsis_iar_clz_not_active + #define __SSAT __cmsis_iar_ssat_not_active + #define __USAT __cmsis_iar_usat_not_active + #define __RBIT __cmsis_iar_rbit_not_active + #define __get_APSR __cmsis_iar_get_APSR_not_active + #endif + + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #define __get_FPSCR __cmsis_iar_get_FPSR_not_active + #define __set_FPSCR __cmsis_iar_set_FPSR_not_active + #endif + + #ifdef __INTRINSICS_INCLUDED + #error intrinsics.h is already included previously! + #endif + + #include + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #undef __CLZ + #undef __SSAT + #undef __USAT + #undef __RBIT + #undef __get_APSR + + __STATIC_INLINE uint8_t __CLZ(uint32_t data) + { + if (data == 0U) { return 32U; } + + uint32_t count = 0U; + uint32_t mask = 0x80000000U; + + while ((data & mask) == 0U) + { + count += 1U; + mask = mask >> 1U; + } + return count; + } + + __STATIC_INLINE uint32_t __RBIT(uint32_t v) + { + uint8_t sc = 31U; + uint32_t r = v; + for (v >>= 1U; v; v >>= 1U) + { + r <<= 1U; + r |= v & 1U; + sc--; + } + return (r << sc); + } + + __STATIC_INLINE uint32_t __get_APSR(void) + { + uint32_t res; + __asm("MRS %0,APSR" : "=r" (res)); + return res; + } + + #endif + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #undef __get_FPSCR + #undef __set_FPSCR + #define __get_FPSCR() (0) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #pragma diag_suppress=Pe940 + #pragma diag_suppress=Pe177 + + #define __enable_irq __enable_interrupt + #define __disable_irq __disable_interrupt + #define __NOP __no_operation + + #define __get_xPSR __get_PSR + + #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0) + + __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr) + { + return __LDREX((unsigned long *)ptr); + } + + __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr) + { + return __STREX(value, (unsigned long *)ptr); + } + #endif + + + /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + #if (__CORTEX_M >= 0x03) + + __IAR_FT uint32_t __RRX(uint32_t value) + { + uint32_t result; + __ASM volatile("RRX %0, %1" : "=r"(result) : "r" (value)); + return(result); + } + + __IAR_FT void __set_BASEPRI_MAX(uint32_t value) + { + __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value)); + } + + + #define __enable_fault_irq __enable_fiq + #define __disable_fault_irq __disable_fiq + + + #endif /* (__CORTEX_M >= 0x03) */ + + __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2) + { + return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2)); + } + + #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + __IAR_FT uint32_t __get_MSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,MSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_MSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR MSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __get_PSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_PSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_CONTROL_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,CONTROL_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value) + { + __asm volatile("MSR CONTROL_NS,%0" :: "r" (value)); + __iar_builtin_ISB(); + } + + __IAR_FT uint32_t __TZ_get_PSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PSP_NS(uint32_t value) + { + __asm volatile("MSR PSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_MSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSP_NS(uint32_t value) + { + __asm volatile("MSR MSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_SP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,SP_NS" : "=r" (res)); + return res; + } + __IAR_FT void __TZ_set_SP_NS(uint32_t value) + { + __asm volatile("MSR SP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value) + { + __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value) + { + __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value) + { + __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value) + { + __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value)); + } + + #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + +#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value)) + +#if __IAR_M0_FAMILY + __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) + { + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; + } + + __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) + { + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; + } +#endif + +#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + + __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr) + { + uint32_t res; + __ASM volatile ("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr) + { + uint32_t res; + __ASM volatile ("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDRT(volatile uint32_t *addr) + { + uint32_t res; + __ASM volatile ("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return res; + } + + __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr) + { + __ASM volatile ("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr) + { + __ASM volatile ("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr) + { + __ASM volatile ("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory"); + } + +#endif /* (__CORTEX_M >= 0x03) */ + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + + __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDA(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr) + { + __ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr) + { + __ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr) + { + __ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + +#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#undef __IAR_FT +#undef __IAR_M0_FAMILY +#undef __ICCARM_V8 + +#pragma diag_default=Pe940 +#pragma diag_default=Pe177 + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* __CMSIS_ICCARM_H__ */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h new file mode 100644 index 0000000000..8b4765f186 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h @@ -0,0 +1,39 @@ +/**************************************************************************//** + * @file cmsis_version.h + * @brief CMSIS Core(M) Version definitions + * @version V5.0.5 + * @date 02. February 2022 + ******************************************************************************/ +/* + * Copyright (c) 2009-2022 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CMSIS_VERSION_H +#define __CMSIS_VERSION_H + +/* CMSIS Version definitions */ +#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ +#define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */ +#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ + __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h new file mode 100644 index 0000000000..94128a1a70 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h @@ -0,0 +1,4228 @@ +/**************************************************************************//** + * @file core_armv81mml.h + * @brief CMSIS Armv8.1-M Mainline Core Peripheral Access Layer Header File + * @version V1.4.2 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV81MML_H_GENERIC +#define __CORE_ARMV81MML_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMV81MML + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS ARMV81MML definitions */ +#define __ARMv81MML_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv81MML_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv81MML_CMSIS_VERSION ((__ARMv81MML_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv81MML_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (81U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV81MML_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV81MML_H_DEPENDANT +#define __CORE_ARMV81MML_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv81MML_REV + #define __ARMv81MML_REV 0x0000U + #warning "__ARMv81MML_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 2U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 31 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv81MML */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[3]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE4 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE8 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFEC (R/W) PMU Peripheral Identification Register 3 */ + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (0xFFFFUL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (0xFFFFUL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (0xFFUL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (0x3FUL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/** \brief PMU Authentication Status Register Definitions */ + +#define PMU_AUTHSTATUS_NSID_Pos 0U /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSID_Msk (0x3UL /*<< PMU_AUTHSTATUS_NSID_Pos*/) /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSNID_Pos 2U /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSNID_Msk (0x3UL << PMU_AUTHSTATUS_NSNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SID_Pos 4U /*!< PMU AUTHSTATUS: Secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_SID_Msk (0x3UL << PMU_AUTHSTATUS_SID_Pos) /*!< PMU AUTHSTATUS: Secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SNID_Pos 6U /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SNID_Msk (0x3UL << PMU_AUTHSTATUS_SNID_Pos) /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUID_Pos 16U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUID_Msk (0x3UL << PMU_AUTHSTATUS_NSUID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUNID_Pos 18U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUNID_Msk (0x3UL << PMU_AUTHSTATUS_NSUNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUID_Pos 20U /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_SUID_Msk (0x3UL << PMU_AUTHSTATUS_SUID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUNID_Pos 22U /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SUNID_Msk (0x3UL << PMU_AUTHSTATUS_SUNID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Mask */ + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV81MML_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h new file mode 100644 index 0000000000..e9c9b5bf59 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h @@ -0,0 +1,2222 @@ +/**************************************************************************//** + * @file core_armv8mbl.h + * @brief CMSIS Armv8-M Baseline Core Peripheral Access Layer Header File + * @version V5.1.0 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV8MBL_H_GENERIC +#define __CORE_ARMV8MBL_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMv8MBL + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS definitions */ +#define __ARMv8MBL_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv8MBL_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv8MBL_CMSIS_VERSION ((__ARMv8MBL_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv8MBL_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (2U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MBL_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV8MBL_H_DEPENDANT +#define __CORE_ARMV8MBL_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv8MBL_REV + #define __ARMv8MBL_REV 0x0000U + #warning "__ARMv8MBL_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif + + #ifndef __ETM_PRESENT + #define __ETM_PRESENT 0U + #warning "__ETM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MTB_PRESENT + #define __MTB_PRESENT 0U + #warning "__MTB_PRESENT not defined in device header file; using default!" + #endif + +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv8MBL */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint32_t IPR[124U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHPR[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t RESERVED0[6U]; + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x3UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + uint32_t RESERVED0[7U]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: EN Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: EN Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#endif +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_DWTENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: DWTENA Position */ +#define CoreDebug_DEMCR_DWTENA_Msk (1UL << CoreDebug_DEMCR_DWTENA_Pos) /*!< \deprecated CoreDebug DEMCR: DWTENA Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MBL_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h new file mode 100644 index 0000000000..c119fbf242 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h @@ -0,0 +1,3209 @@ +/**************************************************************************//** + * @file core_armv8mml.h + * @brief CMSIS Armv8-M Mainline Core Peripheral Access Layer Header File + * @version V5.2.3 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV8MML_H_GENERIC +#define __CORE_ARMV8MML_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMv8MML + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS Armv8MML definitions */ +#define __ARMv8MML_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv8MML_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv8MML_CMSIS_VERSION ((__ARMv8MML_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv8MML_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (80U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MML_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV8MML_H_DEPENDANT +#define __CORE_ARMV8MML_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv8MML_REV + #define __ARMv8MML_REV 0x0000U + #warning "__ARMv8MML_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv8MML */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MML_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h new file mode 100644 index 0000000000..0a0ba223e1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h @@ -0,0 +1,952 @@ +/**************************************************************************//** + * @file core_cm0.h + * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File + * @version V5.0.8 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0_H_GENERIC +#define __CORE_CM0_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M0 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0 definitions */ +#define __CM0_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ + __CM0_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0_H_DEPENDANT +#define __CORE_CM0_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0_REV + #define __CM0_REV 0x0000U + #warning "__CM0_REV not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M0 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + uint32_t RESERVED0; + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + Address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ + /* ARM Application Note 321 states that the M0 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h new file mode 100644 index 0000000000..879a384124 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h @@ -0,0 +1,1087 @@ +/**************************************************************************//** + * @file core_cm0plus.h + * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File + * @version V5.0.9 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0PLUS_H_GENERIC +#define __CORE_CM0PLUS_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex-M0+ + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0+ definitions */ +#define __CM0PLUS_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0PLUS_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ + __CM0PLUS_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0PLUS_H_DEPENDANT +#define __CORE_CM0PLUS_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0PLUS_REV + #define __CM0PLUS_REV 0x0000U + #warning "__CM0PLUS_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex-M0+ */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0+ header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0+ */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ +#endif + /* ARM Application Note 321 states that the M0+ does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +#endif +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h new file mode 100644 index 0000000000..83b8fc6a0d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h @@ -0,0 +1,979 @@ +/**************************************************************************//** + * @file core_cm1.h + * @brief CMSIS Cortex-M1 Core Peripheral Access Layer Header File + * @version V1.0.1 + * @date 12. November 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM1_H_GENERIC +#define __CORE_CM1_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M1 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM1 definitions */ +#define __CM1_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM1_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM1_CMSIS_VERSION ((__CM1_CMSIS_VERSION_MAIN << 16U) | \ + __CM1_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (1U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM1_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM1_H_DEPENDANT +#define __CORE_CM1_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM1_REV + #define __CM1_REV 0x0100U + #warning "__CM1_REV not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M1 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + uint32_t RESERVED0; + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_ITCMUAEN_Pos 4U /*!< ACTLR: Instruction TCM Upper Alias Enable Position */ +#define SCnSCB_ACTLR_ITCMUAEN_Msk (1UL << SCnSCB_ACTLR_ITCMUAEN_Pos) /*!< ACTLR: Instruction TCM Upper Alias Enable Mask */ + +#define SCnSCB_ACTLR_ITCMLAEN_Pos 3U /*!< ACTLR: Instruction TCM Lower Alias Enable Position */ +#define SCnSCB_ACTLR_ITCMLAEN_Msk (1UL << SCnSCB_ACTLR_ITCMLAEN_Pos) /*!< ACTLR: Instruction TCM Lower Alias Enable Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M1 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M1 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M1 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + Address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)0x0U; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M1 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)0x0U; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM1_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h new file mode 100644 index 0000000000..f2cf49fb16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h @@ -0,0 +1,2297 @@ +/**************************************************************************//** + * @file core_cm23.h + * @brief CMSIS Cortex-M23 Core Peripheral Access Layer Header File + * @version V5.1.0 + * @date 11. February 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM23_H_GENERIC +#define __CORE_CM23_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M23 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS definitions */ +#define __CM23_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM23_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM23_CMSIS_VERSION ((__CM23_CMSIS_VERSION_MAIN << 16U) | \ + __CM23_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (23U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM23_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM23_H_DEPENDANT +#define __CORE_CM23_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM23_REV + #define __CM23_REV 0x0000U + #warning "__CM23_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif + + #ifndef __ETM_PRESENT + #define __ETM_PRESENT 0U + #warning "__ETM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MTB_PRESENT + #define __MTB_PRESENT 0U + #warning "__MTB_PRESENT not defined in device header file; using default!" + #endif + +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M23 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint32_t IPR[124U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHPR[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t RESERVED0[6U]; + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x3UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + uint32_t RESERVED0[7U]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: EN Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: EN Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#endif +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register */ +#define CoreDebug_DEMCR_DWTENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: DWTENA Position */ +#define CoreDebug_DEMCR_DWTENA_Msk (1UL << CoreDebug_DEMCR_DWTENA_Pos) /*!< \deprecated CoreDebug DEMCR: DWTENA Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else +/*#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping not available for Cortex-M23 */ +/*#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping not available for Cortex-M23 */ + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM23_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h new file mode 100644 index 0000000000..74fb87e5c5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h @@ -0,0 +1,1943 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V5.1.2 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM3_H_GENERIC +#define __CORE_CM3_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M3 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (3U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM3_H_DEPENDANT +#define __CORE_CM3_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM3_REV + #define __CM3_REV 0x0200U + #warning "__CM3_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M3 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV < 0x0201U) /* core r2p1 */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#else +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +#else + uint32_t RESERVED1[1U]; +#endif +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ +#endif + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h new file mode 100644 index 0000000000..18a2e6fb03 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h @@ -0,0 +1,3277 @@ +/**************************************************************************//** + * @file core_cm33.h + * @brief CMSIS Cortex-M33 Core Peripheral Access Layer Header File + * @version V5.2.3 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM33_H_GENERIC +#define __CORE_CM33_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M33 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM33 definitions */ +#define __CM33_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM33_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM33_CMSIS_VERSION ((__CM33_CMSIS_VERSION_MAIN << 16U) | \ + __CM33_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (33U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM33_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM33_H_DEPENDANT +#define __CORE_CM33_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM33_REV + #define __CM33_REV 0x0000U + #warning "__CM33_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M33 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM33_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h new file mode 100644 index 0000000000..3843d9542c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h @@ -0,0 +1,3277 @@ +/**************************************************************************//** + * @file core_cm35p.h + * @brief CMSIS Cortex-M35P Core Peripheral Access Layer Header File + * @version V1.1.3 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM35P_H_GENERIC +#define __CORE_CM35P_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M35P + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM35P definitions */ +#define __CM35P_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM35P_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM35P_CMSIS_VERSION ((__CM35P_CMSIS_VERSION_MAIN << 16U) | \ + __CM35P_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (35U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM35P_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM35P_H_DEPENDANT +#define __CORE_CM35P_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM35P_REV + #define __CM35P_REV 0x0000U + #warning "__CM35P_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M35P */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM35P_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h new file mode 100644 index 0000000000..e21cd14925 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h @@ -0,0 +1,2129 @@ +/**************************************************************************//** + * @file core_cm4.h + * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File + * @version V5.1.2 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM4_H_GENERIC +#define __CORE_CM4_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M4 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM4 definitions */ +#define __CM4_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM4_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ + __CM4_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (4U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM4_H_DEPENDANT +#define __CORE_CM4_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM4_REV + #define __CM4_REV 0x0000U + #warning "__CM4_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M4 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and FP Feature Register 2 Definitions */ + +#define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ +#define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ +#define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M4 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h new file mode 100644 index 0000000000..faa30ce36a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h @@ -0,0 +1,4817 @@ +/**************************************************************************//** + * @file core_cm55.h + * @brief CMSIS Cortex-M55 Core Peripheral Access Layer Header File + * @version V1.2.4 + * @date 21. April 2022 + ******************************************************************************/ +/* + * Copyright (c) 2018-2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM55_H_GENERIC +#define __CORE_CM55_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M55 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM55 definitions */ +#define __CM55_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM55_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM55_CMSIS_VERSION ((__CM55_CMSIS_VERSION_MAIN << 16U) | \ + __CM55_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (55U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM55_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM55_H_DEPENDANT +#define __CORE_CM55_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM55_REV + #define __CM55_REV 0x0000U + #warning "__CM55_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 8U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 8 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M55 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core EWIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core PMU Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ICB Implementation Control Block register (ICB) + \brief Type definitions for the Implementation Control Block Register + @{ + */ + +/** + \brief Structure type to access the Implementation Control Block (ICB). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} ICB_Type; + +/* Auxiliary Control Register Definitions */ +#define ICB_ACTLR_DISCRITAXIRUW_Pos 27U /*!< ACTLR: DISCRITAXIRUW Position */ +#define ICB_ACTLR_DISCRITAXIRUW_Msk (1UL << ICB_ACTLR_DISCRITAXIRUW_Pos) /*!< ACTLR: DISCRITAXIRUW Mask */ + +#define ICB_ACTLR_DISDI_Pos 16U /*!< ACTLR: DISDI Position */ +#define ICB_ACTLR_DISDI_Msk (3UL << ICB_ACTLR_DISDI_Pos) /*!< ACTLR: DISDI Mask */ + +#define ICB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define ICB_ACTLR_DISCRITAXIRUR_Msk (1UL << ICB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define ICB_ACTLR_EVENTBUSEN_Pos 14U /*!< ACTLR: EVENTBUSEN Position */ +#define ICB_ACTLR_EVENTBUSEN_Msk (1UL << ICB_ACTLR_EVENTBUSEN_Pos) /*!< ACTLR: EVENTBUSEN Mask */ + +#define ICB_ACTLR_EVENTBUSEN_S_Pos 13U /*!< ACTLR: EVENTBUSEN_S Position */ +#define ICB_ACTLR_EVENTBUSEN_S_Msk (1UL << ICB_ACTLR_EVENTBUSEN_S_Pos) /*!< ACTLR: EVENTBUSEN_S Mask */ + +#define ICB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define ICB_ACTLR_DISITMATBFLUSH_Msk (1UL << ICB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define ICB_ACTLR_DISNWAMODE_Pos 11U /*!< ACTLR: DISNWAMODE Position */ +#define ICB_ACTLR_DISNWAMODE_Msk (1UL << ICB_ACTLR_DISNWAMODE_Pos) /*!< ACTLR: DISNWAMODE Mask */ + +#define ICB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define ICB_ACTLR_FPEXCODIS_Msk (1UL << ICB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +#define ICB_ACTLR_DISOLAP_Pos 7U /*!< ACTLR: DISOLAP Position */ +#define ICB_ACTLR_DISOLAP_Msk (1UL << ICB_ACTLR_DISOLAP_Pos) /*!< ACTLR: DISOLAP Mask */ + +#define ICB_ACTLR_DISOLAPS_Pos 6U /*!< ACTLR: DISOLAPS Position */ +#define ICB_ACTLR_DISOLAPS_Msk (1UL << ICB_ACTLR_DISOLAPS_Pos) /*!< ACTLR: DISOLAPS Mask */ + +#define ICB_ACTLR_DISLOBR_Pos 5U /*!< ACTLR: DISLOBR Position */ +#define ICB_ACTLR_DISLOBR_Msk (1UL << ICB_ACTLR_DISLOBR_Pos) /*!< ACTLR: DISLOBR Mask */ + +#define ICB_ACTLR_DISLO_Pos 4U /*!< ACTLR: DISLO Position */ +#define ICB_ACTLR_DISLO_Msk (1UL << ICB_ACTLR_DISLO_Pos) /*!< ACTLR: DISLO Mask */ + +#define ICB_ACTLR_DISLOLEP_Pos 3U /*!< ACTLR: DISLOLEP Position */ +#define ICB_ACTLR_DISLOLEP_Msk (1UL << ICB_ACTLR_DISLOLEP_Pos) /*!< ACTLR: DISLOLEP Mask */ + +#define ICB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define ICB_ACTLR_DISFOLD_Msk (1UL << ICB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +/* Interrupt Controller Type Register Definitions */ +#define ICB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define ICB_ICTR_INTLINESNUM_Msk (0xFUL /*<< ICB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_ICB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup MemSysCtl_Type Memory System Control Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Memory System Control Registers (MEMSYSCTL) + @{ + */ + +/** + \brief Structure type to access the Memory System Control Registers (MEMSYSCTL). + */ +typedef struct +{ + __IOM uint32_t MSCR; /*!< Offset: 0x000 (R/W) Memory System Control Register */ + __IOM uint32_t PFCR; /*!< Offset: 0x004 (R/W) Prefetcher Control Register */ + uint32_t RESERVED1[2U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x010 (R/W) ITCM Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x014 (R/W) DTCM Control Register */ + __IOM uint32_t PAHBCR; /*!< Offset: 0x018 (R/W) P-AHB Control Register */ + uint32_t RESERVED2[313U]; + __IOM uint32_t ITGU_CTRL; /*!< Offset: 0x500 (R/W) ITGU Control Register */ + __IOM uint32_t ITGU_CFG; /*!< Offset: 0x504 (R/W) ITGU Configuration Register */ + uint32_t RESERVED3[2U]; + __IOM uint32_t ITGU_LUT[16U]; /*!< Offset: 0x510 (R/W) ITGU Look Up Table Register */ + uint32_t RESERVED4[44U]; + __IOM uint32_t DTGU_CTRL; /*!< Offset: 0x600 (R/W) DTGU Control Registers */ + __IOM uint32_t DTGU_CFG; /*!< Offset: 0x604 (R/W) DTGU Configuration Register */ + uint32_t RESERVED5[2U]; + __IOM uint32_t DTGU_LUT[16U]; /*!< Offset: 0x610 (R/W) DTGU Look Up Table Register */ +} MemSysCtl_Type; + +/* MEMSYSCTL Memory System Control Register (MSCR) Register Definitions */ +#define MEMSYSCTL_MSCR_CPWRDN_Pos 17U /*!< MEMSYSCTL MSCR: CPWRDN Position */ +#define MEMSYSCTL_MSCR_CPWRDN_Msk (0x1UL << MEMSYSCTL_MSCR_CPWRDN_Pos) /*!< MEMSYSCTL MSCR: CPWRDN Mask */ + +#define MEMSYSCTL_MSCR_DCCLEAN_Pos 16U /*!< MEMSYSCTL MSCR: DCCLEAN Position */ +#define MEMSYSCTL_MSCR_DCCLEAN_Msk (0x1UL << MEMSYSCTL_MSCR_DCCLEAN_Pos) /*!< MEMSYSCTL MSCR: DCCLEAN Mask */ + +#define MEMSYSCTL_MSCR_ICACTIVE_Pos 13U /*!< MEMSYSCTL MSCR: ICACTIVE Position */ +#define MEMSYSCTL_MSCR_ICACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_ICACTIVE_Pos) /*!< MEMSYSCTL MSCR: ICACTIVE Mask */ + +#define MEMSYSCTL_MSCR_DCACTIVE_Pos 12U /*!< MEMSYSCTL MSCR: DCACTIVE Position */ +#define MEMSYSCTL_MSCR_DCACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_DCACTIVE_Pos) /*!< MEMSYSCTL MSCR: DCACTIVE Mask */ + +#define MEMSYSCTL_MSCR_TECCCHKDIS_Pos 4U /*!< MEMSYSCTL MSCR: TECCCHKDIS Position */ +#define MEMSYSCTL_MSCR_TECCCHKDIS_Msk (0x1UL << MEMSYSCTL_MSCR_TECCCHKDIS_Pos) /*!< MEMSYSCTL MSCR: TECCCHKDIS Mask */ + +#define MEMSYSCTL_MSCR_EVECCFAULT_Pos 3U /*!< MEMSYSCTL MSCR: EVECCFAULT Position */ +#define MEMSYSCTL_MSCR_EVECCFAULT_Msk (0x1UL << MEMSYSCTL_MSCR_EVECCFAULT_Pos) /*!< MEMSYSCTL MSCR: EVECCFAULT Mask */ + +#define MEMSYSCTL_MSCR_FORCEWT_Pos 2U /*!< MEMSYSCTL MSCR: FORCEWT Position */ +#define MEMSYSCTL_MSCR_FORCEWT_Msk (0x1UL << MEMSYSCTL_MSCR_FORCEWT_Pos) /*!< MEMSYSCTL MSCR: FORCEWT Mask */ + +#define MEMSYSCTL_MSCR_ECCEN_Pos 1U /*!< MEMSYSCTL MSCR: ECCEN Position */ +#define MEMSYSCTL_MSCR_ECCEN_Msk (0x1UL << MEMSYSCTL_MSCR_ECCEN_Pos) /*!< MEMSYSCTL MSCR: ECCEN Mask */ + +/* MEMSYSCTL Prefetcher Control Register (PFCR) Register Definitions */ +#define MEMSYSCTL_PFCR_MAX_OS_Pos 7U /*!< MEMSYSCTL PFCR: MAX_OS Position */ +#define MEMSYSCTL_PFCR_MAX_OS_Msk (0x7UL << MEMSYSCTL_PFCR_MAX_OS_Pos) /*!< MEMSYSCTL PFCR: MAX_OS Mask */ + +#define MEMSYSCTL_PFCR_MAX_LA_Pos 4U /*!< MEMSYSCTL PFCR: MAX_LA Position */ +#define MEMSYSCTL_PFCR_MAX_LA_Msk (0x7UL << MEMSYSCTL_PFCR_MAX_LA_Pos) /*!< MEMSYSCTL PFCR: MAX_LA Mask */ + +#define MEMSYSCTL_PFCR_MIN_LA_Pos 1U /*!< MEMSYSCTL PFCR: MIN_LA Position */ +#define MEMSYSCTL_PFCR_MIN_LA_Msk (0x7UL << MEMSYSCTL_PFCR_MIN_LA_Pos) /*!< MEMSYSCTL PFCR: MIN_LA Mask */ + +#define MEMSYSCTL_PFCR_ENABLE_Pos 0U /*!< MEMSYSCTL PFCR: ENABLE Position */ +#define MEMSYSCTL_PFCR_ENABLE_Msk (0x1UL /*<< MEMSYSCTL_PFCR_ENABLE_Pos*/) /*!< MEMSYSCTL PFCR: ENABLE Mask */ + +/* MEMSYSCTL ITCM Control Register (ITCMCR) Register Definitions */ +#define MEMSYSCTL_ITCMCR_SZ_Pos 3U /*!< MEMSYSCTL ITCMCR: SZ Position */ +#define MEMSYSCTL_ITCMCR_SZ_Msk (0xFUL << MEMSYSCTL_ITCMCR_SZ_Pos) /*!< MEMSYSCTL ITCMCR: SZ Mask */ + +#define MEMSYSCTL_ITCMCR_EN_Pos 0U /*!< MEMSYSCTL ITCMCR: EN Position */ +#define MEMSYSCTL_ITCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_ITCMCR_EN_Pos*/) /*!< MEMSYSCTL ITCMCR: EN Mask */ + +/* MEMSYSCTL DTCM Control Register (DTCMCR) Register Definitions */ +#define MEMSYSCTL_DTCMCR_SZ_Pos 3U /*!< MEMSYSCTL DTCMCR: SZ Position */ +#define MEMSYSCTL_DTCMCR_SZ_Msk (0xFUL << MEMSYSCTL_DTCMCR_SZ_Pos) /*!< MEMSYSCTL DTCMCR: SZ Mask */ + +#define MEMSYSCTL_DTCMCR_EN_Pos 0U /*!< MEMSYSCTL DTCMCR: EN Position */ +#define MEMSYSCTL_DTCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_DTCMCR_EN_Pos*/) /*!< MEMSYSCTL DTCMCR: EN Mask */ + +/* MEMSYSCTL P-AHB Control Register (PAHBCR) Register Definitions */ +#define MEMSYSCTL_PAHBCR_SZ_Pos 1U /*!< MEMSYSCTL PAHBCR: SZ Position */ +#define MEMSYSCTL_PAHBCR_SZ_Msk (0x7UL << MEMSYSCTL_PAHBCR_SZ_Pos) /*!< MEMSYSCTL PAHBCR: SZ Mask */ + +#define MEMSYSCTL_PAHBCR_EN_Pos 0U /*!< MEMSYSCTL PAHBCR: EN Position */ +#define MEMSYSCTL_PAHBCR_EN_Msk (0x1UL /*<< MEMSYSCTL_PAHBCR_EN_Pos*/) /*!< MEMSYSCTL PAHBCR: EN Mask */ + +/* MEMSYSCTL ITGU Control Register (ITGU_CTRL) Register Definitions */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL ITGU_CTRL: DEREN Position */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_ITGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL ITGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL ITGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_ITGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL ITGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL ITGU Configuration Register (ITGU_CFG) Register Definitions */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL ITGU_CFG: PRESENT Position */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_ITGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL ITGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL ITGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_ITGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL ITGU_CFG: BLKSZ Mask */ + +/* MEMSYSCTL DTGU Control Registers (DTGU_CTRL) Register Definitions */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL DTGU_CTRL: DEREN Position */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_DTGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL DTGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL DTGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_DTGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL DTGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL DTGU Configuration Register (DTGU_CFG) Register Definitions */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL DTGU_CFG: PRESENT Position */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_DTGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL DTGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL DTGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_DTGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL DTGU_CFG: BLKSZ Mask */ + + +/*@}*/ /* end of group MemSysCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PwrModCtl_Type Power Mode Control Registers + \brief Type definitions for the Power Mode Control Registers (PWRMODCTL) + @{ + */ + +/** + \brief Structure type to access the Power Mode Control Registers (PWRMODCTL). + */ +typedef struct +{ + __IOM uint32_t CPDLPSTATE; /*!< Offset: 0x000 (R/W) Core Power Domain Low Power State Register */ + __IOM uint32_t DPDLPSTATE; /*!< Offset: 0x004 (R/W) Debug Power Domain Low Power State Register */ +} PwrModCtl_Type; + +/* PWRMODCTL Core Power Domain Low Power State (CPDLPSTATE) Register Definitions */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos 8U /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos 4U /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos 0U /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Msk (0x3UL /*<< PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos*/) /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Mask */ + +/* PWRMODCTL Debug Power Domain Low Power State (DPDLPSTATE) Register Definitions */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos 0U /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Position */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Msk (0x3UL /*<< PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos*/) /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Mask */ + +/*@}*/ /* end of group PwrModCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup EWIC_Type External Wakeup Interrupt Controller Registers + \brief Type definitions for the External Wakeup Interrupt Controller Registers (EWIC) + @{ + */ + +/** + \brief Structure type to access the External Wakeup Interrupt Controller Registers (EWIC). + */ +typedef struct +{ + __OM uint32_t EVENTSPR; /*!< Offset: 0x000 ( /W) Event Set Pending Register */ + uint32_t RESERVED0[31U]; + __IM uint32_t EVENTMASKA; /*!< Offset: 0x080 (R/W) Event Mask A Register */ + __IM uint32_t EVENTMASK[15]; /*!< Offset: 0x084 (R/W) Event Mask Register */ +} EWIC_Type; + +/* EWIC External Wakeup Interrupt Controller (EVENTSPR) Register Definitions */ +#define EWIC_EVENTSPR_EDBGREQ_Pos 2U /*!< EWIC EVENTSPR: EDBGREQ Position */ +#define EWIC_EVENTSPR_EDBGREQ_Msk (0x1UL << EWIC_EVENTSPR_EDBGREQ_Pos) /*!< EWIC EVENTSPR: EDBGREQ Mask */ + +#define EWIC_EVENTSPR_NMI_Pos 1U /*!< EWIC EVENTSPR: NMI Position */ +#define EWIC_EVENTSPR_NMI_Msk (0x1UL << EWIC_EVENTSPR_NMI_Pos) /*!< EWIC EVENTSPR: NMI Mask */ + +#define EWIC_EVENTSPR_EVENT_Pos 0U /*!< EWIC EVENTSPR: EVENT Position */ +#define EWIC_EVENTSPR_EVENT_Msk (0x1UL /*<< EWIC_EVENTSPR_EVENT_Pos*/) /*!< EWIC EVENTSPR: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASKA) Register Definitions */ +#define EWIC_EVENTMASKA_EDBGREQ_Pos 2U /*!< EWIC EVENTMASKA: EDBGREQ Position */ +#define EWIC_EVENTMASKA_EDBGREQ_Msk (0x1UL << EWIC_EVENTMASKA_EDBGREQ_Pos) /*!< EWIC EVENTMASKA: EDBGREQ Mask */ + +#define EWIC_EVENTMASKA_NMI_Pos 1U /*!< EWIC EVENTMASKA: NMI Position */ +#define EWIC_EVENTMASKA_NMI_Msk (0x1UL << EWIC_EVENTMASKA_NMI_Pos) /*!< EWIC EVENTMASKA: NMI Mask */ + +#define EWIC_EVENTMASKA_EVENT_Pos 0U /*!< EWIC EVENTMASKA: EVENT Position */ +#define EWIC_EVENTMASKA_EVENT_Msk (0x1UL /*<< EWIC_EVENTMASKA_EVENT_Pos*/) /*!< EWIC EVENTMASKA: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASK) Register Definitions */ +#define EWIC_EVENTMASK_IRQ_Pos 0U /*!< EWIC EVENTMASKA: IRQ Position */ +#define EWIC_EVENTMASK_IRQ_Msk (0xFFFFFFFFUL /*<< EWIC_EVENTMASKA_IRQ_Pos*/) /*!< EWIC EVENTMASKA: IRQ Mask */ + +/*@}*/ /* end of group EWIC_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup ErrBnk_Type Error Banking Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Error Banking Registers (ERRBNK) + @{ + */ + +/** + \brief Structure type to access the Error Banking Registers (ERRBNK). + */ +typedef struct +{ + __IOM uint32_t IEBR0; /*!< Offset: 0x000 (R/W) Instruction Cache Error Bank Register 0 */ + __IOM uint32_t IEBR1; /*!< Offset: 0x004 (R/W) Instruction Cache Error Bank Register 1 */ + uint32_t RESERVED0[2U]; + __IOM uint32_t DEBR0; /*!< Offset: 0x010 (R/W) Data Cache Error Bank Register 0 */ + __IOM uint32_t DEBR1; /*!< Offset: 0x014 (R/W) Data Cache Error Bank Register 1 */ + uint32_t RESERVED1[2U]; + __IOM uint32_t TEBR0; /*!< Offset: 0x020 (R/W) TCM Error Bank Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t TEBR1; /*!< Offset: 0x028 (R/W) TCM Error Bank Register 1 */ +} ErrBnk_Type; + +/* ERRBNK Instruction Cache Error Bank Register 0 (IEBR0) Register Definitions */ +#define ERRBNK_IEBR0_SWDEF_Pos 30U /*!< ERRBNK IEBR0: SWDEF Position */ +#define ERRBNK_IEBR0_SWDEF_Msk (0x3UL << ERRBNK_IEBR0_SWDEF_Pos) /*!< ERRBNK IEBR0: SWDEF Mask */ + +#define ERRBNK_IEBR0_BANK_Pos 16U /*!< ERRBNK IEBR0: BANK Position */ +#define ERRBNK_IEBR0_BANK_Msk (0x1UL << ERRBNK_IEBR0_BANK_Pos) /*!< ERRBNK IEBR0: BANK Mask */ + +#define ERRBNK_IEBR0_LOCATION_Pos 2U /*!< ERRBNK IEBR0: LOCATION Position */ +#define ERRBNK_IEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR0_LOCATION_Pos) /*!< ERRBNK IEBR0: LOCATION Mask */ + +#define ERRBNK_IEBR0_LOCKED_Pos 1U /*!< ERRBNK IEBR0: LOCKED Position */ +#define ERRBNK_IEBR0_LOCKED_Msk (0x1UL << ERRBNK_IEBR0_LOCKED_Pos) /*!< ERRBNK IEBR0: LOCKED Mask */ + +#define ERRBNK_IEBR0_VALID_Pos 0U /*!< ERRBNK IEBR0: VALID Position */ +#define ERRBNK_IEBR0_VALID_Msk (0x1UL << /*ERRBNK_IEBR0_VALID_Pos*/) /*!< ERRBNK IEBR0: VALID Mask */ + +/* ERRBNK Instruction Cache Error Bank Register 1 (IEBR1) Register Definitions */ +#define ERRBNK_IEBR1_SWDEF_Pos 30U /*!< ERRBNK IEBR1: SWDEF Position */ +#define ERRBNK_IEBR1_SWDEF_Msk (0x3UL << ERRBNK_IEBR1_SWDEF_Pos) /*!< ERRBNK IEBR1: SWDEF Mask */ + +#define ERRBNK_IEBR1_BANK_Pos 16U /*!< ERRBNK IEBR1: BANK Position */ +#define ERRBNK_IEBR1_BANK_Msk (0x1UL << ERRBNK_IEBR1_BANK_Pos) /*!< ERRBNK IEBR1: BANK Mask */ + +#define ERRBNK_IEBR1_LOCATION_Pos 2U /*!< ERRBNK IEBR1: LOCATION Position */ +#define ERRBNK_IEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR1_LOCATION_Pos) /*!< ERRBNK IEBR1: LOCATION Mask */ + +#define ERRBNK_IEBR1_LOCKED_Pos 1U /*!< ERRBNK IEBR1: LOCKED Position */ +#define ERRBNK_IEBR1_LOCKED_Msk (0x1UL << ERRBNK_IEBR1_LOCKED_Pos) /*!< ERRBNK IEBR1: LOCKED Mask */ + +#define ERRBNK_IEBR1_VALID_Pos 0U /*!< ERRBNK IEBR1: VALID Position */ +#define ERRBNK_IEBR1_VALID_Msk (0x1UL << /*ERRBNK_IEBR1_VALID_Pos*/) /*!< ERRBNK IEBR1: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 0 (DEBR0) Register Definitions */ +#define ERRBNK_DEBR0_SWDEF_Pos 30U /*!< ERRBNK DEBR0: SWDEF Position */ +#define ERRBNK_DEBR0_SWDEF_Msk (0x3UL << ERRBNK_DEBR0_SWDEF_Pos) /*!< ERRBNK DEBR0: SWDEF Mask */ + +#define ERRBNK_DEBR0_TYPE_Pos 17U /*!< ERRBNK DEBR0: TYPE Position */ +#define ERRBNK_DEBR0_TYPE_Msk (0x1UL << ERRBNK_DEBR0_TYPE_Pos) /*!< ERRBNK DEBR0: TYPE Mask */ + +#define ERRBNK_DEBR0_BANK_Pos 16U /*!< ERRBNK DEBR0: BANK Position */ +#define ERRBNK_DEBR0_BANK_Msk (0x1UL << ERRBNK_DEBR0_BANK_Pos) /*!< ERRBNK DEBR0: BANK Mask */ + +#define ERRBNK_DEBR0_LOCATION_Pos 2U /*!< ERRBNK DEBR0: LOCATION Position */ +#define ERRBNK_DEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR0_LOCATION_Pos) /*!< ERRBNK DEBR0: LOCATION Mask */ + +#define ERRBNK_DEBR0_LOCKED_Pos 1U /*!< ERRBNK DEBR0: LOCKED Position */ +#define ERRBNK_DEBR0_LOCKED_Msk (0x1UL << ERRBNK_DEBR0_LOCKED_Pos) /*!< ERRBNK DEBR0: LOCKED Mask */ + +#define ERRBNK_DEBR0_VALID_Pos 0U /*!< ERRBNK DEBR0: VALID Position */ +#define ERRBNK_DEBR0_VALID_Msk (0x1UL << /*ERRBNK_DEBR0_VALID_Pos*/) /*!< ERRBNK DEBR0: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 1 (DEBR1) Register Definitions */ +#define ERRBNK_DEBR1_SWDEF_Pos 30U /*!< ERRBNK DEBR1: SWDEF Position */ +#define ERRBNK_DEBR1_SWDEF_Msk (0x3UL << ERRBNK_DEBR1_SWDEF_Pos) /*!< ERRBNK DEBR1: SWDEF Mask */ + +#define ERRBNK_DEBR1_TYPE_Pos 17U /*!< ERRBNK DEBR1: TYPE Position */ +#define ERRBNK_DEBR1_TYPE_Msk (0x1UL << ERRBNK_DEBR1_TYPE_Pos) /*!< ERRBNK DEBR1: TYPE Mask */ + +#define ERRBNK_DEBR1_BANK_Pos 16U /*!< ERRBNK DEBR1: BANK Position */ +#define ERRBNK_DEBR1_BANK_Msk (0x1UL << ERRBNK_DEBR1_BANK_Pos) /*!< ERRBNK DEBR1: BANK Mask */ + +#define ERRBNK_DEBR1_LOCATION_Pos 2U /*!< ERRBNK DEBR1: LOCATION Position */ +#define ERRBNK_DEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR1_LOCATION_Pos) /*!< ERRBNK DEBR1: LOCATION Mask */ + +#define ERRBNK_DEBR1_LOCKED_Pos 1U /*!< ERRBNK DEBR1: LOCKED Position */ +#define ERRBNK_DEBR1_LOCKED_Msk (0x1UL << ERRBNK_DEBR1_LOCKED_Pos) /*!< ERRBNK DEBR1: LOCKED Mask */ + +#define ERRBNK_DEBR1_VALID_Pos 0U /*!< ERRBNK DEBR1: VALID Position */ +#define ERRBNK_DEBR1_VALID_Msk (0x1UL << /*ERRBNK_DEBR1_VALID_Pos*/) /*!< ERRBNK DEBR1: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 0 (TEBR0) Register Definitions */ +#define ERRBNK_TEBR0_SWDEF_Pos 30U /*!< ERRBNK TEBR0: SWDEF Position */ +#define ERRBNK_TEBR0_SWDEF_Msk (0x3UL << ERRBNK_TEBR0_SWDEF_Pos) /*!< ERRBNK TEBR0: SWDEF Mask */ + +#define ERRBNK_TEBR0_POISON_Pos 28U /*!< ERRBNK TEBR0: POISON Position */ +#define ERRBNK_TEBR0_POISON_Msk (0x1UL << ERRBNK_TEBR0_POISON_Pos) /*!< ERRBNK TEBR0: POISON Mask */ + +#define ERRBNK_TEBR0_TYPE_Pos 27U /*!< ERRBNK TEBR0: TYPE Position */ +#define ERRBNK_TEBR0_TYPE_Msk (0x1UL << ERRBNK_TEBR0_TYPE_Pos) /*!< ERRBNK TEBR0: TYPE Mask */ + +#define ERRBNK_TEBR0_BANK_Pos 24U /*!< ERRBNK TEBR0: BANK Position */ +#define ERRBNK_TEBR0_BANK_Msk (0x3UL << ERRBNK_TEBR0_BANK_Pos) /*!< ERRBNK TEBR0: BANK Mask */ + +#define ERRBNK_TEBR0_LOCATION_Pos 2U /*!< ERRBNK TEBR0: LOCATION Position */ +#define ERRBNK_TEBR0_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR0_LOCATION_Pos) /*!< ERRBNK TEBR0: LOCATION Mask */ + +#define ERRBNK_TEBR0_LOCKED_Pos 1U /*!< ERRBNK TEBR0: LOCKED Position */ +#define ERRBNK_TEBR0_LOCKED_Msk (0x1UL << ERRBNK_TEBR0_LOCKED_Pos) /*!< ERRBNK TEBR0: LOCKED Mask */ + +#define ERRBNK_TEBR0_VALID_Pos 0U /*!< ERRBNK TEBR0: VALID Position */ +#define ERRBNK_TEBR0_VALID_Msk (0x1UL << /*ERRBNK_TEBR0_VALID_Pos*/) /*!< ERRBNK TEBR0: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 1 (TEBR1) Register Definitions */ +#define ERRBNK_TEBR1_SWDEF_Pos 30U /*!< ERRBNK TEBR1: SWDEF Position */ +#define ERRBNK_TEBR1_SWDEF_Msk (0x3UL << ERRBNK_TEBR1_SWDEF_Pos) /*!< ERRBNK TEBR1: SWDEF Mask */ + +#define ERRBNK_TEBR1_POISON_Pos 28U /*!< ERRBNK TEBR1: POISON Position */ +#define ERRBNK_TEBR1_POISON_Msk (0x1UL << ERRBNK_TEBR1_POISON_Pos) /*!< ERRBNK TEBR1: POISON Mask */ + +#define ERRBNK_TEBR1_TYPE_Pos 27U /*!< ERRBNK TEBR1: TYPE Position */ +#define ERRBNK_TEBR1_TYPE_Msk (0x1UL << ERRBNK_TEBR1_TYPE_Pos) /*!< ERRBNK TEBR1: TYPE Mask */ + +#define ERRBNK_TEBR1_BANK_Pos 24U /*!< ERRBNK TEBR1: BANK Position */ +#define ERRBNK_TEBR1_BANK_Msk (0x3UL << ERRBNK_TEBR1_BANK_Pos) /*!< ERRBNK TEBR1: BANK Mask */ + +#define ERRBNK_TEBR1_LOCATION_Pos 2U /*!< ERRBNK TEBR1: LOCATION Position */ +#define ERRBNK_TEBR1_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR1_LOCATION_Pos) /*!< ERRBNK TEBR1: LOCATION Mask */ + +#define ERRBNK_TEBR1_LOCKED_Pos 1U /*!< ERRBNK TEBR1: LOCKED Position */ +#define ERRBNK_TEBR1_LOCKED_Msk (0x1UL << ERRBNK_TEBR1_LOCKED_Pos) /*!< ERRBNK TEBR1: LOCKED Mask */ + +#define ERRBNK_TEBR1_VALID_Pos 0U /*!< ERRBNK TEBR1: VALID Position */ +#define ERRBNK_TEBR1_VALID_Msk (0x1UL << /*ERRBNK_TEBR1_VALID_Pos*/) /*!< ERRBNK TEBR1: VALID Mask */ + +/*@}*/ /* end of group ErrBnk_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PrcCfgInf_Type Processor Configuration Information Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Processor Configuration Information Registerss (PRCCFGINF) + @{ + */ + +/** + \brief Structure type to access the Processor Configuration Information Registerss (PRCCFGINF). + */ +typedef struct +{ + __OM uint32_t CFGINFOSEL; /*!< Offset: 0x000 ( /W) Processor Configuration Information Selection Register */ + __IM uint32_t CFGINFORD; /*!< Offset: 0x004 (R/ ) Processor Configuration Information Read Data Register */ +} PrcCfgInf_Type; + +/* PRCCFGINF Processor Configuration Information Selection Register (CFGINFOSEL) Definitions */ + +/* PRCCFGINF Processor Configuration Information Read Data Register (CFGINFORD) Definitions */ + +/*@}*/ /* end of group PrcCfgInf_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup STL_Type Software Test Library Observation Registers + \brief Type definitions for the Software Test Library Observation Registerss (STL) + @{ + */ + +/** + \brief Structure type to access the Software Test Library Observation Registerss (STL). + */ +typedef struct +{ + __IM uint32_t STLNVICPENDOR; /*!< Offset: 0x000 (R/ ) NVIC Pending Priority Tree Register */ + __IM uint32_t STLNVICACTVOR; /*!< Offset: 0x004 (R/ ) NVIC Active Priority Tree Register */ + uint32_t RESERVED0[2U]; + __OM uint32_t STLIDMPUSR; /*!< Offset: 0x010 ( /W) MPU Sanple Register */ + __IM uint32_t STLIMPUOR; /*!< Offset: 0x014 (R/ ) MPU Region Hit Register */ + __IM uint32_t STLD0MPUOR; /*!< Offset: 0x018 (R/ ) MPU Memory Attributes Register 0 */ + __IM uint32_t STLD1MPUOR; /*!< Offset: 0x01C (R/ ) MPU Memory Attributes Register 1 */ + +} STL_Type; + +/* STL Software Test Library Observation Register (STLNVICPENDOR) Definitions */ +#define STL_STLNVICPENDOR_VALID_Pos 18U /*!< STL STLNVICPENDOR: VALID Position */ +#define STL_STLNVICPENDOR_VALID_Msk (0x1UL << STL_STLNVICPENDOR_VALID_Pos) /*!< STL STLNVICPENDOR: VALID Mask */ + +#define STL_STLNVICPENDOR_TARGET_Pos 17U /*!< STL STLNVICPENDOR: TARGET Position */ +#define STL_STLNVICPENDOR_TARGET_Msk (0x1UL << STL_STLNVICPENDOR_TARGET_Pos) /*!< STL STLNVICPENDOR: TARGET Mask */ + +#define STL_STLNVICPENDOR_PRIORITY_Pos 9U /*!< STL STLNVICPENDOR: PRIORITY Position */ +#define STL_STLNVICPENDOR_PRIORITY_Msk (0xFFUL << STL_STLNVICPENDOR_PRIORITY_Pos) /*!< STL STLNVICPENDOR: PRIORITY Mask */ + +#define STL_STLNVICPENDOR_INTNUM_Pos 0U /*!< STL STLNVICPENDOR: INTNUM Position */ +#define STL_STLNVICPENDOR_INTNUM_Msk (0x1FFUL /*<< STL_STLNVICPENDOR_INTNUM_Pos*/) /*!< STL STLNVICPENDOR: INTNUM Mask */ + +/* STL Software Test Library Observation Register (STLNVICACTVOR) Definitions */ +#define STL_STLNVICACTVOR_VALID_Pos 18U /*!< STL STLNVICACTVOR: VALID Position */ +#define STL_STLNVICACTVOR_VALID_Msk (0x1UL << STL_STLNVICACTVOR_VALID_Pos) /*!< STL STLNVICACTVOR: VALID Mask */ + +#define STL_STLNVICACTVOR_TARGET_Pos 17U /*!< STL STLNVICACTVOR: TARGET Position */ +#define STL_STLNVICACTVOR_TARGET_Msk (0x1UL << STL_STLNVICACTVOR_TARGET_Pos) /*!< STL STLNVICACTVOR: TARGET Mask */ + +#define STL_STLNVICACTVOR_PRIORITY_Pos 9U /*!< STL STLNVICACTVOR: PRIORITY Position */ +#define STL_STLNVICACTVOR_PRIORITY_Msk (0xFFUL << STL_STLNVICACTVOR_PRIORITY_Pos) /*!< STL STLNVICACTVOR: PRIORITY Mask */ + +#define STL_STLNVICACTVOR_INTNUM_Pos 0U /*!< STL STLNVICACTVOR: INTNUM Position */ +#define STL_STLNVICACTVOR_INTNUM_Msk (0x1FFUL /*<< STL_STLNVICACTVOR_INTNUM_Pos*/) /*!< STL STLNVICACTVOR: INTNUM Mask */ + +/* STL Software Test Library Observation Register (STLIDMPUSR) Definitions */ +#define STL_STLIDMPUSR_ADDR_Pos 5U /*!< STL STLIDMPUSR: ADDR Position */ +#define STL_STLIDMPUSR_ADDR_Msk (0x7FFFFFFUL << STL_STLIDMPUSR_ADDR_Pos) /*!< STL STLIDMPUSR: ADDR Mask */ + +#define STL_STLIDMPUSR_INSTR_Pos 2U /*!< STL STLIDMPUSR: INSTR Position */ +#define STL_STLIDMPUSR_INSTR_Msk (0x1UL << STL_STLIDMPUSR_INSTR_Pos) /*!< STL STLIDMPUSR: INSTR Mask */ + +#define STL_STLIDMPUSR_DATA_Pos 1U /*!< STL STLIDMPUSR: DATA Position */ +#define STL_STLIDMPUSR_DATA_Msk (0x1UL << STL_STLIDMPUSR_DATA_Pos) /*!< STL STLIDMPUSR: DATA Mask */ + +/* STL Software Test Library Observation Register (STLIMPUOR) Definitions */ +#define STL_STLIMPUOR_HITREGION_Pos 9U /*!< STL STLIMPUOR: HITREGION Position */ +#define STL_STLIMPUOR_HITREGION_Msk (0xFFUL << STL_STLIMPUOR_HITREGION_Pos) /*!< STL STLIMPUOR: HITREGION Mask */ + +#define STL_STLIMPUOR_ATTR_Pos 0U /*!< STL STLIMPUOR: ATTR Position */ +#define STL_STLIMPUOR_ATTR_Msk (0x1FFUL /*<< STL_STLIMPUOR_ATTR_Pos*/) /*!< STL STLIMPUOR: ATTR Mask */ + +/* STL Software Test Library Observation Register (STLD0MPUOR) Definitions */ +#define STL_STLD0MPUOR_HITREGION_Pos 9U /*!< STL STLD0MPUOR: HITREGION Position */ +#define STL_STLD0MPUOR_HITREGION_Msk (0xFFUL << STL_STLD0MPUOR_HITREGION_Pos) /*!< STL STLD0MPUOR: HITREGION Mask */ + +#define STL_STLD0MPUOR_ATTR_Pos 0U /*!< STL STLD0MPUOR: ATTR Position */ +#define STL_STLD0MPUOR_ATTR_Msk (0x1FFUL /*<< STL_STLD0MPUOR_ATTR_Pos*/) /*!< STL STLD0MPUOR: ATTR Mask */ + +/* STL Software Test Library Observation Register (STLD1MPUOR) Definitions */ +#define STL_STLD1MPUOR_HITREGION_Pos 9U /*!< STL STLD1MPUOR: HITREGION Position */ +#define STL_STLD1MPUOR_HITREGION_Msk (0xFFUL << STL_STLD1MPUOR_HITREGION_Pos) /*!< STL STLD1MPUOR: HITREGION Mask */ + +#define STL_STLD1MPUOR_ATTR_Pos 0U /*!< STL STLD1MPUOR: ATTR Position */ +#define STL_STLD1MPUOR_ATTR_Msk (0x1FFUL /*<< STL_STLD1MPUOR_ATTR_Pos*/) /*!< STL STLD1MPUOR: ATTR Mask */ + +/*@}*/ /* end of group STL_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[3]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE4 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE8 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFEC (R/W) PMU Peripheral Identification Register 3 */ + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (0xFFFFUL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (0xFFFFUL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (0xFFUL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (0x3FUL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/** \brief PMU Authentication Status Register Definitions */ + +#define PMU_AUTHSTATUS_NSID_Pos 0U /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSID_Msk (0x3UL /*<< PMU_AUTHSTATUS_NSID_Pos*/) /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSNID_Pos 2U /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSNID_Msk (0x3UL << PMU_AUTHSTATUS_NSNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SID_Pos 4U /*!< PMU AUTHSTATUS: Secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_SID_Msk (0x3UL << PMU_AUTHSTATUS_SID_Pos) /*!< PMU AUTHSTATUS: Secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SNID_Pos 6U /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SNID_Msk (0x3UL << PMU_AUTHSTATUS_SNID_Pos) /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUID_Pos 16U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUID_Msk (0x3UL << PMU_AUTHSTATUS_NSUID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUNID_Pos 18U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUNID_Msk (0x3UL << PMU_AUTHSTATUS_NSUNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUID_Pos 20U /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_SUID_Msk (0x3UL << PMU_AUTHSTATUS_SUID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUNID_Pos 22U /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SUNID_Msk (0x3UL << PMU_AUTHSTATUS_SUNID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Mask */ + + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define MEMSYSCTL_BASE (0xE001E000UL) /*!< Memory System Control Base Address */ + #define ERRBNK_BASE (0xE001E100UL) /*!< Error Banking Base Address */ + #define PWRMODCTL_BASE (0xE001E300UL) /*!< Power Mode Control Base Address */ + #define EWIC_BASE (0xE001E400UL) /*!< External Wakeup Interrupt Controller Base Address */ + #define PRCCFGINF_BASE (0xE001E700UL) /*!< Processor Configuration Information Base Address */ + #define STL_BASE (0xE001E800UL) /*!< Software Test Library Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define ICB ((ICB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define MEMSYSCTL ((MemSysCtl_Type *) MEMSYSCTL_BASE ) /*!< Memory System Control configuration struct */ + #define ERRBNK ((ErrBnk_Type *) ERRBNK_BASE ) /*!< Error Banking configuration struct */ + #define PWRMODCTL ((PwrModCtl_Type *) PWRMODCTL_BASE ) /*!< Power Mode Control configuration struct */ + #define EWIC ((EWIC_Type *) EWIC_BASE ) /*!< EWIC configuration struct */ + #define PRCCFGINF ((PrcCfgInf_Type *) PRCCFGINF_BASE ) /*!< Processor Configuration Information configuration struct */ + #define STL ((STL_Type *) STL_BASE ) /*!< Software Test Library configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define ICB_NS ((ICB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ + +/* 'SCnSCB' is deprecated and replaced by 'ICB' */ +typedef ICB_Type SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISCRITAXIRUW_Pos (ICB_ACTLR_DISCRITAXIRUW_Pos) +#define SCnSCB_ACTLR_DISCRITAXIRUW_Msk (ICB_ACTLR_DISCRITAXIRUW_Msk) + +#define SCnSCB_ACTLR_DISDI_Pos (ICB_ACTLR_DISDI_Pos) +#define SCnSCB_ACTLR_DISDI_Msk (ICB_ACTLR_DISDI_Msk) + +#define SCnSCB_ACTLR_DISCRITAXIRUR_Pos (ICB_ACTLR_DISCRITAXIRUR_Pos) +#define SCnSCB_ACTLR_DISCRITAXIRUR_Msk (ICB_ACTLR_DISCRITAXIRUR_Msk) + +#define SCnSCB_ACTLR_EVENTBUSEN_Pos (ICB_ACTLR_EVENTBUSEN_Pos) +#define SCnSCB_ACTLR_EVENTBUSEN_Msk (ICB_ACTLR_EVENTBUSEN_Msk) + +#define SCnSCB_ACTLR_EVENTBUSEN_S_Pos (ICB_ACTLR_EVENTBUSEN_S_Pos) +#define SCnSCB_ACTLR_EVENTBUSEN_S_Msk (ICB_ACTLR_EVENTBUSEN_S_Msk) + +#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos (ICB_ACTLR_DISITMATBFLUSH_Pos) +#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (ICB_ACTLR_DISITMATBFLUSH_Msk) + +#define SCnSCB_ACTLR_DISNWAMODE_Pos (ICB_ACTLR_DISNWAMODE_Pos) +#define SCnSCB_ACTLR_DISNWAMODE_Msk (ICB_ACTLR_DISNWAMODE_Msk) + +#define SCnSCB_ACTLR_FPEXCODIS_Pos (ICB_ACTLR_FPEXCODIS_Pos) +#define SCnSCB_ACTLR_FPEXCODIS_Msk (ICB_ACTLR_FPEXCODIS_Msk) + +#define SCnSCB_ACTLR_DISOLAP_Pos (ICB_ACTLR_DISOLAP_Pos) +#define SCnSCB_ACTLR_DISOLAP_Msk (ICB_ACTLR_DISOLAP_Msk) + +#define SCnSCB_ACTLR_DISOLAPS_Pos (ICB_ACTLR_DISOLAPS_Pos) +#define SCnSCB_ACTLR_DISOLAPS_Msk (ICB_ACTLR_DISOLAPS_Msk) + +#define SCnSCB_ACTLR_DISLOBR_Pos (ICB_ACTLR_DISLOBR_Pos) +#define SCnSCB_ACTLR_DISLOBR_Msk (ICB_ACTLR_DISLOBR_Msk) + +#define SCnSCB_ACTLR_DISLO_Pos (ICB_ACTLR_DISLO_Pos) +#define SCnSCB_ACTLR_DISLO_Msk (ICB_ACTLR_DISLO_Msk) + +#define SCnSCB_ACTLR_DISLOLEP_Pos (ICB_ACTLR_DISLOLEP_Pos) +#define SCnSCB_ACTLR_DISLOLEP_Msk (ICB_ACTLR_DISLOLEP_Msk) + +#define SCnSCB_ACTLR_DISFOLD_Pos (ICB_ACTLR_DISFOLD_Pos) +#define SCnSCB_ACTLR_DISFOLD_Msk (ICB_ACTLR_DISFOLD_Msk) + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos (ICB_ICTR_INTLINESNUM_Pos) +#define SCnSCB_ICTR_INTLINESNUM_Msk (ICB_ICTR_INTLINESNUM_Msk) + +#define SCnSCB (ICB) +#define SCnSCB_NS (ICB_NS) + +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +/** + \brief Cortex-M55 PMU events + \note Architectural PMU events can be found in pmu_armv8.h +*/ + +#define ARMCM55_PMU_ECC_ERR 0xC000 /*!< Any ECC error */ +#define ARMCM55_PMU_ECC_ERR_FATAL 0xC001 /*!< Any fatal ECC error */ +#define ARMCM55_PMU_ECC_ERR_DCACHE 0xC010 /*!< Any ECC error in the data cache */ +#define ARMCM55_PMU_ECC_ERR_ICACHE 0xC011 /*!< Any ECC error in the instruction cache */ +#define ARMCM55_PMU_ECC_ERR_FATAL_DCACHE 0xC012 /*!< Any fatal ECC error in the data cache */ +#define ARMCM55_PMU_ECC_ERR_FATAL_ICACHE 0xC013 /*!< Any fatal ECC error in the instruction cache*/ +#define ARMCM55_PMU_ECC_ERR_DTCM 0xC020 /*!< Any ECC error in the DTCM */ +#define ARMCM55_PMU_ECC_ERR_ITCM 0xC021 /*!< Any ECC error in the ITCM */ +#define ARMCM55_PMU_ECC_ERR_FATAL_DTCM 0xC022 /*!< Any fatal ECC error in the DTCM */ +#define ARMCM55_PMU_ECC_ERR_FATAL_ITCM 0xC023 /*!< Any fatal ECC error in the ITCM */ +#define ARMCM55_PMU_PF_LINEFILL 0xC100 /*!< A prefetcher starts a line-fill */ +#define ARMCM55_PMU_PF_CANCEL 0xC101 /*!< A prefetcher stops prefetching */ +#define ARMCM55_PMU_PF_DROP_LINEFILL 0xC102 /*!< A linefill triggered by a prefetcher has been dropped because of lack of buffering */ +#define ARMCM55_PMU_NWAMODE_ENTER 0xC200 /*!< No write-allocate mode entry */ +#define ARMCM55_PMU_NWAMODE 0xC201 /*!< Write-allocate store is not allocated into the data cache due to no-write-allocate mode */ +#define ARMCM55_PMU_SAHB_ACCESS 0xC300 /*!< Read or write access on the S-AHB interface to the TCM */ +#define ARMCM55_PMU_PAHB_ACCESS 0xC301 /*!< Read or write access to the P-AHB write interface */ +#define ARMCM55_PMU_AXI_WRITE_ACCESS 0xC302 /*!< Any beat access to M-AXI write interface */ +#define ARMCM55_PMU_AXI_READ_ACCESS 0xC303 /*!< Any beat access to M-AXI read interface */ +#define ARMCM55_PMU_DOSTIMEOUT_DOUBLE 0xC400 /*!< Denial of Service timeout has fired twice and caused buffers to drain to allow forward progress */ +#define ARMCM55_PMU_DOSTIMEOUT_TRIPLE 0xC401 /*!< Denial of Service timeout has fired three times and blocked the LSU to force forward progress */ + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM55_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h new file mode 100644 index 0000000000..010506e9fa --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h @@ -0,0 +1,2366 @@ +/**************************************************************************//** + * @file core_cm7.h + * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File + * @version V5.1.6 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM7_H_GENERIC +#define __CORE_CM7_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M7 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM7 definitions */ +#define __CM7_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM7_CMSIS_VERSION_SUB ( __CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ + __CM7_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (7U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM7_H_DEPENDANT +#define __CORE_CM7_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM7_REV + #define __CM7_REV 0x0000U + #warning "__CM7_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DTCM_PRESENT + #define __DTCM_PRESENT 0U + #warning "__DTCM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M7 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[1U]; + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED3[93U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ + uint32_t RESERVED7[5U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x290 (R/W) Instruction Tightly-Coupled Memory Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x294 (R/W) Data Tightly-Coupled Memory Control Registers */ + __IOM uint32_t AHBPCR; /*!< Offset: 0x298 (R/W) AHBP Control Register */ + __IOM uint32_t CACR; /*!< Offset: 0x29C (R/W) L1 Cache Control Register */ + __IOM uint32_t AHBSCR; /*!< Offset: 0x2A0 (R/W) AHB Slave Control Register */ + uint32_t RESERVED8[1U]; + __IOM uint32_t ABFSR; /*!< Offset: 0x2A8 (R/W) Auxiliary Bus Fault Status Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: Branch prediction enable bit Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: Branch prediction enable bit Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: Instruction cache enable bit Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: Instruction cache enable bit Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: Cache enable bit Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: Cache enable bit Mask */ + +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/* Instruction Tightly-Coupled Memory Control Register Definitions */ +#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ +#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ + +#define SCB_ITCMCR_RETEN_Pos 2U /*!< SCB ITCMCR: RETEN Position */ +#define SCB_ITCMCR_RETEN_Msk (1UL << SCB_ITCMCR_RETEN_Pos) /*!< SCB ITCMCR: RETEN Mask */ + +#define SCB_ITCMCR_RMW_Pos 1U /*!< SCB ITCMCR: RMW Position */ +#define SCB_ITCMCR_RMW_Msk (1UL << SCB_ITCMCR_RMW_Pos) /*!< SCB ITCMCR: RMW Mask */ + +#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ +#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ + +/* Data Tightly-Coupled Memory Control Register Definitions */ +#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ +#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ + +#define SCB_DTCMCR_RETEN_Pos 2U /*!< SCB DTCMCR: RETEN Position */ +#define SCB_DTCMCR_RETEN_Msk (1UL << SCB_DTCMCR_RETEN_Pos) /*!< SCB DTCMCR: RETEN Mask */ + +#define SCB_DTCMCR_RMW_Pos 1U /*!< SCB DTCMCR: RMW Position */ +#define SCB_DTCMCR_RMW_Msk (1UL << SCB_DTCMCR_RMW_Pos) /*!< SCB DTCMCR: RMW Mask */ + +#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ +#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ + +/* AHBP Control Register Definitions */ +#define SCB_AHBPCR_SZ_Pos 1U /*!< SCB AHBPCR: SZ Position */ +#define SCB_AHBPCR_SZ_Msk (7UL << SCB_AHBPCR_SZ_Pos) /*!< SCB AHBPCR: SZ Mask */ + +#define SCB_AHBPCR_EN_Pos 0U /*!< SCB AHBPCR: EN Position */ +#define SCB_AHBPCR_EN_Msk (1UL /*<< SCB_AHBPCR_EN_Pos*/) /*!< SCB AHBPCR: EN Mask */ + +/* L1 Cache Control Register Definitions */ +#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ +#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ + +#define SCB_CACR_ECCEN_Pos 1U /*!< \deprecated SCB CACR: ECCEN Position */ +#define SCB_CACR_ECCEN_Msk (1UL << SCB_CACR_ECCEN_Pos) /*!< \deprecated SCB CACR: ECCEN Mask */ + +#define SCB_CACR_ECCDIS_Pos 1U /*!< SCB CACR: ECCDIS Position */ +#define SCB_CACR_ECCDIS_Msk (1UL << SCB_CACR_ECCDIS_Pos) /*!< SCB CACR: ECCDIS Mask */ + +#define SCB_CACR_SIWT_Pos 0U /*!< SCB CACR: SIWT Position */ +#define SCB_CACR_SIWT_Msk (1UL /*<< SCB_CACR_SIWT_Pos*/) /*!< SCB CACR: SIWT Mask */ + +/* AHBS Control Register Definitions */ +#define SCB_AHBSCR_INITCOUNT_Pos 11U /*!< SCB AHBSCR: INITCOUNT Position */ +#define SCB_AHBSCR_INITCOUNT_Msk (0x1FUL << SCB_AHBSCR_INITCOUNT_Pos) /*!< SCB AHBSCR: INITCOUNT Mask */ + +#define SCB_AHBSCR_TPRI_Pos 2U /*!< SCB AHBSCR: TPRI Position */ +#define SCB_AHBSCR_TPRI_Msk (0x1FFUL << SCB_AHBSCR_TPRI_Pos) /*!< SCB AHBSCR: TPRI Mask */ + +#define SCB_AHBSCR_CTL_Pos 0U /*!< SCB AHBSCR: CTL Position*/ +#define SCB_AHBSCR_CTL_Msk (3UL /*<< SCB_AHBSCR_CTL_Pos*/) /*!< SCB AHBSCR: CTL Mask */ + +/* Auxiliary Bus Fault Status Register Definitions */ +#define SCB_ABFSR_AXIMTYPE_Pos 8U /*!< SCB ABFSR: AXIMTYPE Position*/ +#define SCB_ABFSR_AXIMTYPE_Msk (3UL << SCB_ABFSR_AXIMTYPE_Pos) /*!< SCB ABFSR: AXIMTYPE Mask */ + +#define SCB_ABFSR_EPPB_Pos 4U /*!< SCB ABFSR: EPPB Position*/ +#define SCB_ABFSR_EPPB_Msk (1UL << SCB_ABFSR_EPPB_Pos) /*!< SCB ABFSR: EPPB Mask */ + +#define SCB_ABFSR_AXIM_Pos 3U /*!< SCB ABFSR: AXIM Position*/ +#define SCB_ABFSR_AXIM_Msk (1UL << SCB_ABFSR_AXIM_Pos) /*!< SCB ABFSR: AXIM Mask */ + +#define SCB_ABFSR_AHBP_Pos 2U /*!< SCB ABFSR: AHBP Position*/ +#define SCB_ABFSR_AHBP_Msk (1UL << SCB_ABFSR_AHBP_Pos) /*!< SCB ABFSR: AHBP Mask */ + +#define SCB_ABFSR_DTCM_Pos 1U /*!< SCB ABFSR: DTCM Position*/ +#define SCB_ABFSR_DTCM_Msk (1UL << SCB_ABFSR_DTCM_Pos) /*!< SCB ABFSR: DTCM Mask */ + +#define SCB_ABFSR_ITCM_Pos 0U /*!< SCB ABFSR: ITCM Position*/ +#define SCB_ABFSR_ITCM_Msk (1UL /*<< SCB_ABFSR_ITCM_Pos*/) /*!< SCB ABFSR: ITCM Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISDYNADD_Pos 26U /*!< ACTLR: DISDYNADD Position */ +#define SCnSCB_ACTLR_DISDYNADD_Msk (1UL << SCnSCB_ACTLR_DISDYNADD_Pos) /*!< ACTLR: DISDYNADD Mask */ + +#define SCnSCB_ACTLR_DISISSCH1_Pos 21U /*!< ACTLR: DISISSCH1 Position */ +#define SCnSCB_ACTLR_DISISSCH1_Msk (0x1FUL << SCnSCB_ACTLR_DISISSCH1_Pos) /*!< ACTLR: DISISSCH1 Mask */ + +#define SCnSCB_ACTLR_DISDI_Pos 16U /*!< ACTLR: DISDI Position */ +#define SCnSCB_ACTLR_DISDI_Msk (0x1FUL << SCnSCB_ACTLR_DISDI_Pos) /*!< ACTLR: DISDI Mask */ + +#define SCnSCB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define SCnSCB_ACTLR_DISCRITAXIRUR_Msk (1UL << SCnSCB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define SCnSCB_ACTLR_DISBTACALLOC_Pos 14U /*!< ACTLR: DISBTACALLOC Position */ +#define SCnSCB_ACTLR_DISBTACALLOC_Msk (1UL << SCnSCB_ACTLR_DISBTACALLOC_Pos) /*!< ACTLR: DISBTACALLOC Mask */ + +#define SCnSCB_ACTLR_DISBTACREAD_Pos 13U /*!< ACTLR: DISBTACREAD Position */ +#define SCnSCB_ACTLR_DISBTACREAD_Msk (1UL << SCnSCB_ACTLR_DISBTACREAD_Pos) /*!< ACTLR: DISBTACREAD Mask */ + +#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (1UL << SCnSCB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define SCnSCB_ACTLR_DISRAMODE_Pos 11U /*!< ACTLR: DISRAMODE Position */ +#define SCnSCB_ACTLR_DISRAMODE_Msk (1UL << SCnSCB_ACTLR_DISRAMODE_Pos) /*!< ACTLR: DISRAMODE Mask */ + +#define SCnSCB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define SCnSCB_ACTLR_FPEXCODIS_Msk (1UL << SCnSCB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED3[981U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( W) Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and FP Feature Register 2 Definitions */ + +#define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ +#define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ +#define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = SCB->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + +/*@} end of CMSIS_Core_FpuFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h new file mode 100644 index 0000000000..6046311189 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h @@ -0,0 +1,4672 @@ +/**************************************************************************//** + * @file core_cm85.h + * @brief CMSIS Cortex-M85 Core Peripheral Access Layer Header File + * @version V1.0.4 + * @date 21. April 2022 + ******************************************************************************/ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM85_H_GENERIC +#define __CORE_CM85_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M85 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM85 definitions */ + +#define __CORTEX_M (85U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM85_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM85_H_DEPENDANT +#define __CORE_CM85_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM85_REV + #define __CM85_REV 0x0001U + #warning "__CM85_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 8U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 8 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M85 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core EWIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core PMU Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:1; /*!< bit: 20 Reserved */ + uint32_t B:1; /*!< bit: 21 BTI active (read 0) */ + uint32_t _reserved2:2; /*!< bit: 22..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_B_Pos 21U /*!< xPSR: B Position */ +#define xPSR_B_Msk (1UL << xPSR_B_Pos) /*!< xPSR: B Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t BTI_EN:1; /*!< bit: 4 Privileged branch target identification enable */ + uint32_t UBTI_EN:1; /*!< bit: 5 Unprivileged branch target identification enable */ + uint32_t PAC_EN:1; /*!< bit: 6 Privileged pointer authentication enable */ + uint32_t UPAC_EN:1; /*!< bit: 7 Unprivileged pointer authentication enable */ + uint32_t _reserved1:24; /*!< bit: 8..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_UPAC_EN_Pos 7U /*!< CONTROL: UPAC_EN Position */ +#define CONTROL_UPAC_EN_Msk (1UL << CONTROL_UPAC_EN_Pos) /*!< CONTROL: UPAC_EN Mask */ + +#define CONTROL_PAC_EN_Pos 6U /*!< CONTROL: PAC_EN Position */ +#define CONTROL_PAC_EN_Msk (1UL << CONTROL_PAC_EN_Pos) /*!< CONTROL: PAC_EN Mask */ + +#define CONTROL_UBTI_EN_Pos 5U /*!< CONTROL: UBTI_EN Position */ +#define CONTROL_UBTI_EN_Msk (1UL << CONTROL_UBTI_EN_Pos) /*!< CONTROL: UBTI_EN Mask */ + +#define CONTROL_BTI_EN_Pos 4U /*!< CONTROL: BTI_EN Position */ +#define CONTROL_BTI_EN_Msk (1UL << CONTROL_BTI_EN_Pos) /*!< CONTROL: BTI_EN Mask */ + +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ICB Implementation Control Block register (ICB) + \brief Type definitions for the Implementation Control Block Register + @{ + */ + +/** + \brief Structure type to access the Implementation Control Block (ICB). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} ICB_Type; + +/* Auxiliary Control Register Definitions */ +#define ICB_ACTLR_DISCRITAXIRUW_Pos 27U /*!< ACTLR: DISCRITAXIRUW Position */ +#define ICB_ACTLR_DISCRITAXIRUW_Msk (1UL << ICB_ACTLR_DISCRITAXIRUW_Pos) /*!< ACTLR: DISCRITAXIRUW Mask */ + +#define ICB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define ICB_ACTLR_DISCRITAXIRUR_Msk (1UL << ICB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define ICB_ACTLR_EVENTBUSEN_Pos 14U /*!< ACTLR: EVENTBUSEN Position */ +#define ICB_ACTLR_EVENTBUSEN_Msk (1UL << ICB_ACTLR_EVENTBUSEN_Pos) /*!< ACTLR: EVENTBUSEN Mask */ + +#define ICB_ACTLR_EVENTBUSEN_S_Pos 13U /*!< ACTLR: EVENTBUSEN_S Position */ +#define ICB_ACTLR_EVENTBUSEN_S_Msk (1UL << ICB_ACTLR_EVENTBUSEN_S_Pos) /*!< ACTLR: EVENTBUSEN_S Mask */ + +#define ICB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define ICB_ACTLR_DISITMATBFLUSH_Msk (1UL << ICB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define ICB_ACTLR_DISNWAMODE_Pos 11U /*!< ACTLR: DISNWAMODE Position */ +#define ICB_ACTLR_DISNWAMODE_Msk (1UL << ICB_ACTLR_DISNWAMODE_Pos) /*!< ACTLR: DISNWAMODE Mask */ + +#define ICB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define ICB_ACTLR_FPEXCODIS_Msk (1UL << ICB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +/* Interrupt Controller Type Register Definitions */ +#define ICB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define ICB_ICTR_INTLINESNUM_Msk (0xFUL /*<< ICB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_ICB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup MemSysCtl_Type Memory System Control Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Memory System Control Registers (MEMSYSCTL) + @{ + */ + +/** + \brief Structure type to access the Memory System Control Registers (MEMSYSCTL). + */ +typedef struct +{ + __IOM uint32_t MSCR; /*!< Offset: 0x000 (R/W) Memory System Control Register */ + __IOM uint32_t PFCR; /*!< Offset: 0x004 (R/W) Prefetcher Control Register */ + uint32_t RESERVED1[2U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x010 (R/W) ITCM Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x014 (R/W) DTCM Control Register */ + __IOM uint32_t PAHBCR; /*!< Offset: 0x018 (R/W) P-AHB Control Register */ + uint32_t RESERVED2[313U]; + __IOM uint32_t ITGU_CTRL; /*!< Offset: 0x500 (R/W) ITGU Control Register */ + __IOM uint32_t ITGU_CFG; /*!< Offset: 0x504 (R/W) ITGU Configuration Register */ + uint32_t RESERVED3[2U]; + __IOM uint32_t ITGU_LUT[16U]; /*!< Offset: 0x510 (R/W) ITGU Look Up Table Register */ + uint32_t RESERVED4[44U]; + __IOM uint32_t DTGU_CTRL; /*!< Offset: 0x600 (R/W) DTGU Control Registers */ + __IOM uint32_t DTGU_CFG; /*!< Offset: 0x604 (R/W) DTGU Configuration Register */ + uint32_t RESERVED5[2U]; + __IOM uint32_t DTGU_LUT[16U]; /*!< Offset: 0x610 (R/W) DTGU Look Up Table Register */ +} MemSysCtl_Type; + +/* MEMSYSCTL Memory System Control Register (MSCR) Register Definitions */ +#define MEMSYSCTL_MSCR_CPWRDN_Pos 17U /*!< MEMSYSCTL MSCR: CPWRDN Position */ +#define MEMSYSCTL_MSCR_CPWRDN_Msk (0x1UL << MEMSYSCTL_MSCR_CPWRDN_Pos) /*!< MEMSYSCTL MSCR: CPWRDN Mask */ + +#define MEMSYSCTL_MSCR_DCCLEAN_Pos 16U /*!< MEMSYSCTL MSCR: DCCLEAN Position */ +#define MEMSYSCTL_MSCR_DCCLEAN_Msk (0x1UL << MEMSYSCTL_MSCR_DCCLEAN_Pos) /*!< MEMSYSCTL MSCR: DCCLEAN Mask */ + +#define MEMSYSCTL_MSCR_ICACTIVE_Pos 13U /*!< MEMSYSCTL MSCR: ICACTIVE Position */ +#define MEMSYSCTL_MSCR_ICACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_ICACTIVE_Pos) /*!< MEMSYSCTL MSCR: ICACTIVE Mask */ + +#define MEMSYSCTL_MSCR_DCACTIVE_Pos 12U /*!< MEMSYSCTL MSCR: DCACTIVE Position */ +#define MEMSYSCTL_MSCR_DCACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_DCACTIVE_Pos) /*!< MEMSYSCTL MSCR: DCACTIVE Mask */ + +#define MEMSYSCTL_MSCR_EVECCFAULT_Pos 3U /*!< MEMSYSCTL MSCR: EVECCFAULT Position */ +#define MEMSYSCTL_MSCR_EVECCFAULT_Msk (0x1UL << MEMSYSCTL_MSCR_EVECCFAULT_Pos) /*!< MEMSYSCTL MSCR: EVECCFAULT Mask */ + +#define MEMSYSCTL_MSCR_FORCEWT_Pos 2U /*!< MEMSYSCTL MSCR: FORCEWT Position */ +#define MEMSYSCTL_MSCR_FORCEWT_Msk (0x1UL << MEMSYSCTL_MSCR_FORCEWT_Pos) /*!< MEMSYSCTL MSCR: FORCEWT Mask */ + +#define MEMSYSCTL_MSCR_ECCEN_Pos 1U /*!< MEMSYSCTL MSCR: ECCEN Position */ +#define MEMSYSCTL_MSCR_ECCEN_Msk (0x1UL << MEMSYSCTL_MSCR_ECCEN_Pos) /*!< MEMSYSCTL MSCR: ECCEN Mask */ + +/* MEMSYSCTL Prefetcher Control Register (PFCR) Register Definitions */ +#define MEMSYSCTL_PFCR_DIS_NLP_Pos 7U /*!< MEMSYSCTL PFCR: DIS_NLP Position */ +#define MEMSYSCTL_PFCR_DIS_NLP_Msk (0x1UL << MEMSYSCTL_PFCR_DIS_NLP_Pos) /*!< MEMSYSCTL PFCR: DIS_NLP Mask */ + +#define MEMSYSCTL_PFCR_ENABLE_Pos 0U /*!< MEMSYSCTL PFCR: ENABLE Position */ +#define MEMSYSCTL_PFCR_ENABLE_Msk (0x1UL /*<< MEMSYSCTL_PFCR_ENABLE_Pos*/) /*!< MEMSYSCTL PFCR: ENABLE Mask */ + +/* MEMSYSCTL ITCM Control Register (ITCMCR) Register Definitions */ +#define MEMSYSCTL_ITCMCR_SZ_Pos 3U /*!< MEMSYSCTL ITCMCR: SZ Position */ +#define MEMSYSCTL_ITCMCR_SZ_Msk (0xFUL << MEMSYSCTL_ITCMCR_SZ_Pos) /*!< MEMSYSCTL ITCMCR: SZ Mask */ + +#define MEMSYSCTL_ITCMCR_EN_Pos 0U /*!< MEMSYSCTL ITCMCR: EN Position */ +#define MEMSYSCTL_ITCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_ITCMCR_EN_Pos*/) /*!< MEMSYSCTL ITCMCR: EN Mask */ + +/* MEMSYSCTL DTCM Control Register (DTCMCR) Register Definitions */ +#define MEMSYSCTL_DTCMCR_SZ_Pos 3U /*!< MEMSYSCTL DTCMCR: SZ Position */ +#define MEMSYSCTL_DTCMCR_SZ_Msk (0xFUL << MEMSYSCTL_DTCMCR_SZ_Pos) /*!< MEMSYSCTL DTCMCR: SZ Mask */ + +#define MEMSYSCTL_DTCMCR_EN_Pos 0U /*!< MEMSYSCTL DTCMCR: EN Position */ +#define MEMSYSCTL_DTCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_DTCMCR_EN_Pos*/) /*!< MEMSYSCTL DTCMCR: EN Mask */ + +/* MEMSYSCTL P-AHB Control Register (PAHBCR) Register Definitions */ +#define MEMSYSCTL_PAHBCR_SZ_Pos 1U /*!< MEMSYSCTL PAHBCR: SZ Position */ +#define MEMSYSCTL_PAHBCR_SZ_Msk (0x7UL << MEMSYSCTL_PAHBCR_SZ_Pos) /*!< MEMSYSCTL PAHBCR: SZ Mask */ + +#define MEMSYSCTL_PAHBCR_EN_Pos 0U /*!< MEMSYSCTL PAHBCR: EN Position */ +#define MEMSYSCTL_PAHBCR_EN_Msk (0x1UL /*<< MEMSYSCTL_PAHBCR_EN_Pos*/) /*!< MEMSYSCTL PAHBCR: EN Mask */ + +/* MEMSYSCTL ITGU Control Register (ITGU_CTRL) Register Definitions */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL ITGU_CTRL: DEREN Position */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_ITGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL ITGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL ITGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_ITGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL ITGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL ITGU Configuration Register (ITGU_CFG) Register Definitions */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL ITGU_CFG: PRESENT Position */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_ITGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL ITGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL ITGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_ITGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL ITGU_CFG: BLKSZ Mask */ + +/* MEMSYSCTL DTGU Control Registers (DTGU_CTRL) Register Definitions */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL DTGU_CTRL: DEREN Position */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_DTGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL DTGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL DTGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_DTGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL DTGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL DTGU Configuration Register (DTGU_CFG) Register Definitions */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL DTGU_CFG: PRESENT Position */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_DTGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL DTGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL DTGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_DTGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL DTGU_CFG: BLKSZ Mask */ + + +/*@}*/ /* end of group MemSysCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PwrModCtl_Type Power Mode Control Registers + \brief Type definitions for the Power Mode Control Registers (PWRMODCTL) + @{ + */ + +/** + \brief Structure type to access the Power Mode Control Registers (PWRMODCTL). + */ +typedef struct +{ + __IOM uint32_t CPDLPSTATE; /*!< Offset: 0x000 (R/W) Core Power Domain Low Power State Register */ + __IOM uint32_t DPDLPSTATE; /*!< Offset: 0x004 (R/W) Debug Power Domain Low Power State Register */ +} PwrModCtl_Type; + +/* PWRMODCTL Core Power Domain Low Power State (CPDLPSTATE) Register Definitions */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos 8U /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos 4U /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos 0U /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Msk (0x3UL /*<< PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos*/) /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Mask */ + +/* PWRMODCTL Debug Power Domain Low Power State (DPDLPSTATE) Register Definitions */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos 0U /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Position */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Msk (0x3UL /*<< PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos*/) /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Mask */ + +/*@}*/ /* end of group PwrModCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup EWIC_Type External Wakeup Interrupt Controller Registers + \brief Type definitions for the External Wakeup Interrupt Controller Registers (EWIC) + @{ + */ + +/** + \brief Structure type to access the External Wakeup Interrupt Controller Registers (EWIC). + */ +typedef struct +{ + __OM uint32_t EVENTSPR; /*!< Offset: 0x000 ( /W) Event Set Pending Register */ + uint32_t RESERVED0[31U]; + __IM uint32_t EVENTMASKA; /*!< Offset: 0x080 (R/W) Event Mask A Register */ + __IM uint32_t EVENTMASK[15]; /*!< Offset: 0x084 (R/W) Event Mask Register */ +} EWIC_Type; + +/* EWIC External Wakeup Interrupt Controller (EVENTSPR) Register Definitions */ +#define EWIC_EVENTSPR_EDBGREQ_Pos 2U /*!< EWIC EVENTSPR: EDBGREQ Position */ +#define EWIC_EVENTSPR_EDBGREQ_Msk (0x1UL << EWIC_EVENTSPR_EDBGREQ_Pos) /*!< EWIC EVENTSPR: EDBGREQ Mask */ + +#define EWIC_EVENTSPR_NMI_Pos 1U /*!< EWIC EVENTSPR: NMI Position */ +#define EWIC_EVENTSPR_NMI_Msk (0x1UL << EWIC_EVENTSPR_NMI_Pos) /*!< EWIC EVENTSPR: NMI Mask */ + +#define EWIC_EVENTSPR_EVENT_Pos 0U /*!< EWIC EVENTSPR: EVENT Position */ +#define EWIC_EVENTSPR_EVENT_Msk (0x1UL /*<< EWIC_EVENTSPR_EVENT_Pos*/) /*!< EWIC EVENTSPR: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASKA) Register Definitions */ +#define EWIC_EVENTMASKA_EDBGREQ_Pos 2U /*!< EWIC EVENTMASKA: EDBGREQ Position */ +#define EWIC_EVENTMASKA_EDBGREQ_Msk (0x1UL << EWIC_EVENTMASKA_EDBGREQ_Pos) /*!< EWIC EVENTMASKA: EDBGREQ Mask */ + +#define EWIC_EVENTMASKA_NMI_Pos 1U /*!< EWIC EVENTMASKA: NMI Position */ +#define EWIC_EVENTMASKA_NMI_Msk (0x1UL << EWIC_EVENTMASKA_NMI_Pos) /*!< EWIC EVENTMASKA: NMI Mask */ + +#define EWIC_EVENTMASKA_EVENT_Pos 0U /*!< EWIC EVENTMASKA: EVENT Position */ +#define EWIC_EVENTMASKA_EVENT_Msk (0x1UL /*<< EWIC_EVENTMASKA_EVENT_Pos*/) /*!< EWIC EVENTMASKA: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASK) Register Definitions */ +#define EWIC_EVENTMASK_IRQ_Pos 0U /*!< EWIC EVENTMASKA: IRQ Position */ +#define EWIC_EVENTMASK_IRQ_Msk (0xFFFFFFFFUL /*<< EWIC_EVENTMASKA_IRQ_Pos*/) /*!< EWIC EVENTMASKA: IRQ Mask */ + +/*@}*/ /* end of group EWIC_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup ErrBnk_Type Error Banking Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Error Banking Registers (ERRBNK) + @{ + */ + +/** + \brief Structure type to access the Error Banking Registers (ERRBNK). + */ +typedef struct +{ + __IOM uint32_t IEBR0; /*!< Offset: 0x000 (R/W) Instruction Cache Error Bank Register 0 */ + __IOM uint32_t IEBR1; /*!< Offset: 0x004 (R/W) Instruction Cache Error Bank Register 1 */ + uint32_t RESERVED0[2U]; + __IOM uint32_t DEBR0; /*!< Offset: 0x010 (R/W) Data Cache Error Bank Register 0 */ + __IOM uint32_t DEBR1; /*!< Offset: 0x014 (R/W) Data Cache Error Bank Register 1 */ + uint32_t RESERVED1[2U]; + __IOM uint32_t TEBR0; /*!< Offset: 0x020 (R/W) TCM Error Bank Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t TEBR1; /*!< Offset: 0x028 (R/W) TCM Error Bank Register 1 */ +} ErrBnk_Type; + +/* ERRBNK Instruction Cache Error Bank Register 0 (IEBR0) Register Definitions */ +#define ERRBNK_IEBR0_SWDEF_Pos 30U /*!< ERRBNK IEBR0: SWDEF Position */ +#define ERRBNK_IEBR0_SWDEF_Msk (0x3UL << ERRBNK_IEBR0_SWDEF_Pos) /*!< ERRBNK IEBR0: SWDEF Mask */ + +#define ERRBNK_IEBR0_BANK_Pos 16U /*!< ERRBNK IEBR0: BANK Position */ +#define ERRBNK_IEBR0_BANK_Msk (0x1UL << ERRBNK_IEBR0_BANK_Pos) /*!< ERRBNK IEBR0: BANK Mask */ + +#define ERRBNK_IEBR0_LOCATION_Pos 2U /*!< ERRBNK IEBR0: LOCATION Position */ +#define ERRBNK_IEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR0_LOCATION_Pos) /*!< ERRBNK IEBR0: LOCATION Mask */ + +#define ERRBNK_IEBR0_LOCKED_Pos 1U /*!< ERRBNK IEBR0: LOCKED Position */ +#define ERRBNK_IEBR0_LOCKED_Msk (0x1UL << ERRBNK_IEBR0_LOCKED_Pos) /*!< ERRBNK IEBR0: LOCKED Mask */ + +#define ERRBNK_IEBR0_VALID_Pos 0U /*!< ERRBNK IEBR0: VALID Position */ +#define ERRBNK_IEBR0_VALID_Msk (0x1UL << /*ERRBNK_IEBR0_VALID_Pos*/) /*!< ERRBNK IEBR0: VALID Mask */ + +/* ERRBNK Instruction Cache Error Bank Register 1 (IEBR1) Register Definitions */ +#define ERRBNK_IEBR1_SWDEF_Pos 30U /*!< ERRBNK IEBR1: SWDEF Position */ +#define ERRBNK_IEBR1_SWDEF_Msk (0x3UL << ERRBNK_IEBR1_SWDEF_Pos) /*!< ERRBNK IEBR1: SWDEF Mask */ + +#define ERRBNK_IEBR1_BANK_Pos 16U /*!< ERRBNK IEBR1: BANK Position */ +#define ERRBNK_IEBR1_BANK_Msk (0x1UL << ERRBNK_IEBR1_BANK_Pos) /*!< ERRBNK IEBR1: BANK Mask */ + +#define ERRBNK_IEBR1_LOCATION_Pos 2U /*!< ERRBNK IEBR1: LOCATION Position */ +#define ERRBNK_IEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR1_LOCATION_Pos) /*!< ERRBNK IEBR1: LOCATION Mask */ + +#define ERRBNK_IEBR1_LOCKED_Pos 1U /*!< ERRBNK IEBR1: LOCKED Position */ +#define ERRBNK_IEBR1_LOCKED_Msk (0x1UL << ERRBNK_IEBR1_LOCKED_Pos) /*!< ERRBNK IEBR1: LOCKED Mask */ + +#define ERRBNK_IEBR1_VALID_Pos 0U /*!< ERRBNK IEBR1: VALID Position */ +#define ERRBNK_IEBR1_VALID_Msk (0x1UL << /*ERRBNK_IEBR1_VALID_Pos*/) /*!< ERRBNK IEBR1: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 0 (DEBR0) Register Definitions */ +#define ERRBNK_DEBR0_SWDEF_Pos 30U /*!< ERRBNK DEBR0: SWDEF Position */ +#define ERRBNK_DEBR0_SWDEF_Msk (0x3UL << ERRBNK_DEBR0_SWDEF_Pos) /*!< ERRBNK DEBR0: SWDEF Mask */ + +#define ERRBNK_DEBR0_TYPE_Pos 17U /*!< ERRBNK DEBR0: TYPE Position */ +#define ERRBNK_DEBR0_TYPE_Msk (0x1UL << ERRBNK_DEBR0_TYPE_Pos) /*!< ERRBNK DEBR0: TYPE Mask */ + +#define ERRBNK_DEBR0_BANK_Pos 16U /*!< ERRBNK DEBR0: BANK Position */ +#define ERRBNK_DEBR0_BANK_Msk (0x1UL << ERRBNK_DEBR0_BANK_Pos) /*!< ERRBNK DEBR0: BANK Mask */ + +#define ERRBNK_DEBR0_LOCATION_Pos 2U /*!< ERRBNK DEBR0: LOCATION Position */ +#define ERRBNK_DEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR0_LOCATION_Pos) /*!< ERRBNK DEBR0: LOCATION Mask */ + +#define ERRBNK_DEBR0_LOCKED_Pos 1U /*!< ERRBNK DEBR0: LOCKED Position */ +#define ERRBNK_DEBR0_LOCKED_Msk (0x1UL << ERRBNK_DEBR0_LOCKED_Pos) /*!< ERRBNK DEBR0: LOCKED Mask */ + +#define ERRBNK_DEBR0_VALID_Pos 0U /*!< ERRBNK DEBR0: VALID Position */ +#define ERRBNK_DEBR0_VALID_Msk (0x1UL << /*ERRBNK_DEBR0_VALID_Pos*/) /*!< ERRBNK DEBR0: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 1 (DEBR1) Register Definitions */ +#define ERRBNK_DEBR1_SWDEF_Pos 30U /*!< ERRBNK DEBR1: SWDEF Position */ +#define ERRBNK_DEBR1_SWDEF_Msk (0x3UL << ERRBNK_DEBR1_SWDEF_Pos) /*!< ERRBNK DEBR1: SWDEF Mask */ + +#define ERRBNK_DEBR1_TYPE_Pos 17U /*!< ERRBNK DEBR1: TYPE Position */ +#define ERRBNK_DEBR1_TYPE_Msk (0x1UL << ERRBNK_DEBR1_TYPE_Pos) /*!< ERRBNK DEBR1: TYPE Mask */ + +#define ERRBNK_DEBR1_BANK_Pos 16U /*!< ERRBNK DEBR1: BANK Position */ +#define ERRBNK_DEBR1_BANK_Msk (0x1UL << ERRBNK_DEBR1_BANK_Pos) /*!< ERRBNK DEBR1: BANK Mask */ + +#define ERRBNK_DEBR1_LOCATION_Pos 2U /*!< ERRBNK DEBR1: LOCATION Position */ +#define ERRBNK_DEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR1_LOCATION_Pos) /*!< ERRBNK DEBR1: LOCATION Mask */ + +#define ERRBNK_DEBR1_LOCKED_Pos 1U /*!< ERRBNK DEBR1: LOCKED Position */ +#define ERRBNK_DEBR1_LOCKED_Msk (0x1UL << ERRBNK_DEBR1_LOCKED_Pos) /*!< ERRBNK DEBR1: LOCKED Mask */ + +#define ERRBNK_DEBR1_VALID_Pos 0U /*!< ERRBNK DEBR1: VALID Position */ +#define ERRBNK_DEBR1_VALID_Msk (0x1UL << /*ERRBNK_DEBR1_VALID_Pos*/) /*!< ERRBNK DEBR1: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 0 (TEBR0) Register Definitions */ +#define ERRBNK_TEBR0_SWDEF_Pos 30U /*!< ERRBNK TEBR0: SWDEF Position */ +#define ERRBNK_TEBR0_SWDEF_Msk (0x3UL << ERRBNK_TEBR0_SWDEF_Pos) /*!< ERRBNK TEBR0: SWDEF Mask */ + +#define ERRBNK_TEBR0_POISON_Pos 28U /*!< ERRBNK TEBR0: POISON Position */ +#define ERRBNK_TEBR0_POISON_Msk (0x1UL << ERRBNK_TEBR0_POISON_Pos) /*!< ERRBNK TEBR0: POISON Mask */ + +#define ERRBNK_TEBR0_TYPE_Pos 27U /*!< ERRBNK TEBR0: TYPE Position */ +#define ERRBNK_TEBR0_TYPE_Msk (0x1UL << ERRBNK_TEBR0_TYPE_Pos) /*!< ERRBNK TEBR0: TYPE Mask */ + +#define ERRBNK_TEBR0_BANK_Pos 24U /*!< ERRBNK TEBR0: BANK Position */ +#define ERRBNK_TEBR0_BANK_Msk (0x3UL << ERRBNK_TEBR0_BANK_Pos) /*!< ERRBNK TEBR0: BANK Mask */ + +#define ERRBNK_TEBR0_LOCATION_Pos 2U /*!< ERRBNK TEBR0: LOCATION Position */ +#define ERRBNK_TEBR0_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR0_LOCATION_Pos) /*!< ERRBNK TEBR0: LOCATION Mask */ + +#define ERRBNK_TEBR0_LOCKED_Pos 1U /*!< ERRBNK TEBR0: LOCKED Position */ +#define ERRBNK_TEBR0_LOCKED_Msk (0x1UL << ERRBNK_TEBR0_LOCKED_Pos) /*!< ERRBNK TEBR0: LOCKED Mask */ + +#define ERRBNK_TEBR0_VALID_Pos 0U /*!< ERRBNK TEBR0: VALID Position */ +#define ERRBNK_TEBR0_VALID_Msk (0x1UL << /*ERRBNK_TEBR0_VALID_Pos*/) /*!< ERRBNK TEBR0: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 1 (TEBR1) Register Definitions */ +#define ERRBNK_TEBR1_SWDEF_Pos 30U /*!< ERRBNK TEBR1: SWDEF Position */ +#define ERRBNK_TEBR1_SWDEF_Msk (0x3UL << ERRBNK_TEBR1_SWDEF_Pos) /*!< ERRBNK TEBR1: SWDEF Mask */ + +#define ERRBNK_TEBR1_POISON_Pos 28U /*!< ERRBNK TEBR1: POISON Position */ +#define ERRBNK_TEBR1_POISON_Msk (0x1UL << ERRBNK_TEBR1_POISON_Pos) /*!< ERRBNK TEBR1: POISON Mask */ + +#define ERRBNK_TEBR1_TYPE_Pos 27U /*!< ERRBNK TEBR1: TYPE Position */ +#define ERRBNK_TEBR1_TYPE_Msk (0x1UL << ERRBNK_TEBR1_TYPE_Pos) /*!< ERRBNK TEBR1: TYPE Mask */ + +#define ERRBNK_TEBR1_BANK_Pos 24U /*!< ERRBNK TEBR1: BANK Position */ +#define ERRBNK_TEBR1_BANK_Msk (0x3UL << ERRBNK_TEBR1_BANK_Pos) /*!< ERRBNK TEBR1: BANK Mask */ + +#define ERRBNK_TEBR1_LOCATION_Pos 2U /*!< ERRBNK TEBR1: LOCATION Position */ +#define ERRBNK_TEBR1_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR1_LOCATION_Pos) /*!< ERRBNK TEBR1: LOCATION Mask */ + +#define ERRBNK_TEBR1_LOCKED_Pos 1U /*!< ERRBNK TEBR1: LOCKED Position */ +#define ERRBNK_TEBR1_LOCKED_Msk (0x1UL << ERRBNK_TEBR1_LOCKED_Pos) /*!< ERRBNK TEBR1: LOCKED Mask */ + +#define ERRBNK_TEBR1_VALID_Pos 0U /*!< ERRBNK TEBR1: VALID Position */ +#define ERRBNK_TEBR1_VALID_Msk (0x1UL << /*ERRBNK_TEBR1_VALID_Pos*/) /*!< ERRBNK TEBR1: VALID Mask */ + +/*@}*/ /* end of group ErrBnk_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PrcCfgInf_Type Processor Configuration Information Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Processor Configuration Information Registerss (PRCCFGINF) + @{ + */ + +/** + \brief Structure type to access the Processor Configuration Information Registerss (PRCCFGINF). + */ +typedef struct +{ + __OM uint32_t CFGINFOSEL; /*!< Offset: 0x000 ( /W) Processor Configuration Information Selection Register */ + __IM uint32_t CFGINFORD; /*!< Offset: 0x004 (R/ ) Processor Configuration Information Read Data Register */ +} PrcCfgInf_Type; + +/* PRCCFGINF Processor Configuration Information Selection Register (CFGINFOSEL) Definitions */ + +/* PRCCFGINF Processor Configuration Information Read Data Register (CFGINFORD) Definitions */ + +/*@}*/ /* end of group PrcCfgInf_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[3]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE4 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE8 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFEC (R/W) PMU Peripheral Identification Register 3 */ + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (0xFFFFUL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (0xFFFFUL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (0xFFUL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (0x3FUL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/** \brief PMU Authentication Status Register Definitions */ + +#define PMU_AUTHSTATUS_NSID_Pos 0U /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSID_Msk (0x3UL /*<< PMU_AUTHSTATUS_NSID_Pos*/) /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSNID_Pos 2U /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSNID_Msk (0x3UL << PMU_AUTHSTATUS_NSNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SID_Pos 4U /*!< PMU AUTHSTATUS: Secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_SID_Msk (0x3UL << PMU_AUTHSTATUS_SID_Pos) /*!< PMU AUTHSTATUS: Secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SNID_Pos 6U /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SNID_Msk (0x3UL << PMU_AUTHSTATUS_SNID_Pos) /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUID_Pos 16U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUID_Msk (0x3UL << PMU_AUTHSTATUS_NSUID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUNID_Pos 18U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUNID_Msk (0x3UL << PMU_AUTHSTATUS_NSUNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUID_Pos 20U /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_SUID_Msk (0x3UL << PMU_AUTHSTATUS_SUID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUNID_Pos 22U /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SUNID_Msk (0x3UL << PMU_AUTHSTATUS_SUNID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Mask */ + + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define MEMSYSCTL_BASE (0xE001E000UL) /*!< Memory System Control Base Address */ + #define ERRBNK_BASE (0xE001E100UL) /*!< Error Banking Base Address */ + #define PWRMODCTL_BASE (0xE001E300UL) /*!< Power Mode Control Base Address */ + #define EWIC_BASE (0xE001E400UL) /*!< External Wakeup Interrupt Controller Base Address */ + #define PRCCFGINF_BASE (0xE001E700UL) /*!< Processor Configuration Information Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define ICB ((ICB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define MEMSYSCTL ((MemSysCtl_Type *) MEMSYSCTL_BASE ) /*!< Memory System Control configuration struct */ + #define ERRBNK ((ErrBnk_Type *) ERRBNK_BASE ) /*!< Error Banking configuration struct */ + #define PWRMODCTL ((PwrModCtl_Type *) PWRMODCTL_BASE ) /*!< Power Mode Control configuration struct */ + #define EWIC ((EWIC_Type *) EWIC_BASE ) /*!< EWIC configuration struct */ + #define PRCCFGINF ((PrcCfgInf_Type *) PRCCFGINF_BASE ) /*!< Processor Configuration Information configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define ICB_NS ((ICB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ + +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +/** + \brief Cortex-M85 PMU events + \note Architectural PMU events can be found in pmu_armv8.h +*/ + +#define ARMCM85_PMU_ECC_ERR 0xC000 /*!< One or more Error Correcting Code (ECC) errors detected */ +#define ARMCM85_PMU_ECC_ERR_MBIT 0xC001 /*!< One or more multi-bit ECC errors detected */ +#define ARMCM85_PMU_ECC_ERR_DCACHE 0xC010 /*!< One or more ECC errors in the data cache */ +#define ARMCM85_PMU_ECC_ERR_ICACHE 0xC011 /*!< One or more ECC errors in the instruction cache */ +#define ARMCM85_PMU_ECC_ERR_MBIT_DCACHE 0xC012 /*!< One or more multi-bit ECC errors in the data cache */ +#define ARMCM85_PMU_ECC_ERR_MBIT_ICACHE 0xC013 /*!< One or more multi-bit ECC errors in the instruction cache */ +#define ARMCM85_PMU_ECC_ERR_DTCM 0xC020 /*!< One or more ECC errors in the Data Tightly Coupled Memory (DTCM) */ +#define ARMCM85_PMU_ECC_ERR_ITCM 0xC021 /*!< One or more ECC errors in the Instruction Tightly Coupled Memory (ITCM) */ +#define ARMCM85_PMU_ECC_ERR_MBIT_DTCM 0xC022 /*!< One or more multi-bit ECC errors in the DTCM */ +#define ARMCM85_PMU_ECC_ERR_MBIT_ITCM 0xC023 /*!< One or more multi-bit ECC errors in the ITCM */ +#define ARMCM85_PMU_PF_LINEFILL 0xC100 /*!< The prefetcher starts a line-fill */ +#define ARMCM85_PMU_PF_CANCEL 0xC101 /*!< The prefetcher stops prefetching */ +#define ARMCM85_PMU_PF_DROP_LINEFILL 0xC102 /*!< A linefill triggered by a prefetcher has been dropped because of lack of buffering */ +#define ARMCM85_PMU_NWAMODE_ENTER 0xC200 /*!< No write-allocate mode entry */ +#define ARMCM85_PMU_NWAMODE 0xC201 /*!< Write-allocate store is not allocated into the data cache due to no-write-allocate mode */ +#define ARMCM85_PMU_SAHB_ACCESS 0xC300 /*!< Read or write access on the S-AHB interface to the TCM */ +#define ARMCM85_PMU_PAHB_ACCESS 0xC301 /*!< Read or write access on the P-AHB write interface */ +#define ARMCM85_PMU_AXI_WRITE_ACCESS 0xC302 /*!< Any beat access to M-AXI write interface */ +#define ARMCM85_PMU_AXI_READ_ACCESS 0xC303 /*!< Any beat access to M-AXI read interface */ +#define ARMCM85_PMU_DOSTIMEOUT_DOUBLE 0xC400 /*!< Denial of Service timeout has fired twice and caused buffers to drain to allow forward progress */ +#define ARMCM85_PMU_DOSTIMEOUT_TRIPLE 0xC401 /*!< Denial of Service timeout has fired three times and blocked the LSU to force forward progress */ + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + +/* ################### PAC Key functions ########################### */ + +#if (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) +#include "pac_armv81.h" +#endif + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM85_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h new file mode 100644 index 0000000000..e252068ce6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h @@ -0,0 +1,1030 @@ +/**************************************************************************//** + * @file core_sc000.h + * @brief CMSIS SC000 Core Peripheral Access Layer Header File + * @version V5.0.7 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC000_H_GENERIC +#define __CORE_SC000_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC000 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS SC000 definitions */ +#define __SC000_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __SC000_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \ + __SC000_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_SC (000U) /*!< Cortex secure core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC000_H_DEPENDANT +#define __CORE_SC000_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC000_REV + #define __SC000_REV 0x0000U + #warning "__SC000_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC000 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + uint32_t RESERVED1[154U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the SC000 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else +/*#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping not available for SC000 */ +/*#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping not available for SC000 */ + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for SC000 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M0 and M0+ do not require the architectural barrier - assume SC000 is the same */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h new file mode 100644 index 0000000000..d66621031e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h @@ -0,0 +1,1917 @@ +/**************************************************************************//** + * @file core_sc300.h + * @brief CMSIS SC300 Core Peripheral Access Layer Header File + * @version V5.0.10 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC300_H_GENERIC +#define __CORE_SC300_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC3000 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS SC300 definitions */ +#define __SC300_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __SC300_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16U) | \ + __SC300_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_SC (300U) /*!< Cortex secure core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC300_H_DEPENDANT +#define __CORE_SC300_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC300_REV + #define __SC300_REV 0x0000U + #warning "__SC300_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC300 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED1[129U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h new file mode 100644 index 0000000000..ebc0f77eb7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h @@ -0,0 +1,3592 @@ +/**************************************************************************//** + * @file core_starmc1.h + * @brief CMSIS ArmChina STAR-MC1 Core Peripheral Access Layer Header File + * @version V1.0.2 + * @date 07. April 2022 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. + * Copyright (c) 2018-2022 Arm China. + * All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_STAR_H_GENERIC +#define __CORE_STAR_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup STAR-MC1 + @{ + */ + +#include "cmsis_version.h" + +/* Macro Define for STAR-MC1 */ +#define __STAR_MC (1U) /*!< STAR-MC Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_STAR_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_STAR_H_DEPENDANT +#define __CORE_STAR_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __STAR_REV + #define __STAR_REV 0x0000U + #warning "__STAR_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DTCM_PRESENT + #define __DTCM_PRESENT 0U + #warning "__DTCM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group STAR-MC1 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for STAR-MC1 processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[1U]; + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED_ADD1[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: F00-D00=0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ +} SCB_Type; + +typedef struct +{ + __IOM uint32_t CACR; /*!< Offset: 0x0 (R/W) L1 Cache Control Register */ + __IOM uint32_t ITCMCR; /*!< Offset: 0x10 (R/W) Instruction Tightly-Coupled Memory Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x14 (R/W) Data Tightly-Coupled Memory Control Registers */ +}EMSS_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +#define SCB_CLIDR_IC_Pos 0U /*!< SCB CLIDR: IC Position */ +#define SCB_CLIDR_IC_Msk (1UL << SCB_CLIDR_IC_Pos) /*!< SCB CLIDR: IC Mask */ + +#define SCB_CLIDR_DC_Pos 1U /*!< SCB CLIDR: DC Position */ +#define SCB_CLIDR_DC_Msk (1UL << SCB_CLIDR_DC_Pos) /*!< SCB CLIDR: DC Mask */ + + + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache line Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_LEVEL_Pos 1U /*!< SCB DCISW: Level Position */ +#define SCB_DCISW_LEVEL_Msk (7UL << SCB_DCISW_LEVEL_Pos) /*!< SCB DCISW: Level Mask */ + +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0xFFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean line by Set-way Register Definitions */ +#define SCB_DCCSW_LEVEL_Pos 1U /*!< SCB DCCSW: Level Position */ +#define SCB_DCCSW_LEVEL_Msk (7UL << SCB_DCCSW_LEVEL_Pos) /*!< SCB DCCSW: Level Mask */ + +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0xFFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_LEVEL_Pos 1U /*!< SCB DCCISW: Level Position */ +#define SCB_DCCISW_LEVEL_Msk (7UL << SCB_DCCISW_LEVEL_Pos) /*!< SCB DCCISW: Level Mask */ + +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0xFFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/* ArmChina: Implementation Defined */ +/* Instruction Tightly-Coupled Memory Control Register Definitions */ +#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ +#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ + +#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ +#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ + +/* Data Tightly-Coupled Memory Control Register Definitions */ +#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ +#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ + +#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ +#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ + +/* L1 Cache Control Register Definitions */ +#define SCB_CACR_DCCLEAN_Pos 16U /*!< SCB CACR: DCCLEAN Position */ +#define SCB_CACR_DCCLEAN_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: DCCLEAN Mask */ + +#define SCB_CACR_ICACTIVE_Pos 13U /*!< SCB CACR: ICACTIVE Position */ +#define SCB_CACR_ICACTIVE_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: ICACTIVE Mask */ + +#define SCB_CACR_DCACTIVE_Pos 12U /*!< SCB CACR: DCACTIVE Position */ +#define SCB_CACR_DCACTIVE_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: DCACTIVE Mask */ + +#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ +#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define EMSS_BASE (0xE001E000UL) /*!AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses including + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/** + \brief Software Reset + \details Initiates a system reset request to reset the CPU. + */ +__NO_RETURN __STATIC_INLINE void __SW_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses including + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_BFHFNMINS_Msk) | /* Keep BFHFNMINS unchanged. Use this Reset function in case your case need to keep it */ + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | /* Keep priority group unchanged */ + SCB_AIRCR_SYSRESETREQ_Msk ); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) + +/* ########################## Cache functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_CacheFunctions Cache Functions + \brief Functions that configure Instruction and Data cache. + @{ + */ + +/* Cache Size ID Register Macros */ +#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) +#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) + +#define __SCB_DCACHE_LINE_SIZE 32U /*!< STAR-MC1 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#define __SCB_ICACHE_LINE_SIZE 32U /*!< STAR-MC1 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */ + + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate I-Cache + \details Invalidates I-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief I-Cache Invalidate by address + \details Invalidates I-Cache for the given address. + I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + I-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] isize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (void *addr, int32_t isize) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if ( isize > 0 ) { + int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_ICACHE_LINE_SIZE; + op_size -= __SCB_ICACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */ + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + __DSB(); + + SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable D-Cache + \details Turns off D-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | + ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address. + D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned and invalidated. + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + +/*@} end of CMSIS_Core_CacheFunctions */ +#endif + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_STAR_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h new file mode 100644 index 0000000000..9909f83990 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h @@ -0,0 +1,275 @@ +/****************************************************************************** + * @file mpu_armv7.h + * @brief CMSIS MPU API for Armv7-M MPU + * @version V5.1.2 + * @date 25. May 2020 + ******************************************************************************/ +/* + * Copyright (c) 2017-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV7_H +#define ARM_MPU_ARMV7_H + +#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes +#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes +#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes +#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes +#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes +#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte +#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes +#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes +#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes +#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes +#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes +#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes +#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes +#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes +#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes +#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte +#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes +#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes +#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes +#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes +#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes +#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes +#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes +#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes +#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes +#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte +#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes +#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes + +#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access +#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only +#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only +#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access +#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only +#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access + +/** MPU Region Base Address Register Value +* +* \param Region The region to be configured, number 0 to 15. +* \param BaseAddress The base address for the region. +*/ +#define ARM_MPU_RBAR(Region, BaseAddress) \ + (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ + ((Region) & MPU_RBAR_REGION_Msk) | \ + (MPU_RBAR_VALID_Msk)) + +/** +* MPU Memory Access Attributes +* +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +*/ +#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \ + ((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ + (((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ + (((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ + (((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk)) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \ + ((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ + (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ + (((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \ + (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ + (((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ + (((MPU_RASR_ENABLE_Msk)))) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ + ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size) + +/** +* MPU Memory Access Attribute for strongly ordered memory. +* - TEX: 000b +* - Shareable +* - Non-cacheable +* - Non-bufferable +*/ +#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U) + +/** +* MPU Memory Access Attribute for device memory. +* - TEX: 000b (if shareable) or 010b (if non-shareable) +* - Shareable or non-shareable +* - Non-cacheable +* - Bufferable (if shareable) or non-bufferable (if non-shareable) +* +* \param IsShareable Configures the device memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U)) + +/** +* MPU Memory Access Attribute for normal memory. +* - TEX: 1BBb (reflecting outer cacheability rules) +* - Shareable or non-shareable +* - Cacheable or non-cacheable (reflecting inner cacheability rules) +* - Bufferable or non-bufferable (reflecting inner cacheability rules) +* +* \param OuterCp Configures the outer cache policy. +* \param InnerCp Configures the inner cache policy. +* \param IsShareable Configures the memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U)) + +/** +* MPU Memory Access Attribute non-cacheable policy. +*/ +#define ARM_MPU_CACHEP_NOCACHE 0U + +/** +* MPU Memory Access Attribute write-back, write and read allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_WRA 1U + +/** +* MPU Memory Access Attribute write-through, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WT_NWA 2U + +/** +* MPU Memory Access Attribute write-back, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_NWA 3U + + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; //!< The region base address register value (RBAR) + uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + MPU->RNR = rnr; + MPU->RASR = 0U; +} + +/** Configure an MPU region. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) +{ + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) +{ + MPU->RNR = rnr; + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_Load(). +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + while (cnt > MPU_TYPE_RALIASES) { + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); + table += MPU_TYPE_RALIASES; + cnt -= MPU_TYPE_RALIASES; + } + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); +} + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h new file mode 100644 index 0000000000..19855b9667 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h @@ -0,0 +1,352 @@ +/****************************************************************************** + * @file mpu_armv8.h + * @brief CMSIS MPU API for Armv8-M and Armv8.1-M MPU + * @version V5.1.3 + * @date 03. February 2021 + ******************************************************************************/ +/* + * Copyright (c) 2017-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV8_H +#define ARM_MPU_ARMV8_H + +/** \brief Attribute for device memory (outer only) */ +#define ARM_MPU_ATTR_DEVICE ( 0U ) + +/** \brief Attribute for non-cacheable, normal memory */ +#define ARM_MPU_ATTR_NON_CACHEABLE ( 4U ) + +/** \brief Attribute for normal memory (outer and inner) +* \param NT Non-Transient: Set to 1 for non-transient data. +* \param WB Write-Back: Set to 1 to use write-back update policy. +* \param RA Read Allocation: Set to 1 to use cache allocation on read miss. +* \param WA Write Allocation: Set to 1 to use cache allocation on write miss. +*/ +#define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \ + ((((NT) & 1U) << 3U) | (((WB) & 1U) << 2U) | (((RA) & 1U) << 1U) | ((WA) & 1U)) + +/** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRnE (0U) + +/** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRE (1U) + +/** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGRE (2U) + +/** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_GRE (3U) + +/** \brief Memory Attribute +* \param O Outer memory attributes +* \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes +*/ +#define ARM_MPU_ATTR(O, I) ((((O) & 0xFU) << 4U) | ((((O) & 0xFU) != 0U) ? ((I) & 0xFU) : (((I) & 0x3U) << 2U))) + +/** \brief Normal memory non-shareable */ +#define ARM_MPU_SH_NON (0U) + +/** \brief Normal memory outer shareable */ +#define ARM_MPU_SH_OUTER (2U) + +/** \brief Normal memory inner shareable */ +#define ARM_MPU_SH_INNER (3U) + +/** \brief Memory access permissions +* \param RO Read-Only: Set to 1 for read-only memory. +* \param NP Non-Privileged: Set to 1 for non-privileged memory. +*/ +#define ARM_MPU_AP_(RO, NP) ((((RO) & 1U) << 1U) | ((NP) & 1U)) + +/** \brief Region Base Address Register value +* \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned. +* \param SH Defines the Shareability domain for this memory region. +* \param RO Read-Only: Set to 1 for a read-only memory region. +* \param NP Non-Privileged: Set to 1 for a non-privileged memory region. +* \oaram XN eXecute Never: Set to 1 for a non-executable memory region. +*/ +#define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \ + (((BASE) & MPU_RBAR_BASE_Msk) | \ + (((SH) << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \ + ((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \ + (((XN) << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk)) + +/** \brief Region Limit Address Register value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR(LIMIT, IDX) \ + (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \ + (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#if defined(MPU_RLAR_PXN_Pos) + +/** \brief Region Limit Address Register with PXN value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param PXN Privileged execute never. Defines whether code can be executed from this privileged region. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR_PXN(LIMIT, PXN, IDX) \ + (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \ + (((PXN) << MPU_RLAR_PXN_Pos) & MPU_RLAR_PXN_Msk) | \ + (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#endif + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; /*!< Region Base Address Register value */ + uint32_t RLAR; /*!< Region Limit Address Register value */ +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +#ifdef MPU_NS +/** Enable the Non-secure MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control) +{ + __DMB(); + MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the Non-secure MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable_NS(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} +#endif + +/** Set the memory attribute encoding to the given MPU. +* \param mpu Pointer to the MPU to be configured. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr) +{ + const uint8_t reg = idx / 4U; + const uint32_t pos = ((idx % 4U) * 8U); + const uint32_t mask = 0xFFU << pos; + + if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) { + return; // invalid index + } + + mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask)); +} + +/** Set the memory attribute encoding. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU, idx, attr); +} + +#ifdef MPU_NS +/** Set the memory attribute encoding to the Non-secure MPU. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr); +} +#endif + +/** Clear and disable the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr) +{ + mpu->RNR = rnr; + mpu->RLAR = 0U; +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU, rnr); +} + +#ifdef MPU_NS +/** Clear and disable the given Non-secure MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU_NS, rnr); +} +#endif + +/** Configure the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + mpu->RNR = rnr; + mpu->RBAR = rbar; + mpu->RLAR = rlar; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar); +} + +#ifdef MPU_NS +/** Configure the given Non-secure MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar); +} +#endif + +/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_LoadEx() +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table to the given MPU. +* \param mpu Pointer to the MPU registers to be used. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + if (cnt == 1U) { + mpu->RNR = rnr; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR), &(table->RBAR), rowWordSize); + } else { + uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U); + uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES; + + mpu->RNR = rnrBase; + while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) { + uint32_t c = MPU_TYPE_RALIASES - rnrOffset; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize); + table += c; + cnt -= c; + rnrOffset = 0U; + rnrBase += MPU_TYPE_RALIASES; + mpu->RNR = rnrBase; + } + + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize); + } +} + +/** Load the given number of MPU regions from a table. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU, rnr, table, cnt); +} + +#ifdef MPU_NS +/** Load the given number of MPU regions from a table to the Non-secure MPU. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt); +} +#endif + +#endif + diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h new file mode 100644 index 0000000000..854b60a204 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h @@ -0,0 +1,206 @@ +/****************************************************************************** + * @file pac_armv81.h + * @brief CMSIS PAC key functions for Armv8.1-M PAC extension + * @version V1.0.0 + * @date 23. March 2022 + ******************************************************************************/ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef PAC_ARMV81_H +#define PAC_ARMV81_H + + +/* ################### PAC Key functions ########################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_PacKeyFunctions PAC Key functions + \brief Functions that access the PAC keys. + @{ + */ + +#if (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) + +/** + \brief read the PAC key used for privileged mode + \details Reads the PAC key stored in the PAC_KEY_P registers. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __get_PAC_KEY_P (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_p_0\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_p_1\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_p_2\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_p_3\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for privileged mode + \details writes the given PAC key to the PAC_KEY_P registers. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __set_PAC_KEY_P (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_p_0, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_p_1, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_p_2, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_p_3, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief read the PAC key used for unprivileged mode + \details Reads the PAC key stored in the PAC_KEY_U registers. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __get_PAC_KEY_U (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_u_0\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_u_1\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_u_2\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_u_3\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for unprivileged mode + \details writes the given PAC key to the PAC_KEY_U registers. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __set_PAC_KEY_U (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_u_0, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_u_1, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_u_2, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_u_3, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) + +/** + \brief read the PAC key used for privileged mode (non-secure) + \details Reads the PAC key stored in the non-secure PAC_KEY_P registers when in secure mode. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_get_PAC_KEY_P_NS (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_p_0_ns\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_p_1_ns\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_p_2_ns\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_p_3_ns\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for privileged mode (non-secure) + \details writes the given PAC key to the non-secure PAC_KEY_P registers when in secure mode. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_set_PAC_KEY_P_NS (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_p_0_ns, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_p_1_ns, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_p_2_ns, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_p_3_ns, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief read the PAC key used for unprivileged mode (non-secure) + \details Reads the PAC key stored in the non-secure PAC_KEY_U registers when in secure mode. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_get_PAC_KEY_U_NS (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_u_0_ns\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_u_1_ns\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_u_2_ns\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_u_3_ns\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for unprivileged mode (non-secure) + \details writes the given PAC key to the non-secure PAC_KEY_U registers when in secure mode. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_set_PAC_KEY_U_NS (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_u_0_ns, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_u_1_ns, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_u_2_ns, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_u_3_ns, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +#endif /* (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) */ + +#endif /* (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) */ + +/*@} end of CMSIS_Core_PacKeyFunctions */ + + +#endif /* PAC_ARMV81_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h new file mode 100644 index 0000000000..aa53bb47c1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h @@ -0,0 +1,337 @@ +/****************************************************************************** + * @file pmu_armv8.h + * @brief CMSIS PMU API for Armv8.1-M PMU + * @version V1.0.1 + * @date 15. April 2020 + ******************************************************************************/ +/* + * Copyright (c) 2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_PMU_ARMV8_H +#define ARM_PMU_ARMV8_H + +/** + * \brief PMU Events + * \note See the Armv8.1-M Architecture Reference Manual for full details on these PMU events. + * */ + +#define ARM_PMU_SW_INCR 0x0000 /*!< Software update to the PMU_SWINC register, architecturally executed and condition code check pass */ +#define ARM_PMU_L1I_CACHE_REFILL 0x0001 /*!< L1 I-Cache refill */ +#define ARM_PMU_L1D_CACHE_REFILL 0x0003 /*!< L1 D-Cache refill */ +#define ARM_PMU_L1D_CACHE 0x0004 /*!< L1 D-Cache access */ +#define ARM_PMU_LD_RETIRED 0x0006 /*!< Memory-reading instruction architecturally executed and condition code check pass */ +#define ARM_PMU_ST_RETIRED 0x0007 /*!< Memory-writing instruction architecturally executed and condition code check pass */ +#define ARM_PMU_INST_RETIRED 0x0008 /*!< Instruction architecturally executed */ +#define ARM_PMU_EXC_TAKEN 0x0009 /*!< Exception entry */ +#define ARM_PMU_EXC_RETURN 0x000A /*!< Exception return instruction architecturally executed and the condition code check pass */ +#define ARM_PMU_PC_WRITE_RETIRED 0x000C /*!< Software change to the Program Counter (PC). Instruction is architecturally executed and condition code check pass */ +#define ARM_PMU_BR_IMMED_RETIRED 0x000D /*!< Immediate branch architecturally executed */ +#define ARM_PMU_BR_RETURN_RETIRED 0x000E /*!< Function return instruction architecturally executed and the condition code check pass */ +#define ARM_PMU_UNALIGNED_LDST_RETIRED 0x000F /*!< Unaligned memory memory-reading or memory-writing instruction architecturally executed and condition code check pass */ +#define ARM_PMU_BR_MIS_PRED 0x0010 /*!< Mispredicted or not predicted branch speculatively executed */ +#define ARM_PMU_CPU_CYCLES 0x0011 /*!< Cycle */ +#define ARM_PMU_BR_PRED 0x0012 /*!< Predictable branch speculatively executed */ +#define ARM_PMU_MEM_ACCESS 0x0013 /*!< Data memory access */ +#define ARM_PMU_L1I_CACHE 0x0014 /*!< Level 1 instruction cache access */ +#define ARM_PMU_L1D_CACHE_WB 0x0015 /*!< Level 1 data cache write-back */ +#define ARM_PMU_L2D_CACHE 0x0016 /*!< Level 2 data cache access */ +#define ARM_PMU_L2D_CACHE_REFILL 0x0017 /*!< Level 2 data cache refill */ +#define ARM_PMU_L2D_CACHE_WB 0x0018 /*!< Level 2 data cache write-back */ +#define ARM_PMU_BUS_ACCESS 0x0019 /*!< Bus access */ +#define ARM_PMU_MEMORY_ERROR 0x001A /*!< Local memory error */ +#define ARM_PMU_INST_SPEC 0x001B /*!< Instruction speculatively executed */ +#define ARM_PMU_BUS_CYCLES 0x001D /*!< Bus cycles */ +#define ARM_PMU_CHAIN 0x001E /*!< For an odd numbered counter, increment when an overflow occurs on the preceding even-numbered counter on the same PE */ +#define ARM_PMU_L1D_CACHE_ALLOCATE 0x001F /*!< Level 1 data cache allocation without refill */ +#define ARM_PMU_L2D_CACHE_ALLOCATE 0x0020 /*!< Level 2 data cache allocation without refill */ +#define ARM_PMU_BR_RETIRED 0x0021 /*!< Branch instruction architecturally executed */ +#define ARM_PMU_BR_MIS_PRED_RETIRED 0x0022 /*!< Mispredicted branch instruction architecturally executed */ +#define ARM_PMU_STALL_FRONTEND 0x0023 /*!< No operation issued because of the frontend */ +#define ARM_PMU_STALL_BACKEND 0x0024 /*!< No operation issued because of the backend */ +#define ARM_PMU_L2I_CACHE 0x0027 /*!< Level 2 instruction cache access */ +#define ARM_PMU_L2I_CACHE_REFILL 0x0028 /*!< Level 2 instruction cache refill */ +#define ARM_PMU_L3D_CACHE_ALLOCATE 0x0029 /*!< Level 3 data cache allocation without refill */ +#define ARM_PMU_L3D_CACHE_REFILL 0x002A /*!< Level 3 data cache refill */ +#define ARM_PMU_L3D_CACHE 0x002B /*!< Level 3 data cache access */ +#define ARM_PMU_L3D_CACHE_WB 0x002C /*!< Level 3 data cache write-back */ +#define ARM_PMU_LL_CACHE_RD 0x0036 /*!< Last level data cache read */ +#define ARM_PMU_LL_CACHE_MISS_RD 0x0037 /*!< Last level data cache read miss */ +#define ARM_PMU_L1D_CACHE_MISS_RD 0x0039 /*!< Level 1 data cache read miss */ +#define ARM_PMU_OP_COMPLETE 0x003A /*!< Operation retired */ +#define ARM_PMU_OP_SPEC 0x003B /*!< Operation speculatively executed */ +#define ARM_PMU_STALL 0x003C /*!< Stall cycle for instruction or operation not sent for execution */ +#define ARM_PMU_STALL_OP_BACKEND 0x003D /*!< Stall cycle for instruction or operation not sent for execution due to pipeline backend */ +#define ARM_PMU_STALL_OP_FRONTEND 0x003E /*!< Stall cycle for instruction or operation not sent for execution due to pipeline frontend */ +#define ARM_PMU_STALL_OP 0x003F /*!< Instruction or operation slots not occupied each cycle */ +#define ARM_PMU_L1D_CACHE_RD 0x0040 /*!< Level 1 data cache read */ +#define ARM_PMU_LE_RETIRED 0x0100 /*!< Loop end instruction executed */ +#define ARM_PMU_LE_SPEC 0x0101 /*!< Loop end instruction speculatively executed */ +#define ARM_PMU_BF_RETIRED 0x0104 /*!< Branch future instruction architecturally executed and condition code check pass */ +#define ARM_PMU_BF_SPEC 0x0105 /*!< Branch future instruction speculatively executed and condition code check pass */ +#define ARM_PMU_LE_CANCEL 0x0108 /*!< Loop end instruction not taken */ +#define ARM_PMU_BF_CANCEL 0x0109 /*!< Branch future instruction not taken */ +#define ARM_PMU_SE_CALL_S 0x0114 /*!< Call to secure function, resulting in Security state change */ +#define ARM_PMU_SE_CALL_NS 0x0115 /*!< Call to non-secure function, resulting in Security state change */ +#define ARM_PMU_DWT_CMPMATCH0 0x0118 /*!< DWT comparator 0 match */ +#define ARM_PMU_DWT_CMPMATCH1 0x0119 /*!< DWT comparator 1 match */ +#define ARM_PMU_DWT_CMPMATCH2 0x011A /*!< DWT comparator 2 match */ +#define ARM_PMU_DWT_CMPMATCH3 0x011B /*!< DWT comparator 3 match */ +#define ARM_PMU_MVE_INST_RETIRED 0x0200 /*!< MVE instruction architecturally executed */ +#define ARM_PMU_MVE_INST_SPEC 0x0201 /*!< MVE instruction speculatively executed */ +#define ARM_PMU_MVE_FP_RETIRED 0x0204 /*!< MVE floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_SPEC 0x0205 /*!< MVE floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_HP_RETIRED 0x0208 /*!< MVE half-precision floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_HP_SPEC 0x0209 /*!< MVE half-precision floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_SP_RETIRED 0x020C /*!< MVE single-precision floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_SP_SPEC 0x020D /*!< MVE single-precision floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_MAC_RETIRED 0x0214 /*!< MVE floating-point multiply or multiply-accumulate instruction architecturally executed */ +#define ARM_PMU_MVE_FP_MAC_SPEC 0x0215 /*!< MVE floating-point multiply or multiply-accumulate instruction speculatively executed */ +#define ARM_PMU_MVE_INT_RETIRED 0x0224 /*!< MVE integer instruction architecturally executed */ +#define ARM_PMU_MVE_INT_SPEC 0x0225 /*!< MVE integer instruction speculatively executed */ +#define ARM_PMU_MVE_INT_MAC_RETIRED 0x0228 /*!< MVE multiply or multiply-accumulate instruction architecturally executed */ +#define ARM_PMU_MVE_INT_MAC_SPEC 0x0229 /*!< MVE multiply or multiply-accumulate instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_RETIRED 0x0238 /*!< MVE load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_SPEC 0x0239 /*!< MVE load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_RETIRED 0x023C /*!< MVE load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_SPEC 0x023D /*!< MVE load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_RETIRED 0x0240 /*!< MVE store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_SPEC 0x0241 /*!< MVE store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_CONTIG_RETIRED 0x0244 /*!< MVE contiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_CONTIG_SPEC 0x0245 /*!< MVE contiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_CONTIG_RETIRED 0x0248 /*!< MVE contiguous load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_CONTIG_SPEC 0x0249 /*!< MVE contiguous load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_CONTIG_RETIRED 0x024C /*!< MVE contiguous store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_CONTIG_SPEC 0x024D /*!< MVE contiguous store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_NONCONTIG_RETIRED 0x0250 /*!< MVE non-contiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_NONCONTIG_SPEC 0x0251 /*!< MVE non-contiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_NONCONTIG_RETIRED 0x0254 /*!< MVE non-contiguous load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_NONCONTIG_SPEC 0x0255 /*!< MVE non-contiguous load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_NONCONTIG_RETIRED 0x0258 /*!< MVE non-contiguous store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_NONCONTIG_SPEC 0x0259 /*!< MVE non-contiguous store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_MULTI_RETIRED 0x025C /*!< MVE memory instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_LDST_MULTI_SPEC 0x025D /*!< MVE memory instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_LD_MULTI_RETIRED 0x0260 /*!< MVE memory load instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_LD_MULTI_SPEC 0x0261 /*!< MVE memory load instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_ST_MULTI_RETIRED 0x0261 /*!< MVE memory store instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_ST_MULTI_SPEC 0x0265 /*!< MVE memory store instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_RETIRED 0x028C /*!< MVE unaligned memory load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_SPEC 0x028D /*!< MVE unaligned memory load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_UNALIGNED_RETIRED 0x0290 /*!< MVE unaligned load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_UNALIGNED_SPEC 0x0291 /*!< MVE unaligned load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_UNALIGNED_RETIRED 0x0294 /*!< MVE unaligned store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_UNALIGNED_SPEC 0x0295 /*!< MVE unaligned store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_NONCONTIG_RETIRED 0x0298 /*!< MVE unaligned noncontiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_NONCONTIG_SPEC 0x0299 /*!< MVE unaligned noncontiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_RETIRED 0x02A0 /*!< MVE vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_SPEC 0x02A1 /*!< MVE vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_FP_RETIRED 0x02A4 /*!< MVE floating-point vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_FP_SPEC 0x02A5 /*!< MVE floating-point vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_INT_RETIRED 0x02A8 /*!< MVE integer vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_INT_SPEC 0x02A9 /*!< MVE integer vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_PRED 0x02B8 /*!< Cycles where one or more predicated beats architecturally executed */ +#define ARM_PMU_MVE_STALL 0x02CC /*!< Stall cycles caused by an MVE instruction */ +#define ARM_PMU_MVE_STALL_RESOURCE 0x02CD /*!< Stall cycles caused by an MVE instruction because of resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_MEM 0x02CE /*!< Stall cycles caused by an MVE instruction because of memory resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_FP 0x02CF /*!< Stall cycles caused by an MVE instruction because of floating-point resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_INT 0x02D0 /*!< Stall cycles caused by an MVE instruction because of integer resource conflicts */ +#define ARM_PMU_MVE_STALL_BREAK 0x02D3 /*!< Stall cycles caused by an MVE chain break */ +#define ARM_PMU_MVE_STALL_DEPENDENCY 0x02D4 /*!< Stall cycles caused by MVE register dependency */ +#define ARM_PMU_ITCM_ACCESS 0x4007 /*!< Instruction TCM access */ +#define ARM_PMU_DTCM_ACCESS 0x4008 /*!< Data TCM access */ +#define ARM_PMU_TRCEXTOUT0 0x4010 /*!< ETM external output 0 */ +#define ARM_PMU_TRCEXTOUT1 0x4011 /*!< ETM external output 1 */ +#define ARM_PMU_TRCEXTOUT2 0x4012 /*!< ETM external output 2 */ +#define ARM_PMU_TRCEXTOUT3 0x4013 /*!< ETM external output 3 */ +#define ARM_PMU_CTI_TRIGOUT4 0x4018 /*!< Cross-trigger Interface output trigger 4 */ +#define ARM_PMU_CTI_TRIGOUT5 0x4019 /*!< Cross-trigger Interface output trigger 5 */ +#define ARM_PMU_CTI_TRIGOUT6 0x401A /*!< Cross-trigger Interface output trigger 6 */ +#define ARM_PMU_CTI_TRIGOUT7 0x401B /*!< Cross-trigger Interface output trigger 7 */ + +/** \brief PMU Functions */ + +__STATIC_INLINE void ARM_PMU_Enable(void); +__STATIC_INLINE void ARM_PMU_Disable(void); + +__STATIC_INLINE void ARM_PMU_Set_EVTYPER(uint32_t num, uint32_t type); + +__STATIC_INLINE void ARM_PMU_CYCCNT_Reset(void); +__STATIC_INLINE void ARM_PMU_EVCNTR_ALL_Reset(void); + +__STATIC_INLINE void ARM_PMU_CNTR_Enable(uint32_t mask); +__STATIC_INLINE void ARM_PMU_CNTR_Disable(uint32_t mask); + +__STATIC_INLINE uint32_t ARM_PMU_Get_CCNTR(void); +__STATIC_INLINE uint32_t ARM_PMU_Get_EVCNTR(uint32_t num); + +__STATIC_INLINE uint32_t ARM_PMU_Get_CNTR_OVS(void); +__STATIC_INLINE void ARM_PMU_Set_CNTR_OVS(uint32_t mask); + +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Enable(uint32_t mask); +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Disable(uint32_t mask); + +__STATIC_INLINE void ARM_PMU_CNTR_Increment(uint32_t mask); + +/** + \brief Enable the PMU +*/ +__STATIC_INLINE void ARM_PMU_Enable(void) +{ + PMU->CTRL |= PMU_CTRL_ENABLE_Msk; +} + +/** + \brief Disable the PMU +*/ +__STATIC_INLINE void ARM_PMU_Disable(void) +{ + PMU->CTRL &= ~PMU_CTRL_ENABLE_Msk; +} + +/** + \brief Set event to count for PMU eventer counter + \param [in] num Event counter (0-30) to configure + \param [in] type Event to count +*/ +__STATIC_INLINE void ARM_PMU_Set_EVTYPER(uint32_t num, uint32_t type) +{ + PMU->EVTYPER[num] = type; +} + +/** + \brief Reset cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CYCCNT_Reset(void) +{ + PMU->CTRL |= PMU_CTRL_CYCCNT_RESET_Msk; +} + +/** + \brief Reset all event counters +*/ +__STATIC_INLINE void ARM_PMU_EVCNTR_ALL_Reset(void) +{ + PMU->CTRL |= PMU_CTRL_EVENTCNT_RESET_Msk; +} + +/** + \brief Enable counters + \param [in] mask Counters to enable + \note Enables one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Enable(uint32_t mask) +{ + PMU->CNTENSET = mask; +} + +/** + \brief Disable counters + \param [in] mask Counters to enable + \note Disables one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Disable(uint32_t mask) +{ + PMU->CNTENCLR = mask; +} + +/** + \brief Read cycle counter + \return Cycle count +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_CCNTR(void) +{ + return PMU->CCNTR; +} + +/** + \brief Read event counter + \param [in] num Event counter (0-30) to read + \return Event count +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_EVCNTR(uint32_t num) +{ + return PMU_EVCNTR_CNT_Msk & PMU->EVCNTR[num]; +} + +/** + \brief Read counter overflow status + \return Counter overflow status bits for the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_CNTR_OVS(void) +{ + return PMU->OVSSET; +} + +/** + \brief Clear counter overflow status + \param [in] mask Counter overflow status bits to clear + \note Clears overflow status bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_OVS(uint32_t mask) +{ + PMU->OVSCLR = mask; +} + +/** + \brief Enable counter overflow interrupt request + \param [in] mask Counter overflow interrupt request bits to set + \note Sets overflow interrupt request bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Enable(uint32_t mask) +{ + PMU->INTENSET = mask; +} + +/** + \brief Disable counter overflow interrupt request + \param [in] mask Counter overflow interrupt request bits to clear + \note Clears overflow interrupt request bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Disable(uint32_t mask) +{ + PMU->INTENCLR = mask; +} + +/** + \brief Software increment event counter + \param [in] mask Counters to increment + \note Software increment bits for one or more event counters (0-30) +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Increment(uint32_t mask) +{ + PMU->SWINC = mask; +} + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h new file mode 100644 index 0000000000..facc2c9a47 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h @@ -0,0 +1,70 @@ +/****************************************************************************** + * @file tz_context.h + * @brief Context Management for Armv8-M TrustZone + * @version V1.0.1 + * @date 10. January 2018 + ******************************************************************************/ +/* + * Copyright (c) 2017-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef TZ_CONTEXT_H +#define TZ_CONTEXT_H + +#include + +#ifndef TZ_MODULEID_T +#define TZ_MODULEID_T +/// \details Data type that identifies secure software modules called by a process. +typedef uint32_t TZ_ModuleId_t; +#endif + +/// \details TZ Memory ID identifies an allocated memory slot. +typedef uint32_t TZ_MemoryId_t; + +/// Initialize secure context memory system +/// \return execution status (1: success, 0: error) +uint32_t TZ_InitContextSystem_S (void); + +/// Allocate context memory for calling secure software modules in TrustZone +/// \param[in] module identifies software modules called from non-secure mode +/// \return value != 0 id TrustZone memory slot identifier +/// \return value 0 no memory available or internal error +TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); + +/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); + +/// Load secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); + +/// Store secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); + +#endif // TZ_CONTEXT_H diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c new file mode 100644 index 0000000000..0e56b7cb94 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c @@ -0,0 +1,58 @@ +/****************************************************************************** + * @file main_s.c + * @brief Code template for secure main function + * @version V1.1.1 + * @date 10. January 2018 + ******************************************************************************/ +/* + * Copyright (c) 2013-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Use CMSE intrinsics */ +#include + +#include "RTE_Components.h" +#include CMSIS_device_header + +/* TZ_START_NS: Start address of non-secure application */ +#ifndef TZ_START_NS +#define TZ_START_NS (0x200000U) +#endif + +/* typedef for non-secure callback functions */ +typedef void (*funcptr_void) (void) __attribute__((cmse_nonsecure_call)); + +/* Secure main() */ +int main(void) { + funcptr_void NonSecure_ResetHandler; + + /* Add user setup code for secure part here*/ + + /* Set non-secure main stack (MSP_NS) */ + __TZ_set_MSP_NS(*((uint32_t *)(TZ_START_NS))); + + /* Get non-secure reset handler */ + NonSecure_ResetHandler = (funcptr_void)(*((uint32_t *)((TZ_START_NS) + 4U))); + + /* Start non-secure state software application */ + NonSecure_ResetHandler(); + + /* Non-secure software does not return, this code is not executed */ + while (1) { + __NOP(); + } +} diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c new file mode 100644 index 0000000000..e2e82942f8 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c @@ -0,0 +1,200 @@ +/****************************************************************************** + * @file tz_context.c + * @brief Context Management for Armv8-M TrustZone - Sample implementation + * @version V1.1.1 + * @date 10. January 2018 + ******************************************************************************/ +/* + * Copyright (c) 2016-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "RTE_Components.h" +#include CMSIS_device_header +#include "tz_context.h" + +/// Number of process slots (threads may call secure library code) +#ifndef TZ_PROCESS_STACK_SLOTS +#define TZ_PROCESS_STACK_SLOTS 8U +#endif + +/// Stack size of the secure library code +#ifndef TZ_PROCESS_STACK_SIZE +#define TZ_PROCESS_STACK_SIZE 256U +#endif + +typedef struct { + uint32_t sp_top; // stack space top + uint32_t sp_limit; // stack space limit + uint32_t sp; // current stack pointer +} stack_info_t; + +static stack_info_t ProcessStackInfo [TZ_PROCESS_STACK_SLOTS]; +static uint64_t ProcessStackMemory[TZ_PROCESS_STACK_SLOTS][TZ_PROCESS_STACK_SIZE/8U]; +static uint32_t ProcessStackFreeSlot = 0xFFFFFFFFU; + + +/// Initialize secure context memory system +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_InitContextSystem_S (void) { + uint32_t n; + + if (__get_IPSR() == 0U) { + return 0U; // Thread Mode + } + + for (n = 0U; n < TZ_PROCESS_STACK_SLOTS; n++) { + ProcessStackInfo[n].sp = 0U; + ProcessStackInfo[n].sp_limit = (uint32_t)&ProcessStackMemory[n]; + ProcessStackInfo[n].sp_top = (uint32_t)&ProcessStackMemory[n] + TZ_PROCESS_STACK_SIZE; + *((uint32_t *)ProcessStackMemory[n]) = n + 1U; + } + *((uint32_t *)ProcessStackMemory[--n]) = 0xFFFFFFFFU; + + ProcessStackFreeSlot = 0U; + + // Default process stack pointer and stack limit + __set_PSPLIM((uint32_t)ProcessStackMemory); + __set_PSP ((uint32_t)ProcessStackMemory); + + // Privileged Thread Mode using PSP + __set_CONTROL(0x02U); + + return 1U; // Success +} + + +/// Allocate context memory for calling secure software modules in TrustZone +/// \param[in] module identifies software modules called from non-secure mode +/// \return value != 0 id TrustZone memory slot identifier +/// \return value 0 no memory available or internal error +__attribute__((cmse_nonsecure_entry)) +TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module) { + uint32_t slot; + + (void)module; // Ignore (fixed Stack size) + + if (__get_IPSR() == 0U) { + return 0U; // Thread Mode + } + + if (ProcessStackFreeSlot == 0xFFFFFFFFU) { + return 0U; // No slot available + } + + slot = ProcessStackFreeSlot; + ProcessStackFreeSlot = *((uint32_t *)ProcessStackMemory[slot]); + + ProcessStackInfo[slot].sp = ProcessStackInfo[slot].sp_top; + + return (slot + 1U); +} + + +/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id) { + uint32_t slot; + + if (__get_IPSR() == 0U) { + return 0U; // Thread Mode + } + + if ((id == 0U) || (id > TZ_PROCESS_STACK_SLOTS)) { + return 0U; // Invalid ID + } + + slot = id - 1U; + + if (ProcessStackInfo[slot].sp == 0U) { + return 0U; // Inactive slot + } + ProcessStackInfo[slot].sp = 0U; + + *((uint32_t *)ProcessStackMemory[slot]) = ProcessStackFreeSlot; + ProcessStackFreeSlot = slot; + + return 1U; // Success +} + + +/// Load secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_LoadContext_S (TZ_MemoryId_t id) { + uint32_t slot; + + if ((__get_IPSR() == 0U) || ((__get_CONTROL() & 2U) == 0U)) { + return 0U; // Thread Mode or using Main Stack for threads + } + + if ((id == 0U) || (id > TZ_PROCESS_STACK_SLOTS)) { + return 0U; // Invalid ID + } + + slot = id - 1U; + + if (ProcessStackInfo[slot].sp == 0U) { + return 0U; // Inactive slot + } + + // Setup process stack pointer and stack limit + __set_PSPLIM(ProcessStackInfo[slot].sp_limit); + __set_PSP (ProcessStackInfo[slot].sp); + + return 1U; // Success +} + + +/// Store secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_StoreContext_S (TZ_MemoryId_t id) { + uint32_t slot; + uint32_t sp; + + if ((__get_IPSR() == 0U) || ((__get_CONTROL() & 2U) == 0U)) { + return 0U; // Thread Mode or using Main Stack for threads + } + + if ((id == 0U) || (id > TZ_PROCESS_STACK_SLOTS)) { + return 0U; // Invalid ID + } + + slot = id - 1U; + + if (ProcessStackInfo[slot].sp == 0U) { + return 0U; // Inactive slot + } + + sp = __get_PSP(); + if ((sp < ProcessStackInfo[slot].sp_limit) || + (sp > ProcessStackInfo[slot].sp_top)) { + return 0U; // SP out of range + } + ProcessStackInfo[slot].sp = sp; + + // Default process stack pointer and stack limit + __set_PSPLIM((uint32_t)ProcessStackMemory); + __set_PSP ((uint32_t)ProcessStackMemory); + + return 1U; // Success +} diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h new file mode 100644 index 0000000000..a955d47139 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h @@ -0,0 +1,888 @@ +/**************************************************************************//** + * @file cmsis_armcc.h + * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file + * @version V5.3.2 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_ARMCC_H +#define __CMSIS_ARMCC_H + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) + #error "Please use Arm Compiler Toolchain V4.0.677 or later!" +#endif + +/* CMSIS compiler control architecture macros */ +#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \ + (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) ) + #define __ARM_ARCH_6M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1)) + #define __ARM_ARCH_7M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1)) + #define __ARM_ARCH_7EM__ 1 +#endif + + /* __ARM_ARCH_8M_BASE__ not applicable */ + /* __ARM_ARCH_8M_MAIN__ not applicable */ + /* __ARM_ARCH_8_1M_MAIN__ not applicable */ + +/* CMSIS compiler control DSP macros */ +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __ARM_FEATURE_DSP 1 +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE static __forceinline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __declspec(noreturn) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed)) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT __packed struct +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION __packed union +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x))) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr))) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __memory_changed() +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __nop + + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __dsb(0xF) + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) +{ + rev16 r0, r0 + bx lr +} +#endif + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value) +{ + revsh r0, r0 + bx lr +} +#endif + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +#define __ROR __ror + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __breakpoint(value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __RBIT __rbit +#else +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ + return result; +} +#endif + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __clz + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) +#else + #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) +#else + #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) +#else + #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXB(value, ptr) __strex(value, ptr) +#else + #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXH(value, ptr) __strex(value, ptr) +#else + #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXW(value, ptr) __strex(value, ptr) +#else + #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __clrex + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) +{ + rrx r0, r0 + bx lr +} +#endif + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRBT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRHT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRT(value, ptr) __strt(value, ptr) + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __enable_irq(); */ + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __disable_irq(); */ + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; + __ISB(); +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_INLINE uint32_t __get_IPSR(void) +{ + register uint32_t __regIPSR __ASM("ipsr"); + return(__regIPSR); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_INLINE uint32_t __get_APSR(void) +{ + register uint32_t __regAPSR __ASM("apsr"); + return(__regAPSR); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_INLINE uint32_t __get_xPSR(void) +{ + register uint32_t __regXPSR __ASM("xpsr"); + return(__regXPSR); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + return(__regProcessStackPointer); +} + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + __regProcessStackPointer = topOfProcStack; +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + return(__regMainStackPointer); +} + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + __regMainStackPointer = topOfMainStack; +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xFFU); +} + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + register uint32_t __regBasePriMax __ASM("basepri_max"); + __regBasePriMax = (basePri & 0xFFU); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & (uint32_t)1U); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + return(__regfpscr); +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +#define __SADD8 __sadd8 +#define __QADD8 __qadd8 +#define __SHADD8 __shadd8 +#define __UADD8 __uadd8 +#define __UQADD8 __uqadd8 +#define __UHADD8 __uhadd8 +#define __SSUB8 __ssub8 +#define __QSUB8 __qsub8 +#define __SHSUB8 __shsub8 +#define __USUB8 __usub8 +#define __UQSUB8 __uqsub8 +#define __UHSUB8 __uhsub8 +#define __SADD16 __sadd16 +#define __QADD16 __qadd16 +#define __SHADD16 __shadd16 +#define __UADD16 __uadd16 +#define __UQADD16 __uqadd16 +#define __UHADD16 __uhadd16 +#define __SSUB16 __ssub16 +#define __QSUB16 __qsub16 +#define __SHSUB16 __shsub16 +#define __USUB16 __usub16 +#define __UQSUB16 __uqsub16 +#define __UHSUB16 __uhsub16 +#define __SASX __sasx +#define __QASX __qasx +#define __SHASX __shasx +#define __UASX __uasx +#define __UQASX __uqasx +#define __UHASX __uhasx +#define __SSAX __ssax +#define __QSAX __qsax +#define __SHSAX __shsax +#define __USAX __usax +#define __UQSAX __uqsax +#define __UHSAX __uhsax +#define __USAD8 __usad8 +#define __USADA8 __usada8 +#define __SSAT16 __ssat16 +#define __USAT16 __usat16 +#define __UXTB16 __uxtb16 +#define __UXTAB16 __uxtab16 +#define __SXTB16 __sxtb16 +#define __SXTAB16 __sxtab16 +#define __SMUAD __smuad +#define __SMUADX __smuadx +#define __SMLAD __smlad +#define __SMLADX __smladx +#define __SMLALD __smlald +#define __SMLALDX __smlaldx +#define __SMUSD __smusd +#define __SMUSDX __smusdx +#define __SMLSD __smlsd +#define __SMLSDX __smlsdx +#define __SMLSLD __smlsld +#define __SMLSLDX __smlsldx +#define __SEL __sel +#define __QADD __qadd +#define __QSUB __qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ + ((int64_t)(ARG3) << 32U) ) >> 32U)) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h new file mode 100644 index 0000000000..6911417747 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h @@ -0,0 +1,1503 @@ +/**************************************************************************//** + * @file cmsis_armclang.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V5.4.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +#define __SADD8 __builtin_arm_sadd8 +#define __QADD8 __builtin_arm_qadd8 +#define __SHADD8 __builtin_arm_shadd8 +#define __UADD8 __builtin_arm_uadd8 +#define __UQADD8 __builtin_arm_uqadd8 +#define __UHADD8 __builtin_arm_uhadd8 +#define __SSUB8 __builtin_arm_ssub8 +#define __QSUB8 __builtin_arm_qsub8 +#define __SHSUB8 __builtin_arm_shsub8 +#define __USUB8 __builtin_arm_usub8 +#define __UQSUB8 __builtin_arm_uqsub8 +#define __UHSUB8 __builtin_arm_uhsub8 +#define __SADD16 __builtin_arm_sadd16 +#define __QADD16 __builtin_arm_qadd16 +#define __SHADD16 __builtin_arm_shadd16 +#define __UADD16 __builtin_arm_uadd16 +#define __UQADD16 __builtin_arm_uqadd16 +#define __UHADD16 __builtin_arm_uhadd16 +#define __SSUB16 __builtin_arm_ssub16 +#define __QSUB16 __builtin_arm_qsub16 +#define __SHSUB16 __builtin_arm_shsub16 +#define __USUB16 __builtin_arm_usub16 +#define __UQSUB16 __builtin_arm_uqsub16 +#define __UHSUB16 __builtin_arm_uhsub16 +#define __SASX __builtin_arm_sasx +#define __QASX __builtin_arm_qasx +#define __SHASX __builtin_arm_shasx +#define __UASX __builtin_arm_uasx +#define __UQASX __builtin_arm_uqasx +#define __UHASX __builtin_arm_uhasx +#define __SSAX __builtin_arm_ssax +#define __QSAX __builtin_arm_qsax +#define __SHSAX __builtin_arm_shsax +#define __USAX __builtin_arm_usax +#define __UQSAX __builtin_arm_uqsax +#define __UHSAX __builtin_arm_uhsax +#define __USAD8 __builtin_arm_usad8 +#define __USADA8 __builtin_arm_usada8 +#define __SSAT16 __builtin_arm_ssat16 +#define __USAT16 __builtin_arm_usat16 +#define __UXTB16 __builtin_arm_uxtb16 +#define __UXTAB16 __builtin_arm_uxtab16 +#define __SXTB16 __builtin_arm_sxtb16 +#define __SXTAB16 __builtin_arm_sxtab16 +#define __SMUAD __builtin_arm_smuad +#define __SMUADX __builtin_arm_smuadx +#define __SMLAD __builtin_arm_smlad +#define __SMLADX __builtin_arm_smladx +#define __SMLALD __builtin_arm_smlald +#define __SMLALDX __builtin_arm_smlaldx +#define __SMUSD __builtin_arm_smusd +#define __SMUSDX __builtin_arm_smusdx +#define __SMLSD __builtin_arm_smlsd +#define __SMLSDX __builtin_arm_smlsdx +#define __SMLSLD __builtin_arm_smlsld +#define __SMLSLDX __builtin_arm_smlsldx +#define __SEL __builtin_arm_sel +#define __QADD __builtin_arm_qadd +#define __QSUB __builtin_arm_qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h new file mode 100644 index 0000000000..1e255d5907 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h @@ -0,0 +1,1928 @@ +/**************************************************************************//** + * @file cmsis_armclang_ltm.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V1.5.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h new file mode 100644 index 0000000000..adbf296f15 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h @@ -0,0 +1,283 @@ +/**************************************************************************//** + * @file cmsis_compiler.h + * @brief CMSIS compiler generic header file + * @version V5.1.0 + * @date 09. October 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_COMPILER_H +#define __CMSIS_COMPILER_H + +#include + +/* + * Arm Compiler 4/5 + */ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + + +/* + * Arm Compiler 6.6 LTM (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) + #include "cmsis_armclang_ltm.h" + + /* + * Arm Compiler above 6.10.1 (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) + #include "cmsis_armclang.h" + + +/* + * GNU Compiler + */ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + + +/* + * IAR Compiler + */ +#elif defined ( __ICCARM__ ) + #include + + +/* + * TI Arm Compiler + */ +#elif defined ( __TI_ARM__ ) + #include + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __attribute__((packed)) + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed)) + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed)) + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) + #endif + #ifndef __RESTRICT + #define __RESTRICT __restrict + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * TASKING Compiler + */ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __packed__ + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __packed__ + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __packed__ + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __packed__ T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __align(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * COSMIC Compiler + */ +#elif defined ( __CSMC__ ) + #include + + #ifndef __ASM + #define __ASM _asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + // NO RETURN is automatically detected hence no warning here + #define __NO_RETURN + #endif + #ifndef __USED + #warning No compiler specific solution for __USED. __USED is ignored. + #define __USED + #endif + #ifndef __WEAK + #define __WEAK __weak + #endif + #ifndef __PACKED + #define __PACKED @packed + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT @packed struct + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION @packed union + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + @packed struct T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. + #define __ALIGNED(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +#else + #error Unknown compiler. +#endif + + +#endif /* __CMSIS_COMPILER_H */ + diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h new file mode 100644 index 0000000000..67bda4ef3c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h @@ -0,0 +1,2211 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS compiler GCC header file + * @version V5.4.1 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" + +/* Fallback for __has_builtin */ +#ifndef __has_builtin + #define __has_builtin(x) (0) +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START + +/** + \brief Initializes data and bss sections + \details This default implementations initialized all data and additional bss + sections relying on .copy.table and .zero.table specified properly + in the used linker script. + + */ +__STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) +{ + extern void _start(void) __NO_RETURN; + + typedef struct { + uint32_t const* src; + uint32_t* dest; + uint32_t wlen; + } __copy_table_t; + + typedef struct { + uint32_t* dest; + uint32_t wlen; + } __zero_table_t; + + extern const __copy_table_t __copy_table_start__; + extern const __copy_table_t __copy_table_end__; + extern const __zero_table_t __zero_table_start__; + extern const __zero_table_t __zero_table_end__; + + for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = pTable->src[i]; + } + } + + for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = 0u; + } + } + + _start(); +} + +#define __PROGRAM_START __cmsis_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP __StackTop +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT __StackLimit +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section(".vectors"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL __StackSeal +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP() __ASM volatile ("nop") + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI() __ASM volatile ("wfi":::"memory") + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE() __ASM volatile ("wfe":::"memory") + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV() __ASM volatile ("sev") + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__STATIC_FORCEINLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__STATIC_FORCEINLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__STATIC_FORCEINLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (int16_t)__builtin_bswap16(value); +#else + int16_t result; + + __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + __ASM ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return result; +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__STATIC_FORCEINLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_FORCEINLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_get_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + return __builtin_arm_get_fpscr(); +#else + uint32_t result; + + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + return(result); +#endif +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_set_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + __builtin_arm_set_fpscr(fpscr); +#else + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); +#endif +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +#define __USAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16_RORn(uint32_t op1, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtb16 %0, %1, ROR %2" : "=r" (result) : "r" (op1), "i" (rotate) ); + } else { + result = __SXTB16(__ROR(op1, rotate)) ; + } + return result; +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16_RORn(uint32_t op1, uint32_t op2, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtab16 %0, %1, %2, ROR %3" : "=r" (result) : "r" (op1) , "r" (op2) , "i" (rotate)); + } else { + result = __SXTAB16(op1, __ROR(op2, rotate)); + } + return result; +} + + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +#define __PKHBT(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#pragma GCC diagnostic pop + +#endif /* __CMSIS_GCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h new file mode 100644 index 0000000000..65b824b009 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h @@ -0,0 +1,1002 @@ +/**************************************************************************//** + * @file cmsis_iccarm.h + * @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file + * @version V5.3.0 + * @date 14. April 2021 + ******************************************************************************/ + +//------------------------------------------------------------------------------ +// +// Copyright (c) 2017-2021 IAR Systems +// Copyright (c) 2017-2021 Arm Limited. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//------------------------------------------------------------------------------ + + +#ifndef __CMSIS_ICCARM_H__ +#define __CMSIS_ICCARM_H__ + +#ifndef __ICCARM__ + #error This file should only be compiled by ICCARM +#endif + +#pragma system_include + +#define __IAR_FT _Pragma("inline=forced") __intrinsic + +#if (__VER__ >= 8000000) + #define __ICCARM_V8 1 +#else + #define __ICCARM_V8 0 +#endif + +#ifndef __ALIGNED + #if __ICCARM_V8 + #define __ALIGNED(x) __attribute__((aligned(x))) + #elif (__VER__ >= 7080000) + /* Needs IAR language extensions */ + #define __ALIGNED(x) __attribute__((aligned(x))) + #else + #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored. + #define __ALIGNED(x) + #endif +#endif + + +/* Define compiler macros for CPU architecture, used in CMSIS 5. + */ +#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__ +/* Macros already defined */ +#else + #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M' + #if __ARM_ARCH == 6 + #define __ARM_ARCH_6M__ 1 + #elif __ARM_ARCH == 7 + #if __ARM_FEATURE_DSP + #define __ARM_ARCH_7EM__ 1 + #else + #define __ARM_ARCH_7M__ 1 + #endif + #endif /* __ARM_ARCH */ + #endif /* __ARM_ARCH_PROFILE == 'M' */ +#endif + +/* Alternativ core deduction for older ICCARM's */ +#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \ + !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__) + #if defined(__ARM6M__) && (__CORE__ == __ARM6M__) + #define __ARM_ARCH_6M__ 1 + #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__) + #define __ARM_ARCH_7M__ 1 + #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__) + #define __ARM_ARCH_7EM__ 1 + #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #else + #error "Unknown target." + #endif +#endif + + + +#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1 + #define __IAR_M0_FAMILY 1 +#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1 + #define __IAR_M0_FAMILY 1 +#else + #define __IAR_M0_FAMILY 0 +#endif + + +#ifndef __ASM + #define __ASM __asm +#endif + +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +#ifndef __INLINE + #define __INLINE inline +#endif + +#ifndef __NO_RETURN + #if __ICCARM_V8 + #define __NO_RETURN __attribute__((__noreturn__)) + #else + #define __NO_RETURN _Pragma("object_attribute=__noreturn") + #endif +#endif + +#ifndef __PACKED + #if __ICCARM_V8 + #define __PACKED __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED __packed + #endif +#endif + +#ifndef __PACKED_STRUCT + #if __ICCARM_V8 + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_STRUCT __packed struct + #endif +#endif + +#ifndef __PACKED_UNION + #if __ICCARM_V8 + #define __PACKED_UNION union __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_UNION __packed union + #endif +#endif + +#ifndef __RESTRICT + #if __ICCARM_V8 + #define __RESTRICT __restrict + #else + /* Needs IAR language extensions */ + #define __RESTRICT restrict + #endif +#endif + +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif + +#ifndef __FORCEINLINE + #define __FORCEINLINE _Pragma("inline=forced") +#endif + +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE +#endif + +#ifndef __UNALIGNED_UINT16_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint16_t __iar_uint16_read(void const *ptr) +{ + return *(__packed uint16_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR) +#endif + + +#ifndef __UNALIGNED_UINT16_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val) +{ + *(__packed uint16_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint32_t __iar_uint32_read(void const *ptr) +{ + return *(__packed uint32_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR) +#endif + +#ifndef __UNALIGNED_UINT32_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val) +{ + *(__packed uint32_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32 /* deprecated */ +#pragma language=save +#pragma language=extended +__packed struct __iar_u32 { uint32_t v; }; +#pragma language=restore +#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v) +#endif + +#ifndef __USED + #if __ICCARM_V8 + #define __USED __attribute__((used)) + #else + #define __USED _Pragma("__root") + #endif +#endif + +#undef __WEAK /* undo the definition from DLib_Defaults.h */ +#ifndef __WEAK + #if __ICCARM_V8 + #define __WEAK __attribute__((weak)) + #else + #define __WEAK _Pragma("__weak") + #endif +#endif + +#ifndef __PROGRAM_START +#define __PROGRAM_START __iar_program_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP CSTACK$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT CSTACK$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __vector_table +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE @".intvec" +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL STACKSEAL$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + +#ifndef __ICCARM_INTRINSICS_VERSION__ + #define __ICCARM_INTRINSICS_VERSION__ 0 +#endif + +#if __ICCARM_INTRINSICS_VERSION__ == 2 + + #if defined(__CLZ) + #undef __CLZ + #endif + #if defined(__REVSH) + #undef __REVSH + #endif + #if defined(__RBIT) + #undef __RBIT + #endif + #if defined(__SSAT) + #undef __SSAT + #endif + #if defined(__USAT) + #undef __USAT + #endif + + #include "iccarm_builtin.h" + + #define __disable_fault_irq __iar_builtin_disable_fiq + #define __disable_irq __iar_builtin_disable_interrupt + #define __enable_fault_irq __iar_builtin_enable_fiq + #define __enable_irq __iar_builtin_enable_interrupt + #define __arm_rsr __iar_builtin_rsr + #define __arm_wsr __iar_builtin_wsr + + + #define __get_APSR() (__arm_rsr("APSR")) + #define __get_BASEPRI() (__arm_rsr("BASEPRI")) + #define __get_CONTROL() (__arm_rsr("CONTROL")) + #define __get_FAULTMASK() (__arm_rsr("FAULTMASK")) + + #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + #define __get_FPSCR() (__arm_rsr("FPSCR")) + #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE))) + #else + #define __get_FPSCR() ( 0 ) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #define __get_IPSR() (__arm_rsr("IPSR")) + #define __get_MSP() (__arm_rsr("MSP")) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __get_MSPLIM() (0U) + #else + #define __get_MSPLIM() (__arm_rsr("MSPLIM")) + #endif + #define __get_PRIMASK() (__arm_rsr("PRIMASK")) + #define __get_PSP() (__arm_rsr("PSP")) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __get_PSPLIM() (0U) + #else + #define __get_PSPLIM() (__arm_rsr("PSPLIM")) + #endif + + #define __get_xPSR() (__arm_rsr("xPSR")) + + #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE))) + #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE))) + +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __arm_wsr("CONTROL", control); + __iar_builtin_ISB(); +} + + #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE))) + #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __set_MSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE))) + #endif + #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE))) + #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE))) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __set_PSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE))) + #endif + + #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS")) + +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __arm_wsr("CONTROL_NS", control); + __iar_builtin_ISB(); +} + + #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS")) + #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE))) + #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS")) + #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE))) + #define __TZ_get_SP_NS() (__arm_rsr("SP_NS")) + #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE))) + #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS")) + #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE))) + #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS")) + #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE))) + #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS")) + #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __TZ_get_PSPLIM_NS() (0U) + #define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE)) + #else + #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS")) + #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE))) + #endif + + #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS")) + #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE))) + + #define __NOP __iar_builtin_no_operation + + #define __CLZ __iar_builtin_CLZ + #define __CLREX __iar_builtin_CLREX + + #define __DMB __iar_builtin_DMB + #define __DSB __iar_builtin_DSB + #define __ISB __iar_builtin_ISB + + #define __LDREXB __iar_builtin_LDREXB + #define __LDREXH __iar_builtin_LDREXH + #define __LDREXW __iar_builtin_LDREX + + #define __RBIT __iar_builtin_RBIT + #define __REV __iar_builtin_REV + #define __REV16 __iar_builtin_REV16 + + __IAR_FT int16_t __REVSH(int16_t val) + { + return (int16_t) __iar_builtin_REVSH(val); + } + + #define __ROR __iar_builtin_ROR + #define __RRX __iar_builtin_RRX + + #define __SEV __iar_builtin_SEV + + #if !__IAR_M0_FAMILY + #define __SSAT __iar_builtin_SSAT + #endif + + #define __STREXB __iar_builtin_STREXB + #define __STREXH __iar_builtin_STREXH + #define __STREXW __iar_builtin_STREX + + #if !__IAR_M0_FAMILY + #define __USAT __iar_builtin_USAT + #endif + + #define __WFE __iar_builtin_WFE + #define __WFI __iar_builtin_WFI + + #if __ARM_MEDIA__ + #define __SADD8 __iar_builtin_SADD8 + #define __QADD8 __iar_builtin_QADD8 + #define __SHADD8 __iar_builtin_SHADD8 + #define __UADD8 __iar_builtin_UADD8 + #define __UQADD8 __iar_builtin_UQADD8 + #define __UHADD8 __iar_builtin_UHADD8 + #define __SSUB8 __iar_builtin_SSUB8 + #define __QSUB8 __iar_builtin_QSUB8 + #define __SHSUB8 __iar_builtin_SHSUB8 + #define __USUB8 __iar_builtin_USUB8 + #define __UQSUB8 __iar_builtin_UQSUB8 + #define __UHSUB8 __iar_builtin_UHSUB8 + #define __SADD16 __iar_builtin_SADD16 + #define __QADD16 __iar_builtin_QADD16 + #define __SHADD16 __iar_builtin_SHADD16 + #define __UADD16 __iar_builtin_UADD16 + #define __UQADD16 __iar_builtin_UQADD16 + #define __UHADD16 __iar_builtin_UHADD16 + #define __SSUB16 __iar_builtin_SSUB16 + #define __QSUB16 __iar_builtin_QSUB16 + #define __SHSUB16 __iar_builtin_SHSUB16 + #define __USUB16 __iar_builtin_USUB16 + #define __UQSUB16 __iar_builtin_UQSUB16 + #define __UHSUB16 __iar_builtin_UHSUB16 + #define __SASX __iar_builtin_SASX + #define __QASX __iar_builtin_QASX + #define __SHASX __iar_builtin_SHASX + #define __UASX __iar_builtin_UASX + #define __UQASX __iar_builtin_UQASX + #define __UHASX __iar_builtin_UHASX + #define __SSAX __iar_builtin_SSAX + #define __QSAX __iar_builtin_QSAX + #define __SHSAX __iar_builtin_SHSAX + #define __USAX __iar_builtin_USAX + #define __UQSAX __iar_builtin_UQSAX + #define __UHSAX __iar_builtin_UHSAX + #define __USAD8 __iar_builtin_USAD8 + #define __USADA8 __iar_builtin_USADA8 + #define __SSAT16 __iar_builtin_SSAT16 + #define __USAT16 __iar_builtin_USAT16 + #define __UXTB16 __iar_builtin_UXTB16 + #define __UXTAB16 __iar_builtin_UXTAB16 + #define __SXTB16 __iar_builtin_SXTB16 + #define __SXTAB16 __iar_builtin_SXTAB16 + #define __SMUAD __iar_builtin_SMUAD + #define __SMUADX __iar_builtin_SMUADX + #define __SMMLA __iar_builtin_SMMLA + #define __SMLAD __iar_builtin_SMLAD + #define __SMLADX __iar_builtin_SMLADX + #define __SMLALD __iar_builtin_SMLALD + #define __SMLALDX __iar_builtin_SMLALDX + #define __SMUSD __iar_builtin_SMUSD + #define __SMUSDX __iar_builtin_SMUSDX + #define __SMLSD __iar_builtin_SMLSD + #define __SMLSDX __iar_builtin_SMLSDX + #define __SMLSLD __iar_builtin_SMLSLD + #define __SMLSLDX __iar_builtin_SMLSLDX + #define __SEL __iar_builtin_SEL + #define __QADD __iar_builtin_QADD + #define __QSUB __iar_builtin_QSUB + #define __PKHBT __iar_builtin_PKHBT + #define __PKHTB __iar_builtin_PKHTB + #endif + +#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #define __CLZ __cmsis_iar_clz_not_active + #define __SSAT __cmsis_iar_ssat_not_active + #define __USAT __cmsis_iar_usat_not_active + #define __RBIT __cmsis_iar_rbit_not_active + #define __get_APSR __cmsis_iar_get_APSR_not_active + #endif + + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #define __get_FPSCR __cmsis_iar_get_FPSR_not_active + #define __set_FPSCR __cmsis_iar_set_FPSR_not_active + #endif + + #ifdef __INTRINSICS_INCLUDED + #error intrinsics.h is already included previously! + #endif + + #include + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #undef __CLZ + #undef __SSAT + #undef __USAT + #undef __RBIT + #undef __get_APSR + + __STATIC_INLINE uint8_t __CLZ(uint32_t data) + { + if (data == 0U) { return 32U; } + + uint32_t count = 0U; + uint32_t mask = 0x80000000U; + + while ((data & mask) == 0U) + { + count += 1U; + mask = mask >> 1U; + } + return count; + } + + __STATIC_INLINE uint32_t __RBIT(uint32_t v) + { + uint8_t sc = 31U; + uint32_t r = v; + for (v >>= 1U; v; v >>= 1U) + { + r <<= 1U; + r |= v & 1U; + sc--; + } + return (r << sc); + } + + __STATIC_INLINE uint32_t __get_APSR(void) + { + uint32_t res; + __asm("MRS %0,APSR" : "=r" (res)); + return res; + } + + #endif + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #undef __get_FPSCR + #undef __set_FPSCR + #define __get_FPSCR() (0) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #pragma diag_suppress=Pe940 + #pragma diag_suppress=Pe177 + + #define __enable_irq __enable_interrupt + #define __disable_irq __disable_interrupt + #define __NOP __no_operation + + #define __get_xPSR __get_PSR + + #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0) + + __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr) + { + return __LDREX((unsigned long *)ptr); + } + + __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr) + { + return __STREX(value, (unsigned long *)ptr); + } + #endif + + + /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + #if (__CORTEX_M >= 0x03) + + __IAR_FT uint32_t __RRX(uint32_t value) + { + uint32_t result; + __ASM volatile("RRX %0, %1" : "=r"(result) : "r" (value)); + return(result); + } + + __IAR_FT void __set_BASEPRI_MAX(uint32_t value) + { + __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value)); + } + + + #define __enable_fault_irq __enable_fiq + #define __disable_fault_irq __disable_fiq + + + #endif /* (__CORTEX_M >= 0x03) */ + + __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2) + { + return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2)); + } + + #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + __IAR_FT uint32_t __get_MSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,MSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_MSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR MSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __get_PSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_PSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_CONTROL_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,CONTROL_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value) + { + __asm volatile("MSR CONTROL_NS,%0" :: "r" (value)); + __iar_builtin_ISB(); + } + + __IAR_FT uint32_t __TZ_get_PSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PSP_NS(uint32_t value) + { + __asm volatile("MSR PSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_MSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSP_NS(uint32_t value) + { + __asm volatile("MSR MSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_SP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,SP_NS" : "=r" (res)); + return res; + } + __IAR_FT void __TZ_set_SP_NS(uint32_t value) + { + __asm volatile("MSR SP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value) + { + __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value) + { + __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value) + { + __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value) + { + __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value)); + } + + #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + +#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value)) + +#if __IAR_M0_FAMILY + __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) + { + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; + } + + __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) + { + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; + } +#endif + +#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + + __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr) + { + uint32_t res; + __ASM volatile ("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr) + { + uint32_t res; + __ASM volatile ("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDRT(volatile uint32_t *addr) + { + uint32_t res; + __ASM volatile ("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return res; + } + + __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr) + { + __ASM volatile ("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr) + { + __ASM volatile ("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr) + { + __ASM volatile ("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory"); + } + +#endif /* (__CORTEX_M >= 0x03) */ + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + + __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDA(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr) + { + __ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr) + { + __ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr) + { + __ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + +#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#undef __IAR_FT +#undef __IAR_M0_FAMILY +#undef __ICCARM_V8 + +#pragma diag_default=Pe940 +#pragma diag_default=Pe177 + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* __CMSIS_ICCARM_H__ */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_version.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_version.h new file mode 100644 index 0000000000..8b4765f186 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/cmsis_version.h @@ -0,0 +1,39 @@ +/**************************************************************************//** + * @file cmsis_version.h + * @brief CMSIS Core(M) Version definitions + * @version V5.0.5 + * @date 02. February 2022 + ******************************************************************************/ +/* + * Copyright (c) 2009-2022 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CMSIS_VERSION_H +#define __CMSIS_VERSION_H + +/* CMSIS Version definitions */ +#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ +#define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */ +#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ + __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h new file mode 100644 index 0000000000..879a384124 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h @@ -0,0 +1,1087 @@ +/**************************************************************************//** + * @file core_cm0plus.h + * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File + * @version V5.0.9 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0PLUS_H_GENERIC +#define __CORE_CM0PLUS_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex-M0+ + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0+ definitions */ +#define __CM0PLUS_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0PLUS_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ + __CM0PLUS_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0PLUS_H_DEPENDANT +#define __CORE_CM0PLUS_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0PLUS_REV + #define __CM0PLUS_REV 0x0000U + #warning "__CM0PLUS_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex-M0+ */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0+ header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0+ */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ +#endif + /* ARM Application Note 321 states that the M0+ does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +#endif +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm3.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm3.h new file mode 100644 index 0000000000..74fb87e5c5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/core_cm3.h @@ -0,0 +1,1943 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V5.1.2 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM3_H_GENERIC +#define __CORE_CM3_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M3 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (3U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM3_H_DEPENDANT +#define __CORE_CM3_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM3_REV + #define __CM3_REV 0x0200U + #warning "__CM3_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M3 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV < 0x0201U) /* core r2p1 */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#else +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +#else + uint32_t RESERVED1[1U]; +#endif +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ +#endif + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h new file mode 100644 index 0000000000..9909f83990 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h @@ -0,0 +1,275 @@ +/****************************************************************************** + * @file mpu_armv7.h + * @brief CMSIS MPU API for Armv7-M MPU + * @version V5.1.2 + * @date 25. May 2020 + ******************************************************************************/ +/* + * Copyright (c) 2017-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV7_H +#define ARM_MPU_ARMV7_H + +#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes +#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes +#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes +#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes +#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes +#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte +#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes +#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes +#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes +#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes +#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes +#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes +#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes +#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes +#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes +#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte +#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes +#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes +#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes +#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes +#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes +#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes +#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes +#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes +#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes +#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte +#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes +#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes + +#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access +#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only +#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only +#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access +#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only +#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access + +/** MPU Region Base Address Register Value +* +* \param Region The region to be configured, number 0 to 15. +* \param BaseAddress The base address for the region. +*/ +#define ARM_MPU_RBAR(Region, BaseAddress) \ + (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ + ((Region) & MPU_RBAR_REGION_Msk) | \ + (MPU_RBAR_VALID_Msk)) + +/** +* MPU Memory Access Attributes +* +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +*/ +#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \ + ((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ + (((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ + (((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ + (((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk)) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \ + ((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ + (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ + (((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \ + (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ + (((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ + (((MPU_RASR_ENABLE_Msk)))) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ + ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size) + +/** +* MPU Memory Access Attribute for strongly ordered memory. +* - TEX: 000b +* - Shareable +* - Non-cacheable +* - Non-bufferable +*/ +#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U) + +/** +* MPU Memory Access Attribute for device memory. +* - TEX: 000b (if shareable) or 010b (if non-shareable) +* - Shareable or non-shareable +* - Non-cacheable +* - Bufferable (if shareable) or non-bufferable (if non-shareable) +* +* \param IsShareable Configures the device memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U)) + +/** +* MPU Memory Access Attribute for normal memory. +* - TEX: 1BBb (reflecting outer cacheability rules) +* - Shareable or non-shareable +* - Cacheable or non-cacheable (reflecting inner cacheability rules) +* - Bufferable or non-bufferable (reflecting inner cacheability rules) +* +* \param OuterCp Configures the outer cache policy. +* \param InnerCp Configures the inner cache policy. +* \param IsShareable Configures the memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U)) + +/** +* MPU Memory Access Attribute non-cacheable policy. +*/ +#define ARM_MPU_CACHEP_NOCACHE 0U + +/** +* MPU Memory Access Attribute write-back, write and read allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_WRA 1U + +/** +* MPU Memory Access Attribute write-through, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WT_NWA 2U + +/** +* MPU Memory Access Attribute write-back, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_NWA 3U + + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; //!< The region base address register value (RBAR) + uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + MPU->RNR = rnr; + MPU->RASR = 0U; +} + +/** Configure an MPU region. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) +{ + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) +{ + MPU->RNR = rnr; + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_Load(). +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + while (cnt > MPU_TYPE_RALIASES) { + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); + table += MPU_TYPE_RALIASES; + cnt -= MPU_TYPE_RALIASES; + } + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); +} + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/LICENSE.txt b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/LICENSE.txt new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/README.md b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/README.md new file mode 100644 index 0000000000..0630bf8cd4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/CMSIS/README.md @@ -0,0 +1,141 @@ +# CMSIS Version 5 + +[![Version](https://img.shields.io/github/v/release/arm-software/CMSIS_5)](https://github.com/ARM-software/CMSIS_5/releases/latest) [![License](https://img.shields.io/github/license/arm-software/CMSIS_5)](https://arm-software.github.io/CMSIS_5/General/html/LICENSE.txt) + +The branch *master* of this GitHub repository contains ![Version](https://img.shields.io/github/v/release/arm-software/CMSIS_5?display_name=release&label=%20&sort=semver). +The [documentation](http://arm-software.github.io/CMSIS_5/General/html/index.html) is available under http://arm-software.github.io/CMSIS_5/General/html/index.html + +Use [Issues](https://github.com/ARM-software/CMSIS_5#issues-and-labels) to provide feedback and report problems for CMSIS Version 5. + +**Note:** The branch *develop* of this GitHub repository reflects our current state of development and is constantly updated. It gives our users and partners contiguous access to the CMSIS development. It allows you to review the work and provide feedback or create pull requests for contributions. + +A [pre-built documentation](https://arm-software.github.io/CMSIS_5/develop/General/html/index.html) is updated from time to time, but may be also generated using the instructions under [Generate CMSIS Pack for Release](https://github.com/ARM-software/CMSIS_5#generate-cmsis-pack-for-release). + +## Overview of CMSIS Components + +The following is an list of all CMSIS components that are available. + +| CMSIS-... | Target Processors | Description | +|:----------|:--------------------|:-------------| +|[Core(M)](http://arm-software.github.io/CMSIS_5/Core/html/index.html) | All Cortex-M, SecurCore | Standardized API for the Cortex-M processor core and peripherals. Includes intrinsic functions for Cortex-M4/M7/M33/M35P SIMD instructions.| +|[Core(A)](http://arm-software.github.io/CMSIS_5/Core_A/html/index.html)| Cortex-A5/A7/A9 | API and basic run-time system for the Cortex-A5/A7/A9 processor core and peripherals.| +|[Driver](http://arm-software.github.io/CMSIS_5/Driver/html/index.html) | All Cortex-M, SecurCore | Generic peripheral driver interfaces for middleware. Connects microcontroller peripherals with middleware that implements for example communication stacks, file systems, or graphic user interfaces.| +|[DSP](http://arm-software.github.io/CMSIS_5/DSP/html/index.html) | All Cortex-M | DSP library collection with over 60 Functions for various data types: fixed-point (fractional q7, q15, q31) and single precision floating-point (32-bit). Implementations optimized for the SIMD instruction set are available for Cortex-M4/M7/M33/M35P.| +|[NN](http://arm-software.github.io/CMSIS_5/NN/html/index.html) | All Cortex-M | Collection of efficient neural network kernels developed to maximize the performance and minimize the memory footprint on Cortex-M processor cores.| +|[RTOS v1](http://arm-software.github.io/CMSIS_5/RTOS/html/index.html) | Cortex-M0/M0+/M3/M4/M7 | Common API for real-time operating systems along with a reference implementation based on RTX. It enables software components that can work across multiple RTOS systems.| +|[RTOS v2](http://arm-software.github.io/CMSIS_5/RTOS2/html/index.html)| All Cortex-M, Cortex-A5/A7/A9 | Extends CMSIS-RTOS v1 with Armv8-M support, dynamic object creation, provisions for multi-core systems, binary compatible interface. | +|[Pack](http://arm-software.github.io/CMSIS_5/Pack/html/index.html) | All Cortex-M, SecurCore, Cortex-A5/A7/A9 | Describes a delivery mechanism for software components, device parameters, and evaluation board support. It simplifies software re-use and product life-cycle management (PLM).
Is part of the [Open CMSIS Pack project](https://www.open-cmsis-pack.org). | +|[Build](http://arm-software.github.io/CMSIS_5/Build/html/index.html) | All Cortex-M, SecurCore, Cortex-A5/A7/A9 | A set of tools, software frameworks, and work flows that improve productivity, for example with Continuous Integration (CI) support.
Is replaced with the [CMSIS-Toolbox](https://github.com/Open-CMSIS-Pack/devtools/tree/main/tools). | +|[SVD](http://arm-software.github.io/CMSIS_5/SVD/html/index.html) | All Cortex-M, SecurCore | Peripheral description of a device that can be used to create peripheral awareness in debuggers or CMSIS-Core header files.| +|[DAP](http://arm-software.github.io/CMSIS_5/DAP/html/index.html) | All Cortex | Firmware for a debug unit that interfaces to the CoreSight Debug Access Port. | +|[Zone](http://arm-software.github.io/CMSIS_5/Zone/html/index.html) | All Cortex-M | Defines methods to describe system resources and to partition these resources into multiple projects and execution areas. | + +## Implemented Enhancements + - CMSIS-Pack generation with [shell script template](https://arm-software.github.io/CMSIS_5/Pack/html/bash_script.html) for Windows and Linux + - CMSIS-Pack: [Git workflow](https://arm-software.github.io/CMSIS_5/Pack/html/element_repository.html) via Eclipse menu *Window - Preferences - CMSIS Packs - Manage Local Repositories* and [MDK](http://www.keil.com/support/man/docs/uv4/uv4_ca_packinst_repo.htm) + - [CMSIS-Zone release 1.0](https://arm-software.github.io/CMSIS_5/Zone/html/index.html) with support for multi-processor, TrustZone, and MPU configuration + - Support for Armv8.1M Architecture and Cortex-M55 (release in March 2020) + - CMSIS-DSP is fully ported to SIMD for Cortex-M family (Armv8.1-M) and Cortex-A & Cortex-R with NEON, using the same APIs. + +## Further Planned Enhancements + - CMSIS-Pack: + - System Description SDF Format: describe more complex debug topologies than with a Debug Description in a tool agnostic way + - CPDSC project file format: allows project templates that are agnostic of an IDE + - Minimize need for IDE specific settings: CMSIS-Pack supports IDE specific parameters. Analyze and minimize + - CMSIS-Build: command-line driven make system for CMSIS-Pack based projects (to support CI tests) + +For further details see also the [Slides of the Embedded World CMSIS Partner Meeting](https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS_Review_Meeting_2020.pdf). + +## Other related GitHub repositories + +| Repository | Description | +|:--------------------------- |:--------------------------------------------------------- | +| [cmsis-pack-eclipse](https://github.com/ARM-software/cmsis-pack-eclipse) | CMSIS-Pack Management for Eclipse reference implementation Pack support | +| [CMSIS-FreeRTOS](https://github.com/arm-software/CMSIS-FreeRTOS) | CMSIS-RTOS adoption of FreeRTOS | +| [CMSIS-Driver](https://github.com/arm-software/CMSIS-Driver) | Generic MCU driver implementations and templates for Ethernet MAC/PHY and Flash. | +| [CMSIS-Driver_Validation](https://github.com/ARM-software/CMSIS-Driver_Validation) | CMSIS-Driver Validation can be used to verify CMSIS-Driver in a user system | +| [CMSIS-Zone](https://github.com/ARM-software/CMSIS-Zone) | CMSIS-Zone Utility along with example projects and FreeMarker templates | +| [NXP_LPC](https://github.com/ARM-software/NXP_LPC) | CMSIS Driver Implementations for the NXP LPC Microcontroller Series | +| [mdk-packs](https://github.com/mdk-packs) | IoT cloud connectors as trail implementations for MDK (help us to make it generic)| +| [trustedfirmware.org](https://www.trustedfirmware.org/) | Arm Trusted Firmware provides a reference implementation of secure world software for Armv8-A and Armv8-M.| + + +## Directory Structure + +| Directory | Content | +|:-------------------- |:--------------------------------------------------------- | +| CMSIS/Core | CMSIS-Core(M) related files (for release) | +| CMSIS/Core_A | CMSIS-Core(A) related files (for release) | +| CMSIS/CoreValidation | Validation for Core(M) and Core(A) (NOT part of release) | +| CMSIS/DAP | CMSIS-DAP related files and examples | +| CMSIS/Driver | CMSIS-Driver API headers and template files | +| CMSIS/DSP | CMSIS-DSP related files | +| CMSIS/NN | CMSIS-NN related files | +| CMSIS/RTOS | RTOS v1 related files (for Cortex-M) | +| CMSIS/RTOS2 | RTOS v2 related files (for Cortex-M & Armv8-M) | +| CMSIS/Pack | CMSIS-Pack examples and tutorials | +| CMSIS/DoxyGen | Source of the documentation | +| CMSIS/Utilities | Utility programs | + +## Generate CMSIS Pack for Release + +This GitHub development repository lacks pre-built libraries of various software components (RTOS, RTOS2). +In order to generate a full pack one needs to have the build environment available to build these libraries. +This causes some sort of inconvenience. Hence the pre-built libraries may be moved out into separate pack(s) +in the future. + +To build a complete CMSIS pack for installation the following additional tools are required: + - **doxygen.exe** Version: 1.8.6 (Documentation Generator) + - **mscgen.exe** Version: 0.20 (Message Sequence Chart Converter) + - **7z.exe (7-Zip)** Version: 16.02 (File Archiver) + +Using these tools, you can generate on a Windows PC: + - **CMSIS Documentation** using the batch file **gen_doc.sh** (located in ./CMSIS/Doxygen). + - **CMSIS Software Pack** using the batch file **gen_pack.sh** (located in ./CMSIS/Utilities). + The bash script does not generate the documentation. The pre-built libraries for RTX4 and RTX5 + are not included within this repository. + +The file ./CMSIS/DoxyGen/How2Doc.txt describes the rules for creating API documentation. + +## License + +Arm CMSIS is licensed under Apache 2.0. + +## Contributions and Pull Requests + +Contributions are accepted under Apache 2.0. Only submit contributions where you have authored all of the code. + +### Issues and Labels + +Please feel free to raise an [issue on GitHub](https://github.com/ARM-software/CMSIS_5/issues) +to report misbehavior (i.e. bugs) or start discussions about enhancements. This +is your best way to interact directly with the maintenance team and the community. +We encourage you to append implementation suggestions as this helps to decrease the +workload of the very limited maintenance team. + +We will be monitoring and responding to issues as best we can. +Please attempt to avoid filing duplicates of open or closed items when possible. +In the spirit of openness we will be tagging issues with the following: + +- **bug** – We consider this issue to be a bug that will be investigated. + +- **wontfix** - We appreciate this issue but decided not to change the current behavior. + +- **enhancement** – Denotes something that will be implemented soon. + +- **future** - Denotes something not yet schedule for implementation. + +- **out-of-scope** - We consider this issue loosely related to CMSIS. It might by implemented outside of CMSIS. Let us know about your work. + +- **question** – We have further questions to this issue. Please review and provide feedback. + +- **documentation** - This issue is a documentation flaw that will be improved in future. + +- **review** - This issue is under review. Please be patient. + +- **DONE** - We consider this issue as resolved - please review and close it. In case of no further activity this issues will be closed after a week. + +- **duplicate** - This issue is already addressed elsewhere, see comment with provided references. + +- **Important Information** - We provide essential information regarding planned or resolved major enhancements. + diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/ht32f1xxxx_01.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/ht32f1xxxx_01.h new file mode 100644 index 0000000000..f2bcf5de2a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/ht32f1xxxx_01.h @@ -0,0 +1,1462 @@ +/***************************************************************************//** + * @file ht32f1xxxx_01.h + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File + * @version $Rev:: 2914 $ + * @date $Date:: 2023-05-18 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * Holtek supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within + * development tools that are supporting such ARM-based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F1653, HT32F1654 +// HT32F1655, HT32F1656 +// HT32F12345 +// HT32F12365, HT32F12366 +// HT32F22366 +// HT32F12364 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F1xxxx HT32F1xxxx + * @{ + */ + + +#ifndef __HT32F1XXXX_01_H__ +#define __HT32F1XXXX_01_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +#if !defined(USE_HT32F1653_54) && \ + !defined(USE_HT32F1655_56) && \ + !defined(USE_HT32F12345) && \ + !defined(USE_HT32F12365_66) && \ + !defined(USE_HT32F12364) + + //#define USE_HT32F1653_54 + //#define USE_HT32F1655_56 + //#define USE_HT32F12345 + //#define USE_HT32F12365_66 + +#endif + +#if !defined(USE_NOCHIP) && \ + !defined(USE_HT32F1653_54) && \ + !defined(USE_HT32F1655_56) && \ + !defined(USE_HT32F12345) && \ + !defined(USE_HT32F12365_66) && \ + !defined(USE_HT32F12364) + + #error Please add "USE_HT32Fxxxxx_xx" define into C Preprocessor Symbols of the Project configuration. + +#endif + +/** @addtogroup Library_configuration_section + * @{ + */ +/** + * @brief Value of the High Speed Internal oscillator in Hz + */ +#define HSI_VALUE 8000000UL /*!< Value of the High Speed Internal oscillator in Hz */ + +/** + * @brief Value of the Low Speed Internal oscillator in Hz + */ +#define LSI_VALUE 32000UL /*!< Value of the Low Speed Internal oscillator in Hz */ + +/** + * @brief Value of the Low Speed External oscillator in Hz + */ +#define LSE_VALUE 32768UL /*!< Value of the Low Speed External oscillator in Hz */ + +/** + * @brief Adjust the High Speed External oscillator (HSE) Startup Timeout value + */ +#define HSE_READY_TIME ((uint16_t)0xFFFF) /*!< Time out for HSE start up */ +/** + * @} + */ + +/** @addtogroup Configuration_section_for_CMSIS + * @{ + */ +#define __MPU_PRESENT 0 /*!< MPU present or not */ +#define __NVIC_PRIO_BITS 4 /*!< Number of Bits used for Priority Levels */ +#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ + +/** + * @} + */ + + +/** @addtogroup Configuration_for_Interrupt_Number + * @{ + */ +typedef enum IRQn +{ +/****** Cortex-M3 Processor Exceptions Numbers ****************************** */ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ + HardFault_IRQn = -13, /*!< 3 Cortex-M3 Hard Fault Interrupt */ + MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Int */ + BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */ + UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */ + SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */ + DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */ + PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */ + SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */ + +/****** HT32 Specific Interrupt Numbers ************************************ */ + CKRDY_IRQn = 0, /*!< Clock ready interrupt */ + LVD_IRQn = 1, /*!< Low voltage detection interrupt */ + BOD_IRQn = 2, /*!< Brown-Out detection interrupt */ + #if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) + WDT_IRQn = 3, /*!< WDT global interrupt */ + #endif + RTC_IRQn = 4, /*!< RTC Wake-up Interrupt */ + FLASH_IRQn = 5, /*!< FLASH global Interrupt */ + EVWUP_IRQn = 6, /*!< Event Wake-up Interrupt */ + LPWUP_IRQn = 7, /*!< WAKEUP pin Interrupt */ + EXTI0_IRQn = 8, /*!< EXTI0 Line detection Interrupt */ + EXTI1_IRQn = 9, /*!< EXTI1 Line detection Interrupt */ + EXTI2_IRQn = 10, /*!< EXTI2 Line detection Interrupt */ + EXTI3_IRQn = 11, /*!< EXTI3 Line detection Interrupt */ + EXTI4_IRQn = 12, /*!< EXTI4 Line detection Interrupt */ + EXTI5_IRQn = 13, /*!< EXTI5 Line detection Interrupt */ + EXTI6_IRQn = 14, /*!< EXTI6 Line detection Interrupt */ + EXTI7_IRQn = 15, /*!< EXTI7 Line detection Interrupt */ + EXTI8_IRQn = 16, /*!< EXTI8 Line detection Interrupt */ + EXTI9_IRQn = 17, /*!< EXTI9 Line detection Interrupt */ + EXTI10_IRQn = 18, /*!< EXTI10 Line detection Interrupt */ + EXTI11_IRQn = 19, /*!< EXTI11 Line detection Interrupt */ + EXTI12_IRQn = 20, /*!< EXTI12 Line detection Interrupt */ + EXTI13_IRQn = 21, /*!< EXTI13 Line detection Interrupt */ + EXTI14_IRQn = 22, /*!< EXTI14 Line detection Interrupt */ + EXTI15_IRQn = 23, /*!< EXTI15 Line detection Interrupt */ + #if !defined(USE_HT32F12364) + COMP_IRQn = 24, /*!< Comparator global Interrupt */ + #endif + ADC0_IRQn = 25, /*!< ADC Interrupt */ + #if !defined(USE_HT32F12364) + MCTM0BRK_IRQn = 27, /*!< MCTM0 BRK interrupt */ + MCTM0UP_IRQn = 28, /*!< MCTM0 UP interrupt */ + MCTM0TR_IRQn = 29, /*!< MCTM0 TR interrupt */ + MCTM0CC_IRQn = 30, /*!< MCTM0 CC interrupt */ + MCTM1BRK_IRQn = 31, /*!< MCTM1 BRK interrupt */ + MCTM1UP_IRQn = 32, /*!< MCTM1 UP interrupt */ + MCTM1TR_IRQn = 33, /*!< MCTM1 TR interrupt */ + MCTM1CC_IRQn = 34, /*!< MCTM1 CC interrupt */ + #endif + GPTM0_IRQn = 35, /*!< General-Purpose Timer0 Interrupt */ + #if !defined(USE_HT32F12364) + GPTM1_IRQn = 36, /*!< General-Purpose Timer1 Interrupt */ + #endif + #if defined(USE_HT32F12364) + SCTM0_IRQn = 37, /*!< Single-Channel Timer0 Interrupt */ + SCTM1_IRQn = 38, /*!< Single-Channel Timer1 Interrupt */ + PWM0_IRQn = 39, /*!< Pulse Width Modulator Timer0 Interrupt */ + #endif + BFTM0_IRQn = 41, /*!< Basic Function Timer0 interrupt */ + BFTM1_IRQn = 42, /*!< Basic Function Timer1 interrupt */ + I2C0_IRQn = 43, /*!< I2C0 global Interrupt */ + I2C1_IRQn = 44, /*!< I2C1 global Interrupt */ + SPI0_IRQn = 45, /*!< SPI0 global Interrupt */ + SPI1_IRQn = 46, /*!< SPI1 global Interrupt */ + USART0_IRQn = 47, /*!< USART0 global Interrupt */ + #if !defined(USE_HT32F12364) + USART1_IRQn = 48, /*!< USART1 global Interrupt */ + #endif + UART0_IRQn = 49, /*!< UART0 global Interrupt */ + UART1_IRQn = 50, /*!< UART1 global Interrupt */ + #if !defined(USE_HT32F12345) + SCI_IRQn = 51, /*!< Smart Card interface interrupt */ + #endif + #if !defined(USE_HT32F12364) + I2S_IRQn = 52, /*!< I2S global Interrupt */ + #endif + USB_IRQn = 53, /*!< USB interrupt */ + #if defined(USE_HT32F12365_66) || defined(USE_HT32F12345) + SDIO_IRQn = 54, /*!< SDIO interrupt */ + #endif + PDMACH0_IRQn = 55, /*!< PDMA channel 0 global interrupt */ + PDMACH1_IRQn = 56, /*!< PDMA channel 1 global interrupt */ + PDMACH2_IRQn = 57, /*!< PDMA channel 2 global interrupt */ + PDMACH3_IRQn = 58, /*!< PDMA channel 3 global interrupt */ + PDMACH4_IRQn = 59, /*!< PDMA channel 4 global interrupt */ + PDMACH5_IRQn = 60, /*!< PDMA channel 5 global interrupt */ + #if !defined(USE_HT32F12364) + PDMACH6_IRQn = 61, /*!< PDMA channel 6 global interrupt */ + PDMACH7_IRQn = 62, /*!< PDMA channel 7 global interrupt */ + #endif + #if defined(USE_HT32F12365_66) || defined(USE_HT32F12345) + PDMACH8_IRQn = 63, /*!< PDMA channel 8 global interrupt */ + PDMACH9_IRQn = 64, /*!< PDMA channel 9 global interrupt */ + PDMACH10_IRQn = 65, /*!< PDMA channel 10 global interrupt */ + PDMACH11_IRQn = 66, /*!< PDMA channel 11 global interrupt */ + #endif + #if defined(USE_HT32F12365_66) + CSIF_IRQn = 67, /*!< CMOS sensor interface interrupt */ + #endif + #if !defined(USE_HT32F12364) + EBI_IRQn = 68, /*!< External bus interface interrupt */ + #endif + #if defined(USE_HT32F12365_66) || defined(USE_HT32F12364) + AES_IRQn = 69, /*!< AES interrupt */ + #endif +} IRQn_Type; + +#define MCTM0_IRQn MCTM0UP_IRQn +#define MCTM0_IRQHandler MCTM0UP_IRQHandler +#define MCTM1_IRQn MCTM1UP_IRQn +#define MCTM1_IRQHandler MCTM1UP_IRQHandler + + +/** + * @} + */ + +#include "core_cm3.h" /* Cortex-M3 processor and core peripherals */ +#include "system_ht32f1xxxx_01.h" /* HT32 system */ + + +/** @addtogroup Exported_Types + * @{ + */ + +typedef signed long long s64; +typedef signed int s32; +typedef signed short s16; +typedef signed char s8; + +typedef const s64 sc64; /*!< Read Only */ +typedef const s32 sc32; /*!< Read Only */ +typedef const s16 sc16; /*!< Read Only */ +typedef const s8 sc8; /*!< Read Only */ + +typedef __IO s64 vs64; +typedef __IO s32 vs32; +typedef __IO s16 vs16; +typedef __IO s8 vs8; + +typedef __I s64 vsc64; /*!< Read Only */ +typedef __I s32 vsc32; /*!< Read Only */ +typedef __I s16 vsc16; /*!< Read Only */ +typedef __I s8 vsc8; /*!< Read Only */ + +typedef unsigned long long u64; +typedef unsigned int u32; +typedef unsigned short u16; +typedef unsigned char u8; + +typedef const u64 uc64; /*!< Read Only */ +typedef const u32 uc32; /*!< Read Only */ +typedef const u16 uc16; /*!< Read Only */ +typedef const u8 uc8; /*!< Read Only */ + +typedef __IO u64 vu64; +typedef __IO u32 vu32; +typedef __IO u16 vu16; +typedef __IO u8 vu8; + +typedef __I u64 vuc64; /*!< Read Only */ +typedef __I u32 vuc32; /*!< Read Only */ +typedef __I u16 vuc16; /*!< Read Only */ +typedef __I u8 vuc8; /*!< Read Only */ + + +typedef enum {DISABLE = 0, ENABLE = !DISABLE} EventStatus, ControlStatus; + +#if !defined(bool) && !defined(__cplusplus) // user may already included or CPP +typedef enum {FALSE = 0, TRUE = !FALSE} bool; +#define false FALSE +#define true TRUE +#else +#define FALSE 0 +#define TRUE 1 +#endif + +typedef enum {RESET = 0, SET = !RESET} FlagStatus; + +typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus; + +/** + * @} + */ + +#if defined (__CC_ARM) + #define __ALIGN4 __align(4) +#elif defined (__ICCARM__) + #define __ALIGN4 _Pragma("data_alignment = 4") +#elif defined (__GNUC__) + #define __ALIGN4 __attribute__((aligned(4))) +#endif + +#if defined (__GNUC__) + #define __PACKED_H + #define __PACKED_F __attribute__ ((packed)) +#elif defined (__ICCARM__) || (__CC_ARM) + #define __PACKED_H __packed + #define __PACKED_F +#endif + +#if defined (__CC_ARM) +#pragma anon_unions +#endif + + +#define U8_MAX ((u8)255) +#define S8_MAX ((s8)127) +#define S8_MIN ((s8)-128) +#define U16_MAX ((u16)65535u) +#define S16_MAX ((s16)32767) +#define S16_MIN ((s16)-32768) +#define U32_MAX ((u32)4294967295uL) +#define S32_MAX ((s32)2147483647) +#define S32_MIN ((s32)-2147483648) + + +/** + * @brief Exported constants and macro + */ +#define IS_CONTROL_STATUS(STATUS) ((STATUS == DISABLE) || (STATUS == ENABLE)) + +#define wb(addr, value) (*((u8 volatile *) (addr)) = value) +#define rb(addr) (*((u8 volatile *) (addr))) +#define whw(addr, value) (*((u16 volatile *) (addr)) = value) +#define rhw(addr) (*((u16 volatile *) (addr))) +#define ww(addr, value) (*((u32 volatile *) (addr)) = value) +#define rw(addr) (*((u32 volatile *) (addr))) + + +#define ResetBit_BB(Addr, BitNumber) (*(vu32 *) ((Addr & 0xF0000000) + 0x02000000 + \ + ((Addr & 0xFFFFF) << 5) + (BitNumber << 2)) = 0) +#define SetBit_BB(Addr, BitNumber) (*(vu32 *) ((Addr & 0xF0000000) + 0x02000000 + \ + ((Addr & 0xFFFFF) << 5) + (BitNumber << 2)) = 1) +#define GetBit_BB(Addr, BitNumber) (*(vu32 *) ((Addr & 0xF0000000) + 0x02000000 + \ + ((Addr & 0xFFFFF) << 5) + (BitNumber << 2))) +#define BitBand(Addr, BitNumber) (*(vu32 *) ((Addr & 0xF0000000) + 0x02000000 + \ + ((Addr & 0xFFFFF) << 5) + (BitNumber << 2))) + +#define STRCAT2_(a, b) a##b +#define STRCAT2(a, b) STRCAT2_(a, b) +#define STRCAT3_(a, b, c) a##b##c +#define STRCAT3(a, b, c) STRCAT3_(a, b, c) + +#define IPN_NULL (0) +#define IPN_MCTM0 (0x4002C000) +#define IPN_MCTM1 (0x4002D000) +#define IPN_GPTM0 (0x4006E000) +#define IPN_GPTM1 (0x4006F000) +#define IPN_CHECK(IP) STRCAT2(IPN_, IP) +#define IS_IPN_MCTM(IP) (IPN_CHECK(IP) == IPN_MCTM0) || (IPN_CHECK(IP) == IPN_MCTM1) +#define IS_IPN_GPTM(IP) (IPN_CHECK(IP) == IPN_GPTM0) || (IPN_CHECK(IP) == IPN_GPTM1) + + +/** @addtogroup Peripheral_Registers_Structures + * @{ + */ + + +/** + * @brief Universal Synchronous Asynchronous Receiver Transmitter + */ +typedef struct +{ + /* USART0: 0x40000000 */ + /* USART1: 0x40040000 */ + /* UART0: 0x40001000 */ + /* UART1: 0x40041000 */ + #if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) + union { + __IO uint32_t DR; /*!< 0x000 Data Register */ + __IO uint32_t RBR; /*!< 0x000 Receive Buffer Register */ + __IO uint32_t TBR; /*!< 0x000 Transmit Holding Register */ + }; + __IO uint32_t IER; /*!< 0x004 Interrupt Enable Register */ + __IO uint32_t IIR; /*!< 0x008 Interrupt Identification Register/FIFO Control Register */ + __IO uint32_t FCR; /*!< 0x00C FIFO Control Register */ + __IO uint32_t LCR; /*!< 0x010 Line Control Register */ + __IO uint32_t MCR; /*!< 0x014 Modem Control Register */ + union { + __IO uint32_t LSR; /*!< 0x018 Line Status Register */ + __IO uint32_t SR; /*!< 0x018 Line Status Register */ + }; + __IO uint32_t MSR; /*!< 0x01C Modem Status Register */ + __IO uint32_t TPR; /*!< 0x020 Timing Parameter Register */ + __IO uint32_t MDR; /*!< 0x024 Mode Register */ + __IO uint32_t ICR; /*!< 0x028 IrDA Register */ + __IO uint32_t RCR; /*!< 0x02C RS485 Control Register */ + __IO uint32_t SCR; /*!< 0x030 Synchronous Control Register */ + __IO uint32_t FSR; /*!< 0x034 FIFO Status Register */ + __IO uint32_t DLR; /*!< 0x038 Divisor Latch Register */ + __IO uint32_t DTR; /*!< 0x040 Debug/Test Register */ + #else + __IO uint32_t DR; /*!< 0x000 Data Register */ + __IO uint32_t CR; /*!< 0x004 Control Register */ + __IO uint32_t FCR; /*!< 0x008 FIFO Control Register */ + __IO uint32_t IER; /*!< 0x00C Interrupt Enable Register */ + __IO uint32_t SR; /*!< 0x010 Status Register */ + __IO uint32_t TPR; /*!< 0x014 Timing Parameter Register */ + __IO uint32_t ICR; /*!< 0x018 IrDA COntrol Register */ + __IO uint32_t RCR; /*!< 0x01C RS485 Control Register */ + __IO uint32_t SCR; /*!< 0x020 Synchronous Control Register */ + __IO uint32_t DLR; /*!< 0x024 Divisor Latch Register */ + __IO uint32_t DTR; /*!< 0x028 Debug/Test Register */ + #endif +} HT_USART_TypeDef; + + +/** + * @brief SPI + */ +typedef struct +{ + /* SPI0: 0x40004000 */ + /* SPI1: 0x40044000 */ + __IO uint32_t CR0; /*!< 0x000 Control Register 0 */ + __IO uint32_t CR1; /*!< 0x004 Control Register 1 */ + __IO uint32_t IER; /*!< 0x008 Interrupt Enable Register */ + __IO uint32_t CPR; /*!< 0x00C Clock Prescaler Register */ + __IO uint32_t DR; /*!< 0x010 Data Register */ + __IO uint32_t SR; /*!< 0x014 Status Register */ + __IO uint32_t FCR; /*!< 0x018 FIFO Control Register */ + __IO uint32_t FSR; /*!< 0x01C FIFO Status Register */ + __IO uint32_t FTOCR; /*!< 0x020 FIFO Time Out Counter Register */ +} HT_SPI_TypeDef; + + +/** + * @brief Analog to Digital Converter + */ +typedef struct +{ + /* ADC: 0x40010000 */ +#if defined(USE_HT32F12364) + __IO uint32_t CR; /*!< 0x000 ADC Conversion Control Register */ + __IO uint32_t LST[2]; /*!< 0x004 - 0x008 ADC Conversion List Register 0-1 */ + uint32_t RESERVE0[5]; /*!< 0x00C - 0x01C Reserved */ + __IO uint32_t STR; /*!< 0x020 ADC Input Sampling Time Register */ + uint32_t RESERVE1[3]; /*!< 0x024 - 0x02C Reserved */ + __IO uint32_t DR[8]; /*!< 0x030 - 0x04C ADC Conversion Data Register 0-7 */ + uint32_t RESERVE2[8]; /*!< 0x050 - 0x06C Reserved */ + __IO uint32_t TCR; /*!< 0x070 ADC Trigger Control Register */ + __IO uint32_t TSR; /*!< 0x074 ADC Trigger Source Register */ + __IO uint32_t WCR; /*!< 0x078 ADC Watchdog Control Register */ + __IO uint32_t WTR; /*!< 0x07C ADC Watchdog Threshold Register */ + __IO uint32_t IER; /*!< 0x080 ADC Interrupt Enable Register */ + __IO uint32_t IRAW; /*!< 0x084 ADC Interrupt Raw Status Register */ + __IO uint32_t ISR; /*!< 0x088 ADC Interrupt Status Register */ + __IO uint32_t ICLR; /*!< 0x08C ADC Interrupt Clear Register */ + __IO uint32_t PDMAR; /*!< 0x090 ADC PDMA Request Register */ + uint32_t RESERVE3[3]; /*!< 0x094 - 0x09C Reserved */ + __IO uint32_t VREFCR; /*!< 0x0A0 ADC Reference Voltage Control Register */ + __IO uint32_t VREFVALR; /*!< 0x0A4 ADC Reference Voltage Value Register */ +#else + uint32_t RESERVE0[1]; /*!< 0x000 Reserved */ + __IO uint32_t RST; /*!< 0x004 ADC Reset Register */ + __IO uint32_t CONV; /*!< 0x008 ADC Regular Conversion Mode Register */ + __IO uint32_t HCONV; /*!< 0x00C ADC High-priority Conversion Mode Register */ + __IO uint32_t LST[4]; /*!< 0x010 - 0x01C ADC Regular Conversion List Register 0-3 */ + __IO uint32_t HLST; /*!< 0x020 ADC High-priority Conversion List Register */ + uint32_t RESERVE1[3]; /*!< 0x024 - 0x02C Reserved */ + __IO uint32_t OFR[16]; /*!< 0x030 - 0x06C ADC Input Offset Register 0-15 */ + __IO uint32_t STR[16]; /*!< 0x070 - 0x0AC ADC Input Sampling Time Register 0-15 */ + __IO uint32_t DR[16]; /*!< 0x0B0 - 0x0EC ADC Regular Conversion Data Register 0-15 */ + __IO uint32_t HDR[4]; /*!< 0x0F0 - 0x0FC ADC High-priority Conversion Data Register 0-3 */ + __IO uint32_t TCR; /*!< 0x100 ADC Regular Trigger Control Register */ + __IO uint32_t TSR; /*!< 0x104 ADC Regular Trigger Source Register */ + uint32_t RESERVE2[2]; /*!< 0x108 - 0x10C Reserved */ + __IO uint32_t HTCR; /*!< 0x110 ADC High-priority Trigger Control Register */ + __IO uint32_t HTSR; /*!< 0x114 ADC High-priority Trigger Source Register */ + uint32_t RESERVE3[2]; /*!< 0x118 - 0x11C Reserved */ + __IO uint32_t WCR; /*!< 0x120 ADC Watchdog Control Register */ + __IO uint32_t LTR; /*!< 0x124 ADC Lower Threshold Register */ + __IO uint32_t UTR; /*!< 0x128 ADC Upper Threshold Register */ + uint32_t RESERVE4[1]; /*!< 0x12C Reserved */ + __IO uint32_t IER; /*!< 0x130 ADC Interrupt Enable Register */ + __IO uint32_t IRAW; /*!< 0x134 ADC Interrupt Raw Status Register */ + __IO uint32_t ISR; /*!< 0x138 ADC Interrupt Status Register */ + __IO uint32_t ICLR; /*!< 0x13C ADC Interrupt Clear Register */ + __IO uint32_t PDMAR; /*!< 0x140 ADC PDMA Request Register */ +#endif +} HT_ADC_TypeDef; + + +/** + * @brief Op Amp/Comparator + */ +typedef struct +{ + /* CMP_OP0: 0x40018000 */ + /* CMP_OP1: 0x40018100 */ + __IO uint32_t OPACR; /*!< 0x000 Operational Amplifier control register */ + __IO uint32_t OFVCR; /*!< 0x004 Comparator input offset voltage cancellation register */ + __IO uint32_t CMPIER; /*!< 0x008 Comparator interrupt enable register */ + __IO uint32_t CMPRSR; /*!< 0x00C Comparator raw status register */ + __IO uint32_t CMPISR; /*!< 0x010 Comparator interrupt status register */ + __IO uint32_t CMPICLR; /*!< 0x014 Comparator interrupt clear register */ +} HT_CMP_OP_TypeDef; + +/** + * @brief Comparator + */ +typedef struct +{ + /* CMP0: 0x40058000 */ + /* CMP1: 0x40058100 */ + __IO uint32_t CR; /*!< 0x000 Comparator Control Register */ + __IO uint32_t VALR; /*!< 0x004 Comparator Voltage Reference Value Register */ + __IO uint32_t IER; /*!< 0x008 Comparator Interrupt Enable Register */ + __IO uint32_t TFR; /*!< 0x00C Comparator Transition Flag Register */ +} HT_CMP_TypeDef; + + +/** + * @brief General Purpose I/O + */ +typedef struct +{ + /* GPIOA: 0x400B0000 */ + /* GPIOB: 0x400B2000 */ + /* GPIOC: 0x400B4000 */ + /* GPIOD: 0x400B6000 */ + /* GPIOE: 0x400B8000 */ + /* GPIOF: 0x400BA000 */ + __IO uint32_t DIRCR; /*!< 0x000 Data Direction Control Register */ + __IO uint32_t INER; /*!< 0x004 Input function enable register */ + __IO uint32_t PUR; /*!< 0x008 Pull-Up Selection Register */ + __IO uint32_t PDR; /*!< 0x00C Pull-Down Selection Register */ + __IO uint32_t ODR; /*!< 0x010 Open Drain Selection Register */ + __IO uint32_t DRVR; /*!< 0x014 Drive Current Selection Register */ + __IO uint32_t LOCKR; /*!< 0x018 Lock Register */ + __IO uint32_t DINR; /*!< 0x01c Data Input Register */ + __IO uint32_t DOUTR; /*!< 0x020 Data Output Register */ + __IO uint32_t SRR; /*!< 0x024 Output Set and Reset Control Register */ + __IO uint32_t RR; /*!< 0x028 Output Reset Control Register */ +} HT_GPIO_TypeDef; + + +/** + * @brief AFIO + */ +typedef struct +{ + /* AFIO: 0x40022000 */ + __IO uint32_t ESSR[2]; /*!< 0x000 EXTI Source Selection Register 0 ~ 1 */ + uint32_t RESERVE0[6]; /*!< 0x008 - 0x01C Reserved */ + __IO uint32_t GPACFGR[2]; /*!< 0x020 GPIO Port A Configuration Register 0 ~ 1 */ + __IO uint32_t GPBCFGR[2]; /*!< 0x028 GPIO Port B Configuration Register 0 ~ 1 */ + __IO uint32_t GPCCFGR[2]; /*!< 0x030 GPIO Port C Configuration Register 0 ~ 1 */ + __IO uint32_t GPDCFGR[2]; /*!< 0x038 GPIO Port D Configuration Register 0 ~ 1 */ +#if defined(USE_HT32F1655_56) || defined(USE_HT32F12365_66) + __IO uint32_t GPECFGR[2]; /*!< 0x040 GPIO Port E Configuration Register 0 ~ 1 */ +#else + uint32_t RESERVE1[2]; /*!< 0x040 - 0x044 Reserved */ +#endif +#if defined(USE_HT32F12364) + __IO uint32_t GPECFGR[2]; /*!< 0x048 GPIO Port F Configuration Register 0 ~ 1 */ +#endif +} HT_AFIO_TypeDef; + + +/** + * @brief External Interrupt/Event Controller + */ +typedef struct +{ + /* EXTI: 0x40024000 */ + __IO uint32_t CFGR0; /*!< 0x000 EXTI Interrupt 0 Configuration Register */ + __IO uint32_t CFGR1; /*!< 0x004 EXTI Interrupt 1 Configuration Register */ + __IO uint32_t CFGR2; /*!< 0x008 EXTI Interrupt 2 Configuration Register */ + __IO uint32_t CFGR3; /*!< 0x00C EXTI Interrupt 3 Configuration Register */ + __IO uint32_t CFGR4; /*!< 0x010 EXTI Interrupt 4 Configuration Register */ + __IO uint32_t CFGR5; /*!< 0x014 EXTI Interrupt 5 Configuration Register */ + __IO uint32_t CFGR6; /*!< 0x018 EXTI Interrupt 6 Configuration Register */ + __IO uint32_t CFGR7; /*!< 0x01C EXTI Interrupt 7 Configuration Register */ + __IO uint32_t CFGR8; /*!< 0x020 EXTI Interrupt 8 Configuration Register */ + __IO uint32_t CFGR9; /*!< 0x024 EXTI Interrupt 9 Configuration Register */ + __IO uint32_t CFGR10; /*!< 0x028 EXTI Interrupt 10 Configuration Register */ + __IO uint32_t CFGR11; /*!< 0x02C EXTI Interrupt 11 Configuration Register */ + __IO uint32_t CFGR12; /*!< 0x030 EXTI Interrupt 12 Configuration Register */ + __IO uint32_t CFGR13; /*!< 0x034 EXTI Interrupt 13 Configuration Register */ + __IO uint32_t CFGR14; /*!< 0x038 EXTI Interrupt 14 Configuration Register */ + __IO uint32_t CFGR15; /*!< 0x03C EXTI Interrupt 15 Configuration Register */ + __IO uint32_t CR; /*!< 0x040 EXTI Interrupt Control Register */ + __IO uint32_t EDGEFLGR; /*!< 0x044 EXTI Interrupt Edge Flag Register */ + __IO uint32_t EDGESR; /*!< 0x048 EXTI Interrupt Edge Status Register */ + __IO uint32_t SSCR; /*!< 0x04C EXTI Interrupt Software Set Command Register */ + __IO uint32_t WAKUPCR; /*!< 0x050 EXTI Interrupt Wakeup Control Register */ + __IO uint32_t WAKUPPOLR; /*!< 0x054 EXTI Interrupt Wakeup Polarity Register */ + __IO uint32_t WAKUPFLG; /*!< 0x058 EXTI Interrupt Wakeup Flag Register */ +} HT_EXTI_TypeDef; + + +/** + * @brief Inter-integrated Circuit Interface + */ +typedef struct +{ + /* I2C0: 0x40048000 */ + /* I2C1: 0x40049000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t IER; /*!< 0x004 Interrupt Enable Register */ + __IO uint32_t ADDR; /*!< 0x008 Address Register */ + __IO uint32_t SR; /*!< 0x00C Status Register */ + __IO uint32_t SHPGR; /*!< 0x010 SCL High Period Generation Register */ + __IO uint32_t SLPGR; /*!< 0x014 SCL Low Period Generation Register */ + __IO uint32_t DR; /*!< 0x018 Data Register */ + __IO uint32_t TAR; /*!< 0x01C Target Register */ + __IO uint32_t ADDMR; /*!< 0x020 Address Mask Register */ + __IO uint32_t ADDSR; /*!< 0x024 Address Snoop Register */ + __IO uint32_t TOUT; /*!< 0x028 Timeout Register */ +} HT_I2C_TypeDef; + + +/** + * @brief WATCHDOG + */ +typedef struct +{ + /* WDT: 0x40068000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t MR0; /*!< 0x004 Mode 0 Register */ + __IO uint32_t MR1; /*!< 0x008 Mode 1 Register */ + __IO uint32_t SR; /*!< 0x00C Status Register */ + __IO uint32_t PR; /*!< 0x010 Write Protect Register */ +#if defined(USE_HT32F1655_56) + __IO uint32_t CNTR; /*!< 0x014 Counter Register */ +#else + uint32_t RESERVED0[1]; /*!< 0x014 Reserved */ +#endif + __IO uint32_t CSR; /*!< 0x018 Clock Selection Register */ +} HT_WDT_TypeDef; + + +/** + * @brief Real-Time Clock + */ +typedef struct +{ + /* RTC: 0x4006A000 */ + __IO uint32_t CNT; /*!< 0x000 RTC Counter Register */ + __IO uint32_t CMP; /*!< 0x004 RTC Compare Register */ + __IO uint32_t CR; /*!< 0x008 RTC Control Register */ + __IO uint32_t SR; /*!< 0x00C RTC Status Register */ + __IO uint32_t IWEN; /*!< 0x010 RTC Interrupt/Wake-up Enable Register */ +} HT_RTC_TypeDef; + + +/** + * @brief Power Control Unit + */ +typedef struct +{ + /* PWRCU: 0x4006A100 */ + __IO uint32_t SR; /*!< 0x000 Status Register */ + __IO uint32_t CR; /*!< 0x004 Control Register */ + __IO uint32_t TEST; /*!< 0x008 Test Register */ + __IO uint32_t HSIRCR; /*!< 0x00C HSI Ready Counter Control Register */ + __IO uint32_t LVDCSR; /*!< 0x010 Low Voltage/Brown Out Detect Control and Status Register*/ + uint32_t RESERVE1[59]; /*!< 0x014 ~ 0x0FC Reserved */ +#if !defined(USE_HT32F12364) + __IO uint32_t BAKREG[10]; /*!< 0x100 ~ 0x124 Backup Register 0 ~ 9 */ +#endif +} HT_PWRCU_TypeDef; + + +#if 0 +/** + * @brief General-Purpose Timer + */ +typedef struct +{ + /* GPTM0: 0x4006E000 */ + /* GPTM1: 0x4006F000 */ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[3]; /*!< 0x014 - 0x01C Reserved */ + __IO uint32_t CH0ICFR; /*!< 0x020 Channel-0 Input Configuration Register */ + __IO uint32_t CH1ICFR; /*!< 0x024 Channel-1 Input Configuration Register */ + __IO uint32_t CH2ICFR; /*!< 0x028 Channel-2 Input Configuration Register */ + __IO uint32_t CH3ICFR; /*!< 0x02C Channel-3 Input Configuration Register */ + uint32_t RESERVED2[4]; /*!< 0x030 - 0x03C Reserved */ + __IO uint32_t CH0OCFR; /*!< 0x040 Channel-0 Output Configuration Register */ + __IO uint32_t CH1OCFR; /*!< 0x044 Channel-1 Output Configuration Register */ + __IO uint32_t CH2OCFR; /*!< 0x048 Channel-2 Output Configuration Register */ + __IO uint32_t CH3OCFR; /*!< 0x04C Channel-3 Output Configuration Register */ + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED3[7]; /*!< 0x058 - 0x070 Reserved */ + __IO uint32_t DICTR; /*!< 0x074 DMA / Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + uint32_t RESERVED4[1]; /*!< 0x08C Reserved */ + __IO uint32_t CH0CCR; /*!< 0x090 Channel 0 Capture/Compare Register */ + __IO uint32_t CH1CCR; /*!< 0x094 Channel 1 Capture/Compare Register */ + __IO uint32_t CH2CCR; /*!< 0x098 Channel 2 Capture/Compare Register */ + __IO uint32_t CH3CCR; /*!< 0x09C Channel 3 Capture/Compare Register */ + __IO uint32_t CH0ACR; /*!< 0x0A0 Channel 0 Asymmetric Compare Register */ + __IO uint32_t CH1ACR; /*!< 0x0A4 Channel 1 Asymmetric Compare Register */ + __IO uint32_t CH2ACR; /*!< 0x0A8 Channel 2 Asymmetric Compare Register */ + __IO uint32_t CH3ACR; /*!< 0x0AC Channel 3 Asymmetric Compare Register */ +} HT_GPTM_TypeDef; +#endif + + +/** + * @brief Flash Memory Controller + */ +typedef struct +{ + /* FLASH: 0x40080000 */ + __IO uint32_t TADR; /*!< 0x000 Flash Target Address Register */ + __IO uint32_t WRDR; /*!< 0x004 Flash Write Data Register */ + uint32_t RESERVED0[1]; /*!< 0x008 Reserved */ + __IO uint32_t OCMR; /*!< 0x00C Flash Operation Command Register */ + __IO uint32_t OPCR; /*!< 0x010 Flash Operation Control Register */ + __IO uint32_t OIER; /*!< 0x014 Flash Operation Interrupt Enable Register */ + __IO uint32_t OISR; /*!< 0x018 Flash Operation Interrupt and Status Register */ + uint32_t RESERVED1[1]; /*!< 0x01C Reserved */ + __IO uint32_t PPSR[4]; /*!< 0x020 ~ 0x02C Flash Page Erase/Program Protection Status Register */ + __IO uint32_t CPSR; /*!< 0x030 Flash Security Protection Status Register */ + uint32_t RESERVED2[51]; /*!< 0x034 ~ 0x0FC Reserved */ + __IO uint32_t VMCR; /*!< 0x100 Flash Vector Mapping Control Register */ + uint32_t RESERVED3[31]; /*!< 0x104 ~ 0x17C Reserved */ + __IO uint32_t MDID; /*!< 0x180 Manufacturer and Device ID Register */ + __IO uint32_t PNSR; /*!< 0x184 Flash Page Number Status Register */ + __IO uint32_t PSSR; /*!< 0x188 Flash Page Size Status Register */ +#if defined(USE_HT32F1653_54) | defined(USE_HT32F1655_56) + uint32_t RESERVED4[29]; /*!< 0x18C ~ 0x1FC Reserved */ +#else + __IO uint32_t DID; /*!< 0x18C Device ID Register */ + uint32_t RESERVED4[28]; /*!< 0x190 ~ 0x1FC Reserved */ +#endif + __IO uint32_t CFCR; /*!< 0x200 Flash Cache and Pre-fetch Control Register */ + uint32_t RESERVED5[63]; /*!< 0x204 ~ 0x2FC Reserved */ + __IO uint32_t SBVT[4]; /*!< 0x300 ~ 0x30C SRAM Booting Vector (4x32Bit) */ +#if defined(USE_HT32F1653_54) | defined(USE_HT32F1655_56) +#else + __IO uint32_t CID[4]; /*!< 0x310 ~ 0x31C Custom ID Register */ +#endif +} HT_FLASH_TypeDef; + + +/** + * @brief Clock Control Unit + */ +typedef struct +{ + /* CKCU: 0x40088000 */ + __IO uint32_t GCFGR; /*!< 0x000 Global Clock Configuration Register */ + __IO uint32_t GCCR; /*!< 0x004 Global Clock Control Register */ + __IO uint32_t GCSR; /*!< 0x008 Global Clock Status Register */ + __IO uint32_t GCIR; /*!< 0x00C Global Clock Interrupt Register */ + uint32_t RESERVED0[2]; /*!< 0x010 ~ 0x14 Reserved */ + __IO uint32_t PLLCFGR; /*!< 0x018 PLL Configuration Register */ + __IO uint32_t PLLCR; /*!< 0x01C PLL Control Register */ + __IO uint32_t AHBCFGR; /*!< 0x020 AHB Configuration Register */ + __IO uint32_t AHBCCR; /*!< 0x024 AHB Clock Control Register */ + __IO uint32_t APBCFGR; /*!< 0x028 APB Configuration Register */ + __IO uint32_t APBCCR0; /*!< 0x02C APB Clock Control Register 0 */ + __IO uint32_t APBCCR1; /*!< 0x030 APB Clock Control Register 1 */ + __IO uint32_t CKST; /*!< 0x034 Clock source status Register */ +#if defined(USE_HT32F1655_56) + uint32_t RESERVED1[4]; /*!< 0x038 ~ 0x44 Reserved */ +#else + __IO uint32_t APBPCSR0; /*!< 0x038 APB Peripheral Clock Selection Register 0 */ + __IO uint32_t APBPCSR1; /*!< 0x03C APB Peripheral Clock Selection Register 1 */ + __IO uint32_t HSICR; /*!< 0x040 HSI Control Register */ + __IO uint32_t HSIATCR; /*!< 0x044 HSI Auto Trimming Counter Register */ +#endif +#if defined(USE_HT32F12364) + __IO uint32_t APBPCSR2; /*!< 0x048 APB Peripheral Clock Selection Register 2 */ + uint32_t RESERVED2[173]; /*!< 0x04C ~ 0x2FC Reserved */ +#else + uint32_t RESERVED2[174]; /*!< 0x048 ~ 0x2FC Reserved */ +#endif + __IO uint32_t LPCR; /*!< 0x300 Low Power Control Register */ + __IO uint32_t MCUDBGCR; /*!< 0x304 MCU Debug Control Register */ +} HT_CKCU_TypeDef; + + +/** + * @brief Reset Control Unit + */ +typedef struct +{ + /* RSTCU: 0x40088100 */ + __IO uint32_t GRSR; /*!< 0x000 Global Reset Status Register */ + __IO uint32_t AHBPRST; /*!< 0x004 AHB Peripheral Reset Register */ + __IO uint32_t APBPRST0; /*!< 0x008 APB Peripheral Reset Register 0 */ + __IO uint32_t APBPRST1; /*!< 0x00C APB Peripheral Reset Register 1 */ +} HT_RSTCU_TypeDef; + + +/** + * @brief Smart Card Interface + */ +typedef struct +{ + /* SCI0: 0x40043000 */ + /* SCI1: 0x4003A000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t CCR; /*!< 0x008 Contact Control Register */ + __IO uint32_t ETU; /*!< 0x00C Elementary Time Unit Register */ + __IO uint32_t GT; /*!< 0x010 Guardtime Register */ + __IO uint32_t WT; /*!< 0x014 Waiting Time Register */ + __IO uint32_t IER; /*!< 0x018 Interrupt Enable Register */ + __IO uint32_t IPR; /*!< 0x01C Interrupt Pending Register */ + __IO uint32_t TXB; /*!< 0x020 Transmit Buffer Register */ + __IO uint32_t RXB; /*!< 0x024 Receive Buffer Register */ + __IO uint32_t PSC; /*!< 0x028 Prescaler Register */ +} HT_SCI_TypeDef; + + +/** + * @brief Basic Function Timer + */ +typedef struct +{ + /* BFTM0: 0x40076000 */ + /* BFTM1: 0x40077000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t CNTR; /*!< 0x008 Counter Value Register */ + __IO uint32_t CMP; /*!< 0x00C Compare Value Register */ +} HT_BFTM_TypeDef; + + +#if 0 +/** + * @brief Motor Control Timer + */ +typedef struct +{ + /* MCTM0: 0x4002C000 */ + /* MCTM1: 0x4002D000 */ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[3]; /*!< 0x014 - 0x01C Reserved */ + __IO uint32_t CH0ICFR; /*!< 0x020 Channel-0 Input Configuration Register */ + __IO uint32_t CH1ICFR; /*!< 0x024 Channel-1 Input Configuration Register */ + __IO uint32_t CH2ICFR; /*!< 0x028 Channel-2 Input Configuration Register */ + __IO uint32_t CH3ICFR; /*!< 0x02C Channel-3 Input Configuration Register */ + uint32_t RESERVED2[4]; /*!< 0x030 - 0x03C Reserved */ + __IO uint32_t CH0OCFR; /*!< 0x040 Channel-0 Output Configuration Register */ + __IO uint32_t CH1OCFR; /*!< 0x044 Channel-1 Output Configuration Register */ + __IO uint32_t CH2OCFR; /*!< 0x048 Channel-2 Output Configuration Register */ + __IO uint32_t CH3OCFR; /*!< 0x04C Channel-3 Output Configuration Register */ + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED3[5]; /*!< 0x058 - 0x068 Reserved */ + __IO uint32_t CHBRKCFR; /*!< 0x06C Channel Break Configuration Register */ + __IO uint32_t CHBRKCTR; /*!< 0x070 Channel Break Control Register */ + __IO uint32_t DICTR; /*!< 0x074 DMA / Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + __IO uint32_t REPR; /*!< 0x08C Repetition Register */ + __IO uint32_t CH0CCR; /*!< 0x090 Channel 0 Capture/Compare Register */ + __IO uint32_t CH1CCR; /*!< 0x094 Channel 1 Capture/Compare Register */ + __IO uint32_t CH2CCR; /*!< 0x098 Channel 2 Capture/Compare Register */ + __IO uint32_t CH3CCR; /*!< 0x09C Channel 3 Capture/Compare Register */ + __IO uint32_t CH0ACR; /*!< 0x0A0 Channel 0 Asymmetric Compare Register */ + __IO uint32_t CH1ACR; /*!< 0x0A4 Channel 1 Asymmetric Compare Register */ + __IO uint32_t CH2ACR; /*!< 0x0A8 Channel 2 Asymmetric Compare Register */ + __IO uint32_t CH3ACR; /*!< 0x0AC Channel 3 Asymmetric Compare Register */ +} HT_MCTM_TypeDef; +#endif + + +/** + * @brief Timer + */ +typedef struct +{ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[3]; /*!< 0x014 - 0x01C Reserved */ + __IO uint32_t CH0ICFR; /*!< 0x020 Channel-0 Input Configuration Register */ + __IO uint32_t CH1ICFR; /*!< 0x024 Channel-1 Input Configuration Register */ + __IO uint32_t CH2ICFR; /*!< 0x028 Channel-2 Input Configuration Register */ + __IO uint32_t CH3ICFR; /*!< 0x02C Channel-3 Input Configuration Register */ + uint32_t RESERVED2[4]; /*!< 0x030 - 0x03C Reserved */ + __IO uint32_t CH0OCFR; /*!< 0x040 Channel-0 Output Configuration Register */ + __IO uint32_t CH1OCFR; /*!< 0x044 Channel-1 Output Configuration Register */ + __IO uint32_t CH2OCFR; /*!< 0x048 Channel-2 Output Configuration Register */ + __IO uint32_t CH3OCFR; /*!< 0x04C Channel-3 Output Configuration Register */ + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED3[5]; /*!< 0x058 - 0x068 Reserved */ + __IO uint32_t CHBRKCFR; /*!< 0x06C Channel Break Configuration Register */ + __IO uint32_t CHBRKCTR; /*!< 0x070 Channel Break Control Register */ + __IO uint32_t DICTR; /*!< 0x074 DMA / Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + __IO uint32_t REPR; /*!< 0x08C Repetition Register */ + __IO uint32_t CH0CCR; /*!< 0x090 Channel 0 Capture/Compare Register */ + __IO uint32_t CH1CCR; /*!< 0x094 Channel 1 Capture/Compare Register */ + __IO uint32_t CH2CCR; /*!< 0x098 Channel 2 Capture/Compare Register */ + __IO uint32_t CH3CCR; /*!< 0x09C Channel 3 Capture/Compare Register */ + __IO uint32_t CH0ACR; /*!< 0x0A0 Channel 0 Asymmetric Compare Register */ + __IO uint32_t CH1ACR; /*!< 0x0A4 Channel 1 Asymmetric Compare Register */ + __IO uint32_t CH2ACR; /*!< 0x0A8 Channel 2 Asymmetric Compare Register */ + __IO uint32_t CH3ACR; /*!< 0x0AC Channel 3 Asymmetric Compare Register */ +} HT_TM_TypeDef; + + +/** + * @brief Peripheral Direct Memory Access Channel + */ +typedef struct +{ + __IO uint32_t CR; /*!< 0x000 PDMA Channel Control Register */ + __IO uint32_t SADR; /*!< 0x004 PDMA Channel Source Address Register */ + __IO uint32_t DADR; /*!< 0x008 PDMA Channel Destination Address Register */ +#if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) + __IO uint32_t CADR; /*!< 0x00C PDMA Channel Current Address Register */ +#else + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ +#endif + __IO uint32_t TSR; /*!< 0x010 PDMA Channel Transfer Size Register */ + __IO uint32_t CTSR; /*!< 0x014 PDMA Channel Current Transfer Size Register */ +} HT_PDMACH_TypeDef; + + +/** + * @brief Peripheral Direct Memory Access Global + */ +typedef struct +{ + /* PDMA: 0x40090000 */ + HT_PDMACH_TypeDef PDMACH0; /*!< 0x000 PDMA channel 0 registers */ + HT_PDMACH_TypeDef PDMACH1; /*!< 0x018 PDMA channel 1 registers */ + HT_PDMACH_TypeDef PDMACH2; /*!< 0x030 PDMA channel 2 registers */ + HT_PDMACH_TypeDef PDMACH3; /*!< 0x048 PDMA channel 3 registers */ + HT_PDMACH_TypeDef PDMACH4; /*!< 0x060 PDMA channel 4 registers */ + HT_PDMACH_TypeDef PDMACH5; /*!< 0x078 PDMA channel 5 registers */ +#if !defined(USE_HT32F12364) + HT_PDMACH_TypeDef PDMACH6; /*!< 0x090 PDMA channel 6 registers */ + HT_PDMACH_TypeDef PDMACH7; /*!< 0x0A8 PDMA channel 7 registers */ +#endif +#if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) + uint32_t RESERVED0[24];/*!< 0x0C0 - 0x011C Reserved */ +#elif defined(USE_HT32F12365_66) || defined(USE_HT32F12345) + HT_PDMACH_TypeDef PDMACH8; /*!< 0x0C0 PDMA channel 8 registers */ + HT_PDMACH_TypeDef PDMACH9; /*!< 0x0D8 PDMA channel 9 registers */ + HT_PDMACH_TypeDef PDMACH10; /*!< 0x0F0 PDMA channel 10 registers */ + HT_PDMACH_TypeDef PDMACH11; /*!< 0x108 PDMA channel 11 registers */ +#elif defined(USE_HT32F12364) + uint32_t RESERVED0[36];/*!< 0x090 - 0x11C Reserved */ +#endif + __IO uint32_t ISR0; /*!< 0x120 PDMA Interrupt Status Register 0 */ +#if !defined(USE_HT32F12364) + __IO uint32_t ISR1; /*!< 0x124 PDMA Interrupt Status Register 1 */ +#else + uint32_t RESERVED1[1]; /*!< 0x124 Reserved */ +#endif + __IO uint32_t ISCR0; /*!< 0x128 PDMA Interrupt Status Clear Register 0 */ +#if !defined(USE_HT32F12364) + __IO uint32_t ISCR1; /*!< 0x12C PDMA Interrupt Status Clear Register 1 */ +#else + uint32_t RESERVED2[1]; /*!< 0x12C Reserved */ +#endif + __IO uint32_t IER0; /*!< 0x130 PDMA Interrupt Enable Register 0 */ +#if !defined(USE_HT32F12364) + __IO uint32_t IER1; /*!< 0x134 PDMA Interrupt Enable Register 1 */ +#endif +} HT_PDMA_TypeDef; + + +/** + * @brief Universal Serial Bus Global + */ +typedef struct +{ + /* USB: 0x400A8000 */ + __IO uint32_t CSR; /*!< 0x000 USB Control and Status Register */ + __IO uint32_t IER; /*!< 0x004 USB Interrupt Enable Register */ + __IO uint32_t ISR; /*!< 0x008 USB Interrupt Status Register */ + __IO uint32_t FCR; /*!< 0x00C USB Frame Count Register */ + __IO uint32_t DEVAR; /*!< 0x010 USB Device Address Register */ + __IO uint32_t EP0CSR; /*!< 0x014 USB Endpoint 0 Control and Status Register */ + __IO uint32_t EP0IER; /*!< 0x018 USB Endpoint 0 Interrupt Enable Register */ + __IO uint32_t EP0ISR; /*!< 0x01C USB Endpoint 0 Interrupt Status Register */ + __IO uint32_t EP0TCR; /*!< 0x020 USB Endpoint 0 Transfer Count Register */ + __IO uint32_t EP0CFGR; /*!< 0x024 USB Endpoint 0 Configuration Register */ + __IO uint32_t EP1CSR; /*!< 0x028 USB Endpoint 1 Control and Status Register */ + __IO uint32_t EP1IER; /*!< 0x02C USB Endpoint 1 Interrupt Enable Register */ + __IO uint32_t EP1ISR; /*!< 0x030 USB Endpoint 1 Interrupt Status Register */ + __IO uint32_t EP1TCR; /*!< 0x034 USB Endpoint 1 Transfer Count Register */ + __IO uint32_t EP1CFGR; /*!< 0x038 USB Endpoint 1 Configuration Register */ + __IO uint32_t EP2CSR; /*!< 0x03C USB Endpoint 2 Control and Status Register */ + __IO uint32_t EP2IER; /*!< 0x040 USB Endpoint 2 Interrupt Enable Register */ + __IO uint32_t EP2ISR; /*!< 0x044 USB Endpoint 2 Interrupt Status Register */ + __IO uint32_t EP2TCR; /*!< 0x048 USB Endpoint 2 Transfer Count Register */ + __IO uint32_t EP2CFGR; /*!< 0x04C USB Endpoint 2 Configuration Register */ + __IO uint32_t EP3CSR; /*!< 0x050 USB Endpoint 3 Control and Status Register */ + __IO uint32_t EP3IER; /*!< 0x054 USB Endpoint 3 Interrupt Enable Register */ + __IO uint32_t EP3ISR; /*!< 0x058 USB Endpoint 3 Interrupt Status Register */ + __IO uint32_t EP3TCR; /*!< 0x05C USB Endpoint 3 Transfer Count Register */ + __IO uint32_t EP3CFGR; /*!< 0x060 USB Endpoint 3 Configuration Register */ + __IO uint32_t EP4CSR; /*!< 0x064 USB Endpoint 4 Control and Status Register */ + __IO uint32_t EP4IER; /*!< 0x068 USB Endpoint 4 Interrupt Enable Register */ + __IO uint32_t EP4ISR; /*!< 0x06C USB Endpoint 4 Interrupt Status Register */ + __IO uint32_t EP4TCR; /*!< 0x070 USB Endpoint 4 Transfer Count Register */ + __IO uint32_t EP4CFGR; /*!< 0x074 USB Endpoint 4 Configuration Register */ + __IO uint32_t EP5CSR; /*!< 0x078 USB Endpoint 5 Control and Status Register */ + __IO uint32_t EP5IER; /*!< 0x07C USB Endpoint 5 Interrupt Enable Register */ + __IO uint32_t EP5ISR; /*!< 0x080 USB Endpoint 5 Interrupt Status Register */ + __IO uint32_t EP5TCR; /*!< 0x084 USB Endpoint 5 Transfer Count Register */ + __IO uint32_t EP5CFGR; /*!< 0x088 USB Endpoint 5 Configuration Register */ + __IO uint32_t EP6CSR; /*!< 0x08C USB Endpoint 6 Control and Status Register */ + __IO uint32_t EP6IER; /*!< 0x090 USB Endpoint 6 Interrupt Enable Register */ + __IO uint32_t EP6ISR; /*!< 0x094 USB Endpoint 6 Interrupt Status Register */ + __IO uint32_t EP6TCR; /*!< 0x098 USB Endpoint 6 Transfer Count Register */ + __IO uint32_t EP6CFGR; /*!< 0x09C USB Endpoint 6 Configuration Register */ + __IO uint32_t EP7CSR; /*!< 0x0A0 USB Endpoint 7 Control and Status Register */ + __IO uint32_t EP7IER; /*!< 0x0A4 USB Endpoint 7 Interrupt Enable Register */ + __IO uint32_t EP7ISR; /*!< 0x0A8 USB Endpoint 7 Interrupt Status Register */ + __IO uint32_t EP7TCR; /*!< 0x0AC USB Endpoint 7 Transfer Count Register */ + __IO uint32_t EP7CFGR; /*!< 0x0B0 USB Endpoint 7 Configuration Register */ +} HT_USB_TypeDef; + + +/** + * @brief Universal Serial Bus Endpoint + */ +typedef struct +{ + /* USB Endpoint0: 0x400A8014 */ + /* USB Endpoint1: 0x400A8028 */ + /* USB Endpoint2: 0x400A803C */ + /* USB Endpoint3: 0x400A8050 */ + /* USB Endpoint4: 0x400A8064 */ + /* USB Endpoint5: 0x400A8078 */ + /* USB Endpoint6: 0x400A808C */ + /* USB Endpoint7: 0x400A80A0 */ + __IO uint32_t CSR; /*!< 0x000 USB Endpoint n Control and Status Register */ + __IO uint32_t IER; /*!< 0x004 USB Endpoint n Interrupt Enable Register */ + __IO uint32_t ISR; /*!< 0x008 USB Endpoint n Interrupt Status Register */ + __IO uint32_t TCR; /*!< 0x00C USB Endpoint n Transfer Count Register */ + __IO uint32_t CFGR; /*!< 0x010 USB Endpoint n Configuration Register */ +} HT_USBEP_TypeDef; + + +/** + * @brief External Bus Interface + */ +typedef struct +{ + /* EBI: 0x40098000 */ + __IO uint32_t CR; /*!< 0x000 EBI Control Register */ +#if !defined(USE_HT32F12364) + __IO uint32_t PCR; /*!< 0x004 EBI Page Control Register */ +#else + uint32_t RESERVED0[1]; /*!< 0x004 Reserved */ +#endif + __IO uint32_t SR; /*!< 0x008 EBI Status Register */ + uint32_t RESERVED1[1]; /*!< 0x00C Reserved */ + __IO uint32_t ATR0; /*!< 0x010 EBI Address Timing Register 0 */ + __IO uint32_t RTR0; /*!< 0x014 EBI Read Timing Register 0 */ + __IO uint32_t WTR0; /*!< 0x018 EBI Write Timing Register 0 */ + __IO uint32_t PR0; /*!< 0x01C EBI Parity Register 0 */ +#if !defined(USE_HT32F12364) + __IO uint32_t ATR1; /*!< 0x020 EBI Address Timing Register 1 */ + __IO uint32_t RTR1; /*!< 0x024 EBI Read Timing Register 1 */ + __IO uint32_t WTR1; /*!< 0x028 EBI Write Timing Register 1 */ + __IO uint32_t PR1; /*!< 0x02C EBI Parity Register 1 */ + __IO uint32_t ATR2; /*!< 0x030 EBI Address Timing Register 2 */ + __IO uint32_t RTR2; /*!< 0x034 EBI Read Timing Register 2 */ + __IO uint32_t WTR2; /*!< 0x038 EBI Write Timing Register 2 */ + __IO uint32_t PR2; /*!< 0x03C EBI Parity Register 2 */ + __IO uint32_t ATR3; /*!< 0x040 EBI Address Timing Register 3 */ + __IO uint32_t RTR3; /*!< 0x044 EBI Read Timing Register 3 */ + __IO uint32_t WTR3; /*!< 0x048 EBI Write Timing Register 3 */ + __IO uint32_t PR3; /*!< 0x04C EBI Parity Register 3 */ + __IO uint32_t IEN; /*!< 0x050 EBI Interrupt Enable Register */ + __IO uint32_t IF; /*!< 0x054 EBI Interrupt Flag Register */ + __IO uint32_t IFC; /*!< 0x058 EBI Interrupt Clear Register */ +#endif +} HT_EBI_TypeDef; + + +/** + * @brief Cyclic Redundancy Check + */ +typedef struct +{ + /* CRC: 0x4008A000 */ + __IO uint32_t CR; /*!< 0x000 CRC Control Register */ + __IO uint32_t SDR; /*!< 0x004 CRC Seed Register */ + __IO uint32_t CSR; /*!< 0x008 CRC Checksum Register */ + __IO uint32_t DR; /*!< 0x00C CRC Data Register */ +} HT_CRC_TypeDef; + + +/** + * @brief Integrated Interchip Sound + */ +typedef struct +{ + /* I2S: 0x40026000 */ + __IO uint32_t CR; /*!< 0x000 I2S Control Register */ + __IO uint32_t IER; /*!< 0x004 I2S Interrupt Enable Register */ + __IO uint32_t CDR; /*!< 0x008 I2S Clock Divider Register */ + __IO uint32_t TXDR; /*!< 0x00C I2S TX Data Register */ + __IO uint32_t RXDR; /*!< 0x010 I2S RX Data Register */ + __IO uint32_t FCR; /*!< 0x014 I2S FIFO Control Register */ + __IO uint32_t SR; /*!< 0x018 I2S Status Register */ + __IO uint32_t RCNTR; /*!< 0x01C I2S Rate Counter Register */ +} HT_I2S_TypeDef; + + +/** + * @brief Secure digital input/output + */ +typedef struct +{ + /* SDIO: 0x400A0000 */ + __IO uint32_t BLKSIZE; /*!< 0x000 Block Size Register */ + __IO uint32_t BLKCNT; /*!< 0x004 Block Count Register */ + __IO uint32_t ARG; /*!< 0x008 Argument Register */ + __IO uint32_t TMR; /*!< 0x00C Transfer Mode Register */ + __IO uint32_t CMD; /*!< 0x010 Command Register Register */ + __IO uint32_t RESP0; /*!< 0x014 Response Register 0 */ + __IO uint32_t RESP1; /*!< 0x018 Response Register 1 */ + __IO uint32_t RESP2; /*!< 0x01C Response Register 2 */ + __IO uint32_t RESP3; /*!< 0x020 Response Register 3 */ + __IO uint32_t DR; /*!< 0x024 Data Register */ + __IO uint32_t PSR; /*!< 0x028 Present Status Register */ + __IO uint32_t CR; /*!< 0x02C Control Register */ + uint32_t RESERVED0[2]; /*!< 0x030 - 0x034 Reserved */ + __IO uint32_t CLKCR; /*!< 0x038 Clock Control Register */ + __IO uint32_t TMOCR; /*!< 0x03C Timeout Control Register */ + __IO uint32_t SWRST; /*!< 0x040 Software Reset Register */ + __IO uint32_t SR; /*!< 0x044 Status Register */ + __IO uint32_t SER; /*!< 0x048 Status Enable Register */ + __IO uint32_t IER; /*!< 0x04C Interrupt Enable Register */ +} HT_SDIO_TypeDef; + + +/** + * @brief CMOS Sensor Interface + */ +typedef struct +{ + /* CSIF: 0x400CC000 */ + __IO uint32_t ENR; /*!< 0x000 Enable Register */ + __IO uint32_t CR; /*!< 0x004 Control Register */ + __IO uint32_t IMGWH; /*!< 0x008 Image Width/Height Register */ + __IO uint32_t WCR0; /*!< 0x00C Window Capture 0 Register */ + __IO uint32_t WCR1; /*!< 0x010 Window Capture 1 Register */ + __IO uint32_t SMP; /*!< 0x014 Row & Column Sub-Sample Register */ + __IO uint32_t SMPCOL; /*!< 0x018 Column Sub-Sample Register */ + __IO uint32_t SMPROW; /*!< 0x01C Row Sub-Sample Register */ + __IO uint32_t FIFO0; /*!< 0x020 FIFO Register 0 */ + __IO uint32_t FIFO1; /*!< 0x024 FIFO Register 1 */ + __IO uint32_t FIFO2; /*!< 0x028 FIFO Register 2 */ + __IO uint32_t FIFO3; /*!< 0x02C FIFO Register 3 */ + __IO uint32_t FIFO4; /*!< 0x030 FIFO Register 4 */ + __IO uint32_t FIFO5; /*!< 0x034 FIFO Register 5 */ + __IO uint32_t FIFO6; /*!< 0x038 FIFO Register 6 */ + __IO uint32_t FIFO7; /*!< 0x03C FIFO Register 7 */ + __IO uint32_t IER; /*!< 0x040 Interrupt Enable Register */ + __IO uint32_t SR; /*!< 0x044 Status Register */ +} HT_CSIF_TypeDef; + + +/** + * @brief Advanced Encryption Standard + */ +typedef struct +{ + /* AES: 0x400C8000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t PDMAR; /*!< 0x008 PDMA Register */ + __IO uint32_t ISR; /*!< 0x00C Interrupt Status Register */ + __IO uint32_t IER; /*!< 0x010 Interrupt Enable Register */ + __IO uint32_t DINR; /*!< 0x014 Data Input Register */ + __IO uint32_t DOUTR; /*!< 0x018 Data Output Register */ + __IO uint32_t KEYR[8]; /*!< 0x01C - 0x038 Key Register 0~7 */ + __IO uint32_t IVR[4]; /*!< 0x03C - 0x048 Initial Vector Register 0~3 */ +} HT_AES_TypeDef; + + +/** + * @} + */ + + +/** @addtogroup Peripheral_Memory_Map + * @{ + */ + +#define HT_SRAM_BASE (0x20000000UL) +#define HT_SRAM_BB_BASE (0x22000000UL) + +#define HT_PERIPH_BASE (0x40000000UL) +#define HT_PERIPH_BB_BASE (0x42000000UL) + +#define HT_APB0PERIPH_BASE (HT_PERIPH_BASE) /* 0x40000000 */ +#define HT_APB1PERIPH_BASE (HT_PERIPH_BASE + 0x40000) /* 0x40040000 */ +#define HT_AHBPERIPH_BASE (HT_PERIPH_BASE + 0x80000) /* 0x40080000 */ + +/* APB0 */ +#define HT_USART0_BASE (HT_APB0PERIPH_BASE + 0x0000) /* 0x40000000 */ +#define HT_UART0_BASE (HT_APB0PERIPH_BASE + 0x1000) /* 0x40001000 */ +#define HT_SPI0_BASE (HT_APB0PERIPH_BASE + 0x4000) /* 0x40004000 */ +#define HT_ADC0_BASE (HT_APB0PERIPH_BASE + 0x10000) /* 0x40010000 */ +#define HT_CMP_OP0_BASE (HT_APB0PERIPH_BASE + 0x18000) /* 0x40018000 */ +#define HT_CMP_OP1_BASE (HT_APB0PERIPH_BASE + 0x18100) /* 0x40018100 */ +#define HT_AFIO_BASE (HT_APB0PERIPH_BASE + 0x22000) /* 0x40022000 */ +#define HT_EXTI_BASE (HT_APB0PERIPH_BASE + 0x24000) /* 0x40024000 */ +#define HT_I2S_BASE (HT_APB0PERIPH_BASE + 0x26000) /* 0x40026000 */ +#define HT_MCTM0_BASE (HT_APB0PERIPH_BASE + 0x2C000) /* 0x4002C000 */ +#define HT_MCTM1_BASE (HT_APB0PERIPH_BASE + 0x2D000) /* 0x4002D000 */ +#define HT_PWM0_BASE (HT_APB0PERIPH_BASE + 0x31000) /* 0x40031000 */ +#define HT_SCTM0_BASE (HT_APB0PERIPH_BASE + 0x34000) /* 0x40034000 */ +#define HT_SCI1_BASE (HT_APB0PERIPH_BASE + 0x3A000) /* 0x4003A000 */ + +/* APB1 */ +#define HT_USART1_BASE (HT_APB1PERIPH_BASE + 0x0000) /* 0x40040000 */ +#define HT_UART1_BASE (HT_APB1PERIPH_BASE + 0x1000) /* 0x40041000 */ +#define HT_SCI0_BASE (HT_APB1PERIPH_BASE + 0x3000) /* 0x40043000 */ +#define HT_SPI1_BASE (HT_APB1PERIPH_BASE + 0x4000) /* 0x40044000 */ +#define HT_I2C0_BASE (HT_APB1PERIPH_BASE + 0x8000) /* 0x40048000 */ +#define HT_I2C1_BASE (HT_APB1PERIPH_BASE + 0x9000) /* 0x40049000 */ +#define HT_CMP0_BASE (HT_APB1PERIPH_BASE + 0x18000) /* 0x40058000 */ +#define HT_CMP1_BASE (HT_APB1PERIPH_BASE + 0x18100) /* 0x40058100 */ +#define HT_WDT_BASE (HT_APB1PERIPH_BASE + 0x28000) /* 0x40068000 */ +#define HT_RTC_BASE (HT_APB1PERIPH_BASE + 0x2A000) /* 0x4006A000 */ +#define HT_PWRCU_BASE (HT_APB1PERIPH_BASE + 0x2A100) /* 0x4006A100 */ +#define HT_GPTM0_BASE (HT_APB1PERIPH_BASE + 0x2E000) /* 0x4006E000 */ +#define HT_GPTM1_BASE (HT_APB1PERIPH_BASE + 0x2F000) /* 0x4006F000 */ +#define HT_SCTM1_BASE (HT_APB1PERIPH_BASE + 0x34000) /* 0x40074000 */ +#define HT_BFTM0_BASE (HT_APB1PERIPH_BASE + 0x36000) /* 0x40076000 */ +#define HT_BFTM1_BASE (HT_APB1PERIPH_BASE + 0x37000) /* 0x40077000 */ + +/* AHB */ +#define HT_FLASH_BASE (HT_AHBPERIPH_BASE + 0x0000) /* 0x40080000 */ +#define HT_CKCU_BASE (HT_AHBPERIPH_BASE + 0x8000) /* 0x40088000 */ +#define HT_RSTCU_BASE (HT_AHBPERIPH_BASE + 0x8100) /* 0x40088100 */ +#define HT_CRC_BASE (HT_AHBPERIPH_BASE + 0xA000) /* 0x4008A000 */ +#define HT_PDMA_BASE (HT_AHBPERIPH_BASE + 0x10000) /* 0x40090000 */ +#define HT_EBI_BASE (HT_AHBPERIPH_BASE + 0x18000) /* 0x40098000 */ +#define HT_SDIO_BASE (HT_AHBPERIPH_BASE + 0x20000) /* 0x400A0000 */ +#define HT_USB_BASE (HT_AHBPERIPH_BASE + 0x28000) /* 0x400A8000 */ +#define HT_USB_EP0_BASE (HT_USB_BASE + 0x0014) /* 0x400A8014 */ +#define HT_USB_EP1_BASE (HT_USB_BASE + 0x0028) /* 0x400A8028 */ +#define HT_USB_EP2_BASE (HT_USB_BASE + 0x003C) /* 0x400A803C */ +#define HT_USB_EP3_BASE (HT_USB_BASE + 0x0050) /* 0x400A8050 */ +#define HT_USB_EP4_BASE (HT_USB_BASE + 0x0064) /* 0x400A8064 */ +#define HT_USB_EP5_BASE (HT_USB_BASE + 0x0078) /* 0x400A8078 */ +#define HT_USB_EP6_BASE (HT_USB_BASE + 0x008C) /* 0x400A808C */ +#define HT_USB_EP7_BASE (HT_USB_BASE + 0x00A0) /* 0x400A80A0 */ +#define HT_USB_SRAM_BASE (HT_AHBPERIPH_BASE + 0x2A000) /* 0x400AA000 */ +#define HT_GPIOA_BASE (HT_AHBPERIPH_BASE + 0x30000) /* 0x400B0000 */ +#define HT_GPIOB_BASE (HT_AHBPERIPH_BASE + 0x32000) /* 0x400B2000 */ +#define HT_GPIOC_BASE (HT_AHBPERIPH_BASE + 0x34000) /* 0x400B4000 */ +#define HT_GPIOD_BASE (HT_AHBPERIPH_BASE + 0x36000) /* 0x400B6000 */ +#define HT_GPIOE_BASE (HT_AHBPERIPH_BASE + 0x38000) /* 0x400B8000 */ +#define HT_GPIOF_BASE (HT_AHBPERIPH_BASE + 0x3A000) /* 0x400BA000 */ +#define HT_AES_BASE (HT_AHBPERIPH_BASE + 0x48000) /* 0x400C8000 */ +#define HT_CSIF_BASE (HT_AHBPERIPH_BASE + 0x4C000) /* 0x400CC000 */ + +/** + * @} + */ + +/* Peripheral declaration */ +#define HT_ADC0 ((HT_ADC_TypeDef *) HT_ADC0_BASE) +#define HT_AFIO ((HT_AFIO_TypeDef *) HT_AFIO_BASE) +#define HT_BFTM0 ((HT_BFTM_TypeDef *) HT_BFTM0_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_CKCU ((HT_CKCU_TypeDef *) HT_CKCU_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_EXTI ((HT_EXTI_TypeDef *) HT_EXTI_BASE) +#define HT_FLASH ((HT_FLASH_TypeDef *) HT_FLASH_BASE) +#define HT_GPIOA ((HT_GPIO_TypeDef *) HT_GPIOA_BASE) +#define HT_GPIOB ((HT_GPIO_TypeDef *) HT_GPIOB_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_GPTM0 ((HT_TM_TypeDef *) HT_GPTM0_BASE) +#define HT_I2C0 ((HT_I2C_TypeDef *) HT_I2C0_BASE) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_PWRCU ((HT_PWRCU_TypeDef *) HT_PWRCU_BASE) +#define HT_RSTCU ((HT_RSTCU_TypeDef *) HT_RSTCU_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_SPI0 ((HT_SPI_TypeDef *) HT_SPI0_BASE) +#define HT_UART0 ((HT_USART_TypeDef *) HT_UART0_BASE) +#define HT_USART0 ((HT_USART_TypeDef *) HT_USART0_BASE) +#define HT_USB ((HT_USB_TypeDef *) HT_USB_BASE) +#define HT_USBEP0 ((HT_USBEP_TypeDef *) HT_USB_EP0_BASE) +#define HT_USBEP1 ((HT_USBEP_TypeDef *) HT_USB_EP1_BASE) +#define HT_USBEP2 ((HT_USBEP_TypeDef *) HT_USB_EP2_BASE) +#define HT_USBEP3 ((HT_USBEP_TypeDef *) HT_USB_EP3_BASE) +#define HT_USBEP4 ((HT_USBEP_TypeDef *) HT_USB_EP4_BASE) +#define HT_USBEP5 ((HT_USBEP_TypeDef *) HT_USB_EP5_BASE) +#define HT_USBEP6 ((HT_USBEP_TypeDef *) HT_USB_EP6_BASE) +#define HT_USBEP7 ((HT_USBEP_TypeDef *) HT_USB_EP7_BASE) +#define HT_WDT ((HT_WDT_TypeDef *) HT_WDT_BASE) + + +#if defined(USE_HT32F1655_56) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CMP_OP0 ((HT_CMP_OP_TypeDef *) HT_CMP_OP0_BASE) +#define HT_CMP_OP1 ((HT_CMP_OP_TypeDef *) HT_CMP_OP1_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_MCTM1 ((HT_TM_TypeDef *) HT_MCTM1_BASE) +#define HT_GPTM1 ((HT_TM_TypeDef *) HT_GPTM1_BASE) +#define HT_SCI0 ((HT_SCI_TypeDef *) HT_SCI0_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_GPIOE ((HT_GPIO_TypeDef *) HT_GPIOE_BASE) +#endif + +#if defined(USE_HT32F1653_54) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_MCTM1 ((HT_TM_TypeDef *) HT_MCTM1_BASE) +#define HT_GPTM1 ((HT_TM_TypeDef *) HT_GPTM1_BASE) +#define HT_SCI0 ((HT_SCI_TypeDef *) HT_SCI0_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#endif + +#if defined(USE_HT32F12365_66) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_MCTM1 ((HT_TM_TypeDef *) HT_MCTM1_BASE) +#define HT_GPTM1 ((HT_TM_TypeDef *) HT_GPTM1_BASE) +#define HT_SCI0 ((HT_SCI_TypeDef *) HT_SCI0_BASE) +#define HT_SCI1 ((HT_SCI_TypeDef *) HT_SCI1_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_GPIOE ((HT_GPIO_TypeDef *) HT_GPIOE_BASE) +#define HT_SDIO ((HT_SDIO_TypeDef *) HT_SDIO_BASE) +#define HT_AES ((HT_AES_TypeDef *) HT_AES_BASE) +#define HT_CSIF ((HT_CSIF_TypeDef *) HT_CSIF_BASE) +#endif + +#if defined(USE_HT32F12345) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_MCTM1 ((HT_TM_TypeDef *) HT_MCTM1_BASE) +#define HT_GPTM1 ((HT_TM_TypeDef *) HT_GPTM1_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_SDIO ((HT_SDIO_TypeDef *) HT_SDIO_BASE) +#endif + +#if defined(USE_HT32F12364) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_SCI0 ((HT_SCI_TypeDef *) HT_SCI0_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_GPIOF ((HT_GPIO_TypeDef *) HT_GPIOF_BASE) +#define HT_AES ((HT_AES_TypeDef *) HT_AES_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_SCTM0 ((HT_TM_TypeDef *) HT_SCTM0_BASE) +#define HT_SCTM1 ((HT_TM_TypeDef *) HT_SCTM1_BASE) +#endif + +#if defined USE_HT32_DRIVER + #include "ht32f1xxxx_lib.h" +#endif + +/** + * @brief Adjust the value of High Speed External oscillator (HSE) + Tip: To avoid from modifying every time for different HSE, please define + the "HSE_VALUE=n000000" ("n" represents n MHz) in your own toolchain compiler preprocessor, + or edit the "HSE_VALUE" in the "ht32f1xxxx_conf.h" file. + */ +#if !defined HSE_VALUE + /* Available HSE_VALUE: 4 MHz ~ 16 MHz */ + #define HSE_VALUE 8000000UL /*!< Value of the External oscillator in Hz */ +#endif + +/** + * @brief Define for backward compatibility + */ +#define HT_ADC HT_ADC0 +#define ADC ADC0 +#define ADC_IRQn ADC0_IRQn + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_01.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_01.h new file mode 100644 index 0000000000..bdba227af0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_01.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f1xxxx_01.h + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File + * for the Holtek HT32F1xxxx Device Series + * @version $Rev:: 735 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F1xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F1XXXX_01_H +#define __SYSTEM_HT32F1XXXX_01_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F1xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F1xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_02.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_02.h new file mode 100644 index 0000000000..ea20c74d67 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_02.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f1xxxx_02.h + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File + * for the Holtek HT32F1xxxx Device Series + * @version $Rev:: 735 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F1xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F1XXXX_02_H +#define __SYSTEM_HT32F1XXXX_02_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F1xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F1xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_03.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_03.h new file mode 100644 index 0000000000..214d0008f7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Include/system_ht32f1xxxx_03.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f1xxxx_03.h + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File + * for the Holtek HT32F1xxxx Device Series + * @version $Rev:: 735 $ + * @date $Date:: 2019-06-12 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F1xxxx_system + * @{ + */ + + +#ifndef __system_ht32f1xxxx_03_H +#define __system_ht32f1xxxx_03_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F1xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F1xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12345.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12345.s new file mode 100644 index 0000000000..f3f24a1faf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12345.s @@ -0,0 +1,469 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_01.s +; Version : $Rev:: 2524 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +USE_HT32_CHIP_SET EQU 3 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012366 + +HT32F1653_54_55_56 EQU 1 +HT32F12365_66 EQU 2 +HT32F12345 EQU 3 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-131072:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-131072:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD WDT_IRQHandler ; 03, 19, 0x04C, + ELSE + DCD _RESERVED ; 03, 19, 0x04C, + ENDIF + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD COMP_IRQHandler ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MCTM0BRK_IRQHandler ; 27, 43, 0x0AC, + DCD MCTM0UP_IRQHandler ; 28, 44, 0x0B0, + DCD MCTM0TR_IRQHandler ; 29, 45, 0x0B4, + DCD MCTM0CC_IRQHandler ; 30, 46, 0x0B8, + DCD MCTM1BRK_IRQHandler ; 31, 47, 0x0BC, + DCD MCTM1UP_IRQHandler ; 32, 48, 0x0C0, + DCD MCTM1TR_IRQHandler ; 33, 49, 0x0C4, + DCD MCTM1CC_IRQHandler ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD GPTM1_IRQHandler ; 36, 52, 0x0D0, + DCD _RESERVED ; 37, 53, 0x0D4, + DCD _RESERVED ; 38, 54, 0x0D8, + DCD _RESERVED ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD USART1_IRQHandler ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + IF (USE_HT32_CHIP=HT32F12345) + DCD _RESERVED ; 51, 67, 0x10C, + ELSE + DCD SCI_IRQHandler ; 51, 67, 0x10C, + ENDIF + DCD I2S_IRQHandler ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 54, 70, 0x118, + ELSE + DCD SDIO_IRQHandler ; 54, 70, 0x118, + ENDIF + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD PDMA_CH6_IRQHandler ; 61, 77, 0x134, + DCD PDMA_CH7_IRQHandler ; 62, 78, 0x138, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + ELSE + DCD PDMA_CH8_IRQHandler ; 63, 79, 0x13C, + DCD PDMA_CH9_IRQHandler ; 64, 80, 0x140, + DCD PDMA_CH10_IRQHandler ; 65, 81, 0x144, + DCD PDMA_CH11_IRQHandler ; 66, 82, 0x148, + ENDIF + IF (USE_HT32_CHIP=HT32F12365_66) + DCD CSIF_IRQHandler ; 67, 83, 0x14C, + ELSE + DCD _RESERVED ; 67, 83, 0x14C, + ENDIF + DCD EBI_IRQHandler ; 68, 84, 0x150, + IF (USE_HT32_CHIP=HT32F12365_66) + DCD AES_IRQHandler ; 69, 85, 0x154, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE + LDR R0, =BootProcess + BLX R0 + ENDIF + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + ENDIF + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +MemManage_Handler PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP + +BusFault_Handler PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP + +UsageFault_Handler PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +DebugMon_Handler PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT CKRDY_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT LPWUP_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT EXTI5_IRQHandler [WEAK] + EXPORT EXTI6_IRQHandler [WEAK] + EXPORT EXTI7_IRQHandler [WEAK] + EXPORT EXTI8_IRQHandler [WEAK] + EXPORT EXTI9_IRQHandler [WEAK] + EXPORT EXTI10_IRQHandler [WEAK] + EXPORT EXTI11_IRQHandler [WEAK] + EXPORT EXTI12_IRQHandler [WEAK] + EXPORT EXTI13_IRQHandler [WEAK] + EXPORT EXTI14_IRQHandler [WEAK] + EXPORT EXTI15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0BRK_IRQHandler [WEAK] + EXPORT MCTM0UP_IRQHandler [WEAK] + EXPORT MCTM0TR_IRQHandler [WEAK] + EXPORT MCTM0CC_IRQHandler [WEAK] + EXPORT MCTM1BRK_IRQHandler [WEAK] + EXPORT MCTM1UP_IRQHandler [WEAK] + EXPORT MCTM1TR_IRQHandler [WEAK] + EXPORT MCTM1CC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT SDIO_IRQHandler [WEAK] + EXPORT PDMA_CH0_IRQHandler [WEAK] + EXPORT PDMA_CH1_IRQHandler [WEAK] + EXPORT PDMA_CH2_IRQHandler [WEAK] + EXPORT PDMA_CH3_IRQHandler [WEAK] + EXPORT PDMA_CH4_IRQHandler [WEAK] + EXPORT PDMA_CH5_IRQHandler [WEAK] + EXPORT PDMA_CH6_IRQHandler [WEAK] + EXPORT PDMA_CH7_IRQHandler [WEAK] + EXPORT PDMA_CH8_IRQHandler [WEAK] + EXPORT PDMA_CH9_IRQHandler [WEAK] + EXPORT PDMA_CH10_IRQHandler [WEAK] + EXPORT PDMA_CH11_IRQHandler [WEAK] + EXPORT CSIF_IRQHandler [WEAK] + EXPORT EBI_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0BRK_IRQHandler +MCTM0UP_IRQHandler +MCTM0TR_IRQHandler +MCTM0CC_IRQHandler +MCTM1BRK_IRQHandler +MCTM1UP_IRQHandler +MCTM1TR_IRQHandler +MCTM1CC_IRQHandler +GPTM0_IRQHandler +GPTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +SDIO_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +PDMA_CH6_IRQHandler +PDMA_CH7_IRQHandler +PDMA_CH8_IRQHandler +PDMA_CH9_IRQHandler +PDMA_CH10_IRQHandler +PDMA_CH11_IRQHandler +CSIF_IRQHandler +EBI_IRQHandler +AES_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12364.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12364.s new file mode 100644 index 0000000000..a1a24ab522 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12364.s @@ -0,0 +1,393 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_03.s +; Version : $Rev:: 2524 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F12364 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <16=> HT32F12364 +USE_HT32_CHIP_SET EQU 16 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012364 + +HT32F12364 EQU 16 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-131072:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-131072:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + DCD _RESERVED ; 03, 19, 0x04C, + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + DCD _RESERVED ; 32, 48, 0x0C0, + DCD _RESERVED ; 33, 49, 0x0C4, + DCD _RESERVED ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD _RESERVED ; 36, 52, 0x0D0, + DCD SCTM0_IRQHandler ; 37, 53, 0x0D4, + DCD SCTM1_IRQHandler ; 38, 54, 0x0D8, + DCD PWM0_IRQHandler ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD _RESERVED ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + DCD SCI_IRQHandler ; 51, 67, 0x10C, + DCD _RESERVED ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + DCD _RESERVED ; 54, 70, 0x118, + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD _RESERVED ; 61, 77, 0x134, + DCD _RESERVED ; 62, 78, 0x138, + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + DCD _RESERVED ; 67, 83, 0x14C, + DCD _RESERVED ; 68, 84, 0x150, + DCD AES_IRQHandler ; 69, 85, 0x154, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +MemManage_Handler PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP + +BusFault_Handler PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP + +UsageFault_Handler PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +DebugMon_Handler PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT CKRDY_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT LPWUP_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT EXTI5_IRQHandler [WEAK] + EXPORT EXTI6_IRQHandler [WEAK] + EXPORT EXTI7_IRQHandler [WEAK] + EXPORT EXTI8_IRQHandler [WEAK] + EXPORT EXTI9_IRQHandler [WEAK] + EXPORT EXTI10_IRQHandler [WEAK] + EXPORT EXTI11_IRQHandler [WEAK] + EXPORT EXTI12_IRQHandler [WEAK] + EXPORT EXTI13_IRQHandler [WEAK] + EXPORT EXTI14_IRQHandler [WEAK] + EXPORT EXTI15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_IRQHandler [WEAK] + EXPORT PDMA_CH1_IRQHandler [WEAK] + EXPORT PDMA_CH2_IRQHandler [WEAK] + EXPORT PDMA_CH3_IRQHandler [WEAK] + EXPORT PDMA_CH4_IRQHandler [WEAK] + EXPORT PDMA_CH5_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +USB_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +AES_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12365_66.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12365_66.s new file mode 100644 index 0000000000..3381f58240 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f12365_66.s @@ -0,0 +1,469 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_01.s +; Version : $Rev:: 2524 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +USE_HT32_CHIP_SET EQU 2 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012366 + +HT32F1653_54_55_56 EQU 1 +HT32F12365_66 EQU 2 +HT32F12345 EQU 3 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-131072:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-131072:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD WDT_IRQHandler ; 03, 19, 0x04C, + ELSE + DCD _RESERVED ; 03, 19, 0x04C, + ENDIF + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD COMP_IRQHandler ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MCTM0BRK_IRQHandler ; 27, 43, 0x0AC, + DCD MCTM0UP_IRQHandler ; 28, 44, 0x0B0, + DCD MCTM0TR_IRQHandler ; 29, 45, 0x0B4, + DCD MCTM0CC_IRQHandler ; 30, 46, 0x0B8, + DCD MCTM1BRK_IRQHandler ; 31, 47, 0x0BC, + DCD MCTM1UP_IRQHandler ; 32, 48, 0x0C0, + DCD MCTM1TR_IRQHandler ; 33, 49, 0x0C4, + DCD MCTM1CC_IRQHandler ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD GPTM1_IRQHandler ; 36, 52, 0x0D0, + DCD _RESERVED ; 37, 53, 0x0D4, + DCD _RESERVED ; 38, 54, 0x0D8, + DCD _RESERVED ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD USART1_IRQHandler ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + IF (USE_HT32_CHIP=HT32F12345) + DCD _RESERVED ; 51, 67, 0x10C, + ELSE + DCD SCI_IRQHandler ; 51, 67, 0x10C, + ENDIF + DCD I2S_IRQHandler ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 54, 70, 0x118, + ELSE + DCD SDIO_IRQHandler ; 54, 70, 0x118, + ENDIF + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD PDMA_CH6_IRQHandler ; 61, 77, 0x134, + DCD PDMA_CH7_IRQHandler ; 62, 78, 0x138, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + ELSE + DCD PDMA_CH8_IRQHandler ; 63, 79, 0x13C, + DCD PDMA_CH9_IRQHandler ; 64, 80, 0x140, + DCD PDMA_CH10_IRQHandler ; 65, 81, 0x144, + DCD PDMA_CH11_IRQHandler ; 66, 82, 0x148, + ENDIF + IF (USE_HT32_CHIP=HT32F12365_66) + DCD CSIF_IRQHandler ; 67, 83, 0x14C, + ELSE + DCD _RESERVED ; 67, 83, 0x14C, + ENDIF + DCD EBI_IRQHandler ; 68, 84, 0x150, + IF (USE_HT32_CHIP=HT32F12365_66) + DCD AES_IRQHandler ; 69, 85, 0x154, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE + LDR R0, =BootProcess + BLX R0 + ENDIF + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + ENDIF + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +MemManage_Handler PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP + +BusFault_Handler PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP + +UsageFault_Handler PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +DebugMon_Handler PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT CKRDY_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT LPWUP_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT EXTI5_IRQHandler [WEAK] + EXPORT EXTI6_IRQHandler [WEAK] + EXPORT EXTI7_IRQHandler [WEAK] + EXPORT EXTI8_IRQHandler [WEAK] + EXPORT EXTI9_IRQHandler [WEAK] + EXPORT EXTI10_IRQHandler [WEAK] + EXPORT EXTI11_IRQHandler [WEAK] + EXPORT EXTI12_IRQHandler [WEAK] + EXPORT EXTI13_IRQHandler [WEAK] + EXPORT EXTI14_IRQHandler [WEAK] + EXPORT EXTI15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0BRK_IRQHandler [WEAK] + EXPORT MCTM0UP_IRQHandler [WEAK] + EXPORT MCTM0TR_IRQHandler [WEAK] + EXPORT MCTM0CC_IRQHandler [WEAK] + EXPORT MCTM1BRK_IRQHandler [WEAK] + EXPORT MCTM1UP_IRQHandler [WEAK] + EXPORT MCTM1TR_IRQHandler [WEAK] + EXPORT MCTM1CC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT SDIO_IRQHandler [WEAK] + EXPORT PDMA_CH0_IRQHandler [WEAK] + EXPORT PDMA_CH1_IRQHandler [WEAK] + EXPORT PDMA_CH2_IRQHandler [WEAK] + EXPORT PDMA_CH3_IRQHandler [WEAK] + EXPORT PDMA_CH4_IRQHandler [WEAK] + EXPORT PDMA_CH5_IRQHandler [WEAK] + EXPORT PDMA_CH6_IRQHandler [WEAK] + EXPORT PDMA_CH7_IRQHandler [WEAK] + EXPORT PDMA_CH8_IRQHandler [WEAK] + EXPORT PDMA_CH9_IRQHandler [WEAK] + EXPORT PDMA_CH10_IRQHandler [WEAK] + EXPORT PDMA_CH11_IRQHandler [WEAK] + EXPORT CSIF_IRQHandler [WEAK] + EXPORT EBI_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0BRK_IRQHandler +MCTM0UP_IRQHandler +MCTM0TR_IRQHandler +MCTM0CC_IRQHandler +MCTM1BRK_IRQHandler +MCTM1UP_IRQHandler +MCTM1TR_IRQHandler +MCTM1CC_IRQHandler +GPTM0_IRQHandler +GPTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +SDIO_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +PDMA_CH6_IRQHandler +PDMA_CH7_IRQHandler +PDMA_CH8_IRQHandler +PDMA_CH9_IRQHandler +PDMA_CH10_IRQHandler +PDMA_CH11_IRQHandler +CSIF_IRQHandler +EBI_IRQHandler +AES_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f165x.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f165x.s new file mode 100644 index 0000000000..9a0fd83e61 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f165x.s @@ -0,0 +1,469 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_01.s +; Version : $Rev:: 2524 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +USE_HT32_CHIP_SET EQU 1 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012366 + +HT32F1653_54_55_56 EQU 1 +HT32F12365_66 EQU 2 +HT32F12345 EQU 3 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-131072:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-131072:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD WDT_IRQHandler ; 03, 19, 0x04C, + ELSE + DCD _RESERVED ; 03, 19, 0x04C, + ENDIF + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD COMP_IRQHandler ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MCTM0BRK_IRQHandler ; 27, 43, 0x0AC, + DCD MCTM0UP_IRQHandler ; 28, 44, 0x0B0, + DCD MCTM0TR_IRQHandler ; 29, 45, 0x0B4, + DCD MCTM0CC_IRQHandler ; 30, 46, 0x0B8, + DCD MCTM1BRK_IRQHandler ; 31, 47, 0x0BC, + DCD MCTM1UP_IRQHandler ; 32, 48, 0x0C0, + DCD MCTM1TR_IRQHandler ; 33, 49, 0x0C4, + DCD MCTM1CC_IRQHandler ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD GPTM1_IRQHandler ; 36, 52, 0x0D0, + DCD _RESERVED ; 37, 53, 0x0D4, + DCD _RESERVED ; 38, 54, 0x0D8, + DCD _RESERVED ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD USART1_IRQHandler ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + IF (USE_HT32_CHIP=HT32F12345) + DCD _RESERVED ; 51, 67, 0x10C, + ELSE + DCD SCI_IRQHandler ; 51, 67, 0x10C, + ENDIF + DCD I2S_IRQHandler ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 54, 70, 0x118, + ELSE + DCD SDIO_IRQHandler ; 54, 70, 0x118, + ENDIF + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD PDMA_CH6_IRQHandler ; 61, 77, 0x134, + DCD PDMA_CH7_IRQHandler ; 62, 78, 0x138, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + ELSE + DCD PDMA_CH8_IRQHandler ; 63, 79, 0x13C, + DCD PDMA_CH9_IRQHandler ; 64, 80, 0x140, + DCD PDMA_CH10_IRQHandler ; 65, 81, 0x144, + DCD PDMA_CH11_IRQHandler ; 66, 82, 0x148, + ENDIF + IF (USE_HT32_CHIP=HT32F12365_66) + DCD CSIF_IRQHandler ; 67, 83, 0x14C, + ELSE + DCD _RESERVED ; 67, 83, 0x14C, + ENDIF + DCD EBI_IRQHandler ; 68, 84, 0x150, + IF (USE_HT32_CHIP=HT32F12365_66) + DCD AES_IRQHandler ; 69, 85, 0x154, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE + LDR R0, =BootProcess + BLX R0 + ENDIF + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + ENDIF + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +MemManage_Handler PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP + +BusFault_Handler PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP + +UsageFault_Handler PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +DebugMon_Handler PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT CKRDY_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT LPWUP_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT EXTI5_IRQHandler [WEAK] + EXPORT EXTI6_IRQHandler [WEAK] + EXPORT EXTI7_IRQHandler [WEAK] + EXPORT EXTI8_IRQHandler [WEAK] + EXPORT EXTI9_IRQHandler [WEAK] + EXPORT EXTI10_IRQHandler [WEAK] + EXPORT EXTI11_IRQHandler [WEAK] + EXPORT EXTI12_IRQHandler [WEAK] + EXPORT EXTI13_IRQHandler [WEAK] + EXPORT EXTI14_IRQHandler [WEAK] + EXPORT EXTI15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0BRK_IRQHandler [WEAK] + EXPORT MCTM0UP_IRQHandler [WEAK] + EXPORT MCTM0TR_IRQHandler [WEAK] + EXPORT MCTM0CC_IRQHandler [WEAK] + EXPORT MCTM1BRK_IRQHandler [WEAK] + EXPORT MCTM1UP_IRQHandler [WEAK] + EXPORT MCTM1TR_IRQHandler [WEAK] + EXPORT MCTM1CC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT SDIO_IRQHandler [WEAK] + EXPORT PDMA_CH0_IRQHandler [WEAK] + EXPORT PDMA_CH1_IRQHandler [WEAK] + EXPORT PDMA_CH2_IRQHandler [WEAK] + EXPORT PDMA_CH3_IRQHandler [WEAK] + EXPORT PDMA_CH4_IRQHandler [WEAK] + EXPORT PDMA_CH5_IRQHandler [WEAK] + EXPORT PDMA_CH6_IRQHandler [WEAK] + EXPORT PDMA_CH7_IRQHandler [WEAK] + EXPORT PDMA_CH8_IRQHandler [WEAK] + EXPORT PDMA_CH9_IRQHandler [WEAK] + EXPORT PDMA_CH10_IRQHandler [WEAK] + EXPORT PDMA_CH11_IRQHandler [WEAK] + EXPORT CSIF_IRQHandler [WEAK] + EXPORT EBI_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0BRK_IRQHandler +MCTM0UP_IRQHandler +MCTM0TR_IRQHandler +MCTM0CC_IRQHandler +MCTM1BRK_IRQHandler +MCTM1UP_IRQHandler +MCTM1TR_IRQHandler +MCTM1CC_IRQHandler +GPTM0_IRQHandler +GPTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +SDIO_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +PDMA_CH6_IRQHandler +PDMA_CH7_IRQHandler +PDMA_CH8_IRQHandler +PDMA_CH9_IRQHandler +PDMA_CH10_IRQHandler +PDMA_CH11_IRQHandler +CSIF_IRQHandler +EBI_IRQHandler +AES_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_01.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_01.s new file mode 100644 index 0000000000..481edd75d0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_01.s @@ -0,0 +1,469 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_01.s +; Version : $Rev:: 2524 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012366 + +HT32F1653_54_55_56 EQU 1 +HT32F12365_66 EQU 2 +HT32F12345 EQU 3 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-131072:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-131072:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD WDT_IRQHandler ; 03, 19, 0x04C, + ELSE + DCD _RESERVED ; 03, 19, 0x04C, + ENDIF + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD COMP_IRQHandler ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MCTM0BRK_IRQHandler ; 27, 43, 0x0AC, + DCD MCTM0UP_IRQHandler ; 28, 44, 0x0B0, + DCD MCTM0TR_IRQHandler ; 29, 45, 0x0B4, + DCD MCTM0CC_IRQHandler ; 30, 46, 0x0B8, + DCD MCTM1BRK_IRQHandler ; 31, 47, 0x0BC, + DCD MCTM1UP_IRQHandler ; 32, 48, 0x0C0, + DCD MCTM1TR_IRQHandler ; 33, 49, 0x0C4, + DCD MCTM1CC_IRQHandler ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD GPTM1_IRQHandler ; 36, 52, 0x0D0, + DCD _RESERVED ; 37, 53, 0x0D4, + DCD _RESERVED ; 38, 54, 0x0D8, + DCD _RESERVED ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD USART1_IRQHandler ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + IF (USE_HT32_CHIP=HT32F12345) + DCD _RESERVED ; 51, 67, 0x10C, + ELSE + DCD SCI_IRQHandler ; 51, 67, 0x10C, + ENDIF + DCD I2S_IRQHandler ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 54, 70, 0x118, + ELSE + DCD SDIO_IRQHandler ; 54, 70, 0x118, + ENDIF + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD PDMA_CH6_IRQHandler ; 61, 77, 0x134, + DCD PDMA_CH7_IRQHandler ; 62, 78, 0x138, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + ELSE + DCD PDMA_CH8_IRQHandler ; 63, 79, 0x13C, + DCD PDMA_CH9_IRQHandler ; 64, 80, 0x140, + DCD PDMA_CH10_IRQHandler ; 65, 81, 0x144, + DCD PDMA_CH11_IRQHandler ; 66, 82, 0x148, + ENDIF + IF (USE_HT32_CHIP=HT32F12365_66) + DCD CSIF_IRQHandler ; 67, 83, 0x14C, + ELSE + DCD _RESERVED ; 67, 83, 0x14C, + ENDIF + DCD EBI_IRQHandler ; 68, 84, 0x150, + IF (USE_HT32_CHIP=HT32F12365_66) + DCD AES_IRQHandler ; 69, 85, 0x154, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE + LDR R0, =BootProcess + BLX R0 + ENDIF + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + ENDIF + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +MemManage_Handler PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP + +BusFault_Handler PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP + +UsageFault_Handler PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +DebugMon_Handler PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT CKRDY_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT LPWUP_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT EXTI5_IRQHandler [WEAK] + EXPORT EXTI6_IRQHandler [WEAK] + EXPORT EXTI7_IRQHandler [WEAK] + EXPORT EXTI8_IRQHandler [WEAK] + EXPORT EXTI9_IRQHandler [WEAK] + EXPORT EXTI10_IRQHandler [WEAK] + EXPORT EXTI11_IRQHandler [WEAK] + EXPORT EXTI12_IRQHandler [WEAK] + EXPORT EXTI13_IRQHandler [WEAK] + EXPORT EXTI14_IRQHandler [WEAK] + EXPORT EXTI15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0BRK_IRQHandler [WEAK] + EXPORT MCTM0UP_IRQHandler [WEAK] + EXPORT MCTM0TR_IRQHandler [WEAK] + EXPORT MCTM0CC_IRQHandler [WEAK] + EXPORT MCTM1BRK_IRQHandler [WEAK] + EXPORT MCTM1UP_IRQHandler [WEAK] + EXPORT MCTM1TR_IRQHandler [WEAK] + EXPORT MCTM1CC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT SDIO_IRQHandler [WEAK] + EXPORT PDMA_CH0_IRQHandler [WEAK] + EXPORT PDMA_CH1_IRQHandler [WEAK] + EXPORT PDMA_CH2_IRQHandler [WEAK] + EXPORT PDMA_CH3_IRQHandler [WEAK] + EXPORT PDMA_CH4_IRQHandler [WEAK] + EXPORT PDMA_CH5_IRQHandler [WEAK] + EXPORT PDMA_CH6_IRQHandler [WEAK] + EXPORT PDMA_CH7_IRQHandler [WEAK] + EXPORT PDMA_CH8_IRQHandler [WEAK] + EXPORT PDMA_CH9_IRQHandler [WEAK] + EXPORT PDMA_CH10_IRQHandler [WEAK] + EXPORT PDMA_CH11_IRQHandler [WEAK] + EXPORT CSIF_IRQHandler [WEAK] + EXPORT EBI_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0BRK_IRQHandler +MCTM0UP_IRQHandler +MCTM0TR_IRQHandler +MCTM0CC_IRQHandler +MCTM1BRK_IRQHandler +MCTM1UP_IRQHandler +MCTM1TR_IRQHandler +MCTM1CC_IRQHandler +GPTM0_IRQHandler +GPTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +SDIO_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +PDMA_CH6_IRQHandler +PDMA_CH7_IRQHandler +PDMA_CH8_IRQHandler +PDMA_CH9_IRQHandler +PDMA_CH10_IRQHandler +PDMA_CH11_IRQHandler +CSIF_IRQHandler +EBI_IRQHandler +AES_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_03.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_03.s new file mode 100644 index 0000000000..323e76c6b6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/ARM/startup_ht32f1xxxx_03.s @@ -0,0 +1,393 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_03.s +; Version : $Rev:: 2524 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F12364 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <16=> HT32F12364 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012364 + +HT32F12364 EQU 16 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-131072:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-131072:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + DCD _RESERVED ; 03, 19, 0x04C, + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + DCD _RESERVED ; 32, 48, 0x0C0, + DCD _RESERVED ; 33, 49, 0x0C4, + DCD _RESERVED ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD _RESERVED ; 36, 52, 0x0D0, + DCD SCTM0_IRQHandler ; 37, 53, 0x0D4, + DCD SCTM1_IRQHandler ; 38, 54, 0x0D8, + DCD PWM0_IRQHandler ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD _RESERVED ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + DCD SCI_IRQHandler ; 51, 67, 0x10C, + DCD _RESERVED ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + DCD _RESERVED ; 54, 70, 0x118, + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD _RESERVED ; 61, 77, 0x134, + DCD _RESERVED ; 62, 78, 0x138, + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + DCD _RESERVED ; 67, 83, 0x14C, + DCD _RESERVED ; 68, 84, 0x150, + DCD AES_IRQHandler ; 69, 85, 0x154, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +MemManage_Handler PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP + +BusFault_Handler PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP + +UsageFault_Handler PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +DebugMon_Handler PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT CKRDY_IRQHandler [WEAK] + EXPORT LVD_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT LPWUP_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT EXTI5_IRQHandler [WEAK] + EXPORT EXTI6_IRQHandler [WEAK] + EXPORT EXTI7_IRQHandler [WEAK] + EXPORT EXTI8_IRQHandler [WEAK] + EXPORT EXTI9_IRQHandler [WEAK] + EXPORT EXTI10_IRQHandler [WEAK] + EXPORT EXTI11_IRQHandler [WEAK] + EXPORT EXTI12_IRQHandler [WEAK] + EXPORT EXTI13_IRQHandler [WEAK] + EXPORT EXTI14_IRQHandler [WEAK] + EXPORT EXTI15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_IRQHandler [WEAK] + EXPORT PDMA_CH1_IRQHandler [WEAK] + EXPORT PDMA_CH2_IRQHandler [WEAK] + EXPORT PDMA_CH3_IRQHandler [WEAK] + EXPORT PDMA_CH4_IRQHandler [WEAK] + EXPORT PDMA_CH5_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +USB_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +AES_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_01.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_01.s new file mode 100644 index 0000000000..0e11813688 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_01.s @@ -0,0 +1,427 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_cs3_01.s +; Version : $Rev:: 1578 $ +; Date : $Date:: 2019-03-29 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00012366 +*/ + + .equ HT32F1653_54_55_56, 1 + .equ HT32F12365_66, 2 + .equ HT32F12345, 3 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* ---, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* ---, 03, 0x00C, Hard Fault Handler */ + .long MemManage_Handler /* ---, 04, 0x010, MPU Fault Handler */ + .long BusFault_Handler /* ---, 05, 0x014, Bus Fault Handler */ + .long UsageFault_Handler /* ---, 06, 0x018, Usage Fault Handler */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* ---, 11, 0x02C, SVC Handler */ + .long DebugMon_Handler /* ---, 12, 0x030, Debug Monitor Handler */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* ---, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* ---, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long CKRDY_IRQHandler /* 00, 16, 0x040, */ + .long LVD_IRQHandler /* 01, 17, 0x044, */ + .long BOD_IRQHandler /* 02, 18, 0x048, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long WDT_IRQHandler /* 03, 19, 0x04C, */ + .else + .long _RESERVED /* 03, 19, 0x04C, */ + .endif + .long RTC_IRQHandler /* 04, 20, 0x050, */ + .long FLASH_IRQHandler /* 05, 21, 0x054, */ + .long EVWUP_IRQHandler /* 06, 22, 0x058, */ + .long LPWUP_IRQHandler /* 07, 23, 0x05C, */ + .long EXTI0_IRQHandler /* 08, 24, 0x060, */ + .long EXTI1_IRQHandler /* 09, 25, 0x064, */ + .long EXTI2_IRQHandler /* 10, 26, 0x068, */ + .long EXTI3_IRQHandler /* 11, 27, 0x06C, */ + .long EXTI4_IRQHandler /* 12, 28, 0x070, */ + .long EXTI5_IRQHandler /* 13, 29, 0x074, */ + .long EXTI6_IRQHandler /* 14, 30, 0x078, */ + .long EXTI7_IRQHandler /* 15, 31, 0x07C, */ + .long EXTI8_IRQHandler /* 16, 32, 0x080, */ + .long EXTI9_IRQHandler /* 17, 33, 0x084, */ + .long EXTI10_IRQHandler /* 18, 34, 0x088, */ + .long EXTI11_IRQHandler /* 19, 35, 0x08C, */ + .long EXTI12_IRQHandler /* 20, 36, 0x090, */ + .long EXTI13_IRQHandler /* 21, 37, 0x094, */ + .long EXTI14_IRQHandler /* 22, 38, 0x098, */ + .long EXTI15_IRQHandler /* 23, 39, 0x09C, */ + .long COMP_IRQHandler /* 24, 40, 0x0A0, */ + .long ADC_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MCTM0BRK_IRQHandler /* 27, 43, 0x0AC, */ + .long MCTM0UP_IRQHandler /* 28, 44, 0x0B0, */ + .long MCTM0TR_IRQHandler /* 29, 45, 0x0B4, */ + .long MCTM0CC_IRQHandler /* 30, 46, 0x0B8, */ + .long MCTM1BRK_IRQHandler /* 31, 47, 0x0BC, */ + .long MCTM1UP_IRQHandler /* 32, 48, 0x0C0, */ + .long MCTM1TR_IRQHandler /* 33, 49, 0x0C4, */ + .long MCTM1CC_IRQHandler /* 34, 50, 0x0C8, */ + .long GPTM0_IRQHandler /* 35, 51, 0x0CC, */ + .long GPTM1_IRQHandler /* 36, 52, 0x0D0, */ + .long _RESERVED /* 37, 53, 0x0D4, */ + .long _RESERVED /* 38, 54, 0x0D8, */ + .long _RESERVED /* 39, 55, 0x0DC, */ + .long _RESERVED /* 40, 56, 0x0E0, */ + .long BFTM0_IRQHandler /* 41, 57, 0x0E4, */ + .long BFTM1_IRQHandler /* 42, 58, 0x0E8, */ + .long I2C0_IRQHandler /* 43, 59, 0x0EC, */ + .long I2C1_IRQHandler /* 44, 60, 0x0F0, */ + .long SPI0_IRQHandler /* 45, 61, 0x0F4, */ + .long SPI1_IRQHandler /* 46, 62, 0x0F8, */ + .long USART0_IRQHandler /* 47, 63, 0x0FC, */ + .long USART1_IRQHandler /* 48, 64, 0x100, */ + .long UART0_IRQHandler /* 49, 65, 0x104, */ + .long UART1_IRQHandler /* 50, 66, 0x108, */ + .if (USE_HT32_CHIP==HT32F12345) + .long _RESERVED /* 51, 67, 0x10C, */ + .else + .long SCI_IRQHandler /* 51, 67, 0x10C, */ + .endif + .long I2S_IRQHandler /* 52, 68, 0x110, */ + .long USB_IRQHandler /* 53, 69, 0x114, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long _RESERVED /* 54, 70, 0x118, */ + .else + .long SDIO_IRQHandler /* 54, 70, 0x118, */ + .endif + .long PDMA_CH0_IRQHandler /* 55, 71, 0x11C, */ + .long PDMA_CH1_IRQHandler /* 56, 72, 0x120, */ + .long PDMA_CH2_IRQHandler /* 57, 73, 0x124, */ + .long PDMA_CH3_IRQHandler /* 58, 74, 0x128, */ + .long PDMA_CH4_IRQHandler /* 59, 75, 0x12C, */ + .long PDMA_CH5_IRQHandler /* 60, 76, 0x130, */ + .long PDMA_CH6_IRQHandler /* 61, 77, 0x134, */ + .long PDMA_CH7_IRQHandler /* 62, 78, 0x138, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long _RESERVED /* 63, 79, 0x13C, */ + .long _RESERVED /* 64, 80, 0x140, */ + .long _RESERVED /* 65, 81, 0x144, */ + .long _RESERVED /* 66, 82, 0x148, */ + .else + .long PDMA_CH8_IRQHandler /* 63, 79, 0x13C, */ + .long PDMA_CH9_IRQHandler /* 64, 80, 0x140, */ + .long PDMA_CH10_IRQHandler /* 65, 81, 0x144, */ + .long PDMA_CH11_IRQHandler /* 66, 82, 0x148, */ + .endif + .if (USE_HT32_CHIP==HT32F12365_66) + .long CSIF_IRQHandler /* 67, 83, 0x14C, */ + .else + .long _RESERVED /* 67, 83, 0x14C, */ + .endif + .long EBI_IRQHandler /* 68, 84, 0x150, */ + .if (USE_HT32_CHIP==HT32F12365_66) + .long AES_IRQHandler /* 69, 85, 0x154, */ + .endif + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .else + LDR R0, =BootProcess + BLX R0 + .endif + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .else + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .endif + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak MemManage_Handler + .type MemManage_Handler, %function +MemManage_Handler: + B . + .size MemManage_Handler, . - MemManage_Handler + + .weak BusFault_Handler + .type BusFault_Handler, %function +BusFault_Handler: + B . + .size BusFault_Handler, . - BusFault_Handler + + .weak UsageFault_Handler + .type UsageFault_Handler, %function +UsageFault_Handler: + B . + .size UsageFault_Handler, . - UsageFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak DebugMon_Handler + .type DebugMon_Handler, %function +DebugMon_Handler: + B . + .size DebugMon_Handler, . - DebugMon_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ CKRDY_IRQHandler + IRQ LVD_IRQHandler + IRQ BOD_IRQHandler + IRQ WDT_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ LPWUP_IRQHandler + IRQ EXTI0_IRQHandler + IRQ EXTI1_IRQHandler + IRQ EXTI2_IRQHandler + IRQ EXTI3_IRQHandler + IRQ EXTI4_IRQHandler + IRQ EXTI5_IRQHandler + IRQ EXTI6_IRQHandler + IRQ EXTI7_IRQHandler + IRQ EXTI8_IRQHandler + IRQ EXTI9_IRQHandler + IRQ EXTI10_IRQHandler + IRQ EXTI11_IRQHandler + IRQ EXTI12_IRQHandler + IRQ EXTI13_IRQHandler + IRQ EXTI14_IRQHandler + IRQ EXTI15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0BRK_IRQHandler + IRQ MCTM0UP_IRQHandler + IRQ MCTM0TR_IRQHandler + IRQ MCTM0CC_IRQHandler + IRQ MCTM1BRK_IRQHandler + IRQ MCTM1UP_IRQHandler + IRQ MCTM1TR_IRQHandler + IRQ MCTM1CC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ GPTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ SDIO_IRQHandler + IRQ PDMA_CH0_IRQHandler + IRQ PDMA_CH1_IRQHandler + IRQ PDMA_CH2_IRQHandler + IRQ PDMA_CH3_IRQHandler + IRQ PDMA_CH4_IRQHandler + IRQ PDMA_CH5_IRQHandler + IRQ PDMA_CH6_IRQHandler + IRQ PDMA_CH7_IRQHandler + IRQ PDMA_CH8_IRQHandler + IRQ PDMA_CH9_IRQHandler + IRQ PDMA_CH10_IRQHandler + IRQ PDMA_CH11_IRQHandler + IRQ CSIF_IRQHandler + IRQ EBI_IRQHandler + IRQ AES_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_03.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_03.s new file mode 100644 index 0000000000..2d3a6034d9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/CodeSourcery/startup_ht32f1xxxx_cs3_03.s @@ -0,0 +1,370 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_cs3_03.s +; Version : $Rev:: 1771 $ +; Date : $Date:: 2019-07-25 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F12364 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <16=> HT32F12364 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00012364 +*/ + + .equ HT32F12364, 16 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* ---, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* ---, 03, 0x00C, Hard Fault Handler */ + .long MemManage_Handler /* ---, 04, 0x010, MPU Fault Handler */ + .long BusFault_Handler /* ---, 05, 0x014, Bus Fault Handler */ + .long UsageFault_Handler /* ---, 06, 0x018, Usage Fault Handler */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* ---, 11, 0x02C, SVC Handler */ + .long DebugMon_Handler /* ---, 12, 0x030, Debug Monitor Handler */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* ---, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* ---, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long CKRDY_IRQHandler /* 00, 16, 0x040, */ + .long LVD_IRQHandler /* 01, 17, 0x044, */ + .long BOD_IRQHandler /* 02, 18, 0x048, */ + .long _RESERVED /* 03, 19, 0x04C, */ + .long RTC_IRQHandler /* 04, 20, 0x050, */ + .long FLASH_IRQHandler /* 05, 21, 0x054, */ + .long EVWUP_IRQHandler /* 06, 22, 0x058, */ + .long LPWUP_IRQHandler /* 07, 23, 0x05C, */ + .long EXTI0_IRQHandler /* 08, 24, 0x060, */ + .long EXTI1_IRQHandler /* 09, 25, 0x064, */ + .long EXTI2_IRQHandler /* 10, 26, 0x068, */ + .long EXTI3_IRQHandler /* 11, 27, 0x06C, */ + .long EXTI4_IRQHandler /* 12, 28, 0x070, */ + .long EXTI5_IRQHandler /* 13, 29, 0x074, */ + .long EXTI6_IRQHandler /* 14, 30, 0x078, */ + .long EXTI7_IRQHandler /* 15, 31, 0x07C, */ + .long EXTI8_IRQHandler /* 16, 32, 0x080, */ + .long EXTI9_IRQHandler /* 17, 33, 0x084, */ + .long EXTI10_IRQHandler /* 18, 34, 0x088, */ + .long EXTI11_IRQHandler /* 19, 35, 0x08C, */ + .long EXTI12_IRQHandler /* 20, 36, 0x090, */ + .long EXTI13_IRQHandler /* 21, 37, 0x094, */ + .long EXTI14_IRQHandler /* 22, 38, 0x098, */ + .long EXTI15_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long ADC_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long _RESERVED /* 30, 46, 0x0B8, */ + .long _RESERVED /* 31, 47, 0x0BC, */ + .long _RESERVED /* 32, 48, 0x0C0, */ + .long _RESERVED /* 33, 49, 0x0C4, */ + .long _RESERVED /* 34, 50, 0x0C8, */ + .long GPTM0_IRQHandler /* 35, 51, 0x0CC, */ + .long _RESERVED /* 36, 52, 0x0D0, */ + .long SCTM0_IRQHandler /* 37, 53, 0x0D4, */ + .long SCTM1_IRQHandler /* 38, 54, 0x0D8, */ + .long PWM0_IRQHandler /* 39, 55, 0x0DC, */ + .long _RESERVED /* 40, 56, 0x0E0, */ + .long BFTM0_IRQHandler /* 41, 57, 0x0E4, */ + .long BFTM1_IRQHandler /* 42, 58, 0x0E8, */ + .long I2C0_IRQHandler /* 43, 59, 0x0EC, */ + .long I2C1_IRQHandler /* 44, 60, 0x0F0, */ + .long SPI0_IRQHandler /* 45, 61, 0x0F4, */ + .long SPI1_IRQHandler /* 46, 62, 0x0F8, */ + .long USART0_IRQHandler /* 47, 63, 0x0FC, */ + .long _RESERVED /* 48, 64, 0x100, */ + .long UART0_IRQHandler /* 49, 65, 0x104, */ + .long UART1_IRQHandler /* 50, 66, 0x108, */ + .long SCI_IRQHandler /* 51, 67, 0x10C, */ + .long _RESERVED /* 52, 68, 0x110, */ + .long USB_IRQHandler /* 53, 69, 0x114, */ + .long _RESERVED /* 54, 70, 0x118, */ + .long PDMA_CH0_IRQHandler /* 55, 71, 0x11C, */ + .long PDMA_CH1_IRQHandler /* 56, 72, 0x120, */ + .long PDMA_CH2_IRQHandler /* 57, 73, 0x124, */ + .long PDMA_CH3_IRQHandler /* 58, 74, 0x128, */ + .long PDMA_CH4_IRQHandler /* 59, 75, 0x12C, */ + .long PDMA_CH5_IRQHandler /* 60, 76, 0x130, */ + .long _RESERVED /* 61, 77, 0x134, */ + .long _RESERVED /* 62, 78, 0x138, */ + .long _RESERVED /* 63, 79, 0x13C, */ + .long _RESERVED /* 64, 80, 0x140, */ + .long _RESERVED /* 65, 81, 0x144, */ + .long _RESERVED /* 66, 82, 0x148, */ + .long _RESERVED /* 67, 83, 0x14C, */ + .long _RESERVED /* 68, 84, 0x150, */ + .long AES_IRQHandler /* 69, 85, 0x154, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak MemManage_Handler + .type MemManage_Handler, %function +MemManage_Handler: + B . + .size MemManage_Handler, . - MemManage_Handler + + .weak BusFault_Handler + .type BusFault_Handler, %function +BusFault_Handler: + B . + .size BusFault_Handler, . - BusFault_Handler + + .weak UsageFault_Handler + .type UsageFault_Handler, %function +UsageFault_Handler: + B . + .size UsageFault_Handler, . - UsageFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak DebugMon_Handler + .type DebugMon_Handler, %function +DebugMon_Handler: + B . + .size DebugMon_Handler, . - DebugMon_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ CKRDY_IRQHandler + IRQ LVD_IRQHandler + IRQ BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ LPWUP_IRQHandler + IRQ EXTI0_IRQHandler + IRQ EXTI1_IRQHandler + IRQ EXTI2_IRQHandler + IRQ EXTI3_IRQHandler + IRQ EXTI4_IRQHandler + IRQ EXTI5_IRQHandler + IRQ EXTI6_IRQHandler + IRQ EXTI7_IRQHandler + IRQ EXTI8_IRQHandler + IRQ EXTI9_IRQHandler + IRQ EXTI10_IRQHandler + IRQ EXTI11_IRQHandler + IRQ EXTI12_IRQHandler + IRQ EXTI13_IRQHandler + IRQ EXTI14_IRQHandler + IRQ EXTI15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_IRQHandler + IRQ PDMA_CH1_IRQHandler + IRQ PDMA_CH2_IRQHandler + IRQ PDMA_CH3_IRQHandler + IRQ PDMA_CH4_IRQHandler + IRQ PDMA_CH5_IRQHandler + IRQ AES_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_01.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_01.s new file mode 100644 index 0000000000..623ce3b725 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_01.s @@ -0,0 +1,485 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_gcc_01.s +; Version : $Rev:: 1578 $ +; Date : $Date:: 2019-03-29 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00012366 +*/ + + .equ HT32F1653_54_55_56, 1 + .equ HT32F12365_66, 2 + .equ HT32F12345, 3 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m3 + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* ---, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* ---, 03, 0x00C, Hard Fault Handler */ + .long MemManage_Handler /* ---, 04, 0x010, MPU Fault Handler */ + .long BusFault_Handler /* ---, 05, 0x014, Bus Fault Handler */ + .long UsageFault_Handler /* ---, 06, 0x018, Usage Fault Handler */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* ---, 11, 0x02C, SVC Handler */ + .long DebugMon_Handler /* ---, 12, 0x030, Debug Monitor Handler */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* ---, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* ---, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long CKRDY_IRQHandler /* 00, 16, 0x040, */ + .long LVD_IRQHandler /* 01, 17, 0x044, */ + .long BOD_IRQHandler /* 02, 18, 0x048, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long WDT_IRQHandler /* 03, 19, 0x04C, */ + .else + .long _RESERVED /* 03, 19, 0x04C, */ + .endif + .long RTC_IRQHandler /* 04, 20, 0x050, */ + .long FLASH_IRQHandler /* 05, 21, 0x054, */ + .long EVWUP_IRQHandler /* 06, 22, 0x058, */ + .long LPWUP_IRQHandler /* 07, 23, 0x05C, */ + .long EXTI0_IRQHandler /* 08, 24, 0x060, */ + .long EXTI1_IRQHandler /* 09, 25, 0x064, */ + .long EXTI2_IRQHandler /* 10, 26, 0x068, */ + .long EXTI3_IRQHandler /* 11, 27, 0x06C, */ + .long EXTI4_IRQHandler /* 12, 28, 0x070, */ + .long EXTI5_IRQHandler /* 13, 29, 0x074, */ + .long EXTI6_IRQHandler /* 14, 30, 0x078, */ + .long EXTI7_IRQHandler /* 15, 31, 0x07C, */ + .long EXTI8_IRQHandler /* 16, 32, 0x080, */ + .long EXTI9_IRQHandler /* 17, 33, 0x084, */ + .long EXTI10_IRQHandler /* 18, 34, 0x088, */ + .long EXTI11_IRQHandler /* 19, 35, 0x08C, */ + .long EXTI12_IRQHandler /* 20, 36, 0x090, */ + .long EXTI13_IRQHandler /* 21, 37, 0x094, */ + .long EXTI14_IRQHandler /* 22, 38, 0x098, */ + .long EXTI15_IRQHandler /* 23, 39, 0x09C, */ + .long COMP_IRQHandler /* 24, 40, 0x0A0, */ + .long ADC_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MCTM0BRK_IRQHandler /* 27, 43, 0x0AC, */ + .long MCTM0UP_IRQHandler /* 28, 44, 0x0B0, */ + .long MCTM0TR_IRQHandler /* 29, 45, 0x0B4, */ + .long MCTM0CC_IRQHandler /* 30, 46, 0x0B8, */ + .long MCTM1BRK_IRQHandler /* 31, 47, 0x0BC, */ + .long MCTM1UP_IRQHandler /* 32, 48, 0x0C0, */ + .long MCTM1TR_IRQHandler /* 33, 49, 0x0C4, */ + .long MCTM1CC_IRQHandler /* 34, 50, 0x0C8, */ + .long GPTM0_IRQHandler /* 35, 51, 0x0CC, */ + .long GPTM1_IRQHandler /* 36, 52, 0x0D0, */ + .long _RESERVED /* 37, 53, 0x0D4, */ + .long _RESERVED /* 38, 54, 0x0D8, */ + .long _RESERVED /* 39, 55, 0x0DC, */ + .long _RESERVED /* 40, 56, 0x0E0, */ + .long BFTM0_IRQHandler /* 41, 57, 0x0E4, */ + .long BFTM1_IRQHandler /* 42, 58, 0x0E8, */ + .long I2C0_IRQHandler /* 43, 59, 0x0EC, */ + .long I2C1_IRQHandler /* 44, 60, 0x0F0, */ + .long SPI0_IRQHandler /* 45, 61, 0x0F4, */ + .long SPI1_IRQHandler /* 46, 62, 0x0F8, */ + .long USART0_IRQHandler /* 47, 63, 0x0FC, */ + .long USART1_IRQHandler /* 48, 64, 0x100, */ + .long UART0_IRQHandler /* 49, 65, 0x104, */ + .long UART1_IRQHandler /* 50, 66, 0x108, */ + .if (USE_HT32_CHIP==HT32F12345) + .long _RESERVED /* 51, 67, 0x10C, */ + .else + .long SCI_IRQHandler /* 51, 67, 0x10C, */ + .endif + .long I2S_IRQHandler /* 52, 68, 0x110, */ + .long USB_IRQHandler /* 53, 69, 0x114, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long _RESERVED /* 54, 70, 0x118, */ + .else + .long SDIO_IRQHandler /* 54, 70, 0x118, */ + .endif + .long PDMA_CH0_IRQHandler /* 55, 71, 0x11C, */ + .long PDMA_CH1_IRQHandler /* 56, 72, 0x120, */ + .long PDMA_CH2_IRQHandler /* 57, 73, 0x124, */ + .long PDMA_CH3_IRQHandler /* 58, 74, 0x128, */ + .long PDMA_CH4_IRQHandler /* 59, 75, 0x12C, */ + .long PDMA_CH5_IRQHandler /* 60, 76, 0x130, */ + .long PDMA_CH6_IRQHandler /* 61, 77, 0x134, */ + .long PDMA_CH7_IRQHandler /* 62, 78, 0x138, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long _RESERVED /* 63, 79, 0x13C, */ + .long _RESERVED /* 64, 80, 0x140, */ + .long _RESERVED /* 65, 81, 0x144, */ + .long _RESERVED /* 66, 82, 0x148, */ + .else + .long PDMA_CH8_IRQHandler /* 63, 79, 0x13C, */ + .long PDMA_CH9_IRQHandler /* 64, 80, 0x140, */ + .long PDMA_CH10_IRQHandler /* 65, 81, 0x144, */ + .long PDMA_CH11_IRQHandler /* 66, 82, 0x148, */ + .endif + .if (USE_HT32_CHIP==HT32F12365_66) + .long CSIF_IRQHandler /* 67, 83, 0x14C, */ + .else + .long _RESERVED /* 67, 83, 0x14C, */ + .endif + .long EBI_IRQHandler /* 68, 84, 0x150, */ + .if (USE_HT32_CHIP==HT32F12365_66) + .long AES_IRQHandler /* 69, 85, 0x154, */ + .endif + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .else + LDR R0, =BootProcess + BLX R0 + .endif + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .else + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .endif + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak MemManage_Handler + .type MemManage_Handler, %function +MemManage_Handler: + B . + .size MemManage_Handler, . - MemManage_Handler + + .weak BusFault_Handler + .type BusFault_Handler, %function +BusFault_Handler: + B . + .size BusFault_Handler, . - BusFault_Handler + + .weak UsageFault_Handler + .type UsageFault_Handler, %function +UsageFault_Handler: + B . + .size UsageFault_Handler, . - UsageFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak DebugMon_Handler + .type DebugMon_Handler, %function +DebugMon_Handler: + B . + .size DebugMon_Handler, . - DebugMon_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ CKRDY_IRQHandler + IRQ LVD_IRQHandler + IRQ BOD_IRQHandler + IRQ WDT_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ LPWUP_IRQHandler + IRQ EXTI0_IRQHandler + IRQ EXTI1_IRQHandler + IRQ EXTI2_IRQHandler + IRQ EXTI3_IRQHandler + IRQ EXTI4_IRQHandler + IRQ EXTI5_IRQHandler + IRQ EXTI6_IRQHandler + IRQ EXTI7_IRQHandler + IRQ EXTI8_IRQHandler + IRQ EXTI9_IRQHandler + IRQ EXTI10_IRQHandler + IRQ EXTI11_IRQHandler + IRQ EXTI12_IRQHandler + IRQ EXTI13_IRQHandler + IRQ EXTI14_IRQHandler + IRQ EXTI15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0BRK_IRQHandler + IRQ MCTM0UP_IRQHandler + IRQ MCTM0TR_IRQHandler + IRQ MCTM0CC_IRQHandler + IRQ MCTM1BRK_IRQHandler + IRQ MCTM1UP_IRQHandler + IRQ MCTM1TR_IRQHandler + IRQ MCTM1CC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ GPTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ SDIO_IRQHandler + IRQ PDMA_CH0_IRQHandler + IRQ PDMA_CH1_IRQHandler + IRQ PDMA_CH2_IRQHandler + IRQ PDMA_CH3_IRQHandler + IRQ PDMA_CH4_IRQHandler + IRQ PDMA_CH5_IRQHandler + IRQ PDMA_CH6_IRQHandler + IRQ PDMA_CH7_IRQHandler + IRQ PDMA_CH8_IRQHandler + IRQ PDMA_CH9_IRQHandler + IRQ PDMA_CH10_IRQHandler + IRQ PDMA_CH11_IRQHandler + IRQ CSIF_IRQHandler + IRQ EBI_IRQHandler + IRQ AES_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_03.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_03.s new file mode 100644 index 0000000000..652eb11061 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/GCC/startup_ht32f1xxxx_gcc_03.s @@ -0,0 +1,428 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_gcc_03.s +; Version : $Rev:: 1771 $ +; Date : $Date:: 2019-07-25 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F12364 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <16=> HT32F12364 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00012364 +*/ + + .equ HT32F12364, 16 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m3 + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* ---, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* ---, 03, 0x00C, Hard Fault Handler */ + .long MemManage_Handler /* ---, 04, 0x010, MPU Fault Handler */ + .long BusFault_Handler /* ---, 05, 0x014, Bus Fault Handler */ + .long UsageFault_Handler /* ---, 06, 0x018, Usage Fault Handler */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* ---, 11, 0x02C, SVC Handler */ + .long DebugMon_Handler /* ---, 12, 0x030, Debug Monitor Handler */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* ---, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* ---, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long CKRDY_IRQHandler /* 00, 16, 0x040, */ + .long LVD_IRQHandler /* 01, 17, 0x044, */ + .long BOD_IRQHandler /* 02, 18, 0x048, */ + .long _RESERVED /* 03, 19, 0x04C, */ + .long RTC_IRQHandler /* 04, 20, 0x050, */ + .long FLASH_IRQHandler /* 05, 21, 0x054, */ + .long EVWUP_IRQHandler /* 06, 22, 0x058, */ + .long LPWUP_IRQHandler /* 07, 23, 0x05C, */ + .long EXTI0_IRQHandler /* 08, 24, 0x060, */ + .long EXTI1_IRQHandler /* 09, 25, 0x064, */ + .long EXTI2_IRQHandler /* 10, 26, 0x068, */ + .long EXTI3_IRQHandler /* 11, 27, 0x06C, */ + .long EXTI4_IRQHandler /* 12, 28, 0x070, */ + .long EXTI5_IRQHandler /* 13, 29, 0x074, */ + .long EXTI6_IRQHandler /* 14, 30, 0x078, */ + .long EXTI7_IRQHandler /* 15, 31, 0x07C, */ + .long EXTI8_IRQHandler /* 16, 32, 0x080, */ + .long EXTI9_IRQHandler /* 17, 33, 0x084, */ + .long EXTI10_IRQHandler /* 18, 34, 0x088, */ + .long EXTI11_IRQHandler /* 19, 35, 0x08C, */ + .long EXTI12_IRQHandler /* 20, 36, 0x090, */ + .long EXTI13_IRQHandler /* 21, 37, 0x094, */ + .long EXTI14_IRQHandler /* 22, 38, 0x098, */ + .long EXTI15_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long ADC_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long _RESERVED /* 30, 46, 0x0B8, */ + .long _RESERVED /* 31, 47, 0x0BC, */ + .long _RESERVED /* 32, 48, 0x0C0, */ + .long _RESERVED /* 33, 49, 0x0C4, */ + .long _RESERVED /* 34, 50, 0x0C8, */ + .long GPTM0_IRQHandler /* 35, 51, 0x0CC, */ + .long _RESERVED /* 36, 52, 0x0D0, */ + .long SCTM0_IRQHandler /* 37, 53, 0x0D4, */ + .long SCTM1_IRQHandler /* 38, 54, 0x0D8, */ + .long PWM0_IRQHandler /* 39, 55, 0x0DC, */ + .long _RESERVED /* 40, 56, 0x0E0, */ + .long BFTM0_IRQHandler /* 41, 57, 0x0E4, */ + .long BFTM1_IRQHandler /* 42, 58, 0x0E8, */ + .long I2C0_IRQHandler /* 43, 59, 0x0EC, */ + .long I2C1_IRQHandler /* 44, 60, 0x0F0, */ + .long SPI0_IRQHandler /* 45, 61, 0x0F4, */ + .long SPI1_IRQHandler /* 46, 62, 0x0F8, */ + .long USART0_IRQHandler /* 47, 63, 0x0FC, */ + .long _RESERVED /* 48, 64, 0x100, */ + .long UART0_IRQHandler /* 49, 65, 0x104, */ + .long UART1_IRQHandler /* 50, 66, 0x108, */ + .long SCI_IRQHandler /* 51, 67, 0x10C, */ + .long _RESERVED /* 52, 68, 0x110, */ + .long USB_IRQHandler /* 53, 69, 0x114, */ + .long _RESERVED /* 54, 70, 0x118, */ + .long PDMA_CH0_IRQHandler /* 55, 71, 0x11C, */ + .long PDMA_CH1_IRQHandler /* 56, 72, 0x120, */ + .long PDMA_CH2_IRQHandler /* 57, 73, 0x124, */ + .long PDMA_CH3_IRQHandler /* 58, 74, 0x128, */ + .long PDMA_CH4_IRQHandler /* 59, 75, 0x12C, */ + .long PDMA_CH5_IRQHandler /* 60, 76, 0x130, */ + .long _RESERVED /* 61, 77, 0x134, */ + .long _RESERVED /* 62, 78, 0x138, */ + .long _RESERVED /* 63, 79, 0x13C, */ + .long _RESERVED /* 64, 80, 0x140, */ + .long _RESERVED /* 65, 81, 0x144, */ + .long _RESERVED /* 66, 82, 0x148, */ + .long _RESERVED /* 67, 83, 0x14C, */ + .long _RESERVED /* 68, 84, 0x150, */ + .long AES_IRQHandler /* 69, 85, 0x154, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak MemManage_Handler + .type MemManage_Handler, %function +MemManage_Handler: + B . + .size MemManage_Handler, . - MemManage_Handler + + .weak BusFault_Handler + .type BusFault_Handler, %function +BusFault_Handler: + B . + .size BusFault_Handler, . - BusFault_Handler + + .weak UsageFault_Handler + .type UsageFault_Handler, %function +UsageFault_Handler: + B . + .size UsageFault_Handler, . - UsageFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak DebugMon_Handler + .type DebugMon_Handler, %function +DebugMon_Handler: + B . + .size DebugMon_Handler, . - DebugMon_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ CKRDY_IRQHandler + IRQ LVD_IRQHandler + IRQ BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ LPWUP_IRQHandler + IRQ EXTI0_IRQHandler + IRQ EXTI1_IRQHandler + IRQ EXTI2_IRQHandler + IRQ EXTI3_IRQHandler + IRQ EXTI4_IRQHandler + IRQ EXTI5_IRQHandler + IRQ EXTI6_IRQHandler + IRQ EXTI7_IRQHandler + IRQ EXTI8_IRQHandler + IRQ EXTI9_IRQHandler + IRQ EXTI10_IRQHandler + IRQ EXTI11_IRQHandler + IRQ EXTI12_IRQHandler + IRQ EXTI13_IRQHandler + IRQ EXTI14_IRQHandler + IRQ EXTI15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_IRQHandler + IRQ PDMA_CH1_IRQHandler + IRQ PDMA_CH2_IRQHandler + IRQ PDMA_CH3_IRQHandler + IRQ PDMA_CH4_IRQHandler + IRQ PDMA_CH5_IRQHandler + IRQ AES_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_01.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_01.s new file mode 100644 index 0000000000..331f561dc0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_01.s @@ -0,0 +1,416 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_iar_01.s +; Version : $Rev:: 1774 $ +; Date : $Date:: 2019-07-25 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 + +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012366 + +HT32F1653_54_55_56 EQU 1 +HT32F12365_66 EQU 2 +HT32F12345 EQU 3 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD WDT_IRQHandler ; 03, 19, 0x04C, + ELSE + DCD _RESERVED ; 03, 19, 0x04C, + ENDIF + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD COMP_IRQHandler ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MCTM0BRK_IRQHandler ; 27, 43, 0x0AC, + DCD MCTM0UP_IRQHandler ; 28, 44, 0x0B0, + DCD MCTM0TR_IRQHandler ; 29, 45, 0x0B4, + DCD MCTM0CC_IRQHandler ; 30, 46, 0x0B8, + DCD MCTM1BRK_IRQHandler ; 31, 47, 0x0BC, + DCD MCTM1UP_IRQHandler ; 32, 48, 0x0C0, + DCD MCTM1TR_IRQHandler ; 33, 49, 0x0C4, + DCD MCTM1CC_IRQHandler ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD GPTM1_IRQHandler ; 36, 52, 0x0D0, + DCD _RESERVED ; 37, 53, 0x0D4, + DCD _RESERVED ; 38, 54, 0x0D8, + DCD _RESERVED ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD USART1_IRQHandler ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + IF (USE_HT32_CHIP=HT32F12345) + DCD _RESERVED ; 51, 67, 0x10C, + ELSE + DCD SCI_IRQHandler ; 51, 67, 0x10C, + ENDIF + DCD I2S_IRQHandler ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 54, 70, 0x118, + ELSE + DCD SDIO_IRQHandler ; 54, 70, 0x118, + ENDIF + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD PDMA_CH6_IRQHandler ; 61, 77, 0x134, + DCD PDMA_CH7_IRQHandler ; 62, 78, 0x138, + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + ELSE + DCD PDMA_CH8_IRQHandler ; 63, 79, 0x13C, + DCD PDMA_CH9_IRQHandler ; 64, 80, 0x140, + DCD PDMA_CH10_IRQHandler ; 65, 81, 0x144, + DCD PDMA_CH11_IRQHandler ; 66, 82, 0x148, + ENDIF + IF (USE_HT32_CHIP=HT32F12365_66) + DCD CSIF_IRQHandler ; 67, 83, 0x14C, + ELSE + DCD _RESERVED ; 67, 83, 0x14C, + ENDIF + DCD EBI_IRQHandler ; 68, 84, 0x150, + IF (USE_HT32_CHIP=HT32F12365_66) + DCD AES_IRQHandler ; 69, 85, 0x154, + ENDIF + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE + LDR R0, =BootProcess + BLX R0 + ENDIF + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + IF (USE_HT32_CHIP=HT32F1653_54_55_56) + ELSE +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDIF + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK MemManage_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +MemManage_Handler + B . + + PUBWEAK BusFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +BusFault_Handler + B . + + PUBWEAK UsageFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +UsageFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK DebugMon_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +DebugMon_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK CKRDY_IRQHandler + PUBWEAK LVD_IRQHandler + PUBWEAK BOD_IRQHandler + PUBWEAK WDT_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK LPWUP_IRQHandler + PUBWEAK EXTI0_IRQHandler + PUBWEAK EXTI1_IRQHandler + PUBWEAK EXTI2_IRQHandler + PUBWEAK EXTI3_IRQHandler + PUBWEAK EXTI4_IRQHandler + PUBWEAK EXTI5_IRQHandler + PUBWEAK EXTI6_IRQHandler + PUBWEAK EXTI7_IRQHandler + PUBWEAK EXTI8_IRQHandler + PUBWEAK EXTI9_IRQHandler + PUBWEAK EXTI10_IRQHandler + PUBWEAK EXTI11_IRQHandler + PUBWEAK EXTI12_IRQHandler + PUBWEAK EXTI13_IRQHandler + PUBWEAK EXTI14_IRQHandler + PUBWEAK EXTI15_IRQHandler + PUBWEAK COMP_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK MCTM0BRK_IRQHandler + PUBWEAK MCTM0UP_IRQHandler + PUBWEAK MCTM0TR_IRQHandler + PUBWEAK MCTM0CC_IRQHandler + PUBWEAK MCTM1BRK_IRQHandler + PUBWEAK MCTM1UP_IRQHandler + PUBWEAK MCTM1TR_IRQHandler + PUBWEAK MCTM1CC_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK GPTM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK USART1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK SCI_IRQHandler + PUBWEAK I2S_IRQHandler + PUBWEAK USB_IRQHandler + PUBWEAK SDIO_IRQHandler + PUBWEAK PDMA_CH0_IRQHandler + PUBWEAK PDMA_CH1_IRQHandler + PUBWEAK PDMA_CH2_IRQHandler + PUBWEAK PDMA_CH3_IRQHandler + PUBWEAK PDMA_CH4_IRQHandler + PUBWEAK PDMA_CH5_IRQHandler + PUBWEAK PDMA_CH6_IRQHandler + PUBWEAK PDMA_CH7_IRQHandler + PUBWEAK PDMA_CH8_IRQHandler + PUBWEAK PDMA_CH9_IRQHandler + PUBWEAK PDMA_CH10_IRQHandler + PUBWEAK PDMA_CH11_IRQHandler + PUBWEAK CSIF_IRQHandler + PUBWEAK EBI_IRQHandler + PUBWEAK AES_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +WDT_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0BRK_IRQHandler +MCTM0UP_IRQHandler +MCTM0TR_IRQHandler +MCTM0CC_IRQHandler +MCTM1BRK_IRQHandler +MCTM1UP_IRQHandler +MCTM1TR_IRQHandler +MCTM1CC_IRQHandler +GPTM0_IRQHandler +GPTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +SDIO_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +PDMA_CH6_IRQHandler +PDMA_CH7_IRQHandler +PDMA_CH8_IRQHandler +PDMA_CH9_IRQHandler +PDMA_CH10_IRQHandler +PDMA_CH11_IRQHandler +CSIF_IRQHandler +EBI_IRQHandler +AES_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_03.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_03.s new file mode 100644 index 0000000000..dc39012845 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/IAR/startup_ht32f1xxxx_iar_03.s @@ -0,0 +1,339 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_iar_03.s +; Version : $Rev:: 1774 $ +; Date : $Date:: 2019-07-25 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F12364 + +;// HT32 Device +;// <0=> By Project Asm Define +;// <16=> HT32F12364 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00012364 + +HT32F12364 EQU 16 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; ---, 02, 0x008, NMI Handler + DCD HardFault_Handler ; ---, 03, 0x00C, Hard Fault Handler + DCD MemManage_Handler ; ---, 04, 0x010, Memory Management Fault Handler + DCD BusFault_Handler ; ---, 05, 0x014, Bus Fault Handler + DCD UsageFault_Handler ; ---, 06, 0x018, Usage Fault Handler + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; ---, 11, 0x02C, SVC Handler + DCD DebugMon_Handler ; ---, 12, 0x030, Debug Monitor Handler + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; ---, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; ---, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD CKRDY_IRQHandler ; 00, 16, 0x040, + DCD LVD_IRQHandler ; 01, 17, 0x044, + DCD BOD_IRQHandler ; 02, 18, 0x048, + DCD _RESERVED ; 03, 19, 0x04C, + DCD RTC_IRQHandler ; 04, 20, 0x050, + DCD FLASH_IRQHandler ; 05, 21, 0x054, + DCD EVWUP_IRQHandler ; 06, 22, 0x058, + DCD LPWUP_IRQHandler ; 07, 23, 0x05C, + DCD EXTI0_IRQHandler ; 08, 24, 0x060, + DCD EXTI1_IRQHandler ; 09, 25, 0x064, + DCD EXTI2_IRQHandler ; 10, 26, 0x068, + DCD EXTI3_IRQHandler ; 11, 27, 0x06C, + DCD EXTI4_IRQHandler ; 12, 28, 0x070, + DCD EXTI5_IRQHandler ; 13, 29, 0x074, + DCD EXTI6_IRQHandler ; 14, 30, 0x078, + DCD EXTI7_IRQHandler ; 15, 31, 0x07C, + DCD EXTI8_IRQHandler ; 16, 32, 0x080, + DCD EXTI9_IRQHandler ; 17, 33, 0x084, + DCD EXTI10_IRQHandler ; 18, 34, 0x088, + DCD EXTI11_IRQHandler ; 19, 35, 0x08C, + DCD EXTI12_IRQHandler ; 20, 36, 0x090, + DCD EXTI13_IRQHandler ; 21, 37, 0x094, + DCD EXTI14_IRQHandler ; 22, 38, 0x098, + DCD EXTI15_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD ADC_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + DCD _RESERVED ; 32, 48, 0x0C0, + DCD _RESERVED ; 33, 49, 0x0C4, + DCD _RESERVED ; 34, 50, 0x0C8, + DCD GPTM0_IRQHandler ; 35, 51, 0x0CC, + DCD _RESERVED ; 36, 52, 0x0D0, + DCD SCTM0_IRQHandler ; 37, 53, 0x0D4, + DCD SCTM1_IRQHandler ; 38, 54, 0x0D8, + DCD PWM0_IRQHandler ; 39, 55, 0x0DC, + DCD _RESERVED ; 40, 56, 0x0E0, + DCD BFTM0_IRQHandler ; 41, 57, 0x0E4, + DCD BFTM1_IRQHandler ; 42, 58, 0x0E8, + DCD I2C0_IRQHandler ; 43, 59, 0x0EC, + DCD I2C1_IRQHandler ; 44, 60, 0x0F0, + DCD SPI0_IRQHandler ; 45, 61, 0x0F4, + DCD SPI1_IRQHandler ; 46, 62, 0x0F8, + DCD USART0_IRQHandler ; 47, 63, 0x0FC, + DCD _RESERVED ; 48, 64, 0x100, + DCD UART0_IRQHandler ; 49, 65, 0x104, + DCD UART1_IRQHandler ; 50, 66, 0x108, + DCD SCI_IRQHandler ; 51, 67, 0x10C, + DCD _RESERVED ; 52, 68, 0x110, + DCD USB_IRQHandler ; 53, 69, 0x114, + DCD _RESERVED ; 54, 70, 0x118, + DCD PDMA_CH0_IRQHandler ; 55, 71, 0x11C, + DCD PDMA_CH1_IRQHandler ; 56, 72, 0x120, + DCD PDMA_CH2_IRQHandler ; 57, 73, 0x124, + DCD PDMA_CH3_IRQHandler ; 58, 74, 0x128, + DCD PDMA_CH4_IRQHandler ; 59, 75, 0x12C, + DCD PDMA_CH5_IRQHandler ; 60, 76, 0x130, + DCD _RESERVED ; 61, 77, 0x134, + DCD _RESERVED ; 62, 78, 0x138, + DCD _RESERVED ; 63, 79, 0x13C, + DCD _RESERVED ; 64, 80, 0x140, + DCD _RESERVED ; 65, 81, 0x144, + DCD _RESERVED ; 66, 82, 0x148, + DCD _RESERVED ; 67, 83, 0x14C, + DCD _RESERVED ; 68, 84, 0x150, + DCD AES_IRQHandler ; 69, 85, 0x154, + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK MemManage_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +MemManage_Handler + B . + + PUBWEAK BusFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +BusFault_Handler + B . + + PUBWEAK UsageFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +UsageFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK DebugMon_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +DebugMon_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK CKRDY_IRQHandler + PUBWEAK LVD_IRQHandler + PUBWEAK BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK LPWUP_IRQHandler + PUBWEAK EXTI0_IRQHandler + PUBWEAK EXTI1_IRQHandler + PUBWEAK EXTI2_IRQHandler + PUBWEAK EXTI3_IRQHandler + PUBWEAK EXTI4_IRQHandler + PUBWEAK EXTI5_IRQHandler + PUBWEAK EXTI6_IRQHandler + PUBWEAK EXTI7_IRQHandler + PUBWEAK EXTI8_IRQHandler + PUBWEAK EXTI9_IRQHandler + PUBWEAK EXTI10_IRQHandler + PUBWEAK EXTI11_IRQHandler + PUBWEAK EXTI12_IRQHandler + PUBWEAK EXTI13_IRQHandler + PUBWEAK EXTI14_IRQHandler + PUBWEAK EXTI15_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK SCI_IRQHandler + PUBWEAK USB_IRQHandler + PUBWEAK PDMA_CH0_IRQHandler + PUBWEAK PDMA_CH1_IRQHandler + PUBWEAK PDMA_CH2_IRQHandler + PUBWEAK PDMA_CH3_IRQHandler + PUBWEAK PDMA_CH4_IRQHandler + PUBWEAK PDMA_CH5_IRQHandler + PUBWEAK AES_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +CKRDY_IRQHandler +LVD_IRQHandler +BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +LPWUP_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +EXTI5_IRQHandler +EXTI6_IRQHandler +EXTI7_IRQHandler +EXTI8_IRQHandler +EXTI9_IRQHandler +EXTI10_IRQHandler +EXTI11_IRQHandler +EXTI12_IRQHandler +EXTI13_IRQHandler +EXTI14_IRQHandler +EXTI15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +USB_IRQHandler +PDMA_CH0_IRQHandler +PDMA_CH1_IRQHandler +PDMA_CH2_IRQHandler +PDMA_CH3_IRQHandler +PDMA_CH4_IRQHandler +PDMA_CH5_IRQHandler +AES_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/SEGGER_THUMB_Startup.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/SEGGER_THUMB_Startup.s new file mode 100644 index 0000000000..63a379c804 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/SEGGER_THUMB_Startup.s @@ -0,0 +1,435 @@ +// ********************************************************************** +// * SEGGER Microcontroller GmbH * +// * The Embedded Experts * +// ********************************************************************** +// * * +// * (c) 2014 - 2018 SEGGER Microcontroller GmbH * +// * (c) 2001 - 2018 Rowley Associates Limited * +// * * +// * www.segger.com Support: support@segger.com * +// * * +// ********************************************************************** +// * * +// * All rights reserved. * +// * * +// * Redistribution and use in source and binary forms, with or * +// * without modification, are permitted provided that the following * +// * conditions are met: * +// * * +// * - Redistributions of source code must retain the above copyright * +// * notice, this list of conditions and the following disclaimer. * +// * * +// * - Neither the name of SEGGER Microcontroller GmbH * +// * nor the names of its contributors may be used to endorse or * +// * promote products derived from this software without specific * +// * prior written permission. * +// * * +// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +// * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +// * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +// * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +// * DISCLAIMED. * +// * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR * +// * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +// * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +// * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +// * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +// * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +// * DAMAGE. * +// * * +// ********************************************************************** +// Preprocessor Definitions +// ------------------------ +// +// FULL_LIBRARY +// +// If defined then +// - argc, argv are setup by the debug_getargs. +// - the exit symbol is defined and executes on return from main. +// - the exit symbol calls destructors, atexit functions and then debug_exit. +// +// If not defined then +// - argc and argv are zero. +// - the exit symbol is defined, executes on return from main and loops +// + + .syntax unified + + .section .segger.init.__SEGGER_init_lzss, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_lzss +.thumb_func +__SEGGER_init_lzss: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source stream + adds r4, r4, #8 +2: + ldrb r2, [r1] + adds r1, r1, #1 + tst r2, r2 + beq 9f @ 0 -> end of table + cmp r2, #0x80 + bcc 1f @ +ve -> literal run +// +// -ve -> copy run +// +// r0 = pointer to output stream +// r1 = pointer to input stream +// r2 = run length +// r3 = copy byte +// r4 = pointer to initialization table +// +3: + subs r2, r2, #0x80 // convert to run length + beq 10f + ldrb r3, [r1] // r3 = first byte of distance + adds r1, r1, #1 + cmp r3, #0x80 + bcc 5f // r3 < 128, short run + subs r3, r3, #0x80 // Adjust to recover true run length high byte + lsls r3, r3, #8 // Prepare to fuse + ldrb r5, [r1] // extract run length low byte + adds r1, r1, #1 + adds r3, r3, r5 // construct run length +5: + subs r5, r0, r3 // source of where to copy from +4: + ldrb r3, [r5] // source byte of run + strb r3, [r0] // store to destination + adds r5, r5, #1 + adds r0, r0, #1 + subs r2, r2, #1 + bne 4b + b 2b +// +// +ve -> literal run +// +// r0 = pointer to output stream +// r1 = pointer to input stream +// r2 = run length +// r3 = copy byte +// r4 = pointer to initialization table +// +1: + ldrb r3, [r1] // source byte of run + adds r1, r1, #1 + strb r3, [r0] // store to destination + adds r0, r0, #1 + subs r2, r2, #1 + bne 1b + b 2b +9: + bx lr +10: + b 10b + + .section .segger.init.__SEGGER_init_zero, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_zero +.thumb_func +__SEGGER_init_zero: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ size + adds r4, r4, #8 + tst r1, r1 + beq 2f + movs r2, #0 +1: + strb r2, [r0] + adds r0, r0, #1 + subs r1, r1, #1 + bne 1b +2: + bx lr + + .section .segger.init.__SEGGER_init_copy, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_copy +.thumb_func +__SEGGER_init_copy: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source + ldr r2, [r4, #8] @ size + adds r4, r4, #12 + tst r2, r2 + beq 2f +1: + ldrb r3, [r1] + strb r3, [r0] + adds r0, r0, #1 + adds r1, r1, #1 + subs r2, r2, #1 + bne 1b +2: + bx lr + + .section .segger.init.__SEGGER_init_pack, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_pack +.thumb_func +__SEGGER_init_pack: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source stream + adds r4, r4, #8 +1: + ldrb r2, [r1] + adds r1, r1, #1 + cmp r2, #0x80 + beq 4f + bcc 3f + ldrb r3, [r1] @ byte to replicate + adds r1, r1, #1 + negs r2, r2 + adds r2, r2, #255 + adds r2, r2, #1 +2: + strb r3, [r0] + adds r0, r0, #1 + subs r2, r2, #1 + bpl 2b + b 1b + +3: @ 1+n literal bytes + ldrb r3, [r1] + strb r3, [r0] + adds r0, r0, #1 + adds r1, r1, #1 + subs r2, r2, #1 + bpl 3b + b 1b +4: + bx lr + + .section .segger.init.__SEGGER_init_zpak, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_zpak +.thumb_func +__SEGGER_init_zpak: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source stream + ldr r2, [r4, #8] @ size + adds r4, r4, #12 @ skip table entries +1: + ldrb r3, [r1] @ get control byte from source stream + adds r1, r1, #1 + movs r6, #8 +2: + movs r5, #0 @ prepare zero filler + lsrs r3, r3, #1 @ get byte control flag + bcs 3f @ carry set -> zero filler + ldrb r5, [r1] @ get literal byte from source stream + adds r1, r1, #1 +3: + strb r5, [r0] @ store initialization byte + adds r0, r0, #1 + subs r2, r2, #1 @ size -= 1 + beq 4f @ exit when destination filled + subs r6, r6, #1 @ decrement bit count + bne 2b @ still within this control byte + b 1b @ get next control byte +4: + bx lr + +#ifndef APP_ENTRY_POINT +#define APP_ENTRY_POINT main +#endif + +#ifndef ARGSSPACE +#define ARGSSPACE 128 +#endif + + .global _start + .extern APP_ENTRY_POINT + .global exit + .weak exit + +#ifdef INITIALIZE_USER_SECTIONS + .extern InitializeUserMemorySections +#endif + + .section .init, "ax" + .code 16 + .align 1 + .thumb_func + +_start: + ldr r0, = __stack_end__ + mov sp, r0 + ldr r4, =__SEGGER_init_table__ +1: + ldr r0, [r4] + adds r4, r4, #4 + tst r0, r0 + beq 2f + blx r0 + b 1b +2: + + /* Initialize the heap */ + ldr r0, = __heap_start__ + ldr r1, = __heap_end__ + subs r1, r1, r0 + cmp r1, #8 + blt 1f + movs r2, #0 + str r2, [r0] + adds r0, r0, #4 + str r1, [r0] +1: + +#ifdef INITIALIZE_USER_SECTIONS + ldr r2, =InitializeUserMemorySections + blx r2 +#endif + + /* Call constructors */ + ldr r0, =__ctors_start__ + ldr r1, =__ctors_end__ +ctor_loop: + cmp r0, r1 + beq ctor_end + ldr r2, [r0] + adds r0, #4 + push {r0-r1} + blx r2 + pop {r0-r1} + b ctor_loop +ctor_end: + + /* Setup initial call frame */ + movs r0, #0 + mov lr, r0 + mov r12, sp + + .type start, function +start: + /* Jump to application entry point */ +#ifdef FULL_LIBRARY + movs r0, #ARGSSPACE + ldr r1, =args + ldr r2, =debug_getargs + blx r2 + ldr r1, =args +#else + movs r0, #0 + movs r1, #0 +#endif + ldr r2, =APP_ENTRY_POINT + blx r2 + + .thumb_func +exit: +#ifdef FULL_LIBRARY + mov r5, r0 // save the exit parameter/return result + + /* Call destructors */ + ldr r0, =__dtors_start__ + ldr r1, =__dtors_end__ +dtor_loop: + cmp r0, r1 + beq dtor_end + ldr r2, [r0] + add r0, #4 + push {r0-r1} + blx r2 + pop {r0-r1} + b dtor_loop +dtor_end: + + /* Call atexit functions */ + ldr r2, =_execute_at_exit_fns + blx r2 + + /* Call debug_exit with return result/exit parameter */ + mov r0, r5 + ldr r2, =debug_exit + blx r2 +#endif + + /* Returned from application entry point, loop forever. */ +exit_loop: + b exit_loop + + // default C/C++ library helpers + +.macro HELPER helper_name + .section .text.\helper_name, "ax", %progbits + .global \helper_name + .align 1 + .weak \helper_name +\helper_name: + .thumb_func +.endm + +.macro JUMPTO name +#if defined(__thumb__) && !defined(__thumb2__) + mov r12, r0 + ldr r0, =\name + push {r0} + mov r0, r12 + pop {pc} +#else + b \name +#endif +.endm + +HELPER __aeabi_read_tp + ldr r0, =__tbss_start__-8 + bx lr +HELPER abort + b . +HELPER __assert + b . +HELPER __aeabi_assert + b . +HELPER __sync_synchronize + bx lr +HELPER __getchar + JUMPTO debug_getchar +HELPER __putchar + JUMPTO debug_putchar +HELPER __open + JUMPTO debug_fopen +HELPER __close + JUMPTO debug_fclose +HELPER __write + mov r3, r0 + mov r0, r1 + movs r1, #1 + JUMPTO debug_fwrite +HELPER __read + mov r3, r0 + mov r0, r1 + movs r1, #1 + JUMPTO debug_fread +HELPER __seek + push {r4, lr} + mov r4, r0 + bl debug_fseek + cmp r0, #0 + bne 1f + mov r0, r4 + bl debug_ftell + pop {r4, pc} +1: + ldr r0, =-1 + pop {r4, pc} + // char __user_locale_name_buffer[]; + .section .bss.__user_locale_name_buffer, "aw", %nobits + .global __user_locale_name_buffer + .weak __user_locale_name_buffer + __user_locale_name_buffer: + .word 0x0 + +#ifdef FULL_LIBRARY + .bss +args: + .space ARGSSPACE +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_01.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_01.s new file mode 100644 index 0000000000..5f60bca990 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_01.s @@ -0,0 +1,391 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_es_01.s +; Version : $Rev:: 1578 $ +; Date : $Date:: 2019-03-29 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F1653, HT32F1654 +; HT32F1655, HT32F1656 +; HT32F12365, HT32F12366 +; HT32F12345 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F1653/1654/1655/1656 +;// <2=> HT32F12365/12366 +;// <3=> HT32F12345 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00012366 +*/ + + .equ HT32F1653_54_55_56, 1 + .equ HT32F12365_66, 2 + .equ HT32F12345, 3 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* ---, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* ---, 03, 0x00C, Hard Fault Handler */ + .long MemManage_Handler /* ---, 04, 0x010, MPU Fault Handler */ + .long BusFault_Handler /* ---, 05, 0x014, Bus Fault Handler */ + .long UsageFault_Handler /* ---, 06, 0x018, Usage Fault Handler */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* ---, 11, 0x02C, SVC Handler */ + .long DebugMon_Handler /* ---, 12, 0x030, Debug Monitor Handler */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* ---, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* ---, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long CKRDY_IRQHandler /* 00, 16, 0x040, */ + .long LVD_IRQHandler /* 01, 17, 0x044, */ + .long BOD_IRQHandler /* 02, 18, 0x048, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long WDT_IRQHandler /* 03, 19, 0x04C, */ + .else + .long _RESERVED /* 03, 19, 0x04C, */ + .endif + .long RTC_IRQHandler /* 04, 20, 0x050, */ + .long FLASH_IRQHandler /* 05, 21, 0x054, */ + .long EVWUP_IRQHandler /* 06, 22, 0x058, */ + .long LPWUP_IRQHandler /* 07, 23, 0x05C, */ + .long EXTI0_IRQHandler /* 08, 24, 0x060, */ + .long EXTI1_IRQHandler /* 09, 25, 0x064, */ + .long EXTI2_IRQHandler /* 10, 26, 0x068, */ + .long EXTI3_IRQHandler /* 11, 27, 0x06C, */ + .long EXTI4_IRQHandler /* 12, 28, 0x070, */ + .long EXTI5_IRQHandler /* 13, 29, 0x074, */ + .long EXTI6_IRQHandler /* 14, 30, 0x078, */ + .long EXTI7_IRQHandler /* 15, 31, 0x07C, */ + .long EXTI8_IRQHandler /* 16, 32, 0x080, */ + .long EXTI9_IRQHandler /* 17, 33, 0x084, */ + .long EXTI10_IRQHandler /* 18, 34, 0x088, */ + .long EXTI11_IRQHandler /* 19, 35, 0x08C, */ + .long EXTI12_IRQHandler /* 20, 36, 0x090, */ + .long EXTI13_IRQHandler /* 21, 37, 0x094, */ + .long EXTI14_IRQHandler /* 22, 38, 0x098, */ + .long EXTI15_IRQHandler /* 23, 39, 0x09C, */ + .long COMP_IRQHandler /* 24, 40, 0x0A0, */ + .long ADC_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MCTM0BRK_IRQHandler /* 27, 43, 0x0AC, */ + .long MCTM0UP_IRQHandler /* 28, 44, 0x0B0, */ + .long MCTM0TR_IRQHandler /* 29, 45, 0x0B4, */ + .long MCTM0CC_IRQHandler /* 30, 46, 0x0B8, */ + .long MCTM1BRK_IRQHandler /* 31, 47, 0x0BC, */ + .long MCTM1UP_IRQHandler /* 32, 48, 0x0C0, */ + .long MCTM1TR_IRQHandler /* 33, 49, 0x0C4, */ + .long MCTM1CC_IRQHandler /* 34, 50, 0x0C8, */ + .long GPTM0_IRQHandler /* 35, 51, 0x0CC, */ + .long GPTM1_IRQHandler /* 36, 52, 0x0D0, */ + .long _RESERVED /* 37, 53, 0x0D4, */ + .long _RESERVED /* 38, 54, 0x0D8, */ + .long _RESERVED /* 39, 55, 0x0DC, */ + .long _RESERVED /* 40, 56, 0x0E0, */ + .long BFTM0_IRQHandler /* 41, 57, 0x0E4, */ + .long BFTM1_IRQHandler /* 42, 58, 0x0E8, */ + .long I2C0_IRQHandler /* 43, 59, 0x0EC, */ + .long I2C1_IRQHandler /* 44, 60, 0x0F0, */ + .long SPI0_IRQHandler /* 45, 61, 0x0F4, */ + .long SPI1_IRQHandler /* 46, 62, 0x0F8, */ + .long USART0_IRQHandler /* 47, 63, 0x0FC, */ + .long USART1_IRQHandler /* 48, 64, 0x100, */ + .long UART0_IRQHandler /* 49, 65, 0x104, */ + .long UART1_IRQHandler /* 50, 66, 0x108, */ + .if (USE_HT32_CHIP==HT32F12345) + .long _RESERVED /* 51, 67, 0x10C, */ + .else + .long SCI_IRQHandler /* 51, 67, 0x10C, */ + .endif + .long I2S_IRQHandler /* 52, 68, 0x110, */ + .long USB_IRQHandler /* 53, 69, 0x114, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long _RESERVED /* 54, 70, 0x118, */ + .else + .long SDIO_IRQHandler /* 54, 70, 0x118, */ + .endif + .long PDMA_CH0_IRQHandler /* 55, 71, 0x11C, */ + .long PDMA_CH1_IRQHandler /* 56, 72, 0x120, */ + .long PDMA_CH2_IRQHandler /* 57, 73, 0x124, */ + .long PDMA_CH3_IRQHandler /* 58, 74, 0x128, */ + .long PDMA_CH4_IRQHandler /* 59, 75, 0x12C, */ + .long PDMA_CH5_IRQHandler /* 60, 76, 0x130, */ + .long PDMA_CH6_IRQHandler /* 61, 77, 0x134, */ + .long PDMA_CH7_IRQHandler /* 62, 78, 0x138, */ + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .long _RESERVED /* 63, 79, 0x13C, */ + .long _RESERVED /* 64, 80, 0x140, */ + .long _RESERVED /* 65, 81, 0x144, */ + .long _RESERVED /* 66, 82, 0x148, */ + .else + .long PDMA_CH8_IRQHandler /* 63, 79, 0x13C, */ + .long PDMA_CH9_IRQHandler /* 64, 80, 0x140, */ + .long PDMA_CH10_IRQHandler /* 65, 81, 0x144, */ + .long PDMA_CH11_IRQHandler /* 66, 82, 0x148, */ + .endif + .if (USE_HT32_CHIP==HT32F12365_66) + .long CSIF_IRQHandler /* 67, 83, 0x14C, */ + .else + .long _RESERVED /* 67, 83, 0x14C, */ + .endif + .long EBI_IRQHandler /* 68, 84, 0x150, */ + .if (USE_HT32_CHIP==HT32F12365_66) + .long AES_IRQHandler /* 69, 85, 0x154, */ + .endif + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .else + LDR R0, =BootProcess + BLX R0 + .endif + LDR R0, =SystemInit + BLX R0 + BL _start + .if (USE_HT32_CHIP==HT32F1653_54_55_56) + .else + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .endif + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak MemManage_Handler + .type MemManage_Handler, %function +MemManage_Handler: + B . + .size MemManage_Handler, . - MemManage_Handler + + .weak BusFault_Handler + .type BusFault_Handler, %function +BusFault_Handler: + B . + .size BusFault_Handler, . - BusFault_Handler + + .weak UsageFault_Handler + .type UsageFault_Handler, %function +UsageFault_Handler: + B . + .size UsageFault_Handler, . - UsageFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak DebugMon_Handler + .type DebugMon_Handler, %function +DebugMon_Handler: + B . + .size DebugMon_Handler, . - DebugMon_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ CKRDY_IRQHandler + IRQ LVD_IRQHandler + IRQ BOD_IRQHandler + IRQ WDT_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ LPWUP_IRQHandler + IRQ EXTI0_IRQHandler + IRQ EXTI1_IRQHandler + IRQ EXTI2_IRQHandler + IRQ EXTI3_IRQHandler + IRQ EXTI4_IRQHandler + IRQ EXTI5_IRQHandler + IRQ EXTI6_IRQHandler + IRQ EXTI7_IRQHandler + IRQ EXTI8_IRQHandler + IRQ EXTI9_IRQHandler + IRQ EXTI10_IRQHandler + IRQ EXTI11_IRQHandler + IRQ EXTI12_IRQHandler + IRQ EXTI13_IRQHandler + IRQ EXTI14_IRQHandler + IRQ EXTI15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0BRK_IRQHandler + IRQ MCTM0UP_IRQHandler + IRQ MCTM0TR_IRQHandler + IRQ MCTM0CC_IRQHandler + IRQ MCTM1BRK_IRQHandler + IRQ MCTM1UP_IRQHandler + IRQ MCTM1TR_IRQHandler + IRQ MCTM1CC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ GPTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ SDIO_IRQHandler + IRQ PDMA_CH0_IRQHandler + IRQ PDMA_CH1_IRQHandler + IRQ PDMA_CH2_IRQHandler + IRQ PDMA_CH3_IRQHandler + IRQ PDMA_CH4_IRQHandler + IRQ PDMA_CH5_IRQHandler + IRQ PDMA_CH6_IRQHandler + IRQ PDMA_CH7_IRQHandler + IRQ PDMA_CH8_IRQHandler + IRQ PDMA_CH9_IRQHandler + IRQ PDMA_CH10_IRQHandler + IRQ PDMA_CH11_IRQHandler + IRQ CSIF_IRQHandler + IRQ EBI_IRQHandler + IRQ AES_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_03.s b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_03.s new file mode 100644 index 0000000000..4360057e33 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/emStudio/startup_ht32f1xxxx_es_03.s @@ -0,0 +1,335 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f1xxxx_es_03.s +; Version : $Rev:: 1771 $ +; Date : $Date:: 2019-07-25 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F12364 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <16=> HT32F12364 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00012364 +*/ + + .equ HT32F12364, 16 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* ---, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* ---, 03, 0x00C, Hard Fault Handler */ + .long MemManage_Handler /* ---, 04, 0x010, MPU Fault Handler */ + .long BusFault_Handler /* ---, 05, 0x014, Bus Fault Handler */ + .long UsageFault_Handler /* ---, 06, 0x018, Usage Fault Handler */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* ---, 11, 0x02C, SVC Handler */ + .long DebugMon_Handler /* ---, 12, 0x030, Debug Monitor Handler */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* ---, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* ---, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long CKRDY_IRQHandler /* 00, 16, 0x040, */ + .long LVD_IRQHandler /* 01, 17, 0x044, */ + .long BOD_IRQHandler /* 02, 18, 0x048, */ + .long _RESERVED /* 03, 19, 0x04C, */ + .long RTC_IRQHandler /* 04, 20, 0x050, */ + .long FLASH_IRQHandler /* 05, 21, 0x054, */ + .long EVWUP_IRQHandler /* 06, 22, 0x058, */ + .long LPWUP_IRQHandler /* 07, 23, 0x05C, */ + .long EXTI0_IRQHandler /* 08, 24, 0x060, */ + .long EXTI1_IRQHandler /* 09, 25, 0x064, */ + .long EXTI2_IRQHandler /* 10, 26, 0x068, */ + .long EXTI3_IRQHandler /* 11, 27, 0x06C, */ + .long EXTI4_IRQHandler /* 12, 28, 0x070, */ + .long EXTI5_IRQHandler /* 13, 29, 0x074, */ + .long EXTI6_IRQHandler /* 14, 30, 0x078, */ + .long EXTI7_IRQHandler /* 15, 31, 0x07C, */ + .long EXTI8_IRQHandler /* 16, 32, 0x080, */ + .long EXTI9_IRQHandler /* 17, 33, 0x084, */ + .long EXTI10_IRQHandler /* 18, 34, 0x088, */ + .long EXTI11_IRQHandler /* 19, 35, 0x08C, */ + .long EXTI12_IRQHandler /* 20, 36, 0x090, */ + .long EXTI13_IRQHandler /* 21, 37, 0x094, */ + .long EXTI14_IRQHandler /* 22, 38, 0x098, */ + .long EXTI15_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long ADC_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long _RESERVED /* 30, 46, 0x0B8, */ + .long _RESERVED /* 31, 47, 0x0BC, */ + .long _RESERVED /* 32, 48, 0x0C0, */ + .long _RESERVED /* 33, 49, 0x0C4, */ + .long _RESERVED /* 34, 50, 0x0C8, */ + .long GPTM0_IRQHandler /* 35, 51, 0x0CC, */ + .long _RESERVED /* 36, 52, 0x0D0, */ + .long SCTM0_IRQHandler /* 37, 53, 0x0D4, */ + .long SCTM1_IRQHandler /* 38, 54, 0x0D8, */ + .long PWM0_IRQHandler /* 39, 55, 0x0DC, */ + .long _RESERVED /* 40, 56, 0x0E0, */ + .long BFTM0_IRQHandler /* 41, 57, 0x0E4, */ + .long BFTM1_IRQHandler /* 42, 58, 0x0E8, */ + .long I2C0_IRQHandler /* 43, 59, 0x0EC, */ + .long I2C1_IRQHandler /* 44, 60, 0x0F0, */ + .long SPI0_IRQHandler /* 45, 61, 0x0F4, */ + .long SPI1_IRQHandler /* 46, 62, 0x0F8, */ + .long USART0_IRQHandler /* 47, 63, 0x0FC, */ + .long _RESERVED /* 48, 64, 0x100, */ + .long UART0_IRQHandler /* 49, 65, 0x104, */ + .long UART1_IRQHandler /* 50, 66, 0x108, */ + .long SCI_IRQHandler /* 51, 67, 0x10C, */ + .long _RESERVED /* 52, 68, 0x110, */ + .long USB_IRQHandler /* 53, 69, 0x114, */ + .long _RESERVED /* 54, 70, 0x118, */ + .long PDMA_CH0_IRQHandler /* 55, 71, 0x11C, */ + .long PDMA_CH1_IRQHandler /* 56, 72, 0x120, */ + .long PDMA_CH2_IRQHandler /* 57, 73, 0x124, */ + .long PDMA_CH3_IRQHandler /* 58, 74, 0x128, */ + .long PDMA_CH4_IRQHandler /* 59, 75, 0x12C, */ + .long PDMA_CH5_IRQHandler /* 60, 76, 0x130, */ + .long _RESERVED /* 61, 77, 0x134, */ + .long _RESERVED /* 62, 78, 0x138, */ + .long _RESERVED /* 63, 79, 0x13C, */ + .long _RESERVED /* 64, 80, 0x140, */ + .long _RESERVED /* 65, 81, 0x144, */ + .long _RESERVED /* 66, 82, 0x148, */ + .long _RESERVED /* 67, 83, 0x14C, */ + .long _RESERVED /* 68, 84, 0x150, */ + .long AES_IRQHandler /* 69, 85, 0x154, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #1 + BEQ BP3 + CMP R1, #2 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak MemManage_Handler + .type MemManage_Handler, %function +MemManage_Handler: + B . + .size MemManage_Handler, . - MemManage_Handler + + .weak BusFault_Handler + .type BusFault_Handler, %function +BusFault_Handler: + B . + .size BusFault_Handler, . - BusFault_Handler + + .weak UsageFault_Handler + .type UsageFault_Handler, %function +UsageFault_Handler: + B . + .size UsageFault_Handler, . - UsageFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak DebugMon_Handler + .type DebugMon_Handler, %function +DebugMon_Handler: + B . + .size DebugMon_Handler, . - DebugMon_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ CKRDY_IRQHandler + IRQ LVD_IRQHandler + IRQ BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ LPWUP_IRQHandler + IRQ EXTI0_IRQHandler + IRQ EXTI1_IRQHandler + IRQ EXTI2_IRQHandler + IRQ EXTI3_IRQHandler + IRQ EXTI4_IRQHandler + IRQ EXTI5_IRQHandler + IRQ EXTI6_IRQHandler + IRQ EXTI7_IRQHandler + IRQ EXTI8_IRQHandler + IRQ EXTI9_IRQHandler + IRQ EXTI10_IRQHandler + IRQ EXTI11_IRQHandler + IRQ EXTI12_IRQHandler + IRQ EXTI13_IRQHandler + IRQ EXTI14_IRQHandler + IRQ EXTI15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_IRQHandler + IRQ PDMA_CH1_IRQHandler + IRQ PDMA_CH2_IRQHandler + IRQ PDMA_CH3_IRQHandler + IRQ PDMA_CH4_IRQHandler + IRQ PDMA_CH5_IRQHandler + IRQ AES_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_01.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_01.c new file mode 100644 index 0000000000..37cb60ba18 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_01.c @@ -0,0 +1,462 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_01.c + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Source File + * for the Holtek HT32F165x Device Series + * @version $Rev:: 2817 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F1653, HT32F1654 +// HT32F1655, HT32F1656 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F1xxxx_system HT32F1xxxx System + * @{ + */ + + +#include "ht32f1xxxx_01.h" + +/** @addtogroup HT32F1xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = ((HSE or HSI) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Feedback Clock Divider (NF2): 1 ~ 64 +// <1-64:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 64 MHz to 144 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 8 MHz to 144 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 MHz <= CK_AHB <= 24 MHz +// 1 WS: 24 MHz < CK_AHB <= 48 MHz +// 2 WS: 48 MHz < CK_AHB <= 72 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable +// Default branch cache = ENABLE +// Dcode cache-able +// <0=> YES +// <1=> NO +// Default Dcode cache-able = NO +// +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f1xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_NF2_DIV (18) /*!< 1~64: DIV1~DIV64 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI */ +#define HCLK_DIV (1) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DCODE_CACHE_ABLE (1) /*!< 0: YES, 1: NO */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = ((HSE or HSI) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO (HSI_VALUE * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO (HSE_VALUE * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 64000000UL + #define VCO_MAX 144000000UL + #define PLL_MIN 8000000UL + #define PLL_MAX 144000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000000UL +#define CKAHB_MAX 72000000UL +#define WS0_CLK 24000000UL +#define WS1_CLK 48000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F1xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F1xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + HT_CKCU->LPCR = 1; /* configure Backup domain isolation */ + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + +#if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while (((HT_CKCU->CKST >> 30) & 3UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ +#endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x3F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~3UL) | HCLK_SRC); /* select CK_SYS source */ + while (((HT_CKCU->CKST >> 30) & 3UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ + #if (DCODE_CACHE_ABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 7); /* 0: DCODE cache-able, 1: DCODE non cache-able */ + #else + SetBit_BB((u32)(&HT_FLASH->CFCR), 7); /* 0: DCODE cache-able, 1: DCODE non cache-able */ + #endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 3UL; + u32 PllFeedbackClockDiv = ((HT_CKCU->PLLCFGR >> 23) == 0) ? (64) : (HT_CKCU->PLLCFGR >> 23); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = (HT_CKCU->CKST >> 30) & 3UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = ((HSI_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((HSE_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_02.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_02.c new file mode 100644 index 0000000000..c0d6be9038 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_02.c @@ -0,0 +1,525 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_02.c + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Source File + * for the Holtek HT32F1xxxx Device Series + * @version $Rev:: 2817 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F12345 +// HT32F12365, HT32F12366 +// HT32F22366 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F1xxxx_system HT32F1xxxx System + * @{ + */ + + +#include "ht32f1xxxx_01.h" + +/** @addtogroup HT32F1xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = ((HSE or HSI) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Feedback Clock Divider (NF2): 1 ~ 32 +// <1-32:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 64 MHz to 96 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 8 MHz to 96 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <3=> 3 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 24 MHz +// 1 WS: 24 MHz < CK_AHB <= 48 MHz +// 2 WS: 48 MHz < CK_AHB <= 72 MHz +// 3 WS: 72 MHz < CK_AHB <= 96 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable +// Default branch cache = ENABLE +// Dcode cache-able +// <0=> YES +// <1=> NO +// Default Dcode cache-able = NO +// +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f1xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_NF2_DIV (12) /*!< 1~32: DIV1~DIV32 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 3: WS = 3, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DCODE_CACHE_ABLE (1) /*!< 0: YES, 1: NO */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = ((HSE or HSI) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO (HSI_VALUE * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO (HSE_VALUE * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 64000000UL + #define VCO_MAX 96000000UL + #define PLL_MIN 8000000UL + #define PLL_MAX 96000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 96000000UL +#define WS0_CLK 24000000UL +#define WS1_CLK 48000000UL +#define WS2_CLK 72000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS2_CLK) && (WAIT_STATE < 3) || \ + (__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif + +/** + * @brief LDO_MODE definition + */ +#if (__CK_AHB > 90000000UL) + #define __LDO_MODE (3) +#elif (__CK_AHB > 80000000UL) + #define __LDO_MODE (2) +#endif +/** + * @} + */ + +/** @addtogroup HT32F1xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F1xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + +#if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 3); /* disable USB PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 9); /* select USB PLL source as HSI */ +#endif + + /* LDO initiation */ +#if (__CK_AHB > 80000000UL) + do { + HT_PWRCU->CR = (HT_PWRCU->CR & ~(3UL << 4)) | (__LDO_MODE << 4); + } while (((HT_PWRCU->CR >> 4) & 3UL) != __LDO_MODE); +#endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x1F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS2_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 4UL); /* auto-select wait state */ + #elif (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* LDO initiation */ +#if (__CK_AHB > 80000000UL) +#else + do { + HT_PWRCU->CR = (HT_PWRCU->CR & ~(3UL << 4)); + } while (((HT_PWRCU->CR >> 4) & 3UL) != 0x0); +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ + #if (DCODE_CACHE_ABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 7); /* 0: DCODE cache-able, 1: DCODE non cache-able */ + #else + SetBit_BB((u32)(&HT_FLASH->CFCR), 7); /* 0: DCODE cache-able, 1: DCODE non cache-able */ + #endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllFeedbackClockDiv = ((HT_CKCU->PLLCFGR >> 23) == 0) ? (32) : (HT_CKCU->PLLCFGR >> 23); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = ((HSI_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((HSE_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_03.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_03.c new file mode 100644 index 0000000000..64d7a6b6f7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_03.c @@ -0,0 +1,526 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F1xxxx/Source/system_ht32f1xxxx_03.c + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Source File + * for the Holtek HT32F1xxxx Device Series + * @version $Rev:: 2817 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F12364 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F1xxxx_system HT32F1xxxx System + * @{ + */ + + +#include "ht32f1xxxx_01.h" + +/** @addtogroup HT32F1xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 32 +// <1-32:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 64 MHz to 76 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 8 MHz to 76 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <3=> 3 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// 3 WS: 60 MHz < CK_AHB <= 76 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable +// Default branch cache = ENABLE +// Dcode cache-able +// <0=> YES +// <1=> NO +// Default Dcode cache-able = NO +// +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f1xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (0) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (9) /*!< 1~32: DIV1~DIV32 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 3: WS = 3, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DCODE_CACHE_ABLE (1) /*!< 0: YES, 1: NO */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 64000000UL + #define VCO_MAX 76000000UL + #define PLL_MIN 8000000UL + #define PLL_MAX 76000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 76000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL +#define WS2_CLK 60000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS2_CLK) && (WAIT_STATE < 3) || \ + (__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F1xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F1xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + +#if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 3); /* disable USB PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 9); /* select USB PLL source as HSI */ +#endif + + /* LDO initiation */ +#if (__CK_AHB > 72000000UL) + do { + HT_PWRCU->CR = (HT_PWRCU->CR & ~(3UL << 4)) | (3UL << 4); + } while (((HT_PWRCU->CR >> 4) & 3UL) != 3UL); +#endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x1F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS2_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 4UL); /* auto-select wait state */ + #elif (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* LDO initiation */ +#if (__CK_AHB > 72000000UL) +#else + do { + HT_PWRCU->CR = (HT_PWRCU->CR & ~(3UL << 4)); + } while (((HT_PWRCU->CR >> 4) & 3UL) != 0x0); +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ + #if (DCODE_CACHE_ABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 7); /* 0: DCODE cache-able, 1: DCODE non cache-able */ + #else + SetBit_BB((u32)(&HT_FLASH->CFCR), 7); /* 0: DCODE cache-able, 1: DCODE non cache-able */ + #endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 31UL) == 0) ? (32) : ((HT_CKCU->PLLCFGR >> 23) & 31UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32.h new file mode 100644 index 0000000000..bbfcf8bd2c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32.h @@ -0,0 +1,35 @@ +/*********************************************************************************************************//** + * @file ht32.h + * @version $Rev:: 80 $ + * @date $Date:: 2017-05-25 #$ + * @brief The API between application and HT32FXXXX Firmware Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_H +#define __HT32_H + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_01.h" + +#endif /* __HT32_H -----------------------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_cm3_misc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_cm3_misc.h new file mode 100644 index 0000000000..2acc00f77a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_cm3_misc.h @@ -0,0 +1,132 @@ +/*********************************************************************************************************//** + * @file ht32_cm3_misc.h + * @version $Rev:: 5 $ + * @date $Date:: 2017-05-11 #$ + * @brief All the function prototypes for the miscellaneous firmware library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_CM3_MISC_H +#define __HT32_CM3_MISC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32_Peripheral_Driver + * @{ + */ + +/** @addtogroup MISC + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Exported_Constants MISC exported constants + * @{ + */ + +/* Vector Table Base */ +#define NVIC_VECTTABLE_RAM ((u32)0x20000000) +#define NVIC_VECTTABLE_FLASH ((u32)0x00000000) + +#define IS_NVIC_VECTTABLE(VECTTABLE) ((VECTTABLE == NVIC_VECTTABLE_RAM) || \ + (VECTTABLE == NVIC_VECTTABLE_FLASH)) + +#define IS_NVIC_OFFSET(OFFSET) (OFFSET < 0x0001FFFF) + +/* System Low Power */ +#define NVIC_LOWPOWER_SEVONPEND ((u8)0x10) +#define NVIC_LOWPOWER_SLEEPDEEP ((u8)0x04) +#define NVIC_LOWPOWER_SLEEPONEXIT ((u8)0x02) + +#define IS_NVIC_LOWPOWER(LOWPOWER) ((LOWPOWER == NVIC_LOWPOWER_SEVONPEND) || \ + (LOWPOWER == NVIC_LOWPOWER_SLEEPDEEP) || \ + (LOWPOWER == NVIC_LOWPOWER_SLEEPONEXIT)) + +/* System Handler */ +#define SYSTEMHANDLER_NMI ((u32)0x80000000) +#define SYSTEMHANDLER_PSV ((u32)0x10000000) +#define SYSTEMHANDLER_SYSTICK ((u32)0x04000000) +#define SYSTEMHANDLER_ALL ((u32)0x94000000) + +#define IS_NVIC_SYSTEMHANDLER(HANDLER) ((HANDLER == SYSTEMHANDLER_NMI) || \ + (HANDLER == SYSTEMHANDLER_PSV) || \ + (HANDLER == SYSTEMHANDLER_SYSTICK) ||\ + (HANDLER == SYSTEMHANDLER_ALL)) + +/* SysTick clock source */ +#define SYSTICK_SRC_STCLK ((u32)0xFFFFFFFB) +#define SYSTICK_SRC_FCLK ((u32)0x00000004) + +#define IS_SYSTICK_CLOCK_SOURCE(SOURCE) ((SOURCE == SYSTICK_SRC_STCLK) || \ + (SOURCE == SYSTICK_SRC_FCLK) ) + +/* SysTick counter state */ +#define SYSTICK_COUNTER_DISABLE ((u32)0xFFFFFFFE) +#define SYSTICK_COUNTER_ENABLE ((u32)0x00000001) +#define SYSTICK_COUNTER_CLEAR ((u32)0x00000000) + +#define IS_SYSTICK_COUNTER(COUNTER) ((COUNTER == SYSTICK_COUNTER_DISABLE) || \ + (COUNTER == SYSTICK_COUNTER_ENABLE) || \ + (COUNTER == SYSTICK_COUNTER_CLEAR)) + +#define IS_SYSTICK_RELOAD(RELOAD) ((RELOAD > 0) && (RELOAD <= 0xFFFFFF)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Exported_Functions MISC exported functions + * @{ + */ +void NVIC_SetVectorTable(u32 NVIC_VectTable, u32 NVIC_Offset); +void NVIC_LowPowerConfig(u8 NVIC_LowPowerMode, ControlStatus NewState); +void NVIC_CoreReset(void); +void NVIC_SetPendingSystemHandler(u32 SystemHandler); +void SYSTICK_ClockSourceConfig(u32 SysTick_ClockSource); +void SYSTICK_CounterCmd(u32 SysTick_Counter); +void SYSTICK_IntConfig(ControlStatus NewState); +void SYSTICK_SetReloadValue(u32 SysTick_Reload); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_dependency.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_dependency.h new file mode 100644 index 0000000000..46eef808e9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_dependency.h @@ -0,0 +1,86 @@ +/*********************************************************************************************************//** + * @file ht32_dependency.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of dependency check. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +#ifdef __cplusplus + extern "C" { +#endif + + +#if 0 // Version setting example for module + +/* Dependency check ----------------------------------------------------------------------------------------*/ +#define MIN_HT32_FWLIB_VER (0x01000005) //0xmmnnnrrr -> Vm.n.r +#define MIN_HT32_FWLIB_SVN (0x2200) +#include "ht32_dependency.h" // Not exist means the version of HT32 Firmware Library is older than the module required. + +#endif + +#if 0 // Version setting example for module + +/* Dependency check ----------------------------------------------------------------------------------------*/ +#if (__CORTEX_M == 0) +#define MIN_HT32_FWLIB_VER (0x01000024) //0xmmnnnrrr -> Vm.n.r +#define MIN_HT32_FWLIB_SVN (0x5762) +#endif +#if (__CORTEX_M == 3) +#define MIN_HT32_FWLIB_VER (0x01000009) //0xmmnnnrrr -> Vm.n.r +#define MIN_HT32_FWLIB_SVN (0x2556) +#endif +#include "ht32_dependency.h" // Not exist means the version of HT32 Firmware Library is older than the module required. + +#endif + + +#if 0 // Enable for test +#undef HT32_FWLIB_VER +#undef HT32_FWLIB_SVN +#define HT32_FWLIB_VER (0x00000004) +#define HT32_FWLIB_SVN (0x1074) +#endif + + +// Check "ht32fxxxxx_lib.h" for the version of HT32 Firmwar Library +#if (HT32_FWLIB_VER != 999999) +#if HT32_FWLIB_VER < MIN_HT32_FWLIB_VER + #error !!! The version of HT32 Firmware Library is older than the module required. Please update HT32 Firmware Library. +#endif + +#if HT32_FWLIB_SVN < MIN_HT32_FWLIB_SVN + #error !!! The version of HT32 Firmware Library is older than the module required. Please update HT32 Firmware Library. +#endif +#endif + + +// Un-defined for next module of the .C include .C case +#undef MIN_HT32_FWLIB_VER +#undef MIN_HT32_FWLIB_SVN + + +#ifdef __cplusplus +} +#endif + +//#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_rand.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_rand.h new file mode 100644 index 0000000000..c3ffdc9ec6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_rand.h @@ -0,0 +1,43 @@ +/*********************************************************************************************************//** + * @file ht32_rand.h + * @version $Rev:: 133 $ + * @date $Date:: 2017-06-14 #$ + * @brief The header file of random number. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_RAND_H +#define __HT32_RAND_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported functions --------------------------------------------------------------------------------------*/ +void Rand_Init(u32 *uSeed, u32 uCount, u32 a, u32 b); +extern u32 (*Rand_Get)(u32 *, u32); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_desc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_desc.h new file mode 100644 index 0000000000..8cc8805086 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_desc.h @@ -0,0 +1,182 @@ +/*********************************************************************************************************//** + * @file ht32_retarget_desc.h + * @version $Rev:: 5 $ + * @date $Date:: 2017-05-11 #$ + * @brief The USB VCP descriptor file of retarget. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_RETARGET_DESC_H +#define __HT32_RETARGET_DESC_H + +/* Exported constants --------------------------------------------------------------------------------------*/ + + /*--------------------------------------------------------------------------------------------------------*/ + /* IAD to associate the two CDC interfaces */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + 8, // bLength 1 Size of this descriptor in bytes + 11, // bDescriptorType 1 Descriptor Type + 11, // bFirstInterface 1 + 2, // bInterfaceCount 1 + 2, // bFunctionClass 1 + 2, // bFunctionSubClass 1 + 0, // bFunctionProtocol 1 + 0x00, // iFunction 1 Index of string descriptor describing this function. + + /*--------------------------------------------------------------------------------------------------------*/ + /* Interface descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_INF, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_04_INF, // bDescriptorType 1 INTERFACE Descriptor Type + 11, // bInterfaceNumber 1 Number of this interface (Zero-based 0) + 0x00, // bAlternateSetting 1 Value used to select alternate setting + 1, // bNumEndpoints 1 Number of endpoints used by this interface + DESC_CLASS_02_CDC_CTRL, // bInterfaceClass 1 Class code (assigned by USB-IF) + 2, // bInterfaceSubClass 1 Subclass code (assigned by USB-IF) + 0, // bInterfaceProtocol 1 Protocol code (assigned by USB) + 0x00, // iInterface 1 Index of string descriptor describing this interface + + /*--------------------------------------------------------------------------------------------------------*/ + /* Header Functional descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 5, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 0, // bDescriptorSubtype 1 header functional descriptor + DESC_H2B(0x0110), // bcdCDC 2 spec release number + + /*--------------------------------------------------------------------------------------------------------*/ + /* Abstract control management Functional */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 4, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 2, // bDescriptorSubtype 1 Abstract Control Management Functional descriptor + 0x02, // bmCapabilities 1 + + /*--------------------------------------------------------------------------------------------------------*/ + /* Union Functional */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 5, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 5, // bDescriptorSubtype 1 Union Functional descriptor + 0x00, // bMasterInterface 1 Communication class interface + 0x01, // bSlaveInterface0 1 Data Class Interface + + /*--------------------------------------------------------------------------------------------------------*/ + /* Call Management Functional */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 5, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 1, // bDescriptorSubtype 1 Call Management Functional descriptor + 0x00, // bmCapabilities 1 + 0x01, // bDataInterface 1 Interface number of Data + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLengthE 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + (0x80 | RETARGET_CTRL_EPT), // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x03, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(RETARGET_CTRL_LEN),// wMaxPacketSize 2 Maximum packet size + 0x00, // bInterval 1 Interval for polling endpoint + + /*--------------------------------------------------------------------------------------------------------*/ + /* Data class interface descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_INF, // bLength 1 Endpoint Descriptor size + DESC_TYPE_04_INF, // bDescriptorType 1 + 12, // bInterfaceNumber 1 Number of Interface + 0x00, // bAlternateSetting 1 Alternate setting + 2, // bNumEndpoints 1 Two endpoints used + DESC_CLASS_0A_CDC_DATA, // bInterfaceClass 1 + 0, // bInterfaceSubClass 1 + 0, // bInterfaceProtocol 1 + 0x00, // iInterface 1 + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint n Out descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + (0x00 | RETARGET_RX_EPT), // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x02, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(RETARGET_RX_LEN), // wMaxPacketSize 2 Maximum packet size + 0x00, // bInterval 1 Interval for polling endpoint + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint n In Descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + (0x80 | RETARGET_TX_EPT), // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x02, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(RETARGET_TX_LEN), // wMaxPacketSize 2 Maximum packet size + 0x00, // bInterval 1 Interval for polling endpoint + +#endif /* __HT32_RETARGET_DESC_H ---------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_usbdconf.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_usbdconf.h new file mode 100644 index 0000000000..e333957f6b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_retarget_usbdconf.h @@ -0,0 +1,321 @@ +/*********************************************************************************************************//** + * @file ht32_retarget_usbdconf.h + * @version $Rev:: 1958 $ + * @date $Date:: 2019-12-27 #$ + * @brief The USB Device configuration of retarget + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_RETARGET_USBDCONF_H +#define __HT32_RETARGET_USBDCONF_H + +/* Settings ------------------------------------------------------------------------------------------------*/ +#define RETARGET_INF (0) +#define RETARGET_DLEN (0) + +#if (_RETARGET == 1) + + #ifdef RETARGET_IS_USB + + #undef RETARGET_INF + #undef RETARGET_DLEN + #define RETARGET_INF (2) + #define RETARGET_DLEN (8 + DESC_LEN_INF * 2 + 5 + 4 + 5 + 5 + DESC_LEN_EPT * 3) + + #if (_EP1_ENABLE == 0 && _EP2_ENABLE == 0 && _EP3_ENABLE == 0 && _EP4_ENABLE == 0 && \ + _EP5_ENABLE == 0 && _EP6_ENABLE == 0 && _EP7_ENABLE == 0) + #define NON_USB_IN_APP + #undef _UIER + #undef _EP0LEN + #undef _EP0_IER + #define _EP0LEN (64) + #define _EP0_IER (0x212) + #define _UIER (0x011D) + #endif + + #define _UIER_ALL (_UIER | (EP0IE << RETARGET_RX_EPT) | (EP0IE << RETARGET_TX_EPT)) + + #if (RETARGET_RX_EPT == 1 || RETARGET_TX_EPT == 1 || RETARGET_CTRL_EPT == 1) + #if (_EP1_ENABLE == 1) + #define _RERATGET1_ERR + #else + #undef _EP1_ENABLE + #undef _EP1_CFG_EPADR + #undef _EP1_CFG_EPEN_TMP + #undef _EP1_TYPR + #undef _EP1_CFG_EPDIR + #undef _EP1LEN_TMP + #undef _EP1_IER + + #define _EP1_ENABLE (1) + #define _EP1_CFG_EPADR (1) + #define _EP1_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 1) + #define _EP1_TYPR (2) + #define _EP1_CFG_EPDIR (0) + #define _EP1LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP1_IER (0x02) + #define RETARGET_RX_LEN (_EP1LEN) + #elif (RETARGET_TX_EPT == 1) + #define _EP1_TYPR (2) + #define _EP1_CFG_EPDIR (1) + #define _EP1LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP1_IER (0x10) + #define RETARGET_TX_LEN (_EP1LEN) + #elif (RETARGET_CTRL_EPT == 1) + #define _EP1_TYPR (3) + #define _EP1_CFG_EPDIR (1) + #define _EP1LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP1_IER (0x10) + #define RETARGET_CTRL_LEN (_EP1LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 2 || RETARGET_TX_EPT == 2 || RETARGET_CTRL_EPT == 2) + #if (_EP2_ENABLE == 1) + #define _RERATGET2_ERR + #else + #undef _EP2_ENABLE + #undef _EP2_CFG_EPADR + #undef _EP2_CFG_EPEN_TMP + #undef _EP2_TYPR + #undef _EP2_CFG_EPDIR + #undef _EP2LEN_TMP + #undef _EP2_IER + + #define _EP2_ENABLE (1) + #define _EP2_CFG_EPADR (2) + #define _EP2_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 2) + #define _EP2_TYPR (2) + #define _EP2_CFG_EPDIR (0) + #define _EP2LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP2_IER (0x02) + #define RETARGET_RX_LEN (_EP2LEN) + #elif (RETARGET_TX_EPT == 2) + #define _EP2_TYPR (2) + #define _EP2_CFG_EPDIR (1) + #define _EP2LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP2_IER (0x10) + #define RETARGET_TX_LEN (_EP2LEN) + #elif (RETARGET_CTRL_EPT == 2) + #define _EP2_TYPR (3) + #define _EP2_CFG_EPDIR (1) + #define _EP2LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP2_IER (0x10) + #define RETARGET_CTRL_LEN (_EP2LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 3 || RETARGET_TX_EPT == 3 || RETARGET_CTRL_EPT == 3) + #if (_EP3_ENABLE == 1) + #define _RERATGET3_ERR + #else + #undef _EP3_ENABLE + #undef _EP3_CFG_EPADR + #undef _EP3_CFG_EPEN_TMP + #undef _EP3_TYPR + #undef _EP3_CFG_EPDIR + #undef _EP3LEN_TMP + #undef _EP3_IER + + #define _EP3_ENABLE (1) + #define _EP3_CFG_EPADR (3) + #define _EP3_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 3) + #define _EP3_TYPR (2) + #define _EP3_CFG_EPDIR (0) + #define _EP3LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP3_IER (0x02) + #define RETARGET_RX_LEN (_EP3LEN) + #elif (RETARGET_TX_EPT == 3) + #define _EP3_TYPR (2) + #define _EP3_CFG_EPDIR (1) + #define _EP3LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP3_IER (0x10) + #define RETARGET_TX_LEN (_EP3LEN) + #elif (RETARGET_CTRL_EPT == 3) + #define _EP3_TYPR (3) + #define _EP3_CFG_EPDIR (1) + #define _EP3LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP3_IER (0x10) + #define RETARGET_CTRL_LEN (_EP3LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 4 || RETARGET_TX_EPT == 4 || RETARGET_CTRL_EPT == 4) + #if (_EP4_ENABLE == 1) + #define _RERATGET4_ERR + #else + #undef _EP4_ENABLE + #undef _EP4_CFG_EPADR + #undef _EP4_CFG_EPEN_TMP + #undef _EP4_TYPR + #undef _EP4_CFG_EPDIR + #undef _EP4LEN_TMP + #undef _EP4_IER + + #define _EP4_ENABLE (1) + #define _EP4_CFG_EPADR (4) + #define _EP4_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 4) + #define _EP4_TYPR (2) + #define _EP4_CFG_EPDIR (0) + #define _EP4LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP4_IER (0x02) + #define RETARGET_RX_LEN (_EP4LEN) + #elif (RETARGET_TX_EPT == 4) + #define _EP4_TYPR (2) + #define _EP4_CFG_EPDIR (1) + #define _EP4LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP4_IER (0x10) + #define RETARGET_TX_LEN (_EP4LEN) + #elif (RETARGET_CTRL_EPT == 4) + #define _EP4_TYPR (3) + #define _EP4_CFG_EPDIR (1) + #define _EP4LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP4_IER (0x10) + #define RETARGET_CTRL_LEN (_EP4LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 5 || RETARGET_TX_EPT == 5 || RETARGET_CTRL_EPT == 5) + #if (_EP5_ENABLE == 1) + #define _RERATGET5_ERR + #else + #undef _EP5_ENABLE + #undef _EP5_CFG_EPADR + #undef _EP5_CFG_EPEN_TMP + #undef _EP5_TYPR + #undef _EP5_CFG_EPDIR + #undef _EP5LEN_TMP + #undef _EP5_IER + + #define _EP5_ENABLE (1) + #define _EP5_CFG_EPADR (5) + #define _EP5_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 5) + #define _EP5_TYPR (2) + #define _EP5_CFG_EPDIR (0) + #define _EP5LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP5_IER (0x02) + #define RETARGET_RX_LEN (_EP5LEN) + #elif (RETARGET_TX_EPT == 5) + #define _EP5_TYPR (2) + #define _EP5_CFG_EPDIR (1) + #define _EP5LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP5_IER (0x10) + #define RETARGET_TX_LEN (_EP5LEN) + #elif (RETARGET_CTRL_EPT == 5) + #define _EP5_TYPR (3) + #define _EP5_CFG_EPDIR (1) + #define _EP5LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP5_IER (0x10) + #define RETARGET_CTRL_LEN (_EP5LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 6 || RETARGET_TX_EPT == 6 || RETARGET_CTRL_EPT == 6) + #if (_EP6_ENABLE == 1) + #define _RERATGET6_ERR + #else + #undef _EP6_ENABLE + #undef _EP6_CFG_EPADR + #undef _EP6_CFG_EPEN_TMP + #undef _EP6_TYPR + #undef _EP6_CFG_EPDIR + #undef _EP6LEN_TMP + #undef _EP6_IER + + #define _EP6_ENABLE (1) + #define _EP6_CFG_EPADR (6) + #define _EP6_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 6) + #define _EP6_TYPR (2) + #define _EP6_CFG_EPDIR (0) + #define _EP6LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP6_IER (0x02) + #define RETARGET_RX_LEN (_EP6LEN) + #elif (RETARGET_TX_EPT == 6) + #define _EP6_TYPR (2) + #define _EP6_CFG_EPDIR (1) + #define _EP6LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP6_IER (0x10) + #define RETARGET_TX_LEN (_EP6LEN) + #elif (RETARGET_CTRL_EPT == 6) + #define _EP6_TYPR (3) + #define _EP6_CFG_EPDIR (1) + #define _EP6LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP6_IER (0x10) + #define RETARGET_CTRL_LEN (_EP6LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 7 || RETARGET_TX_EPT == 7 || RETARGET_CTRL_EPT == 7) + #if (_EP7_ENABLE == 1) + #define _RERATGET7_ERR + #else + #undef _EP7_ENABLE + #undef _EP7_CFG_EPADR + #undef _EP7_CFG_EPEN_TMP + #undef _EP7_TYPR + #undef _EP7_CFG_EPDIR + #undef _EP7LEN_TMP + #undef _EP7_IER + + #define _EP7_ENABLE (1) + #define _EP7_CFG_EPADR (7) + #define _EP7_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 7) + #define _EP7_TYPR (2) + #define _EP7_CFG_EPDIR (0) + #define _EP7LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP7_IER (0x02) + #define RETARGET_RX_LEN (_EP7LEN) + #elif (RETARGET_TX_EPT == 7) + #define _EP7_TYPR (2) + #define _EP7_CFG_EPDIR (1) + #define _EP7LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP7_IER (0x10) + #define RETARGET_TX_LEN (_EP7LEN) + #elif (RETARGET_CTRL_EPT == 7) + #define _EP7_TYPR (3) + #define _EP7_CFG_EPDIR (1) + #define _EP7LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP7_IER (0x10) + #define RETARGET_CTRL_LEN (_EP7LEN) + #endif + #endif + #endif + + #endif /* #ifdef RETARGET_IS_USB */ + +#endif /* #if (_RETARGET == 1) */ + +#endif /* __HT32_RETARGET_USBDCONF_H -----------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_serial.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_serial.h new file mode 100644 index 0000000000..641fb91d51 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_serial.h @@ -0,0 +1,84 @@ +/*********************************************************************************************************//** + * @file ht32_serial.h + * @version $Rev:: 2765 $ + * @date $Date:: 2022-11-11 #$ + * @brief The header file of the Serial library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_SERIAL_H +#define __HT32_SERIAL_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#ifdef RETARGET_IS_USB +#include "ht32_usbd_core.h" +#endif + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @addtogroup SERIAL + * @brief Serial related functions + * @{ + */ + + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Exported_Functions Serial exported functions + * @{ + */ +void RETARGET_UART_IRQHandler(void); +u32 SERIAL_GetChar(void); +u32 SERIAL_PutChar(u32 ch); +#ifdef RETARGET_IS_USB +void SERIAL_USBDClass_Request(USBDCore_Device_TypeDef *pDev); +void SERIAL_USBDClass_RXHandler(USBD_EPTn_Enum EPTn); +void SERIAL_USBDClass_TXHandler(USBD_EPTn_Enum EPTn); +void SERIAL_USBDInit(void); +void SERIAL_Flush(void); +#else +#define SERIAL_Flush(...) +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_time.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_time.h new file mode 100644 index 0000000000..1fc44cdc7c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_time.h @@ -0,0 +1,170 @@ +/*********************************************************************************************************//** + * @file ht32_time.h + * @version $Rev:: 2896 $ + * @date $Date:: 2023-03-04 #$ + * @brief The header file of time function. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_TIME_H +#define __HT32_TIME_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#ifndef HTCFG_TIME_IPSEL +#include "ht32_time_conf.h" +#endif + +/* Settings ------------------------------------------------------------------------------------------------*/ +#ifdef HTCFG_TIME_IPSEL +#if (HTCFG_TIME_IPSEL == 0) +#define HTCFG_TIME_IPN BFTM0 +#endif +#if (HTCFG_TIME_IPSEL == 1) +#define HTCFG_TIME_IPN BFTM1 +#endif +#if (HTCFG_TIME_IPSEL == 2) +#define HTCFG_TIME_IPN SCTM0 +#endif +#if (HTCFG_TIME_IPSEL == 3) +#define HTCFG_TIME_IPN SCTM1 +#endif +#if (HTCFG_TIME_IPSEL == 4) +#define HTCFG_TIME_IPN SCTM2 +#endif +#if (HTCFG_TIME_IPSEL == 5) +#define HTCFG_TIME_IPN SCTM3 +#endif +#if (HTCFG_TIME_IPSEL == 6) +#define HTCFG_TIME_IPN PWM0 +#endif +#if (HTCFG_TIME_IPSEL == 7) +#define HTCFG_TIME_IPN PWM1 +#endif +#if (HTCFG_TIME_IPSEL == 8) +#define HTCFG_TIME_IPN PWM2 +#endif +#if (HTCFG_TIME_IPSEL == 9) +#define HTCFG_TIME_IPN GPTM0 +#endif +#if (HTCFG_TIME_IPSEL == 10) +#define HTCFG_TIME_IPN GPTM1 +#endif +#if (HTCFG_TIME_IPSEL == 11) +#define HTCFG_TIME_IPN MCTM0 +#endif +#endif + +/* Exported constants --------------------------------------------------------------------------------------*/ +#ifndef IS_IPN_BFTM +#undef IPN_MCTM0 +#undef IPN_MCTM1 +#undef IPN_GPTM0 +#undef IPN_GPTM1 + +#define IPN_NULL (0) +#define IPN_MCTM0 (0x4002C000) +#define IPN_MCTM1 (0x4002D000) +#define IPN_GPTM0 (0x4006E000) +#define IPN_GPTM1 (0x4006F000) +#define IPN_SCTM0 (0x40034000) +#define IPN_SCTM1 (0x40074000) +#define IPN_SCTM2 (0x40035000) +#define IPN_SCTM3 (0x40075000) +#define IPN_PWM0 (0x40031000) +#define IPN_PWM1 (0x40071000) +#define IPN_PWM2 (0x40031000) +#define IPN_BFTM0 (0x40076000) +#define IPN_BFTM1 (0x40077000) +#define IPN_CHECK(IP) STRCAT2(IPN_, IP) +#define IS_IPN_BFTM(IP) (IPN_CHECK(IP) == IPN_BFTM0) || (IPN_CHECK(IP) == IPN_BFTM1) +#define IS_IPN_MCTM(IP) (IPN_CHECK(IP) == IPN_MCTM0) || (IPN_CHECK(IP) == IPN_MCTM1) +#define IS_IPN_GPTM(IP) (IPN_CHECK(IP) == IPN_GPTM0) || (IPN_CHECK(IP) == IPN_GPTM1) +#define IS_IPN_SCTM(IP) (IPN_CHECK(IP) == IPN_SCTM0) || (IPN_CHECK(IP) == IPN_SCTM1) || (IPN_CHECK(IP) == IPN_SCTM2) || (IPN_CHECK(IP) == IPN_SCTM3) +#define IS_IPN_PWM(IP) (IPN_CHECK(IP) == IPN_PWM0) || (IPN_CHECK(IP) == IPN_PWM1) || (IPN_CHECK(IP) == IPN_PWM2) +#define IS_IPN_TM(IP) (IS_IPN_MCTM(IP) || IS_IPN_GPTM(IP) || IS_IPN_SCTM(IP) || IS_IPN_PWM(IP)) +#endif + +#define _HTCFG_TIME_PORT STRCAT2(HT_, HTCFG_TIME_IPN) + +#if (HTCFG_TIME_CLKSEL == 0) +#define _HTCFG_TIME_CORECLK (LIBCFG_MAX_SPEED) +#else +#define _HTCFG_TIME_CORECLK (HTCFG_TIME_CLK_MANUAL) +#endif + +#if (LIBCFG_CKCU_NO_APB_PRESCALER == 1) +#undef HTCFG_TIME_PCLK_DIV +#define HTCFG_TIME_PCLK_DIV (0) +#endif + +#define HTCFG_TIME_CLKSRC (_HTCFG_TIME_CORECLK >> HTCFG_TIME_PCLK_DIV) + +#if (IS_IPN_BFTM(HTCFG_TIME_IPN)) +#undef HTCFG_TIME_TICKHZ +#define HTCFG_TIME_TICKHZ HTCFG_TIME_CLKSRC +#endif + +/* Exported macro ------------------------------------------------------------------------------------------*/ +#define TIME_TICKDIFF(start, current) ((current >= start) ? (u32)(current - start) : (u32)(0xFFFFFFFF - start + 1 + current)) + +#if (HTCFG_TIME_TICKHZ < 1000000) +#define TIME_US2TICK(us) (us / (1000000UL / HTCFG_TIME_TICKHZ)) +#define TIME_TICK2US(t) (t * (1000000UL / HTCFG_TIME_TICKHZ)) +#else +#define TIME_US2TICK(us) (us * (HTCFG_TIME_TICKHZ / 1000000UL)) +#define TIME_TICK2US(t) (t / (HTCFG_TIME_TICKHZ / 1000000UL)) +#endif + +#if (HTCFG_TIME_TICKHZ < 1000) +#define TIME_MS2TICK(ms) (ms / (1000UL / HTCFG_TIME_TICKHZ)) +#define TIME_TICK2MS(t) (t * (1000UL / HTCFG_TIME_TICKHZ)) +#else +#define TIME_MS2TICK(ms) (ms * (HTCFG_TIME_TICKHZ / 1000UL)) +#define TIME_TICK2MS(t) (t / (HTCFG_TIME_TICKHZ / 1000UL)) +#endif + +#define TIME_S2TICK(s) (s * (u32)(HTCFG_TIME_TICKHZ)) +#define TIME_TICK2S(t) (t / (HTCFG_TIME_TICKHZ)) + + +#define GET_CNT() (_HTCFG_TIME_PORT->CNTR) + +/* Exported functions --------------------------------------------------------------------------------------*/ +void Time_Init(void); +void Time_Delay(u32 delay); +u32 Time_GetTick(void); + +#if (IS_IPN_BFTM(HTCFG_TIME_IPN)) +// BFTM +#define Time_GetTick GET_CNT +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_undef_IP.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_undef_IP.h new file mode 100644 index 0000000000..4339a8135d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32_undef_IP.h @@ -0,0 +1,200 @@ +/*********************************************************************************************************//** + * @file ht32_undef_IP.h + * @version $Rev:: 2962 $ + * @date $Date:: 2023-10-18 #$ + * @brief Header file for undefined IP. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ + +#ifndef __HT32_UNDEF_IP_H +#define __HT32_UNDEF_IP_H + +#ifdef __cplusplus + extern "C" { +#endif + +#if _AES +#undef _AES +#endif + +#ifdef _ADC +#undef _ADC +#endif + +#ifdef _BFTM +#undef _BFTM +#endif + +#ifdef _CAN +#undef _CAN +#endif + +#ifdef _CKCU +#undef _CKCU +#endif + +#ifdef _CMP +#undef _CMP +#endif + +#ifdef _CRC +#undef _CRC +#endif + +#ifdef _CSIF +#undef _CSIF +#endif + +#ifdef _DAC +#undef _DAC +#endif + +#ifdef _DIV +#undef _DIV +#endif + +#ifdef _EBI +#undef _EBI +#endif + +#ifdef _EXTI +#undef _EXTI +#endif + +#ifdef _FLASH +#undef _FLASH +#endif + +#ifdef _GPIO +#undef _GPIO +#endif + +#ifdef _GPTM +#undef _GPTM +#endif + +#ifdef _I2C +#undef _I2C +#endif + +#ifdef _I2S +#undef _I2S +#endif + +#ifdef _LCD +#undef _LCD +#endif + +#ifdef _LEDC +#undef _LEDC +#endif + +#ifdef _MCTM +#undef _MCTM +#endif + +#ifdef _MIDI +#undef _MIDI +#endif + +#ifdef _OPA +#undef _OPA +#endif + +#ifdef _PDMA +#undef _PDMA +#endif + +#ifdef _PWRCU +#undef _PWRCU +#endif + +#ifdef _PWM +#undef _PWM +#endif + +#ifdef _RSTCU +#undef _RSTCU +#endif + +#ifdef _RTC +#undef _RTC +#endif + +#ifdef _SCI +#undef _SCI +#endif + +#ifdef _SCTM +#undef _SCTM +#endif + +#ifdef _SDIO +#undef _SDIO +#endif + +#ifdef _SLED +#undef _SLED +#endif + +#ifdef _SPI +#undef _SPI +#endif + +#ifdef _TKEY +#undef _TKEY +#endif + +#ifdef _USART +#undef _USART +#endif + +#ifdef _USB +#undef _USB +#endif + +#ifdef _WDT +#undef _WDT +#endif + +#ifdef _MISC +#undef _MISC +#endif + +#ifdef _SERIAL +#undef _SERIAL +#endif + +#ifdef _SWDIV +#undef _SWDIV +#endif + +#ifdef _SWRAND +#undef _SWRAND +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12345_libcfg.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12345_libcfg.h new file mode 100644 index 0000000000..3e435d4b16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12345_libcfg.h @@ -0,0 +1,57 @@ +/*********************************************************************************************************//** + * @file ht32f12345_libcfg.h + * @version $Rev:: 2805 $ + * @date $Date:: 2022-12-01 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F12345_LIBCFG_H +#define __HT32F12345_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F12345) +#define USE_MEM_HT32F12345 +#endif + +#define LIBCFG_MAX_SPEED (96000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F12345 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x12345) +#endif + +#define LIBCFG_SDIO (1) + +#define LIBCFG_CKCU_NO_ADCPRE_DIV1 (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_FMC_WAIT_STATE_3 (1) +#define LIBCFG_PDMA_CH8_11 (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_RTC_LSI_LOAD_TRIM (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12364_libcfg.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12364_libcfg.h new file mode 100644 index 0000000000..5093b68847 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12364_libcfg.h @@ -0,0 +1,77 @@ +/*********************************************************************************************************//** + * @file ht32f12364_libcfg.h + * @version $Rev:: 2805 $ + * @date $Date:: 2022-12-01 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F12364_LIBCFG_H +#define __HT32F12364_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F12364) +#define USE_MEM_HT32F12364 +#endif + +#define LIBCFG_MAX_SPEED (72000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F12364 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 128) + #define LIBCFG_CHIPNAME (0x12364) +#endif + +#define LIBCFG_ADC_V01 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_AES (1) +#define LIBCFG_CKCU_APBPCSR2 (1) +#define LIBCFG_CKCU_ADCPRE_DIV5 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_EBI_V01 (1) +#define LIBCFG_FLASH_2PAGE_PER_WPBIT (1) +#define LIBCFG_FMC_WAIT_STATE_3 (1) +#define LIBCFG_GPIOF (1) +#define LIBCFG_NO_ADC_CH8_15 (1) +#define LIBCFG_NO_BACK_DOMAIN (1) +#define LIBCFG_NO_CKCU_USBPRE (1) +#define LIBCFG_NO_CMP_TRIG_ADC (1) +#define LIBCFG_NO_CMP_HPTRIG_ADC (1) +#define LIBCFG_NO_GPTM1 (1) +#define LIBCFG_NO_I2S (1) +#define LIBCFG_NO_MCTM0 (1) +#define LIBCFG_NO_MCTM1 (1) +#define LIBCFG_NO_PDMA_CH6_11 (1) +#define LIBCFG_NO_USART1 (1) +#define LIBCFG_PDMA_V01 (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWRCU_LVDS_17_31 (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SPI_CLK_PRE_V01 (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12365_66_libcfg.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12365_66_libcfg.h new file mode 100644 index 0000000000..ee16bf2fa1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f12365_66_libcfg.h @@ -0,0 +1,78 @@ +/*********************************************************************************************************//** + * @file ht32f12365_66_libcfg.h + * @version $Rev:: 2805 $ + * @date $Date:: 2022-12-01 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F12365_66_LIBCFG_H +#define __HT32F12365_66_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F12365) && !defined(USE_MEM_HT32F12366) && !defined(USE_MEM_HT32F22366) +#define USE_MEM_HT32F12366 +#endif + +#define LIBCFG_MAX_SPEED (96000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F12365 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 64) + #define LIBCFG_CHIPNAME (0x12365) +#endif + +#ifdef USE_MEM_HT32F12366 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 128) + #define LIBCFG_CHIPNAME (0x12366) +#endif + +#ifdef USE_MEM_HT32F22366 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 128) + #define LIBCFG_CHIPNAME (0x22366) +#endif + +#define LIBCFG_AES (1) +#define LIBCFG_CSIF (1) +#define LIBCFG_GPIOE (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SCI1 (1) +#define LIBCFG_SDIO (1) + +#define LIBCFG_ADC_CH12_15 (1) +#define LIBCFG_CKCU_NO_ADCPRE_DIV1 (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_EBI_BYTELAND_ASYNCREADY (1) +#define LIBCFG_FLASH_2PAGE_PER_WPBIT (1) +#define LIBCFG_FMC_WAIT_STATE_3 (1) +#define LIBCFG_PDMA_CH8_11 (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_RTC_LSI_LOAD_TRIM (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_AES_SWAP (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1653_54_libcfg.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1653_54_libcfg.h new file mode 100644 index 0000000000..cebe74e637 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1653_54_libcfg.h @@ -0,0 +1,77 @@ +/*********************************************************************************************************//** + * @file ht32f1653_54_libcfg.h + * @version $Rev:: 2805 $ + * @date $Date:: 2022-12-01 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1653_54_LIBCFG_H +#define __HT32F1653_54_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F1653) && !defined(USE_MEM_HT32F1654) +#define USE_MEM_HT32F1654 +#endif + +#define LIBCFG_MAX_SPEED (72000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F1653 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x1653) +#endif + +#ifdef USE_MEM_HT32F1654 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x1654) +#endif + +#define LIBCFG_SCI0 (1) + +#define LIBCFG_ADC_NOENBIT (1) +#define LIBCFG_CKCU_AUTOTRIM_NOCKIN (1) +#define LIBCFG_CKCU_CKSWST_LEGACY (1) +#define LIBCFG_CKCU_NO_ADCPRE_DIV1 (1) +#define LIBCFG_CKCU_NO_HCLK_LOW_SPEED (1) +#define LIBCDG_CKCU_PLL_144M (1) +#define LIBCDG_CKCU_SYSCLK_DIV8_ONLY (1) +#define LIBCFG_CKCU_USB_DIV3 (1) +#define LIBCFG_FLASH_HALFCYCYLE (1) +#define LIBCFG_FLASH_ZWPWESAVING (1) +#define LIBCFG_NO_CMP_HPTRIG_ADC (1) +#define LIBCFG_GPIO_DV_4_8MA_ONLY (1) +#define LIBCFG_PDMA_BLKLEN65536 (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_PWRCU_HSI_READY_COUNTER (1) +#define LIBCFG_PWRCU_LDO_LEGACY (1) +#define LIBCFG_PWRCU_LVDS_27_35 (1) +#define LIBCFG_RTC_LSI_LOAD_TRIM (1) +#define LIBCFG_USART_V01 (1) +#define LIBCFG_WDT_INT (1) +#define LIBCFC_WEAK_AF1 (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1655_56_libcfg.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1655_56_libcfg.h new file mode 100644 index 0000000000..30ac2b2792 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1655_56_libcfg.h @@ -0,0 +1,86 @@ +/*********************************************************************************************************//** + * @file ht32f1655_56_libcfg.h + * @version $Rev:: 2887 $ + * @date $Date:: 2023-03-02 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1655_56_LIBCFG_H +#define __HT32F1655_56_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F1655) && !defined(USE_MEM_HT32F1656) +#define USE_MEM_HT32F1656 +#endif + +#define LIBCFG_MAX_SPEED (72000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F1655 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 128) + #define LIBCFG_RAM_SIZE (1024 * 32) + #define LIBCFG_CHIPNAME (0x1655) +#endif + +#ifdef USE_MEM_HT32F1656 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 32) + #define LIBCFG_CHIPNAME (0x1656) +#endif + +#define LIBCFG_CMP_OPA (1) +#define LIBCFG_GPIOE (1) +#define LIBCFG_SCI0 (1) + +#define LIBCFG_ADC_CH12_15 (1) +#define LIBCFG_ADC_NOENBIT (1) +#define LIBCFG_CKCU_NO_APB_PRESCALER (1) +#define LIBCFG_CKCU_CKSWST_LEGACY (1) +#define LIBCFG_CKCU_HSI_NO_AUTOTRIM (1) +#define LIBCFG_CKCU_NO_ADCPRE_DIV1 (1) +#define LIBCFG_CKCU_NO_HCLK_LOW_SPEED (1) +#define LIBCDG_CKCU_PLL_144M (1) +#define LIBCDG_CKCU_SYSCLK_DIV8_ONLY (1) +#define LIBCFG_CKCU_USART_PRESCALER (1) +#define LIBCFG_CKCU_USB_DIV3 (1) +#define LIBCFG_EBI_BYTELAND_ASYNCREADY (1) +#define LIBCFG_EXTI_8BIT_DEBOUNCE_COUNTER (1) +#define LIBCFG_GPIO_DV_4_8MA_ONLY (1) +#define LIBCFG_FLASH_2PAGE_PER_WPBIT (1) +#define LIBCFG_FLASH_HALFCYCYLE (1) +#define LIBCFG_FLASH_ZWPWESAVING (1) +#define LIBCFG_NO_CMP_TRIG_ADC (1) +#define LIBCFG_NO_CMP_HPTRIG_ADC (1) +#define LIBCFG_PDMA_BLKLEN65536 (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_PWRCU_HSI_READY_COUNTER (1) +#define LIBCFG_PWRCU_LDO_LEGACY (1) +#define LIBCFG_PWRCU_LVDS_27_35 (1) +#define LIBCFG_RTC_LSI_LOAD_TRIM (1) +#define LIBCFG_USART_V01 (1) +#define LIBCFG_WDT_INT (1) +#define LIBCFC_WEAK_AF1 (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_adc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_adc.h new file mode 100644 index 0000000000..92e286f14b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_adc.h @@ -0,0 +1,498 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_adc.h + * @version $Rev:: 2791 $ + * @date $Date:: 2022-11-24 #$ + * @brief The header file of the ADC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_ADC_H +#define __HT32F1XXXX_ADC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup ADC + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Exported_Constants ADC exported constants + * @{ + */ +#define IS_ADC(x) (x == HT_ADC) + +#define ONE_SHOT_MODE (0x00000000) +#define CONTINUOUS_MODE (0x00000002) +#define DISCONTINUOUS_MODE (0x00000003) + +#define IS_ADC_CONVERSION_MODE(REGULAR_MODE) (((REGULAR_MODE) == ONE_SHOT_MODE) || \ + ((REGULAR_MODE) == CONTINUOUS_MODE) || \ + ((REGULAR_MODE) == DISCONTINUOUS_MODE)) + +#define IS_ADC_HP_CONVERSION_MODE(HP_MODE) (((HP_MODE) == ONE_SHOT_MODE) || \ + ((HP_MODE) == CONTINUOUS_MODE) || \ + ((HP_MODE) == DISCONTINUOUS_MODE)) + + +#define ADC_CH_0 (0) +#define ADC_CH_1 (1) +#define ADC_CH_2 (2) +#define ADC_CH_3 (3) +#define ADC_CH_4 (4) +#define ADC_CH_5 (5) +#define ADC_CH_6 (6) +#define ADC_CH_7 (7) +#if !(LIBCFG_NO_ADC_CH8_15) +#define ADC_CH_8 (8) +#define ADC_CH_9 (9) +#define ADC_CH_10 (10) +#define ADC_CH_11 (11) +#if (LIBCFG_ADC_CH12_15) +#define ADC_CH_12 (12) +#define ADC_CH_13 (13) +#define ADC_CH_14 (14) +#define ADC_CH_15 (15) +#define IS_ADC_CHANNEL12_15(CHANNEL) (((CHANNEL) == ADC_CH_12) || ((CHANNEL) == ADC_CH_13) || \ + ((CHANNEL) == ADC_CH_14) || ((CHANNEL) == ADC_CH_15)) +#else +#define IS_ADC_CHANNEL12_15(CHANNEL) (0) +#endif +#else +#define IS_ADC_CHANNEL8_14(CHANNEL) (0) +#define ADC_CH_IVREF (15) +#endif +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) + +#define ADC_CH_GNDREF ADC_CH_GND_VREF +#define ADC_CH_VREF ADC_CH_VDD_VREF + + +#if (LIBCFG_NO_ADC_CH8_15) +#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7) || \ + (IS_ADC_CHANNEL8_14(CHANNEL)) || \ + ((CHANNEL) == ADC_CH_IVREF) || ((CHANNEL) == ADC_CH_GND_VREF) || \ + ((CHANNEL) == ADC_CH_VDD_VREF)) +#else +#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7) || \ + ((CHANNEL) == ADC_CH_8) || ((CHANNEL) == ADC_CH_9) || \ + ((CHANNEL) == ADC_CH_10) || ((CHANNEL) == ADC_CH_11) || \ + (IS_ADC_CHANNEL12_15(CHANNEL)) || \ + ((CHANNEL) == ADC_CH_GND_VREF) || ((CHANNEL) == ADC_CH_VDD_VREF)) +#endif + +#if (LIBCFG_NO_ADC_CH8_15) +#define IS_ADC_INPUT_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7)) +#else +#define IS_ADC_INPUT_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7) || \ + ((CHANNEL) == ADC_CH_8) || ((CHANNEL) == ADC_CH_9) || \ + ((CHANNEL) == ADC_CH_10) || ((CHANNEL) == ADC_CH_11) || \ + (IS_ADC_CHANNEL12_15(CHANNEL))) +#endif + +#define ADC_TRIG_SOFTWARE (1UL << 0) + +/* ((ADCTCR[4] << 4) | (ADCTSR[20] << 20)) */ +#if (!LIBCFG_NO_CMP_TRIG_ADC) +#define ADC_TRIG_CMP0 ((1UL << 4) | (0UL << 20)) +#define ADC_TRIG_CMP1 ((1UL << 4) | (1UL << 20)) +#endif + +#if (!LIBCFG_NO_CMP_HPTRIG_ADC) +#define ADC_HPTRIG_CMP0 ADC_TRIG_CMP0 +#define ADC_HPTRIG_CMP1 ADC_TRIG_CMP1 +#endif + +/* ((ADCTCR[3] << 3) | (ADCTSR[23:22] << 22) | (ADCTSR[19] << 19)) */ +#define ADC_TRIG_BFTM0 ((1UL << 3) | (0UL << 22) | (0UL << 19)) +#define ADC_TRIG_BFTM1 ((1UL << 3) | (0UL << 22) | (1UL << 19)) + +/* ((ADCTCR[3] << 3) | (ADCTSR[29:27]) << 27) | (ADCTSR[23:22] << 22) | (ADCTSR[19] << 19)) */ +#if (LIBCFG_PWM0) +#define ADC_TRIG_PWM0_MTO ((1UL << 3) | (0UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH0O ((1UL << 3) | (1UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH1O ((1UL << 3) | (2UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH2O ((1UL << 3) | (3UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH3O ((1UL << 3) | (4UL << 27) | (1UL << 22) | (0UL << 19)) +#endif +#if (LIBCFG_PWM1) +#define ADC_TRIG_PWM1_MTO ((1UL << 3) | (0UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH0O ((1UL << 3) | (1UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH1O ((1UL << 3) | (2UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH2O ((1UL << 3) | (3UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH3O ((1UL << 3) | (4UL << 27) | (1UL << 22) | (1UL << 19)) +#endif + +/* ((ADCTCR[2] << 2) | (ADCTSR[26:24] << 24) | (ADCTSR[18:16] << 16)) */ +#if (!LIBCFG_NO_MCTM0) +#define ADC_TRIG_MCTM0_MTO ((1UL << 2) | (0UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH0O ((1UL << 2) | (1UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH1O ((1UL << 2) | (2UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH2O ((1UL << 2) | (3UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH3O ((1UL << 2) | (4UL << 24) | (0UL << 16)) +#endif + +#if (!LIBCFG_NO_MCTM1) +#define ADC_TRIG_MCTM1_MTO ((1UL << 2) | (0UL << 24) | (1UL << 16)) +#define ADC_TRIG_MCTM1_CH0O ((1UL << 2) | (1UL << 24) | (1UL << 16)) +#define ADC_TRIG_MCTM1_CH1O ((1UL << 2) | (2UL << 24) | (1UL << 16)) +#define ADC_TRIG_MCTM1_CH2O ((1UL << 2) | (3UL << 24) | (1UL << 16)) +#define ADC_TRIG_MCTM1_CH3O ((1UL << 2) | (4UL << 24) | (1UL << 16)) +#endif + +#define ADC_TRIG_GPTM0_MTO ((1UL << 2) | (0UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH0O ((1UL << 2) | (1UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH1O ((1UL << 2) | (2UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH2O ((1UL << 2) | (3UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH3O ((1UL << 2) | (4UL << 24) | (2UL << 16)) + +#if (!LIBCFG_NO_GPTM1) +#define ADC_TRIG_GPTM1_MTO ((1UL << 2) | (0UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH0O ((1UL << 2) | (1UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH1O ((1UL << 2) | (2UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH2O ((1UL << 2) | (3UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH3O ((1UL << 2) | (4UL << 24) | (3UL << 16)) +#endif + +/* (ADCTCR[1] << 1) | (ADCTSR[11:8] << 8) */ +#define ADC_TRIG_EXTI_0 ((1UL << 1) | ( 0UL << 8)) +#define ADC_TRIG_EXTI_1 ((1UL << 1) | ( 1UL << 8)) +#define ADC_TRIG_EXTI_2 ((1UL << 1) | ( 2UL << 8)) +#define ADC_TRIG_EXTI_3 ((1UL << 1) | ( 3UL << 8)) +#define ADC_TRIG_EXTI_4 ((1UL << 1) | ( 4UL << 8)) +#define ADC_TRIG_EXTI_5 ((1UL << 1) | ( 5UL << 8)) +#define ADC_TRIG_EXTI_6 ((1UL << 1) | ( 6UL << 8)) +#define ADC_TRIG_EXTI_7 ((1UL << 1) | ( 7UL << 8)) +#define ADC_TRIG_EXTI_8 ((1UL << 1) | ( 8UL << 8)) +#define ADC_TRIG_EXTI_9 ((1UL << 1) | ( 9UL << 8)) +#define ADC_TRIG_EXTI_10 ((1UL << 1) | (10UL << 8)) +#define ADC_TRIG_EXTI_11 ((1UL << 1) | (11UL << 8)) +#define ADC_TRIG_EXTI_12 ((1UL << 1) | (12UL << 8)) +#define ADC_TRIG_EXTI_13 ((1UL << 1) | (13UL << 8)) +#define ADC_TRIG_EXTI_14 ((1UL << 1) | (14UL << 8)) +#define ADC_TRIG_EXTI_15 ((1UL << 1) | (15UL << 8)) + + +#define IS_ADC_TRIG(REGTRIG) (IS_ADC_TRIG1(REGTRIG) || \ + IS_ADC_TRIG2(REGTRIG) || \ + IS_ADC_TRIG3(REGTRIG) || \ + IS_ADC_TRIG4(REGTRIG) || \ + IS_ADC_TRIG5(REGTRIG) || \ + IS_ADC_TRIG6(REGTRIG) || \ + IS_ADC_TRIG7(REGTRIG)) + +#define IS_ADC_HPTRIG(REGTRIG) (IS_ADC_TRIG1(REGTRIG) || \ + IS_ADC_TRIG2(REGTRIG) || \ + IS_ADC_TRIG3(REGTRIG) || \ + IS_ADC_TRIG4(REGTRIG) || \ + IS_ADC_TRIG5(REGTRIG) || \ + IS_ADC_TRIG6(REGTRIG) || \ + IS_ADC_HPTRIG7(REGTRIG)) + +#define IS_ADC_TRIG1(REGTRIG) (((REGTRIG) == ADC_TRIG_GPTM0_MTO) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH0O) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH1O) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH2O) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH3O) || \ + ((REGTRIG) == ADC_TRIG_BFTM0) || \ + ((REGTRIG) == ADC_TRIG_EXTI_0) || \ + ((REGTRIG) == ADC_TRIG_EXTI_1) || \ + ((REGTRIG) == ADC_TRIG_EXTI_2) || \ + ((REGTRIG) == ADC_TRIG_EXTI_3) || \ + ((REGTRIG) == ADC_TRIG_EXTI_4) || \ + ((REGTRIG) == ADC_TRIG_EXTI_5) || \ + ((REGTRIG) == ADC_TRIG_EXTI_6) || \ + ((REGTRIG) == ADC_TRIG_EXTI_7) || \ + ((REGTRIG) == ADC_TRIG_EXTI_8) || \ + ((REGTRIG) == ADC_TRIG_EXTI_9) || \ + ((REGTRIG) == ADC_TRIG_EXTI_10) || \ + ((REGTRIG) == ADC_TRIG_EXTI_11) || \ + ((REGTRIG) == ADC_TRIG_EXTI_12) || \ + ((REGTRIG) == ADC_TRIG_EXTI_13) || \ + ((REGTRIG) == ADC_TRIG_EXTI_14) || \ + ((REGTRIG) == ADC_TRIG_EXTI_15) || \ + ((REGTRIG) == ADC_TRIG_SOFTWARE)) + +#define IS_ADC_TRIG2(REGTRIG) ((REGTRIG) == ADC_TRIG_BFTM1) + +#if (!LIBCFG_NO_MCTM0) +#define IS_ADC_TRIG3(REGTRIG) (((REGTRIG) == ADC_TRIG_MCTM0_MTO) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH0O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH1O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH2O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH3O) || \ + ((REGTRIG) == ADC_TRIG_BFTM1)) +#else +#define IS_ADC_TRIG3(REGTRIG) (0) +#endif + +#if (!LIBCFG_NO_MCTM1) +#define IS_ADC_TRIG4(REGTRIG) (((REGTRIG) == ADC_TRIG_GPTM1_MTO) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH0O) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH1O) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH2O) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH3O)) +#else +#define IS_ADC_TRIG4(REGTRIG) (0) +#endif + +#if (LIBCFG_PWM0) +#define IS_ADC_TRIG5(REGTRIG) (((REGTRIG) == ADC_TRIG_PWM0_MTO) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH0O) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH1O) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH2O) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH3O)) +#else +#define IS_ADC_TRIG5(REGTRIG) (0) +#endif + +#if (LIBCFG_PWM1) +#define IS_ADC_TRIG6(REGTRIG) (((REGTRIG) == ADC_TRIG_PWM1_MTO) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH0O) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH1O) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH2O) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH3O)) +#else +#define IS_ADC_TRIG6(REGTRIG) (0) +#endif + +#if (!LIBCFG_NO_CMP_TRIG_ADC) +#define IS_ADC_TRIG7(REGTRIG) (((REGTRIG) == ADC_TRIG_CMP0) || \ + ((REGTRIG) == ADC_TRIG_CMP1)) +#else +#define IS_ADC_TRIG7(REGTRIG) (0) +#endif + +#if (!LIBCFG_NO_CMP_HPTRIG_ADC) +#define IS_ADC_HPTRIG7(REGTRIG) (((REGTRIG) == ADC_HPTRIG_CMP0) || \ + ((REGTRIG) == ADC_HPTRIG_CMP1)) +#else +#define IS_ADC_HPTRIG7(REGTRIG) (0) +#endif + + +#define ADC_INT_SINGLE_EOC (0x00000001) +#define ADC_INT_SUB_GROUP_EOC (0x00000002) +#define ADC_INT_CYCLE_EOC (0x00000004) +#define ADC_INT_HP_SINGLE_EOC (0x00000100) +#define ADC_INT_HP_SUB_GROUP_EOC (0x00000200) +#define ADC_INT_HP_CYCLE_EOC (0x00000400) +#define ADC_INT_AWD_LOWER (0x00010000) +#define ADC_INT_AWD_UPPER (0x00020000) +#define ADC_INT_DATA_OVERWRITE (0x01000000) +#define ADC_INT_HP_DATA_OVERWRITE (0x02000000) + +#define IS_ADC_INT(INT) ((((INT) & 0xFCFCF8F8) == 0) && ((INT) != 0)) + + +#define ADC_FLAG_SINGLE_EOC (0x00000001) +#define ADC_FLAG_SUB_GROUP_EOC (0x00000002) +#define ADC_FLAG_CYCLE_EOC (0x00000004) +#define ADC_FLAG_HP_SINGLE_EOC (0x00000100) +#define ADC_FLAG_HP_SUB_GROUP_EOC (0x00000200) +#define ADC_FLAG_HP_CYCLE_EOC (0x00000400) +#define ADC_FLAG_AWD_LOWER (0x00010000) +#define ADC_FLAG_AWD_UPPER (0x00020000) +#define ADC_FLAG_DATA_OVERWRITE (0x01000000) +#define ADC_FLAG_HP_DATA_OVERWRITE (0x02000000) + +#define IS_ADC_FLAG(FLAG) ((((FLAG) & 0xFCFCF8F8) == 0) && ((FLAG) != 0)) + + +#define ADC_REGULAR_DATA0 (0) +#define ADC_REGULAR_DATA1 (1) +#define ADC_REGULAR_DATA2 (2) +#define ADC_REGULAR_DATA3 (3) +#define ADC_REGULAR_DATA4 (4) +#define ADC_REGULAR_DATA5 (5) +#define ADC_REGULAR_DATA6 (6) +#define ADC_REGULAR_DATA7 (7) +#define ADC_REGULAR_DATA8 (8) +#define ADC_REGULAR_DATA9 (9) +#define ADC_REGULAR_DATA10 (10) +#define ADC_REGULAR_DATA11 (11) +#define ADC_REGULAR_DATA12 (12) +#define ADC_REGULAR_DATA13 (13) +#define ADC_REGULAR_DATA14 (14) +#define ADC_REGULAR_DATA15 (15) + +#define IS_ADC_REGULAR_DATA(DATA) ((DATA) < 16) + + +#define ADC_HP_DATA0 (0) +#define ADC_HP_DATA1 (1) +#define ADC_HP_DATA2 (2) +#define ADC_HP_DATA3 (3) + +#define IS_ADC_HP_DATA(DATA) ((DATA) < 4) + + +#define ADC_AWD_DISABLE (u8)0x00 +#define ADC_AWD_ALL_LOWER (u8)0x05 +#define ADC_AWD_ALL_UPPER (u8)0x06 +#define ADC_AWD_ALL_LOWER_UPPER (u8)0x07 +#define ADC_AWD_SINGLE_LOWER (u8)0x01 +#define ADC_AWD_SINGLE_UPPER (u8)0x02 +#define ADC_AWD_SINGLE_LOWER_UPPER (u8)0x03 + +#define IS_ADC_AWD(AWD) (((AWD) == ADC_AWD_DISABLE) || \ + ((AWD) == ADC_AWD_ALL_LOWER) || \ + ((AWD) == ADC_AWD_ALL_UPPER) || \ + ((AWD) == ADC_AWD_ALL_LOWER_UPPER) || \ + ((AWD) == ADC_AWD_SINGLE_LOWER) || \ + ((AWD) == ADC_AWD_SINGLE_UPPER) || \ + ((AWD) == ADC_AWD_SINGLE_LOWER_UPPER)) + +#define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) < 4096) + +#define ADC_PDMA_REGULAR_SINGLE (0x00000001) +#define ADC_PDMA_REGULAR_SUBGROUP (0x00000002) +#define ADC_PDMA_REGULAR_CYCLE (0x00000004) + +#define ADC_PDMA_HP_SINGLE (0x00000100) +#define ADC_PDMA_HP_SUBGROUP (0x00000200) +#define ADC_PDMA_HP_CYCLE (0x00000400) + +#define IS_ADC_PDMA(PDMA) (((PDMA) == ADC_PDMA_REGULAR_SINGLE) || \ + ((PDMA) == ADC_PDMA_REGULAR_SUBGROUP) || \ + ((PDMA) == ADC_PDMA_REGULAR_CYCLE) || \ + ((PDMA) == ADC_PDMA_HP_SINGLE) || \ + ((PDMA) == ADC_PDMA_HP_SUBGROUP) || \ + ((PDMA) == ADC_PDMA_HP_CYCLE)) + + +#define IS_ADC_INPUT_SAMPLING_TIME(TIME) ((TIME) <= 255) + +#define IS_ADC_OFFSET(OFFSET) ((OFFSET) < 4096) + +#define IS_ADC_REGULAR_RANK(RANK) ((RANK) < 16) + +#define IS_ADC_HP_RANK(RANK) ((RANK) < 4) + +#define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 1) && ((LENGTH) <= 16)) +#define IS_ADC_REGULAR_SUB_LENGTH(SUB_LENGTH) (((SUB_LENGTH) >= 1) && ((SUB_LENGTH) <= 16)) + +#define IS_ADC_HP_LENGTH(LENGTH) (((LENGTH) >= 1) && ((LENGTH) <= 4)) +#define IS_ADC_HP_SUB_LENGTH(SUB_LENGTH) (((SUB_LENGTH) >= 1) && ((SUB_LENGTH) <= 4)) + +#define ADC_VREF_1V215 (0ul << 4) +#define ADC_VREF_2V0 (1ul << 4) +#define ADC_VREF_2V5 (2ul << 4) +#define ADC_VREF_2V7 (3ul << 4) + +#define IS_ADC_VREF_SEL(SEL) ((SEL == ADC_VREF_1V215) || \ + (SEL == ADC_VREF_2V0) || \ + (SEL == ADC_VREF_2V5) || \ + (SEL == ADC_VREF_2V7)) + +typedef enum +{ + ADC_ALIGN_RIGHT = (0 << 14), + ADC_ALIGN_LEFT = (1 << 14), +} ADC_ALIGN_Enum; + +#define IS_ADC_ALIGN(ALIGN) (((ALIGN) == ADC_ALIGN_RIGHT) || ((ALIGN) == ADC_ALIGN_LEFT)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Exported_Functions ADC exported functions + * @{ + */ +void ADC_DeInit(HT_ADC_TypeDef* HT_ADCn); +void ADC_Reset(HT_ADC_TypeDef* HT_ADCn); +void ADC_Cmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); + +void ADC_SamplingTimeConfig(HT_ADC_TypeDef* HT_ADCn, u8 SampleClock); // Apply for the specific model only +void ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock); +void ADC_RegularGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength); +void ADC_RegularTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x); + +void ADC_HPChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock); +void ADC_HPGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength); +void ADC_HPTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x); + +void ADC_ChannelDataAlign(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ADC_ALIGN_Enum ADC_ALIGN_x); +void ADC_ChannelOffsetValue(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u16 OffsetValue); +void ADC_ChannelOffsetCmd(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ControlStatus NewState); + +void ADC_SoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); +void ADC_HPSoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); + +u16 ADC_GetConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_REGULAR_DATAn); +u16 ADC_GetHPConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_HP_DATAn); + +void ADC_IntConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x, ControlStatus NewState); +FlagStatus ADC_GetIntStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x); +void ADC_ClearIntPendingBit(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x); +FlagStatus ADC_GetFlagStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_FLAG_x); + +void ADC_AWDConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_AWD_x); +void ADC_AWDSingleChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n); +void ADC_AWDThresholdsConfig(HT_ADC_TypeDef* HT_ADCn, u16 UPPER, u16 LOWER); + +void ADC_PDMAConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_PDMA_x, ControlStatus NewState); + +void ADC_VREFCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); +void ADC_VREFConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_VREF_x); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_aes.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_aes.h new file mode 100644 index 0000000000..176bf19e72 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_aes.h @@ -0,0 +1,202 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_aes.h + * @version $Rev:: 2022 $ + * @date $Date:: 2020-02-03 #$ + * @brief The header file of the ADC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_AES_H +#define __HT32F1XXXX_AES_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup AES + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Types AES exported types + * @{ + */ + +/** + * @brief Definition of AES Init Structure + */ +typedef struct +{ + u16 AES_KeySize; + u16 AES_Dir; + u16 AES_Mode; + u16 AES_Swap; +} AES_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Constants AES exported constants + * @{ + */ + +#define IS_AES(AES) (AES == HT_AES) + +/* Definitions of AES key size */ +#define AES_KEYSIZE_128B ((u32)0x00000000) +#define AES_KEYSIZE_192B ((u32)0x00000020) +#define AES_KEYSIZE_256B ((u32)0x00000040) + +#define IS_AES_KEY_SIZE(SIZE) ((SIZE == AES_KEYSIZE_128B) || (SIZE == AES_KEYSIZE_192B) || (SIZE == AES_KEYSIZE_256B)) + +/* Definitions of AES direction */ +typedef enum +{ + AES_DIR_ENCRYPT =0, + AES_DIR_DECRYPT =2 +} AES_DIR_Enum; + +#define IS_AES_DIR(DIR) ((DIR == AES_DIR_ENCRYPT) || (DIR == AES_DIR_DECRYPT)) + +/* Definitions of AES mode */ +#define AES_MODE_ECB ((u32)0x00000000) +#define AES_MODE_CBC ((u32)0x00000004) +#define AES_MODE_CTR ((u32)0x00000008) + +#define IS_AES_MODE(MODE) ((MODE == AES_MODE_ECB) || (MODE == AES_MODE_CBC) || (MODE == AES_MODE_CTR)) + +/* Definitions of AES key start */ +#define AES_KEYSTART_DISABLE ((u32)0x00000000) +#define AES_KEYSTART_ENABLE ((u32)0x00000010) + +#define IS_AES_KEYSTART(KEYSTART) ((KEYSTART == AES_KEYSTART_DISABLE) || (KEYSTART == AES_KEYSTART_ENABLE)) + +/* Definitions of AES swap */ +#define AES_SWAP_DISABLE ((u32)0x00000000) +#define AES_SWAP_ENABLE ((u32)0x00000100) + +#define IS_AES_SWAP(SWAP) ((SWAP == AES_SWAP_DISABLE) || (SWAP == AES_SWAP_ENABLE)) + +/* Definitions of AES flush */ +#define AES_FLUSH_DISABLE ((u32)0x00000000) +#define AES_FLUSH_ENABLE ((u32)0x00000400) + +#define IS_AES_FLUSH(FLUSH) ((FLUSH == AES_FLUSH_DISABLE) || (FLUSH == AES_FLUSH_ENABLE)) + +/* Definitions of AES Enable */ +#define AES_DISABLE ((u32)0x00000000) +#define AES_ENABLE ((u32)0x00000001) + +#define IS_AES_CMD(CMD) ((CMD == AES_DISABLE) || (CMD == AES_ENABLE)) + +/* Definitions of AES status */ +#define AES_SR_IFEMPTY ((u32)0x00000001) +#define AES_SR_IFNFULL ((u32)0x00000002) +#define AES_SR_OFNEMPTY ((u32)0x00000004) +#define AES_SR_OFFULL ((u32)0x00000008) +#define AES_SR_BUSY ((u32)0x00000010) + +#define IS_AES_STATUS(STATUS) ((STATUS == AES_SR_IFEMPTY) || \ + (STATUS == AES_SR_IFNFULL) || \ + (STATUS == AES_SR_OFNEMPTY) || \ + (STATUS == AES_SR_OFFULL) || \ + (STATUS == AES_SR_BUSY)) + +/* Definitions of AES PDMA */ +#define AES_PDMA_IFDMAEN ((u32)0x00000001) +#define AES_PDMA_OFDMAEN ((u32)0x00000002) + +#define IS_AES_PDMA(AES_PDMA) ((AES_PDMA == AES_PDMA_IFDMAEN) || (AES_PDMA == AES_PDMA_OFDMAEN)) + +/* Definitions of AES Interrupt Status */ +#define AES_INTSR_IFINT ((u32)0x00000001) +#define AES_INTSR_OFINT ((u32)0x00000002) + +#define IS_AES_INTSR(AES_INSR) ((AES_INSR == AES_INTSR_IFINT) || (AES_INSR == AES_INTSR_OFINT)) + +/* Definitions of AES interrupt enable */ +#define AES_IER_IFINTEN ((u32)0x00000001) +#define AES_IER_OFINTEN ((u32)0x00000002) + +#define IS_AES_IER(ARS_IER) ((ARS_IER == AES_IER_IFINTEN) || (ARS_IER == AES_IER_OFINTEN)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Functions AES exported functions + * @{ + */ +void AES_ECB_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); +void AES_CBC_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); +void AES_CTR_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); +void AES_SetKeyTable(HT_AES_TypeDef* HT_AESn, uc8* Key, u32 keySize); +ErrStatus _AES_CryptData(HT_AES_TypeDef* HT_AESn, AES_DIR_Enum dir, uc8 *iv, u32 length, uc8 *inputData, u8 *outputData); +#define AES_ECB_CryptData(a, b, c, d, e) _AES_CryptData(a, b, NULL, c, d, e) +#define AES_CBC_CryptData _AES_CryptData +#define AES_CTR_CryptData(a, b, c, d, e) _AES_CryptData(a, AES_DIR_ENCRYPT, b, c, d, e) +#if 0 +ErrStatus AES_ECB_CryptData(HT_AES_TypeDef* HT_AESn, AES_DIR_Enum mode, u32 length, uc8 *inputData, u8 *outputData); +ErrStatus AES_CBC_CryptData(HT_AES_TypeDef* HT_AESn, AES_DIR_Enum mode, uc8 *iv, u32 length, uc8 *inputData, u8 *outputData); +ErrStatus AES_CTR_CryptData(HT_AES_TypeDef* HT_AESn, uc8 *iv, u32 length, uc8 *inputData, u8 *outputData); +#endif + +void AES_StartKey(HT_AES_TypeDef* HT_AESn); +void AES_DeInit(HT_AES_TypeDef* HT_AESn); +void AES_FIFOFlush(HT_AES_TypeDef* HT_AESn); +void AES_Cmd(HT_AES_TypeDef* HT_AESn, ControlStatus NewState); +FlagStatus AES_GetStatus(HT_AES_TypeDef* HT_AESn, u32 AES_Status); +void AES_PDMACmd(HT_AES_TypeDef* HT_AESn, u32 AES_PDMA_xFDMAEN, ControlStatus NewState); +FlagStatus AES_GetIntStatus(HT_AES_TypeDef* HT_AESn, u32 AES_INTSR_x); +void AES_IntConfig(HT_AES_TypeDef* HT_AESn, u32 AES_IER_x, ControlStatus NewState); +void AES_SetInputData(HT_AES_TypeDef* HT_AESn, uc32 AES_Data); +u32 AES_GetOutputData(HT_AES_TypeDef* HT_AESn); +void AES_SetVectorTable(HT_AES_TypeDef* HT_AESn, uc8* Vector); +void AESCore_IRQHandler(HT_AES_TypeDef* HT_AESn); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_bftm.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_bftm.h new file mode 100644 index 0000000000..091cc6dd77 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_bftm.h @@ -0,0 +1,99 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_bftm.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the BFTM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_BFTM_H +#define __HT32F1XXXX_BFTM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup BFTM + * @{ + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Types BFTM exported types + * @{ + */ +typedef u32 BFTM_DataTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Constants BFTM exported constants + * @{ + */ +#define IS_BFTM(x) ((x == HT_BFTM0) || (x == HT_BFTM1)) + +#define BFTM_FLAG_MATCH (1UL << 0) +#define BFTM_INT_MATCH (1UL << 0) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Functions BFTM exported functions + * @{ + */ +void BFTM_DeInit(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_EnaCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState); +void BFTM_SetCompare(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCompare); +u32 BFTM_GetCompare(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_SetCounter(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCounter); +u32 BFTM_GetCounter(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_OneShotModeCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState); +void BFTM_IntConfig(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState); +FlagStatus BFTM_GetFlagStatus(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_ClearFlag(HT_BFTM_TypeDef* HT_BFTMn); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ckcu.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ckcu.h new file mode 100644 index 0000000000..11369ee4d0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ckcu.h @@ -0,0 +1,734 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_ckcu.h + * @version $Rev:: 2974 $ + * @date $Date:: 2023-10-30 #$ + * @brief The header file of the Clock Control Unit library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_CKCU_H +#define __HT32F1XXXX_CKCU_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CKCU + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Exported_Types CKCU exported types + * @{ + */ + +/** + * @brief Enumeration of APB peripheral prescaler. + */ +typedef enum +{ + CKCU_APBCLKPRE_DIV1 = 0, + CKCU_APBCLKPRE_DIV2, + CKCU_APBCLKPRE_DIV4, + CKCU_APBCLKPRE_DIV8, + CKCU_APBCLKPRE_DIV16, + CKCU_APBCLKPRE_DIV32 +} CKCU_APBCLKPRE_TypeDef; + +/** + * @brief Enumeration of CK_REF prescaler. + */ +typedef enum +{ + CKCU_CKREFPRE_DIV2 = 0, + CKCU_CKREFPRE_DIV4, + CKCU_CKREFPRE_DIV6, + CKCU_CKREFPRE_DIV8, + CKCU_CKREFPRE_DIV10, + CKCU_CKREFPRE_DIV12, + CKCU_CKREFPRE_DIV14, + CKCU_CKREFPRE_DIV16, + CKCU_CKREFPRE_DIV18, + CKCU_CKREFPRE_DIV20, + CKCU_CKREFPRE_DIV22, + CKCU_CKREFPRE_DIV24, + CKCU_CKREFPRE_DIV26, + CKCU_CKREFPRE_DIV28, + CKCU_CKREFPRE_DIV30, + CKCU_CKREFPRE_DIV32, + CKCU_CKREFPRE_DIV34, + CKCU_CKREFPRE_DIV36, + CKCU_CKREFPRE_DIV38, + CKCU_CKREFPRE_DIV40, + CKCU_CKREFPRE_DIV42, + CKCU_CKREFPRE_DIV44, + CKCU_CKREFPRE_DIV46, + CKCU_CKREFPRE_DIV48, + CKCU_CKREFPRE_DIV50, + CKCU_CKREFPRE_DIV52, + CKCU_CKREFPRE_DIV54, + CKCU_CKREFPRE_DIV56, + CKCU_CKREFPRE_DIV58, + CKCU_CKREFPRE_DIV60, + CKCU_CKREFPRE_DIV62, + CKCU_CKREFPRE_DIV64 +} CKCU_CKREFPRE_TypeDef; + +/** + * @brief Enumeration of PLL clock source. + */ +typedef enum +{ + CKCU_PLLSRC_HSE = 0, + CKCU_PLLSRC_HSI +} CKCU_PLLSRC_TypeDef; + +#if (LIBCFG_CKCU_USART_PRESCALER) +/** + * @brief Enumeration of CK_USART prescaler. + */ +typedef enum +{ + CKCU_URPRE_DIV1 = 0, + CKCU_URPRE_DIV2 +} CKCU_URPRE_TypeDef; +#endif + +#if (!LIBCFG_NO_CKCU_USBPRE) +/** + * @brief Enumeration of CK_USB prescaler. + */ +typedef enum +{ + CKCU_USBPRE_DIV1 = 0, + CKCU_USBPRE_DIV2, +#if (LIBCFG_CKCU_USB_DIV3) + CKCU_USBPRE_DIV3 +#endif +} CKCU_USBPRE_TypeDef; +#endif + +#if (LIBCFG_CKCU_USB_PLL) +/** + * @brief Enumeration of CK_USB clock source. + */ +typedef enum +{ + CKCU_CKPLL = 0, + CKCU_CKUSBPLL +} CKCU_USBSRC_TypeDef; +#endif + +/** + * @brief Enumeration of WDT clock source. + */ +typedef enum +{ + CKCU_WDTSRC_LSI = 0, + CKCU_WDTSRC_LSE +} CKCU_WDTSRC_TypeDef; + + + +#if (!LIBCFG_CKCU_HSI_NO_AUTOTRIM) +/** + * @brief Enumeration of HSI auto-trim clock source. + */ +typedef enum +{ + CKCU_ATC_LSE = 0, + CKCU_ATC_USB = 1, +#if (LIBCFG_CKCU_AUTOTRIM_NOCKIN) +#else + CKCU_ATC_CKIN = 2, +#endif +} CKCU_ATC_TypeDef; + +#endif + +#if (LIBCFG_CKCU_ATM_V01) +/** + * @brief Enumeration of ATC search algorithm. + */ +typedef enum +{ + CKCU_ATC_BINARY_SEARCH = 0, + CKCU_ATC_LINEAR_SEARCH = 8 +} CKCU_ATCSearchAlgorithm_TypeDef; + +/** + * @brief Enumeration of ATC frequency tolerance. + */ +typedef enum +{ + CKCU_ATC_DOUBLE_PRECISION = 0, + CKCU_ATC_SINGLE_PRECISION = 4 +} CKCU_ATCFrqTolerance_TypeDef; +#endif + +/** + * @brief Enumeration of CK_AHB prescaler. + */ +typedef enum +{ + CKCU_SYSCLK_DIV1 = 0, + CKCU_SYSCLK_DIV2, + CKCU_SYSCLK_DIV4, + CKCU_SYSCLK_DIV8, +#if (LIBCFG_CKCU_SYSCLK_DIV8_ONLY) +#else + CKCU_SYSCLK_DIV16, + CKCU_SYSCLK_DIV32 +#endif +} CKCU_SYSCLKDIV_TypeDef; + +/** + * @brief Enumeration of CK_ADC prescaler. + */ +typedef enum +{ + #if (LIBCFG_CKCU_NO_ADCPRE_DIV1) + #else + CKCU_ADCPRE_DIV1 = 0, + #endif + CKCU_ADCPRE_DIV2 = 1, + CKCU_ADCPRE_DIV4, + CKCU_ADCPRE_DIV8, + CKCU_ADCPRE_DIV16, + CKCU_ADCPRE_DIV32, + CKCU_ADCPRE_DIV64, +#if (LIBCFG_CKCU_ADCPRE_DIV5) + CKCU_ADCPRE_DIV5 +#else + CKCU_ADCPRE_DIV6 +#endif +} CKCU_ADCPRE_TypeDef; + +/** + * @brief Enumeration of CK_ADCn. + */ +typedef enum +{ + CKCU_ADCPRE_ADC0 = 16, +} CKCU_ADCPRE_ADCn_TypeDef; + +/** + * @brief Enumeration of System clock source. + */ +typedef enum +{ + CKCU_SW_PLL = 1, + CKCU_SW_HSE = 2, + CKCU_SW_HSI = 3, +#if (LIBCFG_CKCU_NO_HCLK_LOW_SPEED) +#else + CKCU_SW_LSE = 6, + CKCU_SW_LSI = 7 +#endif +} CKCU_SW_TypeDef; + +/** + * @brief Enumeration of CKOUT clock source. + */ +typedef enum +{ + CKCU_CKOUTSRC_REFCK = 0, + CKCU_CKOUTSRC_HCLK_DIV16 = 1, + CKCU_CKOUTSRC_SYSCK_DIV16 = 2, + CKCU_CKOUTSRC_HSECK_DIV16 = 3, + CKCU_CKOUTSRC_HSICK_DIV16 = 4, + CKCU_CKOUTSRC_LSECK = 5, + CKCU_CKOUTSRC_LSICK = 6 +} CKCU_CKOUTSRC_TypeDef; + +/** + * @brief Enumeration of PLL clock source status. + */ +typedef enum +{ + CKCU_PLLST_SYSCK = 1, + CKCU_PLLST_USB = 4, + CKCU_PLLST_REFCK = 8 +} CKCU_PLLST_TypeDef; + +/** + * @brief Enumeration of HSI clock source status. + */ +typedef enum +{ + CKCU_HSIST_SYSCK = 1, + CKCU_HSIST_PLL = 2, + CKCU_HSIST_CKM = 4 +} CKCU_HSIST_TypeDef; + +/** + * @brief Enumeration of HSE clock source status. + */ +typedef enum +{ + CKCU_HSEST_SYSCK = 1, + CKCU_HSEST_PLL +} CKCU_HSEST_TypeDef; + +/** + * @brief Definition of CKOUT Init Structure. + */ +typedef struct +{ + CKCU_CKOUTSRC_TypeDef CKOUTSRC; +} CKCU_CKOUTInitTypeDef; + +/** + * @brief Definition of PLL Init Structure. + */ +typedef struct +{ + u32 CFG; + CKCU_PLLSRC_TypeDef ClockSource; + ControlStatus BYPASSCmd; +} CKCU_PLLInitTypeDef; + +/** + * @brief Definition of structure for clock frequency. + */ +typedef struct +{ + u32 PLL_Freq; + u32 SYSCK_Freq; + u32 HCLK_Freq; +#if (LIBCFG_CKCU_USART_PRESCALER) + u32 USART_Freq; +#endif + u32 ADC0_Freq; +} CKCU_ClocksTypeDef; + +#if (LIBCFG_CKCU_ATM_V01) +/** + * @brief Definition of ATC Init Structure. + */ +typedef struct +{ + CKCU_ATCSearchAlgorithm_TypeDef SearchAlgorithm; + CKCU_ATCFrqTolerance_TypeDef FrqTolerance; +} CKCU_ATCInitTypeDef; +#endif + +/** + * @brief Definition of initial structure of peripheral clock control. + */ +typedef union +{ + struct + { + /* Definitions of AHB clock control */ + unsigned long FMC :1; // Bit 0 + unsigned long :1; // Bit 1 + unsigned long SRAM :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long PDMA :1; // Bit 4 + unsigned long BM :1; // Bit 5 + unsigned long APB0 :1; // Bit 6 + unsigned long APB1 :1; // Bit 7 + + unsigned long CSIF :1; // Bit 8 + unsigned long CSIFMCLK :1; // Bit 9 + unsigned long USBD :1; // Bit 10 + unsigned long CKREF :1; // Bit 11 + unsigned long EBI :1; // Bit 12 + unsigned long CRC :1; // Bit 13 + unsigned long SDIO :1; // Bit 14 + unsigned long AES :1; // Bit 15 + + unsigned long PA :1; // Bit 16 + unsigned long PB :1; // Bit 17 + unsigned long PC :1; // Bit 18 + unsigned long PD :1; // Bit 19 + unsigned long PE :1; // Bit 20 + unsigned long PF :1; // Bit 21 + unsigned long :1; // Bit 22 + unsigned long :1; // Bit 23 + + unsigned long :1; // Bit 24 + unsigned long :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long :1; // Bit 28 + unsigned long :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB0 clock control */ + unsigned long I2C0 :1; // Bit 0 + unsigned long I2C1 :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long SPI0 :1; // Bit 4 + unsigned long SPI1 :1; // Bit 5 + unsigned long :1; // Bit 6 + unsigned long :1; // Bit 7 + + unsigned long USART0 :1; // Bit 8 + unsigned long USART1 :1; // Bit 9 + unsigned long UART0 :1; // Bit 10 + unsigned long UART1 :1; // Bit 11 + unsigned long :1; // Bit 12 + unsigned long :1; // Bit 13 + unsigned long AFIO :1; // Bit 14 + unsigned long EXTI :1; // Bit 15 + + unsigned long :1; // Bit 16 + unsigned long :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 + unsigned long :1; // Bit 22 + unsigned long :1; // Bit 23 + + unsigned long SCI0 :1; // Bit 24 + unsigned long I2S :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long SCI1 :1; // Bit 27 + unsigned long :1; // Bit 28 + unsigned long :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB1 clock control */ + unsigned long MCTM0 :1; // Bit 0 + unsigned long MCTM1 :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long WDT :1; // Bit 4 + unsigned long :1; // Bit 5 + unsigned long BKP :1; // Bit 6 + unsigned long :1; // Bit 7 + + unsigned long GPTM0 :1; // Bit 8 + unsigned long GPTM1 :1; // Bit 9 + unsigned long :1; // Bit 10 + unsigned long :1; // Bit 11 + unsigned long PWM0 :1; // Bit 12 + unsigned long :1; // Bit 13 + unsigned long :1; // Bit 14 + unsigned long :1; // Bit 15 + + unsigned long BFTM0 :1; // Bit 16 + unsigned long BFTM1 :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 +#if (LIBCFG_CMP_OPA) + unsigned long OPA0 :1; // Bit 22 +#else + unsigned long CMP :1; // Bit 22 +#endif + unsigned long OPA1 :1; // Bit 23 + + unsigned long ADC0 :1; // Bit 24 + unsigned long :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long SCTM0 :1; // Bit 28 + unsigned long SCTM1 :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + } Bit; + u32 Reg[3]; +} CKCU_PeripClockConfig_TypeDef; + +#define CKCU_APBPCSR_OFFSET (5) +#define CKCU_APBPCSR0 (0 << CKCU_APBPCSR_OFFSET) +#define CKCU_APBPCSR1 (1 << CKCU_APBPCSR_OFFSET) +#define CKCU_APBPCSR2 (4 << CKCU_APBPCSR_OFFSET) +typedef enum +{ + CKCU_PCLK_I2C0 = (CKCU_APBPCSR0 | 0), + CKCU_PCLK_I2C1 = (CKCU_APBPCSR0 | 2), + CKCU_PCLK_SPI0 = (CKCU_APBPCSR0 | 4), + CKCU_PCLK_SPI1 = (CKCU_APBPCSR0 | 6), + CKCU_PCLK_BFTM0 = (CKCU_APBPCSR0 | 12), + CKCU_PCLK_BFTM1 = (CKCU_APBPCSR0 | 14), + CKCU_PCLK_MCTM0 = (CKCU_APBPCSR0 | 16), + CKCU_PCLK_MCTM1 = (CKCU_APBPCSR0 | 18), + CKCU_PCLK_GPTM0 = (CKCU_APBPCSR0 | 20), + CKCU_PCLK_GPTM1 = (CKCU_APBPCSR0 | 22), + CKCU_PCLK_USART0 = (CKCU_APBPCSR0 | 24), + CKCU_PCLK_USART1 = (CKCU_APBPCSR0 | 26), + CKCU_PCLK_UART0 = (CKCU_APBPCSR0 | 28), + CKCU_PCLK_UART1 = (CKCU_APBPCSR0 | 30), + CKCU_PCLK_AFIO = (CKCU_APBPCSR1 | 0), + CKCU_PCLK_EXTI = (CKCU_APBPCSR1 | 2), + CKCU_PCLK_ADC = (CKCU_APBPCSR1 | 4), + CKCU_PCLK_CMP = (CKCU_APBPCSR1 | 8), + CKCU_PCLK_WDTR = (CKCU_APBPCSR1 | 12), + CKCU_PCLK_BKPR = (CKCU_APBPCSR1 | 14), +#if (LIBCFG_SCI0) + CKCU_PCLK_SCI0 = (CKCU_APBPCSR1 | 16), +#endif +#if (LIBCFG_SCI1) + CKCU_PCLK_SCI1 = (CKCU_APBPCSR1 | 18), +#endif + CKCU_PCLK_I2S = (CKCU_APBPCSR1 | 20), + CKCU_PCLK_SCTM0 = (CKCU_APBPCSR1 | 24), + CKCU_PCLK_SCTM1 = (CKCU_APBPCSR1 | 26), + CKCU_PCLK_PWM0 = (CKCU_APBPCSR2 | 16), +} CKCU_PeripPrescaler_TypeDef; + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Exported_Constants CKCU exported constants + * @{ + */ + +/* Definitions of clock ready flag */ +#define CKCU_FLAG_PLLRDY (1UL << 1) +#define CKCU_FLAG_HSERDY (1UL << 2) +#define CKCU_FLAG_HSIRDY (1UL << 3) +#define CKCU_FLAG_LSERDY (1UL << 4) +#define CKCU_FLAG_LSIRDY (1UL << 5) +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_FLAG_USBPLLRDY (1UL) +#define IS_CKCU_FLAG(FLAG) (((FLAG & 0xFFFFFFC0) == 0) && (FLAG != 0)) +#else +#define IS_CKCU_FLAG(FLAG) (((FLAG & 0xFFFFFFC1) == 0) && (FLAG != 0)) +#endif +/* Definitions of clock interrupt & flag */ +#define CKCU_INT_CKS (1UL) +#define CKCU_INT_PLLRDY (1UL << 2) +#define CKCU_INT_HSERDY (1UL << 3) +#define CKCU_INT_HSIRDY (1UL << 4) +#define CKCU_INT_LSERDY (1UL << 5) +#define CKCU_INT_LSIRDY (1UL << 6) + +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_INT_USBPLLRDY (1UL << 1) +#define IS_CKCU_INT_FLAG(FLAG) (((FLAG & 0xFFFFFF80) == 0) && (FLAG != 0)) +#else +#define IS_CKCU_INT_FLAG(FLAG) (((FLAG & 0xFFFFFF82) == 0) && (FLAG != 0)) +#endif + +#define CKCU_INT_CKSIE (1UL << 16) +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_INT_USBPLLRDYIE (1UL << 17) +#endif +#define CKCU_INT_PLLRDYIE (1UL << 18) +#define CKCU_INT_HSERDYIE (1UL << 19) +#define CKCU_INT_HSIRDYIE (1UL << 20) +#define CKCU_INT_LSERDYIE (1UL << 21) +#define CKCU_INT_LSIRDYIE (1UL << 22) + +#if (LIBCFG_CKCU_USB_PLL) +#define IS_CKCU_INT(IT) (((IT & 0xFF80FFFF) == 0) && (IT != 0)) +#else +#define IS_CKCU_INT(IT) (((IT & 0xFF82FFFF) == 0) && (IT != 0)) +#endif + +#define IS_PLL_CLKSRC(SRC) ((SRC == CKCU_PLLSRC_HSE) || \ + (SRC == CKCU_PLLSRC_HSI)) + +/* Definitions of PLL frequency */ +#if (LIBCDG_CKCU_PLL_144M) +#define CKCU_PLL_4M_144M ((36UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_144M ((18UL << 23) | (0UL << 21)) +#define CKCU_PLL_12M_144M ((12UL << 23) | (0UL << 21)) +#define CKCU_PLL_16M_144M (( 9UL << 23) | (0UL << 21)) +#endif + +#define CKCU_PLL_4M_48M ((12UL << 23) | (0UL << 21)) +#define CKCU_PLL_4M_72M ((18UL << 23) | (0UL << 21)) +#define CKCU_PLL_4M_96M ((24UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_48M (( 6UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_64M (( 8UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_72M (( 9UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_80M ((10UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_96M ((12UL << 23) | (0UL << 21)) +#define CKCU_PLL_12M_48M (( 4UL << 23) | (0UL << 21)) +#define CKCU_PLL_12M_72M (( 6UL << 23) | (0UL << 21)) +#define CKCU_PLL_12M_96M (( 8UL << 23) | (0UL << 21)) +#define CKCU_PLL_16M_80M (( 5UL << 23) | (0UL << 21)) +#define CKCU_PLL_16M_96M (( 6UL << 23) | (0UL << 21)) + +#if (LIBCDG_CKCU_PLL_144M) +#define IS_PLL_CFG(CFG) (((CFG & 0xE01FFFFF) == 0x0)) +#else +#define IS_PLL_CFG(CFG) (((CFG & 0xF01FFFFF) == 0x0)) +#endif + +#if (LIBCFG_CKCU_USB_PLL) +/* Definitions of USBPLL frequency */ +#define CKCU_USBPLL_4M_48M ((12UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_8M_48M (( 6UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_12M_48M (( 4UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_16M_48M (( 3UL << 7) | (0UL << 5)) + +#define IS_USBPLL_CFG(CFG) (((CFG & 0xFFFFF81F) == 0x0)) +#endif + +/* Definitions of MCU debug control */ +#define CKCU_DBG_SLEEP (1UL) +#define CKCU_DBG_DEEPSLEEP1 (1UL << 1) +#define CKCU_DBG_POWERDOWN (1UL << 2) +#define CKCU_DBG_WDT_HALT (1UL << 3) +#define CKCU_DBG_MCTM0_HALT (1UL << 4) +#define CKCU_DBG_MCTM1_HALT (1UL << 5) +#define CKCU_DBG_GPTM0_HALT (1UL << 6) +#define CKCU_DBG_GPTM1_HALT (1UL << 7) +#define CKCU_DBG_USART0_HALT (1UL << 8) +#define CKCU_DBG_USART1_HALT (1UL << 9) +#define CKCU_DBG_SPI0_HALT (1UL << 10) +#define CKCU_DBG_SPI1_HALT (1UL << 11) +#define CKCU_DBG_I2C0_HALT (1UL << 12) +#define CKCU_DBG_I2C1_HALT (1UL << 13) +#define CKCU_DBG_DEEPSLEEP2 (1UL << 14) +#define CKCU_DBG_SCI_HALT (1UL << 15) +#define CKCU_DBG_BFTM0_HALT (1UL << 16) +#define CKCU_DBG_BFTM1_HALT (1UL << 17) +#define CKCU_DBG_UART0_HALT (1UL << 18) +#define CKCU_DBG_UART1_HALT (1UL << 19) +#define CKCU_DBG_TRACE_ON (1UL << 20) + +#if (LIBCFG_SCI0) +#define CKCU_DBG_SCI0_HALT (1UL << 15) +#endif +#if (LIBCFG_SCI1) +#define CKCU_DBG_SCI1_HALT (1UL << 21) +#endif + +#define IS_CKCU_DBG(MODE) (((MODE & 0xBF200000) == 0) && (MODE != 0)) + +/* Definitions of AHB clock control */ +#define CKCU_AHBEN_SLEEP_FMC (1UL) +#define CKCU_AHBEN_SLEEP_SRAM (1UL << 2) +#define CKCU_AHBEN_SLEEP_BM (1UL << 5) +#define CKCU_AHBEN_SLEEP_APB0 (1UL << 6) +#define CKCU_AHBEN_SLEEP_APB1 (1UL << 7) + +#define IS_CKCU_SLEEP_AHB(PERIPH) (((PERIPH & 0xFFFFFF1A) == 0) && (PERIPH != 0)) + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Exported_Functions CKCU exported functions + * @{ + */ +void CKCU_DeInit(void); + +void CKCU_HSICmd(ControlStatus Cmd); +void CKCU_HSECmd(ControlStatus Cmd); +bool CKCU_IS_HSI_USED(CKCU_HSIST_TypeDef Target); +bool CKCU_IS_HSE_USED(CKCU_HSEST_TypeDef Target); +FlagStatus CKCU_GetClockReadyStatus(u32 CKCU_FLAG); +ErrStatus CKCU_WaitHSEReady(void); + +ErrStatus CKCU_SysClockConfig(CKCU_SW_TypeDef CLKSRC); +u32 CKCU_GetSysClockSource(void); + +void CKCU_PeripClockConfig(CKCU_PeripClockConfig_TypeDef Clock, ControlStatus Cmd); + +void CKCU_PLLInit(CKCU_PLLInitTypeDef *PLL_InitStruct); +void CKCU_PLLCmd(ControlStatus Cmd); +bool CKCU_IS_PLL_USED(CKCU_PLLST_TypeDef Target); + +#if (LIBCFG_CKCU_USB_PLL) +void CKCU_USBPLLInit(CKCU_PLLInitTypeDef *USBPLL_InitStruct); +void CKCU_USBPLLCmd(ControlStatus Cmd); +void CKCU_USBClockConfig(CKCU_USBSRC_TypeDef USBSRC); +#endif + +void CKCU_SleepClockConfig(u32 CKCU_CLK, ControlStatus Cmd); + +void CKCU_SetHCLKPrescaler(CKCU_SYSCLKDIV_TypeDef HCLKPRE); +void CKCU_SetCKREFPrescaler(CKCU_CKREFPRE_TypeDef CKREFPRE); +void CKCU_SetADCnPrescaler(CKCU_ADCPRE_ADCn_TypeDef CKCU_ADCPRE_ADCn, CKCU_ADCPRE_TypeDef CKCU_ADCPRE_DIVn); +#define CKCU_SetADCPrescaler(DIV) CKCU_SetADCnPrescaler(CKCU_ADCPRE_ADC0, DIV) + +#if (LIBCFG_CKCU_USART_PRESCALER) +void CKCU_SetUSARTPrescaler(CKCU_URPRE_TypeDef URPRE); +#endif + +#if (!LIBCFG_NO_CKCU_USBPRE) +void CKCU_SetUSBPrescaler(CKCU_USBPRE_TypeDef USBPRE); +#endif + +#if (LIBCFG_CKCU_NO_APB_PRESCALER) +#else +void CKCU_SetPeripPrescaler(CKCU_PeripPrescaler_TypeDef Perip, CKCU_APBCLKPRE_TypeDef PCLKPRE); +#endif + +void CKCU_GetClocksFrequency(CKCU_ClocksTypeDef* CKCU_Clk); +u32 CKCU_GetPLLFrequency(void); +u32 CKCU_GetPeripFrequency(CKCU_PeripPrescaler_TypeDef Perip); + +void CKCU_CKMCmd(ControlStatus Cmd); +void CKCU_PSRCWKUPCmd(ControlStatus Cmd); +void CKCU_BKISOCmd(ControlStatus Cmd); +void CKCU_CKOUTConfig(CKCU_CKOUTInitTypeDef *CKOUTInit); +void CKCU_MCUDBGConfig(u32 CKCU_DBGx, ControlStatus Cmd); + +void CKCU_IntConfig(u32 CKCU_INT, ControlStatus Cmd); +FlagStatus CKCU_GetIntStatus(u32 CKCU_INT); +void CKCU_ClearIntFlag(u32 CKCU_INT); + +#if (!LIBCFG_CKCU_HSI_NO_AUTOTRIM) +#if (LIBCFG_CKCU_ATM_V01) +void CKCU_ATCInit(CKCU_ATCInitTypeDef* ATC_InitStruct); +void CKCU_HSIAutoTrimAlgorithm(u32 Algo); +void CKCU_HSIAutoTrimFreqTolerance(u32 Tolerance); +#endif +void CKCU_HSIAutoTrimClkConfig(CKCU_ATC_TypeDef CLKSRC); +void CKCU_HSIAutoTrimCmd(ControlStatus Cmd); +bool CKCU_HSIAutoTrimIsReady(void); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp.h new file mode 100644 index 0000000000..7650247fb4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp.h @@ -0,0 +1,230 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_cmp.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the CMP library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_CMP_H +#define __HT32F1XXXX_CMP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CMP + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Types CMP exported types + * @{ + */ + +typedef struct +{ + u32 CMP_Wakeup; + u32 CMP_OutputSelection; + u32 CMP_ScalerSource; + u32 CMP_ScalerOutputBuf; + u32 CMP_ScalerEnable; + u32 CMP_CoutSync; + u32 CMP_OutputPol; + u32 CMP_InvInputSelection; + u32 CMP_Hysteresis; + u32 CMP_Speed; +} CMP_InitTypeDef; + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Constants CMP exported constants + * @{ + */ + +/* Definitions of CMP Protection Key */ +#define CMP_PROTECT_KEY ((u32)0x9C3A0000) + + +/* Definitions of CMP Output Status */ +#define CMP_OUTPUT_HIGH ((u32)0x00008000) +#define CMP_OUTPUT_LOW ((u32)0x00000000) + + +/* Definitions of CMP Wakeup Control Bit */ +#define CMP_WUP_ENABLE ((u32)0x00004000) +#define CMP_WUP_DISABLE ((u32)0x00000000) + +#define IS_CMP_Wakeup_Set(x) ((x == CMP_WUP_ENABLE) || (x == CMP_WUP_DISABLE)) + + +/* Definitions of CMP Output Selection for IP Trigger Source */ +#define CMP_TRIG_NONE ((u32)0x00000000) +#define CMP_TRIG_GPTM_CH3 ((u32)0x00000800) +#define CMP_TRIG_MCTM_CH3 ((u32)0x00001000) +#define CMP_TRIG_MCTM_BK1 ((u32)0x00001800) +#define CMP_TRIG_ADC ((u32)0x00002000) + +#define IS_CMP_OutputSelection(x) ((x == CMP_TRIG_NONE) || (x == CMP_TRIG_GPTM_CH3) || (x == CMP_TRIG_MCTM_CH3) || \ + (x == CMP_TRIG_MCTM_BK1) || (x == CMP_TRIG_ADC)) + +/* Definitions of CMP Scaler Source Selection */ +#define CMP_SCALER_SRC_VDDA ((u32)0x00000000) +#define CMP_SCALER_SRC_VREF ((u32)0x00000400) + +#define IS_CMP_ScalerSource(x) ((x == CMP_SCALER_SRC_VDDA) || (x == CMP_SCALER_SRC_VREF)) + + +/* Definitions of CMP Scaler Output Enable Bit */ +#define CMP_SCALER_OBUF_DISABLE ((u32)0x00000000) +#define CMP_SCALER_OBUF_ENABLE ((u32)0x00000200) + +#define IS_CMP_ScalerOutputBuf(x) ((x == CMP_SCALER_OBUF_DISABLE) || (x == CMP_SCALER_OBUF_ENABLE)) + + +/* Definitions of CMP Scaler Enable Bit */ +#define CMP_SCALER_DISABLE ((u32)0x00000000) +#define CMP_SCALER_ENABLE ((u32)0x00000100) + +#define IS_CMP_ScalerEnable(x) ((x == CMP_SCALER_DISABLE) || (x == CMP_SCALER_ENABLE)) + + +/* Definitions of CMP Sync Output Enable bit */ +#define CMP_ASYNC_OUTPUT ((u32)0x00000000) +#define CMP_SYNC_OUTPUT ((u32)0x00000080) + +#define IS_CMP_CoutSynchronized(x) ((x == CMP_ASYNC_OUTPUT) || (x == CMP_SYNC_OUTPUT)) + + +/* Definitions of CMP Output Polarity Selection */ +#define CMP_NONINV_OUTPUT ((u32)0x00000000) +#define CMP_INV_OUTPUT ((u32)0x00000040) + +#define IS_CMP_OutputPol_Set(x) ((x == CMP_NONINV_OUTPUT) || (x == CMP_INV_OUTPUT)) + + +/* Definitions of CMP Inverted Input Source Selection */ +#define CMP_EXTERNAL_CN_IN ((u32)0x00000000) +#define CMP_SCALER_CN_IN ((u32)0x00000010) + +#define IS_CMP_InvInputSelection(x) ((x == CMP_EXTERNAL_CN_IN) || (x == CMP_SCALER_CN_IN)) + + +/* Definitions of CMP Hysteresis Level Selection */ +#define CMP_NO_HYSTERESIS ((u32)0x00000000) +#define CMP_LOW_HYSTERESIS ((u32)0x00000004) +#define CMP_MID_HYSTERESIS ((u32)0x00000008) +#define CMP_HIGH_HYSTERESIS ((u32)0x0000000C) + +#define IS_CMP_Hysteresis_Set(x) ((x == CMP_NO_HYSTERESIS) || (x == CMP_LOW_HYSTERESIS) || (x == CMP_MID_HYSTERESIS) || \ + (x == CMP_HIGH_HYSTERESIS)) + +/* Definitions of CMP Speed Mode Selection */ +#define CMP_HIGH_SPEED ((u32)0x00000002) +#define CMP_LOW_SPEED ((u32)0x00000000) + +#define IS_CMP_Speed_Set(x) ((x == CMP_HIGH_SPEED) || (x == CMP_LOW_SPEED)) + + +/* Definitions of CMP Enable bit */ +#define CMP_ENABLE ((u32)0x00000001) + + +/* Definitions of CMP Output Edge Interrupt Enable bit */ +#define CMP_INT_RE ((u32)0x00000002) +#define CMP_INT_FE ((u32)0x00000001) + +/* Check the CMP Interrupt Parameter */ +#define IS_CMP_INT(x) ((x & 0xFFFFFF00) != 0x0) + + +/* Definitions of CMP Output Edge Detection Enable bit */ +#define CMP_RE_Detect ((u32)0x00000200) +#define CMP_FE_Detect ((u32)0x00000100) + +#define IS_CMP_EdgeDetect(x) ((x == CMP_RE_Detect) || (x == CMP_FE_Detect)) + + +/* Definitions of CMP Output Edge Flag */ +#define CMP_FLAG_RE ((u32)0x00000002) +#define CMP_FLAG_FE ((u32)0x00000001) + +/* Check the CMP flag Parameter */ +#define IS_CMP_FLAG(x) ((x & 0xFFFFFF00) != 0x0) + + +/* Check the CMPx Parameter */ +#define IS_CMP(x) ((x == HT_CMP0) || (x == HT_CMP1)) + + +/* Check the Scaler Value */ +#define IS_SCALER_VALUE(x) (x <= 0x3F) + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Functions CMP exported functions + * @{ + */ +void CMP_DeInit(HT_CMP_TypeDef* HT_CMPn); +void CMP_UnprotectConfig(HT_CMP_TypeDef* HT_CMPn); +void CMP_Init(HT_CMP_TypeDef* HT_CMPn, CMP_InitTypeDef* CMP_InitStruct); +void CMP_StructInit(CMP_InitTypeDef* CMP_InitStruct); +void CMP_Cmd(HT_CMP_TypeDef* HT_CMPn, ControlStatus NewState); +void CMP_IntConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_INT_x, ControlStatus NewState); +void CMP_EdgeDetectConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_xE_Detect, ControlStatus NewState); +FlagStatus CMP_GetFlagStatus(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x); +void CMP_ClearFlag(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x); +FlagStatus CMP_GetOutputStatus(HT_CMP_TypeDef* HT_CMPn); +void CMP_SetScalerValue(HT_CMP_TypeDef* HT_CMPn, u8 Scaler_Value); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp_op.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp_op.h new file mode 100644 index 0000000000..bcfb5d82ff --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_cmp_op.h @@ -0,0 +1,124 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_cmp_op.h + * @version $Rev:: 122 $ + * @date $Date:: 2017-06-13 #$ + * @brief The header file of the CMP_OP library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_CMP_OP_H +#define __HT32F1XXXX_CMP_OP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CMP_OP + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CMP_OP_Exported_Constants CMP_OP exported constants + * @{ + */ + +/* Definitions of CMP_OP modes */ +#define OP_MODE (0x00000000ul) +#define CMP_MODE (0x00000002ul) + +#define IS_CMP_OP_MODE(MODE) ((MODE == OP_MODE) || (MODE == CMP_MODE)) + +/* Definitions the cancelation reference input of CMP_OP */ +#define CMP_OP_NEGATIVE_INPUT (0x00000000ul) +#define CMP_OP_POSITIVE_INPUT (0x00000008ul) + +#define IS_CMP_OP_REF(REF) ((REF == CMP_OP_NEGATIVE_INPUT ) || (REF == CMP_OP_POSITIVE_INPUT)) + +/* Definitions of CMP_OP input offset */ +#define CMP_OP_IOVC_MIN (0x00000000ul) +#define CMP_OP_IOVC_CENTER (0x00000020ul) +#define CMP_OP_IOVC_MAX (0x0000003Ful) + +#define IS_CMP_OP_IOVC(IOVC) (IOVC <= 63 ) + +/* Definitions of CMP_OP interrupts */ +#define CMP_OP_INT_FALLING (0x00000001ul) +#define CMP_OP_INT_RISING (0x00000002ul) + +#define IS_CMP_OP_INT(CMP_OP_INT) (((CMP_OP_INT & 0xFFFFFFFC) == 0x0) && \ + (CMP_OP_INT != 0x0)) + +/* Definitions of CMP_OP interrupt flags */ +#define CMP_OP_FLAG_FALLING (0x00000001ul) +#define CMP_OP_FLAG_RISING (0x00000002ul) + +#define IS_CMP_OP_FLAG(FLAG) (((FLAG & 0xFFFFFFFC) == 0x0) && \ + (FLAG != 0x0)) + +/* check parameter of the CMP_OPx */ +#define IS_CMP_OP_ALL_PERIPH(PERIPH) ((PERIPH == HT_CMP_OP0) || (PERIPH == HT_CMP_OP1)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CMP_OP_Exported_Functions CMP_OP exported functions + * @{ + */ +void CMP_OP_DeInit(HT_CMP_OP_TypeDef* CMP_OPx); +void CMP_OP_Config(HT_CMP_OP_TypeDef* CMP_OPx, u32 mode, u32 cancellation); +void CMP_OP_Cmd(HT_CMP_OP_TypeDef* CMP_OPx, ControlStatus NewState); +void CMP_OP_CancellationModeConfig(HT_CMP_OP_TypeDef* CMP_OPx, u16 CMP_OP_REF_INPUT); +void CMP_OP_SetCancellationVaule(HT_CMP_OP_TypeDef* CMP_OPx, u32 cancellation); +u32 CMP_OP_GetCancellationVaule(HT_CMP_OP_TypeDef* CMP_OPx); +void CMP_OP_IntConfig(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_INT, ControlStatus NewState); +FlagStatus CMP_OP_GetIntStatus(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_INT); +FlagStatus CMP_OP_GetFlagStatus(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_FLAG); +void CMP_OP_ClearIntPendingBit(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_INT); +FlagStatus CMP_OP_GetOutputStatus(HT_CMP_OP_TypeDef* CMP_OPx); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_crc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_crc.h new file mode 100644 index 0000000000..0247ced9ca --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_crc.h @@ -0,0 +1,124 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_crc.h + * @version $Rev:: 2787 $ + * @date $Date:: 2022-11-23 #$ + * @brief The header file of the CRC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_CRC_H +#define __HT32F1XXXX_CRC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CRC + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Types CRC exported types + * @{ + */ + +/* Definition of CRC Init Structure */ +typedef enum +{ + CRC_CCITT_POLY = 0, + CRC_16_POLY = 1, + CRC_32_POLY = 2, + CRC_USER_DEFINE = 0xF +} CRC_Mode; + +typedef struct +{ + CRC_Mode Mode; + u32 uSeed; + u32 uCR; +} CRC_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Constants CRC exported constants + * @{ + */ +#define IS_CRC_POLY(POLY) ((POLY == CRC_CCITT_POLY) || \ + (POLY == CRC_16_POLY) || \ + (POLY == CRC_32_POLY) || \ + (POLY == CRC_USER_DEFINE)) + +#define CRC_NORMAL_WR (0) +#define CRC_BIT_RVS_WR (1UL << 2) +#define CRC_BYTE_RVS_WR (1UL << 3) +#define CRC_CMPL_WR (1UL << 4) + +#define CRC_NORMAL_SUM (0) +#define CRC_BIT_RVS_SUM (1UL << 5) +#define CRC_BYTE_RVS_SUM (1UL << 6) +#define CRC_CMPL_SUM (1UL << 7) + +#define IS_CRC_MOD(MOD) ((MOD & 0xFFFFFF00) == 0) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Functions CRC exported functions + * @{ + */ +void CRC_DeInit(HT_CRC_TypeDef* HT_CRCn); +void CRC_Init(HT_CRC_TypeDef* HT_CRCn, CRC_InitTypeDef* CRC_InitStruct); +u32 CRC_Process(HT_CRC_TypeDef* HT_CRCn, u8 *buffer, u32 length); + +u16 CRC_CCITT(u16 seed, u8 *buffer, u32 length); +u16 CRC_16(u16 seed, u8 *buffer, u32 length); +u32 CRC_32(u32 seed, u8 *buffer, u32 length); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ebi.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ebi.h new file mode 100644 index 0000000000..b09ba30b77 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_ebi.h @@ -0,0 +1,289 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_ebi.h + * @version $Rev:: 2788 $ + * @date $Date:: 2022-11-24 #$ + * @brief The header file of the EBI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_EBI_H +#define __HT32F1XXXX_EBI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup EBI + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Types EBI exported types + * @{ + */ +typedef struct +{ + u32 EBI_Bank; + u32 EBI_Mode; + #if (LIBCFG_EBI_BYTELAND_ASYNCREADY) + u32 EBI_ByteLane; + u32 EBI_AsynchronousReady; + u32 EBI_ARDYTimeOut; + u32 EBI_ByteLanePolarity; + u32 EBI_ReadySignalPolarity; + #endif + u32 EBI_IdleCycle; + u32 EBI_ChipSelectPolarity; + u32 EBI_AddressLatchPolarity; + u32 EBI_WriteEnablePolarity; + u32 EBI_ReadEnablePolarity; + u32 EBI_IdleCycleTime; + u32 EBI_AddressSetupTime; + u32 EBI_AddressHoldTime; + u32 EBI_WriteSetupTime; + u32 EBI_WriteStrobeTime; + u32 EBI_WriteHoldTime; + u32 EBI_ReadSetupTime; + u32 EBI_ReadStrobeTime; + u32 EBI_ReadHoldTime; + #if !(LIBCFG_EBI_V01) + u32 EBI_PageMode; + u32 EBI_PageLength; + u32 EBI_PageHitMode; + u32 EBI_PageAccessTime; + u32 EBI_PageOpenTime; + #endif +} EBI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Constants EBI exported constants + * @{ + */ +#define EBI_BANK_0 ((u32)0x00000000) +#define EBI_BANK_1 ((u32)0x00000001) +#define EBI_BANK_2 ((u32)0x00000002) +#define EBI_BANK_3 ((u32)0x00000003) + +#define IS_EBI_BANK(BANK) ((BANK == EBI_BANK_0) || \ + (BANK == EBI_BANK_1) || \ + (BANK == EBI_BANK_2) || \ + (BANK == EBI_BANK_3)) + + +#define EBI_MODE_D8A8 ((u32)0x00000000) +#define EBI_MODE_D16A16ALE ((u32)0x00000001) +#define EBI_MODE_D8A24ALE ((u32)0x00000002) +#define EBI_MODE_D16 ((u32)0x00000003) + +#define IS_EBI_MODE(MODE) ((MODE == EBI_MODE_D8A8) || \ + (MODE == EBI_MODE_D16A16ALE) || \ + (MODE == EBI_MODE_D8A24ALE) || \ + (MODE == EBI_MODE_D16)) + + +#if (LIBCFG_EBI_BYTELAND_ASYNCREADY) +#define EBI_BYTELANE_ENABLE ((u32)0x01000000) +#define EBI_BYTELANE_DISABLE ((u32)0x00000000) + +#define IS_EBI_BYTELANE(BYTELANE) ((BYTELANE == EBI_BYTELANE_ENABLE) || \ + (BYTELANE == EBI_BYTELANE_DISABLE)) +#endif + + +#define EBI_IDLECYCLE_ENABLE ((u32)0x00000000) +#define EBI_IDLECYCLE_DISABLE ((u32)0x00001000) + +#define IS_EBI_IDLECYCLE(IDLECYCLE) ((IDLECYCLE == EBI_IDLECYCLE_ENABLE) || \ + (IDLECYCLE == EBI_IDLECYCLE_DISABLE)) + + +#if (LIBCFG_EBI_BYTELAND_ASYNCREADY) +#define EBI_ASYNCHRONOUSREADY_ENABLE ((u32)0x00010000) +#define EBI_ASYNCHRONOUSREADY_DISABLE ((u32)0x00000000) + +#define IS_EBI_ARDY(ARDY) ((ARDY == EBI_ASYNCHRONOUSREADY_ENABLE) || \ + (ARDY == EBI_ASYNCHRONOUSREADY_DISABLE)) + + +#define EBI_ARDYTIMEOUT_ENABLE ((u32)0x00000000) +#define EBI_ARDYTIMEOUT_DISABLE ((u32)0x00020000) + +#define IS_EBI_ARDY_TIMEOUT(TIMEOUT) ((TIMEOUT == EBI_ARDYTIMEOUT_ENABLE) || \ + (TIMEOUT == EBI_ARDYTIMEOUT_DISABLE)) +#endif + + +#define EBI_CHIPSELECTPOLARITY_LOW ((u32)0x00000000) +#define EBI_CHIPSELECTPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_CS_POLARITY(POLARITY) ((POLARITY == EBI_CHIPSELECTPOLARITY_LOW) || \ + (POLARITY == EBI_CHIPSELECTPOLARITY_HIGH)) + + +#define EBI_ADDRESSLATCHPOLARITY_LOW ((u32)0x00000000) +#define EBI_ADDRESSLATCHPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_ALE_POLARITY(POLARITY) ((POLARITY == EBI_ADDRESSLATCHPOLARITY_LOW) || \ + (POLARITY == EBI_ADDRESSLATCHPOLARITY_HIGH)) + + +#define EBI_WRITEENABLEPOLARITY_LOW ((u32)0x00000000) +#define EBI_WRITEENABLEPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_WE_POLARITY(POLARITY) ((POLARITY == EBI_WRITEENABLEPOLARITY_LOW) || \ + (POLARITY == EBI_WRITEENABLEPOLARITY_HIGH)) + + +#define EBI_READENABLEPOLARITY_LOW ((u32)0x00000000) +#define EBI_READENABLEPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_RE_POLARITY(POLARITY) ((POLARITY == EBI_READENABLEPOLARITY_LOW) || \ + (POLARITY == EBI_READENABLEPOLARITY_HIGH)) + + +#if (LIBCFG_EBI_BYTELAND_ASYNCREADY) +#define EBI_BYTELANEPOLARITY_LOW ((u32)0x00000000) +#define EBI_BYTELANEPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_BL_POLARITY(POLARITY) ((POLARITY == EBI_BYTELANEPOLARITY_LOW) || \ + (POLARITY == EBI_BYTELANEPOLARITY_HIGH)) + + +#define EBI_READYSIGNALPOLARITY_LOW ((u32)0x00000000) +#define EBI_READYSIGNALPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_ARDY_POLARITY(POLARITY) ((POLARITY == EBI_READYSIGNALPOLARITY_LOW) || \ + (POLARITY == EBI_READYSIGNALPOLARITY_HIGH)) +#endif + +#if !(LIBCFG_EBI_V01) +#define EBI_PAGEMODE_ENABLE ((u32)0x01000000) +#define EBI_PAGEMODE_DISABLE ((u32)0x00000000) + +#define IS_EBI_PAGE_MODE(MODE) ((MODE == EBI_PAGEMODE_ENABLE) || \ + (MODE == EBI_PAGEMODE_DISABLE)) + + +#define EBI_PAGELENGTH_4 ((u32)0x00000000) +#define EBI_PAGELENGTH_8 ((u32)0x00000001) +#define EBI_PAGELENGTH_16 ((u32)0x00000002) +#define EBI_PAGELENGTH_32 ((u32)0x00000003) + +#define IS_EBI_PAGE_LENGTH(LENGTH) ((LENGTH == EBI_PAGELENGTH_4) || \ + (LENGTH == EBI_PAGELENGTH_8) || \ + (LENGTH == EBI_PAGELENGTH_16) || \ + (LENGTH == EBI_PAGELENGTH_32)) + + +#define EBI_PAGEHITMODE_ADDINC ((u32)0x00000010) +#define EBI_PAGEHITMODE_INTRPAGE ((u32)0x00000000) + +#define IS_EBI_PAGE_HIT_MODE(MODE) ((MODE == EBI_PAGEHITMODE_ADDINC) || \ + (MODE == EBI_PAGEHITMODE_INTRPAGE)) +#endif + + +#if !(LIBCFG_EBI_V01) +#if (LIBCFG_EBI_BYTELAND_ASYNCREADY) +#define EBI_INT_TOUT ((u32)0x00000001) +#endif +#define EBI_INT_ACCDIS ((u32)0x00000002) +#define EBI_INT_ACCERR ((u32)0x00000002) +#define EBI_INT_ACCRES ((u32)0x00000004) +#define EBI_INT_ALL ((u32)0x00000007) + +#define IS_EBI_INT(INT) (((INT & 0xFFFFFFF8) == 0x0) && (INT != 0x0)) + +#define IS_EBI_INT_FLAG(FLAG) (((FLAG & 0xFFFFFFFC) == 0x0) && (FLAG != 0x0)) +#endif + + +#define IS_EBI_IDLE_CYCLE_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_ADDRESS_SETUP_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_ADDRESS_HOLD_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_WRITE_SETUP_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_WRITE_STROBE_TIME(TIME) (TIME < 0x40) + +#define IS_EBI_WRITE_HOLD_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_READ_SETUP_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_READ_STROBE_TIME(TIME) (TIME < 0x40) + +#define IS_EBI_READ_HOLD_TIME(TIME) (TIME < 0x10) + +#if !(LIBCFG_EBI_V01) +#define IS_EBI_PAGE_ACCESS_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_PAGE_OPEN_TIME(TIME) (TIME < 0x100) +#endif +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Functions EBI exported functions + * @{ + */ +void EBI_DeInit(void); +void EBI_Init(EBI_InitTypeDef* EBI_InitStruct); +void EBI_StructInit(EBI_InitTypeDef* EBI_InitStruct); +void EBI_Cmd(u32 EBI_Bank, ControlStatus NewState); +void EBI_IntConfig(u32 EBI_Int, ControlStatus NewState); +FlagStatus EBI_GetIntStatus(u32 EBI_Int); +void EBI_ClearIntFlag(u32 EBI_Int); +FlagStatus EBI_GetBusyStatus(void); +FlagStatus EBI_GetARDYStatus(void); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_exti.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_exti.h new file mode 100644 index 0000000000..ad34ac56bc --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_exti.h @@ -0,0 +1,208 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_exti.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the EXTI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_EXTI_H +#define __HT32F1XXXX_EXTI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup EXTI + * @{ + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Macro EXTI exported macros + * @{ + */ +/*********************************************************************************************************//** + * @brief Convert the pin number of GPIO to the channel of EXTI. + * @param n: can be 0, 1 to 15 to select the pin number of GPIO. + ************************************************************************************************************/ +#define GPIO2EXTI(n) (n) +#define EXTI_GetIRQn(ch) gEXTIn_IRQn[ch] +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Types EXTI exported types + * @{ + */ + +/* Definitions of EXTI interrupt line */ +typedef enum +{ + EXTI_CHANNEL_0 = 0, + EXTI_CHANNEL_1, + EXTI_CHANNEL_2, + EXTI_CHANNEL_3, + EXTI_CHANNEL_4, + EXTI_CHANNEL_5, + EXTI_CHANNEL_6, + EXTI_CHANNEL_7, + EXTI_CHANNEL_8, + EXTI_CHANNEL_9, + EXTI_CHANNEL_10, + EXTI_CHANNEL_11, + EXTI_CHANNEL_12, + EXTI_CHANNEL_13, + EXTI_CHANNEL_14, + EXTI_CHANNEL_15, +} EXTI_Channel_TypeDef; + +#define IS_EXTI_CHANNEL(CHANNEL) ((CHANNEL == EXTI_CHANNEL_0) || \ + (CHANNEL == EXTI_CHANNEL_1) || \ + (CHANNEL == EXTI_CHANNEL_2) || \ + (CHANNEL == EXTI_CHANNEL_3) || \ + (CHANNEL == EXTI_CHANNEL_4) || \ + (CHANNEL == EXTI_CHANNEL_5) || \ + (CHANNEL == EXTI_CHANNEL_6) || \ + (CHANNEL == EXTI_CHANNEL_7) || \ + (CHANNEL == EXTI_CHANNEL_8) || \ + (CHANNEL == EXTI_CHANNEL_9) || \ + (CHANNEL == EXTI_CHANNEL_10) || \ + (CHANNEL == EXTI_CHANNEL_11) || \ + (CHANNEL == EXTI_CHANNEL_12) || \ + (CHANNEL == EXTI_CHANNEL_13) || \ + (CHANNEL == EXTI_CHANNEL_14) || \ + (CHANNEL == EXTI_CHANNEL_15)) + +/* Definitions of EXTI init structure */ +typedef enum +{ + EXTI_LOW_LEVEL = 0x0, + EXTI_HIGH_LEVEL = 0x1, + EXTI_NEGATIVE_EDGE = 0x2, + EXTI_POSITIVE_EDGE = 0x3, + EXTI_BOTH_EDGE = 0x4 +} EXTI_Interrupt_TypeDef; + +#define IS_EXTI_INT_TYPE(TYPE) ((TYPE == EXTI_LOW_LEVEL) || \ + (TYPE == EXTI_HIGH_LEVEL) || \ + (TYPE == EXTI_NEGATIVE_EDGE) || \ + (TYPE == EXTI_POSITIVE_EDGE) || \ + (TYPE == EXTI_BOTH_EDGE)) + +typedef enum +{ + EXTI_DEBOUNCE_DISABLE = 0x0, + EXTI_DEBOUNCE_ENABLE = 0x1 +} EXTI_Deb_TypeDef; + +#define IS_EXTI_DEBOUNCE_TYPE(TYPE) ((TYPE == EXTI_DEBOUNCE_DISABLE) || \ + (TYPE == EXTI_DEBOUNCE_ENABLE)) + +typedef struct +{ + u32 EXTI_Channel; + EXTI_Deb_TypeDef EXTI_Debounce; + #if (LIBCFG_EXTI_8BIT_DEBOUNCE_COUNTER) + u8 EXTI_DebounceCnt; + #else + u16 EXTI_DebounceCnt; + #endif + EXTI_Interrupt_TypeDef EXTI_IntType; +} EXTI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Constants EXTI exported constants + * @{ + */ + +/* Definitions of EXTI wake up polarity */ +#define EXTI_WAKEUP_HIGH_LEVEL ((u8)0x0) +#define EXTI_WAKEUP_LOW_LEVEL ((u8)0x1) + +#define IS_EXTI_WAKEUP_TYPE(TYPE) ((TYPE == EXTI_WAKEUP_HIGH_LEVEL) || \ + (TYPE == EXTI_WAKEUP_LOW_LEVEL)) + + +#define EXTI_EDGE_POSITIVE ((u8)0x0) +#define EXTI_EDGE_NEGATIVE ((u8)0x1) + +#define IS_EXTI_EDGE(EDGE) ((EDGE == EXTI_EDGE_POSITIVE) || \ + (EDGE == EXTI_EDGE_NEGATIVE)) + +#if (LIBCFG_EXTI_8BIT_DEBOUNCE_COUNTER) +#define IS_EXTI_DEBOUNCE_SIZE(SIZE) (SIZE <= 0xFF) +#else +#define IS_EXTI_DEBOUNCE_SIZE(SIZE) (SIZE <= 0xFFFF) +#endif + +extern const IRQn_Type gEXTIn_IRQn[16]; + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Functions EXTI exported functions + * @{ + */ +void EXTI_DeInit(u32 EXTI_Channel); +void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); +void EXTI_IntConfig(u32 EXTI_Channel, ControlStatus NewState); +void EXTI_WakeupEventConfig(u32 EXTI_Channel, u8 EXTI_WakeUpType, ControlStatus NewState); +void EXTI_WakeupEventIntConfig(ControlStatus NewState); +void EXTI_ClearEdgeFlag(u32 EXTI_Channel); +void EXTI_ClearWakeupFlag(u32 EXTI_Channel); +FlagStatus EXTI_GetEdgeFlag(u32 EXTI_Channel); +FlagStatus EXTI_GetEdgeStatus(u32 EXTI_Channel, u32 EXTI_Edge); +FlagStatus EXTI_GetWakeupFlagStatus(u32 EXTI_Channel); +void EXTI_SWIntCmd(u32 EXTI_Channel, ControlStatus NewState); +FlagStatus EXTI_GetSWCmdStatus(u32 EXTI_Channel); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_flash.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_flash.h new file mode 100644 index 0000000000..cb194268c0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_flash.h @@ -0,0 +1,191 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_flash.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the FLASH library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_FLASH_H +#define __HT32F1XXXX_FLASH_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup FLASH + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Types FLASH exported types + * @{ + */ + +/** + * @brief Enumeration of FLASH return status. + */ +typedef enum +{ + FLASH_COMPLETE = 0, + FLASH_ERR_ADDR_OUT_OF_RANGE, + FLASH_ERR_WRITE_PROTECTED, + FLASH_TIME_OUT +} FLASH_State; + +/** + * @brief Enumeration of FLASH boot mode. + */ +typedef enum +{ + FLASH_BOOT_SRAM = 0, + FLASH_BOOT_LOADER = 1, + FLASH_BOOT_MAIN = 2 +} FLASH_Vector; + +typedef struct +{ + u32 WriteProtect[4]; + u32 MainSecurity; + u32 OptionProtect; +} FLASH_OptionByte; + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Constants FLASH exported constants + * @{ + */ + +/* Flash Information */ +#define FLASH_PAGE_SIZE (LIBCFG_FLASH_PAGESIZE) /* Flash page size */ + +/* Flash Wait State */ +#define FLASH_WAITSTATE_0 (0x00000001) /* FLASH zero wait state */ +#define FLASH_WAITSTATE_1 (0x00000002) /* FLASH one wait state */ +#define FLASH_WAITSTATE_2 (0x00000003) /* FLASH two wait state */ +#if (LIBCFG_FMC_WAIT_STATE_3) +#define FLASH_WAITSTATE_3 (0x00000004) /* FLASH three wait state */ +#endif + +#if (LIBCFG_FMC_WAIT_STATE_3) +#define FLASH_WAITSTATE_MAX (FLASH_WAITSTATE_3) +#else +#define FLASH_WAITSTATE_MAX (FLASH_WAITSTATE_2) +#endif + +/* FLASH OISR Flags */ +#define FLASH_FLAG_ORFF (0x00000001) /* Operation Finished Flag */ +#define FLASH_FLAG_ITADF (0x00000002) /* Invalid Target Address Flag */ +#define FLASH_FLAG_OBEF (0x00000004) /* Option Byte Check Sum Error Flag */ +#define FLASH_FLAG_IOCMF (0x00000008) /* Invalid Operation Command Flag */ +#define FLASH_FLAG_OREF (0x00000010) /* Operation Error Flag */ +#define FLASH_FLAG_RORFF (0x00010000) /* Raw Operation Finished Flag */ +#define FLASH_FLAG_PPEF (0x00020000) /* Page Erase/Program Protected Error Flag */ + +/* FLASH OIER */ +#define FLASH_INT_ORFIEN (0x00000001) /* Flash Operation Finished Interrupt Enable */ +#define FLASH_INT_ITADIEN (0x00000002) /* Invalid Target Address Interrupt Enable */ +#define FLASH_INT_OBEIEN (0x00000004) /* Option Byte Checksum Error Interrupt Enable */ +#define FLASH_INT_IOCMIEN (0x00000008) /* Invalid Operation Command Interrupt Enable */ +#define FLASH_INT_OREIEN (0x00000010) /* Operation Error Interrupt Enable */ +#define FLASH_INT_ALL (0x0000001F) /* Flash all Interrupt Enable */ + +/* Option Bytes Address */ +#define OPTION_BYTE_BASE (0x1FF00000) /* Option Byte Base Address */ +#define OB_PP0 (0x1FF00000) /* Option Byte: Write Protection 0 */ +#define OB_PP1 (0x1FF00004) /* Option Byte: Write Protection 1 */ +#define OB_PP2 (0x1FF00008) /* Option Byte: Write Protection 2 */ +#define OB_PP3 (0x1FF0000C) /* Option Byte: Write Protection 3 */ +#define OB_CP (0x1FF00010) /* Option Byte: Security Protection */ +#define OB_CHECKSUM (0x1FF00020) /* Option Byte: Checksum */ + +/* Flash Write Protection Page Mask */ +#if (LIBCFG_FLASH_2PAGE_PER_WPBIT) + #define FLASH_WP_PAGE_SET(OP, PAGE) (OP.WriteProtect[PAGE / 64] |= 1 << ((PAGE % 64) / 2)) + #define FLASH_WP_PAGE_CLEAR(OP, PAGE) (OP.WriteProtect[PAGE / 64] &= ~(1 << ((PAGE % 64) / 2))) + #define FLASH_IS_WP_PAGE(OP, PAGE) (OP.WriteProtect[PAGE / 64] & (1 << ((PAGE % 64) / 2))) +#else + #define FLASH_WP_PAGE_SET(OP, PAGE) (OP.WriteProtect[PAGE / 32] |= 1 << (PAGE % 32)) + #define FLASH_WP_PAGE_CLEAR(OP, PAGE) (OP.WriteProtect[PAGE / 32] &= ~(1 << (PAGE % 32))) + #define FLASH_IS_WP_PAGE(OP, PAGE) (OP.WriteProtect[PAGE / 32] & (1 << (PAGE % 32))) +#endif +#define FLASH_WP_ALLPAGE_SET(OP) {u32 i; for (i = 0; i < 4; i++) { OP.WriteProtect[i] = 0xFFFFFFFF; } } + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Functions FLASH exported functions + * @{ + */ +void FLASH_SetWaitState(u32 FLASH_WAITSTATE_n); +void FLASH_PrefetchBufferCmd(ControlStatus NewState); +void FLASH_DcodeCacheCmd(ControlStatus NewState); +void FLASH_BranchCacheCmd(ControlStatus NewState); +#if (LIBCFG_FLASH_HALFCYCYLE) +ErrStatus FLASH_FlashHalfCycleCmd(ControlStatus NewState); +#endif +#if (LIBCFG_FLASH_ZWPWESAVING) +ErrStatus FLASH_FlashZwPwrSavingCmd(ControlStatus NewState); +#endif +void FLASH_SetRemappingMode(FLASH_Vector RemapMode); +FLASH_State FLASH_ErasePage(u32 PageAddress); +FLASH_State FLASH_EraseOptionByte(void); +FLASH_State FLASH_MassErase(void); +FLASH_State FLASH_ProgramWordData(u32 Address, u32 Data); +FLASH_State FLASH_ProgramOptionByte(FLASH_OptionByte *Option); +void FLASH_GetOptionByteStatus(FLASH_OptionByte *Option); +void FLASH_IntConfig(u32 FLASH_INT, ControlStatus Cmd); +FlagStatus FLASH_GetIntStatus(u32 FLASH_FLAG_x); +void FLASH_ClearIntFlag(u32 FLASH_FLAG_x); +FLASH_State FLASH_WaitForOperationEnd(void); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_gpio.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_gpio.h new file mode 100644 index 0000000000..30e360baf5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_gpio.h @@ -0,0 +1,426 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_gpio.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the GPIO and AFIO library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_GPIO_H +#define __HT32F1XXXX_GPIO_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup GPIO + * @{ + */ + + +/* Settings ------------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Settings GPIO settings + * @{ + */ +#ifndef AUTO_CK_CONTROL +#define AUTO_CK_CONTROL (0) +#endif +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Types GPIO exported types + * @{ + */ + +/** + * @brief Enumeration of GPIO pull resistor. + */ +typedef enum +{ + GPIO_PR_UP = 0, /*!< weak pull-up resistor */ + GPIO_PR_DOWN, /*!< weak pull-down resistor */ + GPIO_PR_DISABLE /*!< Tri-state */ +} GPIO_PR_Enum; +/** + * @brief Enumeration of GPIO output drive current. + */ +typedef enum +{ + GPIO_DV_4MA = 0, /*!< 4mA source/sink current */ + GPIO_DV_8MA, /*!< 8mA source/sink current */ + #if (LIBCFG_GPIO_DV_4_8MA_ONLY) + #else + GPIO_DV_12MA, /*!< 12mA source/sink current */ + GPIO_DV_16MA /*!< 16mA source/sink current */ + #endif +} GPIO_DV_Enum; +/** + * @brief Enumeration of GPIO direction. + */ +typedef enum +{ + GPIO_DIR_IN = 0, /*!< input mode */ + GPIO_DIR_OUT /*!< output mode */ +} GPIO_DIR_Enum; +/** + * @brief Enumeration of GPIO port source for EXTI channel. + */ +typedef enum +{ + AFIO_ESS_PA = 0, /*!< EXTI channel x source come from GPIO Port A */ + AFIO_ESS_PB = 1, /*!< EXTI channel x source come from GPIO Port B */ + AFIO_ESS_PC = 2, /*!< EXTI channel x source come from GPIO Port C */ + AFIO_ESS_PD = 3, /*!< EXTI channel x source come from GPIO Port D */ +#if (LIBCFG_GPIOE) + AFIO_ESS_PE = 4, /*!< EXTI channel x source come from GPIO Port E */ +#endif +#if (LIBCFG_GPIOF) + AFIO_ESS_PF = 5 /*!< EXTI channel x source come from GPIO Port F */ +#endif +} AFIO_ESS_Enum; +/** + * @brief Enumeration of AFIO for EXTI channel. + */ +typedef enum +{ + AFIO_EXTI_CH_0 = 0, /*!< GPIO pin 0 */ + AFIO_EXTI_CH_1, /*!< GPIO pin 1 */ + AFIO_EXTI_CH_2, /*!< GPIO pin 2 */ + AFIO_EXTI_CH_3, /*!< GPIO pin 3 */ + AFIO_EXTI_CH_4, /*!< GPIO pin 4 */ + AFIO_EXTI_CH_5, /*!< GPIO pin 5 */ + AFIO_EXTI_CH_6, /*!< GPIO pin 6 */ + AFIO_EXTI_CH_7, /*!< GPIO pin 7 */ + AFIO_EXTI_CH_8, /*!< GPIO pin 8 */ + AFIO_EXTI_CH_9, /*!< GPIO pin 9 */ + AFIO_EXTI_CH_10, /*!< GPIO pin 10 */ + AFIO_EXTI_CH_11, /*!< GPIO pin 11 */ + AFIO_EXTI_CH_12, /*!< GPIO pin 12 */ + AFIO_EXTI_CH_13, /*!< GPIO pin 13 */ + AFIO_EXTI_CH_14, /*!< GPIO pin 14 */ + AFIO_EXTI_CH_15 /*!< GPIO pin 15 */ +} AFIO_EXTI_CH_Enum; +/** + * @brief Enumeration of AFIO_MODE. + */ +typedef enum +{ + AFIO_MODE_DEFAULT = 0, /*!< Default AFIO mode */ + AFIO_MODE_1, /*!< AFIO mode 1 */ + AFIO_MODE_2, /*!< AFIO mode 2 */ + AFIO_MODE_3, /*!< AFIO mode 3 */ + AFIO_MODE_4, /*!< AFIO mode 4 */ + AFIO_MODE_5, /*!< AFIO mode 5 */ + AFIO_MODE_6, /*!< AFIO mode 6 */ + AFIO_MODE_7, /*!< AFIO mode 7 */ + AFIO_MODE_8, /*!< AFIO mode 8 */ + AFIO_MODE_9, /*!< AFIO mode 9 */ + AFIO_MODE_10, /*!< AFIO mode 10 */ + AFIO_MODE_11, /*!< AFIO mode 11 */ + AFIO_MODE_12, /*!< AFIO mode 12 */ + AFIO_MODE_13, /*!< AFIO mode 13 */ + AFIO_MODE_14, /*!< AFIO mode 14 */ + AFIO_MODE_15 /*!< AFIO mode 15 */ +} AFIO_MODE_Enum; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Constants GPIO exported constants + * @{ + */ + +/* Definitions of AFIO_FUN */ +#define AFIO_FUN_DEFAULT AFIO_MODE_DEFAULT /*!< Default AFIO mode */ +#define AFIO_FUN_GPIO AFIO_MODE_1 /*!< AFIO mode GPIO */ +#define AFIO_FUN_ADC0 AFIO_MODE_2 /*!< AFIO mode ADC0 */ +#define AFIO_FUN_CMP AFIO_MODE_3 /*!< AFIO mode CMP */ +#define AFIO_FUN_MCTM_GPTM AFIO_MODE_4 /*!< AFIO mode MCTM/GPTM */ +#define AFIO_FUN_SPI AFIO_MODE_5 /*!< AFIO mode SPI */ +#define AFIO_FUN_USART_UART AFIO_MODE_6 /*!< AFIO mode USART/UART */ +#define AFIO_FUN_I2C AFIO_MODE_7 /*!< AFIO mode I2C */ +#define AFIO_FUN_SCI AFIO_MODE_8 /*!< AFIO mode SCI */ +#define AFIO_FUN_EBI AFIO_MODE_9 /*!< AFIO mode EBI */ +#define AFIO_FUN_I2S AFIO_MODE_10 /*!< AFIO mode I2S */ +#define AFIO_FUN_SDIO AFIO_MODE_11 /*!< AFIO mode SDIO */ +#define AFIO_FUN_CSIF AFIO_MODE_12 /*!< AFIO mode CSIF */ +#define AFIO_FUN_SCTM AFIO_MODE_13 /*!< AFIO mode SCTM */ +#define AFIO_FUN_PWM AFIO_MODE_13 /*!< AFIO mode PWM */ +#define AFIO_FUN_SYSTEM AFIO_MODE_15 /*!< AFIO mode System */ + +/* Definitions of AFIO_FUN alias */ +#define AFIO_FUN_MCTM0 AFIO_FUN_MCTM_GPTM +#define AFIO_FUN_MCTM1 AFIO_FUN_MCTM_GPTM + +#define AFIO_FUN_GPTM0 AFIO_FUN_MCTM_GPTM +#define AFIO_FUN_GPTM1 AFIO_FUN_MCTM_GPTM +#define AFIO_FUN_GPTM2 AFIO_FUN_MCTM_GPTM +#define AFIO_FUN_GPTM3 AFIO_FUN_MCTM_GPTM + +#define AFIO_FUN_PWM0 AFIO_FUN_PWM +#define AFIO_FUN_PWM1 AFIO_FUN_PWM +#define AFIO_FUN_PWM2 AFIO_FUN_PWM +#define AFIO_FUN_PWM3 AFIO_FUN_PWM + +#define AFIO_FUN_SCTM0 AFIO_FUN_SCTM +#define AFIO_FUN_SCTM1 AFIO_FUN_SCTM + +#define AFIO_FUN_ADC AFIO_FUN_ADC0 +#define AFIO_FUN_PWM_SCTM AFIO_MODE_13 + +/* Definitions of GPIO_Px */ +#define GPIO_PORT_NUM (6) +#define GPIO_PIN_NUM (16) +#define GPIO_PA (0) +#define GPIO_PB (1) +#define GPIO_PC (2) +#define GPIO_PD (3) +#if (LIBCFG_GPIOE) +#define GPIO_PE (4) +#endif +#if (LIBCFG_GPIOF) +#define GPIO_PF (5) +#endif + +/* Definitions of GPIO port source for EXTI channel */ +#define AFIO_ESS_PA GPIO_PA /*!< EXTI channel x source come from GPIO Port A */ +#define AFIO_ESS_PB GPIO_PB /*!< EXTI channel x source come from GPIO Port B */ +#define AFIO_ESS_PC GPIO_PC /*!< EXTI channel x source come from GPIO Port C */ +#define AFIO_ESS_PD GPIO_PD /*!< EXTI channel x source come from GPIO Port D */ +#if (LIBCFG_GPIOE) +#define AFIO_ESS_PE GPIO_PE /*!< EXTI channel x source come from GPIO Port E */ +#endif +#if (LIBCFG_GPIOF) +#define AFIO_ESS_PF GPIO_PF /*!< EXTI channel x source come from GPIO Port F */ +#endif + +/* Definitions of GPIO_PIN */ +#define GPIO_PIN_0 0x0001 /*!< GPIO pin 0 selected */ +#define GPIO_PIN_1 0x0002 /*!< GPIO pin 1 selected */ +#define GPIO_PIN_2 0x0004 /*!< GPIO pin 2 selected */ +#define GPIO_PIN_3 0x0008 /*!< GPIO pin 3 selected */ +#define GPIO_PIN_4 0x0010 /*!< GPIO pin 4 selected */ +#define GPIO_PIN_5 0x0020 /*!< GPIO pin 5 selected */ +#define GPIO_PIN_6 0x0040 /*!< GPIO pin 6 selected */ +#define GPIO_PIN_7 0x0080 /*!< GPIO pin 7 selected */ +#define GPIO_PIN_8 0x0100 /*!< GPIO pin 8 selected */ +#define GPIO_PIN_9 0x0200 /*!< GPIO pin 9 selected */ +#define GPIO_PIN_10 0x0400 /*!< GPIO pin 10 selected */ +#define GPIO_PIN_11 0x0800 /*!< GPIO pin 11 selected */ +#define GPIO_PIN_12 0x1000 /*!< GPIO pin 12 selected */ +#define GPIO_PIN_13 0x2000 /*!< GPIO pin 13 selected */ +#define GPIO_PIN_14 0x4000 /*!< GPIO pin 14 selected */ +#define GPIO_PIN_15 0x8000 /*!< GPIO pin 15 selected */ +#define GPIO_PIN_ALL 0xFFFF /*!< GPIO all pins selected */ + +/* Definitions of AFIO_PIN */ +#define AFIO_PIN_0 0x0001 /*!< AFIO pin 0 selected */ +#define AFIO_PIN_1 0x0002 /*!< AFIO pin 1 selected */ +#define AFIO_PIN_2 0x0004 /*!< AFIO pin 2 selected */ +#define AFIO_PIN_3 0x0008 /*!< AFIO pin 3 selected */ +#define AFIO_PIN_4 0x0010 /*!< AFIO pin 4 selected */ +#define AFIO_PIN_5 0x0020 /*!< AFIO pin 5 selected */ +#define AFIO_PIN_6 0x0040 /*!< AFIO pin 6 selected */ +#define AFIO_PIN_7 0x0080 /*!< AFIO pin 7 selected */ +#define AFIO_PIN_8 0x0100 /*!< AFIO pin 8 selected */ +#define AFIO_PIN_9 0x0200 /*!< AFIO pin 9 selected */ +#define AFIO_PIN_10 0x0400 /*!< AFIO pin 10 selected */ +#define AFIO_PIN_11 0x0800 /*!< AFIO pin 11 selected */ +#define AFIO_PIN_12 0x1000 /*!< AFIO pin 12 selected */ +#define AFIO_PIN_13 0x2000 /*!< AFIO pin 13 selected */ +#define AFIO_PIN_14 0x4000 /*!< AFIO pin 14 selected */ +#define AFIO_PIN_15 0x8000 /*!< AFIO pin 15 selected */ +#define AFIO_PIN_ALL 0xFFFF /*!< All AFIO pins selected */ + +/* Definitions of GPIO_PIN_NUM */ +#define GPIO_PIN_NUM_0 0x00 /*!< GPIO pin number 0 selected */ +#define GPIO_PIN_NUM_1 0x01 /*!< GPIO pin number 1 selected */ +#define GPIO_PIN_NUM_2 0x02 /*!< GPIO pin number 2 selected */ +#define GPIO_PIN_NUM_3 0x03 /*!< GPIO pin number 3 selected */ +#define GPIO_PIN_NUM_4 0x04 /*!< GPIO pin number 4 selected */ +#define GPIO_PIN_NUM_5 0x05 /*!< GPIO pin number 5 selected */ +#define GPIO_PIN_NUM_6 0x06 /*!< GPIO pin number 6 selected */ +#define GPIO_PIN_NUM_7 0x07 /*!< GPIO pin number 7 selected */ +#define GPIO_PIN_NUM_8 0x08 /*!< GPIO pin number 8 selected */ +#define GPIO_PIN_NUM_9 0x09 /*!< GPIO pin number 9 selected */ +#define GPIO_PIN_NUM_10 0x0A /*!< GPIO pin number 10 selected */ +#define GPIO_PIN_NUM_11 0x0B /*!< GPIO pin number 11 selected */ +#define GPIO_PIN_NUM_12 0x0C /*!< GPIO pin number 12 selected */ +#define GPIO_PIN_NUM_13 0x0D /*!< GPIO pin number 13 selected */ +#define GPIO_PIN_NUM_14 0x0E /*!< GPIO pin number 14 selected */ +#define GPIO_PIN_NUM_15 0x0F /*!< GPIO pin number 15 selected */ + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Macro GPIO exported macro + * @{ + */ +/* check parameter of the GPIOx */ +#define IS_GPIO(x) (IS_GPIOABCD(x) || IS_GPIOE(x) || IS_GPIOF(x)) +#define IS_GPIOABCD(x) ((x==HT_GPIOA) || (x==HT_GPIOB) || (x==HT_GPIOC) || (x==HT_GPIOD)) +#if (LIBCFG_GPIOE) +#define IS_GPIOE(x) (x == HT_GPIOE) +#else +#define IS_GPIOE(x) (0) +#endif +#if (LIBCFG_GPIOF) +#define IS_GPIOF(x) (x == HT_GPIOF) +#else +#define IS_GPIOF(x) (0) +#endif + +/* check parameter of the GPIO_Px */ +#define IS_GPIO_PORT(x) (IS_GPIO_PORT1(x) || IS_GPIO_PORT2(x) || IS_GPIO_PORT3(x) || IS_GPIO_PORT4(x) || IS_GPIO_PORT5(x)) + +#define IS_GPIO_PORT1(x) ((x == GPIO_PA) || (x == GPIO_PB) ) + +#define IS_GPIO_PORT2(x) (x == GPIO_PC) + +#define IS_GPIO_PORT3(x) (x == GPIO_PD) + +#if (LIBCFG_GPIOE) +#define IS_GPIO_PORT4(x) (x == GPIO_PE) +#else +#define IS_GPIO_PORT4(x) (0) +#endif +#if (LIBCFG_GPIOF) +#define IS_GPIO_PORT5(x) (x == GPIO_PF) +#else +#define IS_GPIO_PORT5(x) (0) +#endif + +/* check parameter of the GPIO_PIN_NUM */ +#define IS_GPIO_PIN_NUM(x) (x < 16) + +/* check parameter of the GPIOx pull resistor */ +#define IS_GPIO_PR(x) (((x) == GPIO_PR_UP) || ((x) == GPIO_PR_DOWN) || ((x) == GPIO_PR_DISABLE)) + +/* check parameter of the GPIOx driving current */ +#if (LIBCFG_GPIO_DV_4_8MA_ONLY) +#define IS_GPIO_DV_12_16MA(x) (0) +#else +#define IS_GPIO_DV_12_16MA(x) (((x) == GPIO_DV_12MA) || ((x) == GPIO_DV_16MA)) +#endif +#define IS_GPIO_DV(x) (((x) == GPIO_DV_4MA) || ((x) == GPIO_DV_8MA) || IS_GPIO_DV_12_16MA(x)) + +/* check parameter of the GPIOx input/output direction */ +#define IS_GPIO_DIR(x) (((x) == GPIO_DIR_IN) || ((x) == GPIO_DIR_OUT) ) + +/* check parameter of the EXTI source port */ +#if (LIBCFG_GPIOE) +#define IS_ESSE(x) (x == AFIO_ESS_PE) +#else +#define IS_ESSE(x) (0) +#endif +#if (LIBCFG_GPIOF) +#define IS_ESSF(x) (x == AFIO_ESS_PF) +#else +#define IS_ESSF(x) (0) +#endif + +#define IS_AFIO_ESS(x) ((x == AFIO_ESS_PA) || (x == AFIO_ESS_PB) || (x == AFIO_ESS_PC) || (x == AFIO_ESS_PD) || IS_ESSE(x) || IS_ESSF(x)) + +/* check parameter of the EXTI channel */ +#define IS_AFIO_EXTI_CH(x) ((x == AFIO_EXTI_CH_0) || (x == AFIO_EXTI_CH_1) || \ + (x == AFIO_EXTI_CH_2) || (x == AFIO_EXTI_CH_3) || \ + (x == AFIO_EXTI_CH_4) || (x == AFIO_EXTI_CH_5) || \ + (x == AFIO_EXTI_CH_6) || (x == AFIO_EXTI_CH_7) || \ + (x == AFIO_EXTI_CH_8) || (x == AFIO_EXTI_CH_9) || \ + (x == AFIO_EXTI_CH_10) || (x == AFIO_EXTI_CH_11) || \ + (x == AFIO_EXTI_CH_12) || (x == AFIO_EXTI_CH_13) || \ + (x == AFIO_EXTI_CH_14) || (x == AFIO_EXTI_CH_15)) + +/* check parameter of the AFIO mode */ +#define IS_AFIO_MODE(x) ((x == AFIO_MODE_DEFAULT) || (x == AFIO_MODE_1) || \ + (x == AFIO_MODE_2) || (x == AFIO_MODE_3) || \ + (x == AFIO_MODE_4) || (x == AFIO_MODE_5) || \ + (x == AFIO_MODE_6) || (x == AFIO_MODE_7) || \ + (x == AFIO_MODE_8) || (x == AFIO_MODE_9) || \ + (x == AFIO_MODE_10) || (x == AFIO_MODE_11) || \ + (x == AFIO_MODE_12) || (x == AFIO_MODE_13) || \ + (x == AFIO_MODE_14) || (x == AFIO_MODE_15)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Functions GPIO exported functions + * @{ + */ + +/* Prototype of related GPIO function */ +void GPIO_DeInit(HT_GPIO_TypeDef* HT_GPIOx); +void GPIO_DirectionConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DIR_Enum GPIO_DIR_INorOUT); +void GPIO_PullResistorConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_PR_Enum GPIO_PR_x); +void GPIO_InputConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd); +void GPIO_DriveConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DV_Enum GPIO_DV_nMA); +void GPIO_OpenDrainConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd); +FlagStatus GPIO_ReadInBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n); +FlagStatus GPIO_ReadOutBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n); +u16 GPIO_ReadInData(HT_GPIO_TypeDef* HT_GPIOx); +u16 GPIO_ReadOutData(HT_GPIO_TypeDef* HT_GPIOx); +void GPIO_SetOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP); +void GPIO_ClearOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP); +void GPIO_WriteOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, FlagStatus Status); +void GPIO_WriteOutData(HT_GPIO_TypeDef* HT_GPIOx, u16 Data); +void GPIO_PinLock(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP); +bool GPIO_IsPortLocked(HT_GPIO_TypeDef* HT_GPIOx); +bool GPIO_IsPinLocked(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n); +void GPIO_DisableDebugPort(void); +u32 GPIO_GetID(HT_GPIO_TypeDef* HT_GPIOx); + +/* Prototype of related AFIO function */ +void AFIO_DeInit(void); +void AFIO_GPxConfig(u32 GPIO_Px, u32 AFIO_PIN_n, AFIO_MODE_Enum AFIO_MODE_n); +void AFIO_EXTISourceConfig(u32 GPIO_PIN_NUM_n, u32 GPIO_Px); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2c.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2c.h new file mode 100644 index 0000000000..7d1c314490 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2c.h @@ -0,0 +1,325 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_i2c.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the I2C library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_I2C_H +#define __HT32F1XXXX_I2C_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup I2C + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Types I2C exported types + * @{ + */ + +typedef u16 I2C_AddressTypeDef; + +typedef struct +{ + u8 I2C_GeneralCall; + u8 I2C_AddressingMode; + u8 I2C_Acknowledge; + u8 I2C_SpeedOffset; /* Offset value to reach real speed, recommended I2C_SpeedOffset = I2C PCLK/8000000 */ + /* which based on 4.7K Pull up */ + u32 I2C_Speed; + u16 I2C_OwnAddress; +} I2C_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Constants I2C exported constants + * @{ + */ +#define I2C_GENERALCALL_ENABLE ((u32)0x00000004) +#define I2C_GENERALCALL_DISABLE ((u32)0x00000000) + +#define IS_I2C_GENERAL_CALL(CALL) ((CALL == I2C_GENERALCALL_ENABLE) || \ + (CALL == I2C_GENERALCALL_DISABLE)) + +#define I2C_ADDRESSING_7BIT ((u32)0x00000000) +#define I2C_ADDRESSING_10BIT ((u32)0x00000080) + +#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS) ((ADDRESS == I2C_ADDRESSING_7BIT) || \ + (ADDRESS == I2C_ADDRESSING_10BIT)) + +#define I2C_ACK_ENABLE ((u32)0x00000001) +#define I2C_ACK_DISABLE ((u32)0x00000000) + +#define IS_I2C_ACKNOWLEDGE(ACKNOWLEDGE) ((ACKNOWLEDGE == I2C_ACK_ENABLE) || \ + (ACKNOWLEDGE == I2C_ACK_DISABLE)) + + +#define I2C_INT_STA ((u32)0x00000001) +#define I2C_INT_STO ((u32)0x00000002) +#define I2C_INT_ADRS ((u32)0x00000004) +#define I2C_INT_GCS ((u32)0x00000008) +#define I2C_INT_ARBLOS ((u32)0x00000100) +#define I2C_INT_RXNACK ((u32)0x00000200) +#define I2C_INT_BUSERR ((u32)0x00000400) +#define I2C_INT_TOUT ((u32)0x00000800) +#define I2C_INT_RXDNE ((u32)0x00010000) +#define I2C_INT_TXDE ((u32)0x00020000) +#define I2C_INT_RXBF ((u32)0x00040000) +#define I2C_INT_ALL ((u32)0x00070F0F) + +#define IS_I2C_INT(int) (((int & 0xFFF8F0F0) == 0x0) && (int != 0x0)) + +#define I2C_MASTER_READ ((u32)0x00000400) +#define I2C_MASTER_WRITE ((u32)0x00000000) + +#define IS_I2C_DIRECTION(DIRECTION) ((DIRECTION == I2C_MASTER_READ) || \ + (DIRECTION == I2C_MASTER_WRITE)) + + +#define I2C_REGISTER_CR ((u8)0x00) +#define I2C_REGISTER_IER ((u8)0x04) +#define I2C_REGISTER_ADDR ((u8)0x08) +#define I2C_REGISTER_SR ((u8)0x0C) +#define I2C_REGISTER_SHPGR ((u8)0x10) +#define I2C_REGISTER_SLPGR ((u8)0x14) +#define I2C_REGISTER_DR ((u8)0x18) +#define I2C_REGISTER_BFCLR ((u8)0x1C) +#define I2C_REGISTER_TAR ((u8)0x20) + +#define IS_I2C_REGISTER(REGISTER) ((REGISTER == I2C_REGISTER_CR) || \ + (REGISTER == I2C_REGISTER_IER) || \ + (REGISTER == I2C_REGISTER_ADDR) || \ + (REGISTER == I2C_REGISTER_SR) || \ + (REGISTER == I2C_REGISTER_SHPGR) || \ + (REGISTER == I2C_REGISTER_SLPGR) || \ + (REGISTER == I2C_REGISTER_DR) || \ + (REGISTER == I2C_REGISTER_BFCLR) || \ + (REGISTER == I2C_REGISTER_TAR)) + + +#define I2C_FLAG_STA ((u32)0x00000001) +#define I2C_FLAG_STO ((u32)0x00000002) +#define I2C_FLAG_ADRS ((u32)0x00000004) +#define I2C_FLAG_GCS ((u32)0x00000008) +#define I2C_FLAG_ARBLOS ((u32)0x00000100) +#define I2C_FLAG_RXNACK ((u32)0x00000200) +#define I2C_FLAG_BUSERR ((u32)0x00000400) +#define I2C_FLAG_TOUTF ((u32)0x00000800) +#define I2C_FLAG_RXDNE ((u32)0x00010000) +#define I2C_FLAG_TXDE ((u32)0x00020000) +#define I2C_FLAG_RXBF ((u32)0x00040000) +#define I2C_FLAG_BUSBUSY ((u32)0x00080000) +#define I2C_FLAG_MASTER ((u32)0x00100000) +#define I2C_FLAG_TXNRX ((u32)0x00200000) + +#define IS_I2C_FLAG(FLAG) ((FLAG == I2C_FLAG_STA) || \ + (FLAG == I2C_FLAG_STO) || \ + (FLAG == I2C_FLAG_ADRS) || \ + (FLAG == I2C_FLAG_GCS) || \ + (FLAG == I2C_FLAG_ARBLOS) || \ + (FLAG == I2C_FLAG_RXNACK) || \ + (FLAG == I2C_FLAG_BUSERR) || \ + (FLAG == I2C_FLAG_TOUTF) || \ + (FLAG == I2C_FLAG_RXDNE) || \ + (FLAG == I2C_FLAG_TXDE) || \ + (FLAG == I2C_FLAG_RXBF) || \ + (FLAG == I2C_FLAG_BUSBUSY)|| \ + (FLAG == I2C_FLAG_MASTER) || \ + (FLAG == I2C_FLAG_TXNRX)) + +#define IS_I2C_CLEAR_FLAG(FLAG) ((FLAG == I2C_FLAG_ARBLOS) || \ + (FLAG == I2C_FLAG_RXNACK) || \ + (FLAG == I2C_FLAG_BUSERR) || \ + (FLAG == I2C_FLAG_TOUTF)) + +#define I2C_MASTER_SEND_START ((u32)0x00180001) +#define I2C_MASTER_RECEIVER_MODE ((u32)0x00180004) +#define I2C_MASTER_TRANSMITTER_MODE ((u32)0x003A0004) +#define I2C_MASTER_RX_NOT_EMPTY ((u32)0x00190000) +#define I2C_MASTER_RX_NOT_EMPTY_NOBUSY ((u32)0x00010000) +#define I2C_MASTER_TX_EMPTY ((u32)0x003A0000) +#define I2C_MASTER_RX_BUFFER_FULL ((u32)0x001D0000) +#define I2C_SLAVE_ACK_TRANSMITTER_ADDRESS ((u32)0x002A0004) +#define I2C_SLAVE_ACK_RECEIVER_ADDRESS ((u32)0x00080004) +#define I2C_SLAVE_ACK_GCALL_ADDRESS ((u32)0x00080008) +#define I2C_SLAVE_RX_NOT_EMPTY ((u32)0x00090000) +#define I2C_SLAVE_RX_NOT_EMPTY_STOP ((u32)0x00010002) +#define I2C_SLAVE_TX_EMPTY ((u32)0x002A0000) +#define I2C_SLAVE_RX_BUFFER_FULL ((u32)0x000D0000) +#define I2C_SLAVE_RECEIVED_NACK ((u32)0x00080200) +#define I2C_SLAVE_RECEIVED_NACK_STOP ((u32)0x00000202) +#define I2C_SLAVE_STOP_DETECTED ((u32)0x00000002) + + +#define IS_I2C_STATUS(STATUS) ((STATUS == I2C_MASTER_SEND_START) || \ + (STATUS == I2C_MASTER_RECEIVER_MODE) || \ + (STATUS == I2C_MASTER_TRANSMITTER_MODE) || \ + (STATUS == I2C_MASTER_RX_NOT_EMPTY) || \ + (STATUS == I2C_MASTER_RX_NOT_EMPTY_NOBUSY) || \ + (STATUS == I2C_MASTER_TX_EMPTY) || \ + (STATUS == I2C_MASTER_RX_BUFFER_FULL) || \ + (STATUS == I2C_SLAVE_ACK_TRANSMITTER_ADDRESS) || \ + (STATUS == I2C_SLAVE_ACK_RECEIVER_ADDRESS) || \ + (STATUS == I2C_SLAVE_ACK_GCALL_ADDRESS) || \ + (STATUS == I2C_SLAVE_RX_NOT_EMPTY) || \ + (STATUS == I2C_SLAVE_RX_NOT_EMPTY_STOP) || \ + (STATUS == I2C_SLAVE_TX_EMPTY) || \ + (STATUS == I2C_SLAVE_RX_BUFFER_FULL) || \ + (STATUS == I2C_SLAVE_RECEIVED_NACK) || \ + (STATUS == I2C_SLAVE_RECEIVED_NACK_STOP) || \ + (STATUS == I2C_SLAVE_STOP_DETECTED)) + +#define I2C_PDMAREQ_TX ((u32)0x00000100) +#define I2C_PDMAREQ_RX ((u32)0x00000200) + +#define IS_I2C_PDMA_REQ(REQ) (((REQ & 0xFFFFFCFF) == 0x0) && (REQ != 0x0)) + +#define I2C_PRESCALER_1 ((u32)0x00000000) +#define I2C_PRESCALER_2 ((u32)0x00010000) +#define I2C_PRESCALER_4 ((u32)0x00020000) +#define I2C_PRESCALER_8 ((u32)0x00030000) +#define I2C_PRESCALER_16 ((u32)0x00040000) +#define I2C_PRESCALER_32 ((u32)0x00050000) +#define I2C_PRESCALER_64 ((u32)0x00060000) +#define I2C_PRESCALER_128 ((u32)0x00070000) + +#define IS_I2C_PRESCALER(PRESCALER) ((PRESCALER == I2C_PRESCALER_1) || \ + (PRESCALER == I2C_PRESCALER_2) || \ + (PRESCALER == I2C_PRESCALER_4) || \ + (PRESCALER == I2C_PRESCALER_8) || \ + (PRESCALER == I2C_PRESCALER_16) || \ + (PRESCALER == I2C_PRESCALER_32) || \ + (PRESCALER == I2C_PRESCALER_64) || \ + (PRESCALER == I2C_PRESCALER_128)) + +#define I2C_MASKBIT_0 ((u32)0x00000001) +#define I2C_MASKBIT_1 ((u32)0x00000002) +#define I2C_MASKBIT_2 ((u32)0x00000004) +#define I2C_MASKBIT_3 ((u32)0x00000008) +#define I2C_MASKBIT_4 ((u32)0x00000010) +#define I2C_MASKBIT_5 ((u32)0x00000020) +#define I2C_MASKBIT_6 ((u32)0x00000040) +#define I2C_MASKBIT_7 ((u32)0x00000080) +#define I2C_MASKBIT_8 ((u32)0x00000100) +#define I2C_MASKBIT_9 ((u32)0x00000200) + + +#define IS_I2C_ADDRESS_MASK(MASK) ((MASK == I2C_MASKBIT_0) || \ + (MASK == I2C_MASKBIT_1) || \ + (MASK == I2C_MASKBIT_2) || \ + (MASK == I2C_MASKBIT_3) || \ + (MASK == I2C_MASKBIT_4) || \ + (MASK == I2C_MASKBIT_5) || \ + (MASK == I2C_MASKBIT_6) || \ + (MASK == I2C_MASKBIT_7) || \ + (MASK == I2C_MASKBIT_8) || \ + (MASK == I2C_MASKBIT_9)) + + +#define IS_I2C(I2C) ((I2C == HT_I2C0) || (I2C == HT_I2C1)) + +#define IS_I2C_ADDRESS(ADDRESS) (ADDRESS <= 0x3FF) + +#define IS_I2C_SPEED(SPEED) ((SPEED >= 1) && (SPEED <= 1000000)) + +#define IS_I2C_SCL_HIGH(HIGH) (HIGH <= 0xFFFF) + +#define IS_I2C_SCL_LOW(LOW) (LOW <= 0xFFFF) + +#define IS_I2C_TIMEOUT(TIMEOUT) (TIMEOUT <= 0xFFFF) + +#define SEQ_FILTER_DISABLE ((u32)0x00000000) +#define SEQ_FILTER_1_PCLK ((u32)0x00004000) +#define SEQ_FILTER_2_PCLK ((u32)0x00008000) + +#define IS_I2C_SEQ_FILTER_MASK(CONFIG) ((CONFIG == SEQ_FILTER_DISABLE) || \ + (CONFIG == SEQ_FILTER_1_PCLK) || \ + (CONFIG == SEQ_FILTER_2_PCLK)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Functions I2C exported functions + * @{ + */ +void I2C_DeInit(HT_I2C_TypeDef* I2Cx); +void I2C_Init(HT_I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStructure); +void I2C_StructInit(I2C_InitTypeDef* I2C_InitStructure); +void I2C_Cmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_GenerateSTOP(HT_I2C_TypeDef* I2Cx); +void I2C_IntConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Int, ControlStatus NewState); +void I2C_GeneralCallCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_AckCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_SetOwnAddress(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address); +void I2C_TargetAddressConfig(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address, u32 I2C_Direction); +void I2C_SendData(HT_I2C_TypeDef* I2Cx, u8 I2C_Data); +u8 I2C_ReceiveData(HT_I2C_TypeDef* I2Cx); +u32 I2C_ReadRegister(HT_I2C_TypeDef* I2Cx, u8 I2C_Register); +FlagStatus I2C_GetFlagStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag); +ErrStatus I2C_CheckStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Status); +void I2C_ClearFlag(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag); +void I2C_SetSCLHighPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_HighPeriod); +void I2C_SetSCLLowPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_LowPeriod); +void I2C_PDMACmd(HT_I2C_TypeDef* I2Cx, u32 I2C_PDMAREQ, ControlStatus NewState); +void I2C_PDMANACKCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_TimeOutCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_SetTimeOutValue(HT_I2C_TypeDef* I2Cx, u32 I2C_Timeout); +void I2C_SetTimeOutPrescaler(HT_I2C_TypeDef* I2Cx, u32 I2C_Prescaler); +void I2C_AddressMaskConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Mask); +u16 I2C_GetAddressBuffer(HT_I2C_TypeDef* I2Cx); +void I2C_CombFilterCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_SequentialFilterConfig(HT_I2C_TypeDef* I2Cx, u32 Seq_Filter_Select); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2s.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2s.h new file mode 100644 index 0000000000..4a63e99458 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_i2s.h @@ -0,0 +1,240 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_i2s.h + * @version $Rev:: 1364 $ + * @date $Date:: 2018-08-02 #$ + * @brief The header file of the I2S library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_I2S_H +#define __HT32F1XXXX_I2S_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup I2S + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Types I2S exported types + * @{ + */ +typedef struct +{ + u32 I2S_Mode; + u32 I2S_Format; + u32 I2S_WordWidth; + u32 I2S_MclkOut; + u32 I2S_MclkInv; + u32 I2S_BclkInv; + u32 I2S_X_Div; + u32 I2S_Y_Div; + u32 I2S_N_Div; +} I2S_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Constants I2S exported constants + * @{ + */ +/* mode */ +#define I2S_MASTER_TX (1UL << 1) +#define I2S_MASTER_RX (1UL << 2) +#define I2S_MASTER_TX_RX ((1UL << 1) | (1UL << 2)) + +#define I2S_SLAVE_TX ((1UL << 3) | (1UL << 1)) +#define I2S_SLAVE_RX ((1UL << 3) | (1UL << 2)) +#define I2S_SLAVE_TX_RX ((1UL << 3) | (1UL << 1) | (1UL << 2)) + +#define IS_I2S_MODE(MOD) ((MOD == I2S_MASTER_TX) || \ + (MOD == I2S_MASTER_RX) || \ + (MOD == I2S_MASTER_TX_RX) || \ + (MOD == I2S_SLAVE_TX) || \ + (MOD == I2S_SLAVE_RX) || \ + (MOD == I2S_SLAVE_TX_RX)) + + +/* format */ +#define I2S_JUSTIFIED_STEREO (0) +#define LEFT_JUSTIFIED_STEREO (1UL << 6) +#define RIGHT_JUSTIFIED_STEREO (2UL << 6) +#define I2S_JUSTIFIED_REPEAT (1UL << 10) + +#define I2S_JUSTIFIED_STEREO_EXT (1UL << 8) +#define LEFT_JUSTIFIED_STEREO_EXT ((1UL << 8) | (1UL << 6)) +#define RIGHT_JUSTIFIED_STEREO_EXT ((1UL << 8) | (2UL << 6)) +#define I2S_JUSTIFIED_REPEAT_EXT ((1UL << 8) | (1UL << 10)) + +#define I2S_JUSTIFIED_MONO (1UL << 11) +#define LEFT_JUSTIFIED_MONO ((1UL << 11) | (1UL << 6)) +#define RIGHT_JUSTIFIED_MONO ((1UL << 11) | (2UL << 6)) + +#define I2S_JUSTIFIED_MONO_EXT ((1UL << 8) | (1UL << 11)) +#define LEFT_JUSTIFIED_MONO_EXT ((1UL << 8) | (1UL << 11) | (1UL << 6)) +#define RIGHT_JUSTIFIED_MONO_EXT ((1UL << 8) | (1UL << 11) | (2UL << 6)) + +#define IS_I2S_FORMAT(FMT) ((FMT == I2S_JUSTIFIED_STEREO) || \ + (FMT == LEFT_JUSTIFIED_STEREO) || \ + (FMT == RIGHT_JUSTIFIED_STEREO) || \ + (FMT == I2S_JUSTIFIED_REPEAT) || \ + (FMT == I2S_JUSTIFIED_STEREO_EXT) || \ + (FMT == LEFT_JUSTIFIED_STEREO_EXT) || \ + (FMT == RIGHT_JUSTIFIED_STEREO_EXT) || \ + (FMT == I2S_JUSTIFIED_REPEAT_EXT) || \ + (FMT == I2S_JUSTIFIED_MONO) || \ + (FMT == LEFT_JUSTIFIED_MONO) || \ + (FMT == RIGHT_JUSTIFIED_MONO) || \ + (FMT == I2S_JUSTIFIED_MONO_EXT) || \ + (FMT == LEFT_JUSTIFIED_MONO_EXT) || \ + (FMT == RIGHT_JUSTIFIED_MONO_EXT)) + + +/* word width */ +#define I2S_WORDWIDTH_8 (0) +#define I2S_WORDWIDTH_16 (1UL << 4) +#define I2S_WORDWIDTH_24 (2UL << 4) +#define I2S_WORDWIDTH_32 (3UL << 4) + +#define IS_I2S_WORD_WIDTH(WIDTH) ((WIDTH == I2S_WORDWIDTH_8) || \ + (WIDTH == I2S_WORDWIDTH_16) || \ + (WIDTH == I2S_WORDWIDTH_24) || \ + (WIDTH == I2S_WORDWIDTH_32)) + + +/* clock divider */ +#define IS_I2S_MCLK_DIV(X, Y) ((X > 0) && (X < 256) && (Y > 0) && (Y < 256) && (X <= Y)) + +#define IS_I2S_BCLK_DIV(N) (N < 256) + + +/* FIFO */ +#define I2S_TX_FIFO (1UL << 8) +#define I2S_RX_FIFO (2UL << 8) + +#define IS_I2S_ONE_FIFO(FIFO) ((FIFO == I2S_TX_FIFO) || (FIFO == I2S_RX_FIFO)) + +#define IS_I2S_TWO_FIFO(FIFO) (((FIFO & 0xFFFFFCFF) == 0) && (FIFO != 0)) + +#define IS_I2S_FIFO_LEVEL(LEVEL) ((LEVEL & 0x0000000F) < 9) + + +/* interrupt */ +#define I2S_INT_TXFIFO_TRI (1UL) +#define I2S_INT_TXFIFO_UDF (1UL << 1) +#define I2S_INT_TXFIFO_OVF (1UL << 2) + +#define I2S_INT_RXFIFO_TRI (1UL << 4) +#define I2S_INT_RXFIFO_UDF (1UL << 5) +#define I2S_INT_RXFIFO_OVF (1UL << 6) + +#define IS_I2S_INT(INT) (((INT & 0xFFFFFF88) == 0) && (INT != 0)) + + +/* flag */ +#define I2S_FLAG_TXFIFO_TRI (1UL) +#define I2S_FLAG_TXFIFO_UDF (1UL << 1) +#define I2S_FLAG_TXFIFO_OVF (1UL << 2) +#define I2S_FLAG_RXFIFO_TRI (1UL << 8) +#define I2S_FLAG_RXFIFO_UDF (1UL << 9) +#define I2S_FLAG_RXFIFO_OVF (1UL << 10) + +#define I2S_FLAG_TXFIFO_EMP (1UL << 3) +#define I2S_FLAG_TXFIFO_FUL (1UL << 4) +#define I2S_FLAG_RXFIFO_EMP (1UL << 11) +#define I2S_FLAG_RXFIFO_FUL (1UL << 12) +#define I2S_FLAG_RIGHT_CH (1UL << 16) +#define I2S_FLAG_TX_BUSY (1UL << 17) +#define I2S_FLAG_CLK_RDY (1UL << 18) + +#define IS_I2S_FLAG_CLEAR(FLAG) (((FLAG & 0xFFFFF8F8) == 0) && (FLAG != 0)) + +#define IS_I2S_FLAG(FLAG) ((FLAG == I2S_FLAG_TXFIFO_TRI) || \ + (FLAG == I2S_FLAG_TXFIFO_UDF) || \ + (FLAG == I2S_FLAG_TXFIFO_OVF) || \ + (FLAG == I2S_FLAG_TXFIFO_EMP) || \ + (FLAG == I2S_FLAG_TXFIFO_FUL) || \ + (FLAG == I2S_FLAG_RXFIFO_TRI) || \ + (FLAG == I2S_FLAG_RXFIFO_UDF) || \ + (FLAG == I2S_FLAG_RXFIFO_OVF) || \ + (FLAG == I2S_FLAG_RXFIFO_EMP) || \ + (FLAG == I2S_FLAG_RXFIFO_FUL) || \ + (FLAG == I2S_FLAG_RIGHT_CH) || \ + (FLAG == I2S_FLAG_TX_BUSY) || \ + (FLAG == I2S_FLAG_CLK_RDY)) + + +/* PDMA request */ +#define I2S_PDMAREQ_TX (1UL << 13) +#define I2S_PDMAREQ_RX (1UL << 14) + +#define IS_I2S_PDMA_REQ(REQ) (((REQ & 0xFFFF9FFF) == 0) && (REQ != 0)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Functions I2S exported functions + * @{ + */ +void I2S_DeInit(void); +void I2S_Init(I2S_InitTypeDef* I2S_InitStruct); +void I2S_Cmd(ControlStatus NewState); +void I2S_MclkOutputCmd(ControlStatus NewState); +void I2S_TxMuteCmd(ControlStatus NewState); +void I2S_PDMACmd(u32 I2S_PDMAREQ, ControlStatus NewState); +void I2S_FIFOReset(u32 I2S_FIFO); +void I2S_FIFOTrigLevelConfig(u32 I2S_FIFO, u32 I2S_FIFOLevel); +u8 I2S_GetFIFOStatus(u32 I2S_FIFO); +void I2S_IntConfig(u32 I2S_Int, ControlStatus NewState); +FlagStatus I2S_GetFlagStatus(u32 I2S_Flag); +void I2S_ClearFlag(u32 I2S_Flag); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_lib.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_lib.h new file mode 100644 index 0000000000..f3c09ec6c0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_lib.h @@ -0,0 +1,223 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_lib.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file includes all the header files of the libraries. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_LIB_H +#define __HT32F1XXXX_LIB_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Settings ------------------------------------------------------------------------------------------------*/ +#define HT32_FWLIB_VER (0x01004001) +#define HT32_FWLIB_SVN (0x2982) + +#if defined(USE_HT32F1653_54) + #include "ht32f1653_54_libcfg.h" +#endif +#if defined(USE_HT32F1655_56) + #include "ht32f1655_56_libcfg.h" +#endif +#if defined(USE_HT32F12365_66) + #include "ht32f12365_66_libcfg.h" +#endif +#if defined(USE_HT32F12345) + #include "ht32f12345_libcfg.h" +#endif +#if defined(USE_HT32F12364) + #include "ht32f12364_libcfg.h" +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include +#include "ht32f1xxxx_conf.h" + +#if (HT32_LIB_DEBUG == 1) +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define Assert_Param(expr) ((expr) ? (void)0 : assert_error((u8 *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- ------------------------------*/ +void assert_error(u8* file, u32 line); +#else + +#define Assert_Param(expr) ((void)0) + +#endif /* DEBUG --------------------------------------------------------------------------------------------*/ + + +#if _ADC + #include "ht32f1xxxx_adc.h" +#endif + +#if _AES && LIBCFG_AES + #include "ht32f1xxxx_aes.h" +#endif + +#if _BFTM + #include "ht32f1xxxx_bftm.h" +#endif + +#if _CKCU + #include "ht32f1xxxx_ckcu.h" +#endif + +#if _CMP_OPA && LIBCFG_CMP_OPA + #include "ht32f1xxxx_cmp_op.h" +#endif + +#if _CMP && (!LIBCFG_CMP_OPA) + #include "ht32f1xxxx_cmp.h" +#endif + +#if _CRC + #include "ht32f1xxxx_crc.h" +#endif + +#if _CSIF && LIBCFG_CSIF + #include "ht32f2xxxx_csif.h" +#endif + +#if _EBI + #include "ht32f1xxxx_ebi.h" +#endif + +#if _EXTI + #include "ht32f1xxxx_exti.h" +#endif + +#if _FLASH + #include "ht32f1xxxx_flash.h" +#endif + +#if _GPIO + #include "ht32f1xxxx_gpio.h" +#endif + +#if _GPTM + #include "ht32f1xxxx_tm_type.h" + #include "ht32f1xxxx_tm.h" +#endif + +#if _I2C + #include "ht32f1xxxx_i2c.h" +#endif + +#if _I2S + #include "ht32f1xxxx_i2s.h" +#endif + +#if _MCTM && (!LIBCFG_NO_MCTM0) + #include "ht32f1xxxx_tm_type.h" + #include "ht32f1xxxx_tm.h" + #include "ht32f1xxxx_mctm.h" +#endif + +#if _PDMA + #include "ht32f1xxxx_pdma.h" +#endif + +#if _PWRCU + #include "ht32f1xxxx_pwrcu.h" +#endif + +#if _PWM + #include "ht32f1xxxx_tm_type.h" + #include "ht32f1xxxx_tm.h" +#endif + +#if _RSTCU + #include "ht32f1xxxx_rstcu.h" +#endif + +#if _RTC + #include "ht32f1xxxx_rtc.h" +#endif + +#if _SCI && LIBCFG_SCI0 + #include "ht32f1xxxx_sci.h" +#endif + +#if _SDIO && LIBCFG_SDIO + #include "ht32f1xxxx_sdio.h" +#endif + +#if _SPI + #include "ht32f1xxxx_spi.h" +#endif + +#if _SCTM + #include "ht32f1xxxx_tm_type.h" + #include "ht32f1xxxx_tm.h" +#endif + +#if _USART + #include "ht32f1xxxx_usart.h" +#endif + +#if _USB + #include "ht32f1xxxx_usbd.h" +#endif + +#if _WDT + #include "ht32f1xxxx_wdt.h" +#endif + +#if _MISC + #include "ht32_cm3_misc.h" +#endif + +#if _SERIAL + #include "ht32_serial.h" +#endif + +#if _SWRAND + #include "ht32_rand.h" +#endif + +#if (_RETARGET) + #if defined (__GNUC__) + #undef getchar + #define getchar SERIAL_GetChar + #endif +#endif + +#ifdef HTCFG_TIME_IPSEL +#include "ht32_time.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_mctm.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_mctm.h new file mode 100644 index 0000000000..e99cfa0f30 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_mctm.h @@ -0,0 +1,237 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_mctm.h + * @version $Rev:: 122 $ + * @date $Date:: 2017-06-13 #$ + * @brief The header file of the MCTM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_MCTM_H +#define __HT32F1XXXX_MCTM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_tm.h" +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup MCTM + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Types MCTM exported types + * @{ + */ +/** + * @brief Enumeration of MCTM channel output idle state. + */ +/** + * @brief Definition of Break & DeadTime init structure. + */ +typedef struct +{ + u32 OSSRState; + u32 OSSIState; + u32 LockLevel; + u32 Break0; + u32 Break0Polarity; + u32 Break1; + u32 Break1Polarity; + u32 AutomaticOutput; + u8 DeadTime; + u8 BreakFilter; +} MCTM_CHBRKCTRInitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Constants MCTM exported constants + * @{ + */ + +/** @defgroup MCTM_BKE Definitions of MCTM break control + * @{ + */ +#define MCTM_BREAK_ENABLE 0x00000001 /*!< Break enable */ +#define MCTM_BREAK_DISABLE 0x00000000 /*!< Break disable */ +/** + * @} + */ + +/** @defgroup MCTM_BKP Definitions of MCTM break polarity + * @{ + */ +#define MCTM_BREAK_POLARITY_LOW 0x00000000 /*!< Break input pin active low level */ +#define MCTM_BREAK_POLARITY_HIGH 0x00000002 /*!< Break input pin active high level */ +/** + * @} + */ + +/** @defgroup MCTM_CHMOE Definitions of MCTM main output enable function state + * @{ + */ +#define MCTM_CHMOE_DISABLE 0x00000000 /*!< main output disable */ +#define MCTM_CHMOE_ENABLE 0x00000010 /*!< Main output enable */ +/** + * @} + */ + +/** @defgroup MCTM_CHAOE Definitions of MCTM automatic output enable function state + * @{ + */ +#define MCTM_CHAOE_DISABLE 0x00000000 /*!< Automatic output enable function disable */ +#define MCTM_CHAOE_ENABLE 0x00000020 /*!< Automatic output enable function enable */ +/** + * @} + */ + +/** @defgroup MCTM_LOCK_LEVEL Definitions of MCTM lock level selection + * @{ + */ +#define MCTM_LOCK_LEVEL_OFF 0x00000000 /*!< Lock Off */ +#define MCTM_LOCK_LEVEL_1 0x00010000 /*!< Lock level 1 */ +#define MCTM_LOCK_LEVEL_2 0x00020000 /*!< Lock level 2 */ +#define MCTM_LOCK_LEVEL_3 0x00030000 /*!< Lock level 3 */ +/** + * @} + */ + +/** @defgroup MCTM_OSSI Definitions of Off-State Selection for Idle mode states + * @{ + */ +#define MCTM_OSSI_STATE_ENABLE 0x00100000 +#define MCTM_OSSI_STATE_DISABLE 0x00000000 +/** + * @} + */ + +/** @defgroup MCTM_OSSR Definitions of Off-State Selection for Run mode states + * @{ + */ +#define MCTM_OSSR_STATE_ENABLE 0x00200000 +#define MCTM_OSSR_STATE_DISABLE 0x00000000 +/** + * @} + */ + +/** @defgroup MCTM_Check_Parameter Check parameter + * @{ + */ + +/** + * @brief Used to check parameter of the MCTMx. + */ +#define IS_MCTM(x) ((x == HT_MCTM0) || (x == HT_MCTM1)) +/** + * @brief Used to check parameter of the complementary output channel. + */ +#define IS_MCTM_COMPLEMENTARY_CH(x) (((x) == TM_CH_0) || ((x) == TM_CH_1) || \ + ((x) == TM_CH_2)) +/** + * @brief Used to check parameter of the COMUS. + */ +#define IS_MCTM_COMUS(x) ((x == MCTM_COMUS_STIOFF) || (x == MCTM_COMUS_STION)) +/** + * @brief Used to check parameter of the channel output idle state. + */ +#define IS_MCTM_OIS(x) ((x == MCTM_OIS_LOW) || (x == MCTM_OIS_HIGH)) +/** + * @brief Used to check value of MCTM break control state. + */ +#define IS_MCTM_BREAK_STATE(STATE) (((STATE) == MCTM_BREAK_ENABLE) || \ + ((STATE) == MCTM_BREAK_DISABLE)) +/** + * @brief Used to check value of MCTM break polarity. + */ +#define IS_MCTM_BREAK_POLARITY(POLARITY) (((POLARITY) == MCTM_BREAK_POLARITY_LOW) || \ + ((POLARITY) == MCTM_BREAK_POLARITY_HIGH)) +/** + * @brief Used to check value of MCTM automatic output enable control state. + */ +#define IS_MCTM_CHAOE_STATE(STATE) (((STATE) == MCTM_CHAOE_ENABLE) || \ + ((STATE) == MCTM_CHAOE_DISABLE)) +/** + * @brief Used to check value of MCTM lock level. + */ +#define IS_MCTM_LOCK_LEVEL(LEVEL) (((LEVEL) == MCTM_LOCK_LEVEL_OFF) || \ + ((LEVEL) == MCTM_LOCK_LEVEL_1) || \ + ((LEVEL) == MCTM_LOCK_LEVEL_2) || \ + ((LEVEL) == MCTM_LOCK_LEVEL_3)) +/** + * @brief Used to check value of MCTM OSSI state. + */ +#define IS_MCTM_OSSI_STATE(STATE) (((STATE) == MCTM_OSSI_STATE_ENABLE) || \ + ((STATE) == MCTM_OSSI_STATE_DISABLE)) +/** + * @brief Used to check value of MCTM OSSR state. + */ +#define IS_MCTM_OSSR_STATE(STATE) (((STATE) == MCTM_OSSR_STATE_ENABLE) || \ + ((STATE) == MCTM_OSSR_STATE_DISABLE)) +/** + * @} + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Functions MCTM exported functions + * @{ + */ +void MCTM_ChNPolarityConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHP_Enum Pol); +void MCTM_ChannelNConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control); + +void MCTM_CHMOECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState); +void MCTM_CHBRKCTRConfig(HT_TM_TypeDef* MCTMx, MCTM_CHBRKCTRInitTypeDef *CHBRKCTRInit); +void MCTM_CHBRKCTRStructInit(MCTM_CHBRKCTRInitTypeDef* CHBRKCTRInit); +void MCTM_COMPRECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState); +void MCTM_COMUSConfig(HT_TM_TypeDef* MCTMx, MCTM_COMUS_Enum Sel); + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pdma.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pdma.h new file mode 100644 index 0000000000..fbb2259615 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pdma.h @@ -0,0 +1,344 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_pdma.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the PDMA library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_PDMA_H +#define __HT32F1XXXX_PDMA_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup PDMA + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Types PDMA exported types + * @{ + */ + +/** + * @brief Definition of PDMA channel Init Structure + */ +typedef struct +{ + u32 PDMACH_SrcAddr; /*!< source address */ + u32 PDMACH_DstAddr; /*!< destination address */ + u16 PDMACH_BlkCnt; /*!< number of blocks for a PDMA transfer (1 ~ 65,535) */ + u16 PDMACH_BlkLen; /*!< number of data for a block (1 ~ 65,535) */ + u8 PDMACH_DataSize; /*!< number of bits for a data (8-bit/16-bit/32-bit) */ + u16 PDMACH_Priority; /*!< software priority for a PDMA transfer (L/M/H/VH) */ + u16 PDMACH_AdrMod; /*!< address mode (LIN_INC/LIN_DEC/CIR_INC/CIR_DEC/FIX/AUTO_RELOAD) */ +} PDMACH_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Constants PDMA exported constants + * @{ + */ +/* priority */ +#define L_PRIO (0) /*!< low priority */ +#define M_PRIO (1UL << 8) /*!< medium priority */ +#define H_PRIO (2UL << 8) /*!< high priority */ +#define VH_PRIO (3UL << 8) /*!< very high priority */ + +#define IS_PDMA_PRIO(PRIO) ((PRIO >> 8) < 4) /*!< check channel priority parameter */ + +/* address mode */ +#define AUTO_RELOAD (1UL << 11) /*!< enable auto reload */ +#define ADR_FIX (1UL << 10) /*!< enable address fix */ + +#define SRC_ADR_LIN_INC (0) /*!< source address linear increment */ +#define SRC_ADR_LIN_DEC (1UL << 6) /*!< source address linear decrement */ +#define SRC_ADR_CIR_INC (2UL << 6) /*!< source address circular increment */ +#define SRC_ADR_CIR_DEC (3UL << 6) /*!< source address circular decrement */ +#define SRC_ADR_FIX (ADR_FIX | SRC_ADR_CIR_INC) /*!< source address fix */ + +#define DST_ADR_LIN_INC (0) /*!< destination address linear increment */ +#define DST_ADR_LIN_DEC (1UL << 4) /*!< destination address linear decrement */ +#define DST_ADR_CIR_INC (2UL << 4) /*!< destination address circular increment */ +#define DST_ADR_CIR_DEC (3UL << 4) /*!< destination address circular decrement */ +#define DST_ADR_FIX (ADR_FIX | DST_ADR_CIR_INC) /*!< destination address fix */ + +#define IS_PDMA_ADR_MOD(MOD) ((MOD & 0xFFFFF30F) == 0) /*!< check address mode parameters */ + +/* transfer size */ +#if (LIBCFG_PDMA_BLKLEN65536) +#define _PDMA_BLK_LEN (65535) +#else +#define _PDMA_BLK_LEN (255) +#endif +#define IS_PDMA_BLK_CNT(CNT) ((CNT > 0) && (CNT <= 65535)) /*!< block count per transfer */ +#define IS_PDMA_BLK_LEN(LEN) ((LEN > 0) && (LEN <= _PDMA_BLK_LEN)) /*!< block size per block count */ + +/* transfer width */ +#define WIDTH_8BIT (0) /*!< 8-bit transfer width */ +#define WIDTH_16BIT (1UL << 2) /*!< 16-bit transfer width */ +#define WIDTH_32BIT (2UL << 2) /*!< 32-bit transfer width */ + +#define IS_PDMA_WIDTH(WIDTH) ((WIDTH >> 2) < 3) /*!< check transfer width parameter */ + +/* channel number */ +#define PDMA_CH0 (0) /*!< channel 0 number */ +#define PDMA_CH1 (1UL) /*!< channel 1 number */ +#define PDMA_CH2 (2UL) /*!< channel 2 number */ +#define PDMA_CH3 (3UL) /*!< channel 3 number */ +#define PDMA_CH4 (4UL) /*!< channel 4 number */ +#define PDMA_CH5 (5UL) /*!< channel 5 number */ +#if !(LIBCFG_NO_PDMA_CH6_11) +#define PDMA_CH6 (6UL) /*!< channel 6 number */ +#define PDMA_CH7 (7UL) /*!< channel 7 number */ +#if (LIBCFG_PDMA_CH8_11) +#define PDMA_CH8 (8UL) /*!< channel 8 number */ +#define PDMA_CH9 (9UL) /*!< channel 9 number */ +#define PDMA_CH10 (10UL) /*!< channel 10 number */ +#define PDMA_CH11 (11UL) /*!< channel 11 number */ +#endif +#endif + +#if (LIBCFG_NO_PDMA_CH6_11) +#define _PDMA_CH_NUM (6) +#elif (LIBCFG_PDMA_CH8_11) +#define _PDMA_CH_NUM (12) +#else +#define _PDMA_CH_NUM (8) +#endif + +#define IS_PDMA_CH(CH) (CH < _PDMA_CH_NUM) /*!< check channel number parameter */ + +#define PDMA_ADC0 PDMA_CH0 /*!< ADC PDMA channel number */ +#define PDMA_ADC PDMA_ADC0 + +#define PDMA_SPI0_RX PDMA_CH0 /*!< SPI0_RX PDMA channel number */ +#define PDMA_SPI0_TX PDMA_CH1 /*!< SPI0_TX PDMA channel number */ +#define PDMA_SPI1_RX PDMA_CH4 /*!< SPI1_RX PDMA channel number */ +#define PDMA_SPI1_TX PDMA_CH5 /*!< SPI1_TX PDMA channel number */ + +#if defined(USE_HT32F12364) +#define PDMA_USART0_RX PDMA_CH0 /*!< USART_RX PDMA channel number */ +#define PDMA_USART0_TX PDMA_CH1 /*!< USART_TX PDMA channel number */ +#else +#define PDMA_USART0_RX PDMA_CH2 /*!< USART0_RX PDMA channel number */ +#define PDMA_USART0_TX PDMA_CH3 /*!< USART0_TX PDMA channel number */ +#endif +#if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) +#define PDMA_USART1_TX PDMA_CH6 /*!< USART1_TX PDMA channel number */ +#define PDMA_USART1_RX PDMA_CH7 /*!< USART1_RX PDMA channel number */ +#endif +#if defined(USE_HT32F12365_66) || defined(USE_HT32F12345) +#define PDMA_USART1_RX PDMA_CH8 /*!< USART1_RX PDMA channel number */ +#define PDMA_USART1_TX PDMA_CH9 /*!< USART1_TX PDMA channel number */ +#endif +#if defined(USE_HT32F12364) +#define PDMA_UART0_RX PDMA_CH2 /*!< UART0_RX PDMA channel number */ +#define PDMA_UART0_TX PDMA_CH3 /*!< UART0_TX PDMA channel number */ +#else +#define PDMA_UART0_RX PDMA_CH0 /*!< UART0_RX PDMA channel number */ +#define PDMA_UART0_TX PDMA_CH1 /*!< UART0_TX PDMA channel number */ +#endif +#define PDMA_UART1_RX PDMA_CH4 /*!< UART1_RX PDMA channel number */ +#define PDMA_UART1_TX PDMA_CH5 /*!< UART1_TX PDMA channel number */ + +#if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) +#define PDMA_SCI0_RX PDMA_CH6 /*!< SCI_RX PDMA channel number */ +#define PDMA_SCI0_TX PDMA_CH7 /*!< SCI_TX PDMA channel number */ +#endif +#if defined(USE_HT32F12364) +#define PDMA_SCI0_RX PDMA_CH4 /*!< SCI_RX PDMA channel number */ +#define PDMA_SCI0_TX PDMA_CH5 /*!< SCI_TX PDMA channel number */ +#endif +#if defined(USE_HT32F12365_66) +#define PDMA_SCI0_RX PDMA_CH8 /*!< SCI0_RX PDMA channel number */ +#define PDMA_SCI0_TX PDMA_CH9 /*!< SCI0_TX PDMA channel number */ +#define PDMA_SCI1_RX PDMA_CH10 /*!< SCI1_RX PDMA channel number */ +#define PDMA_SCI1_TX PDMA_CH11 /*!< SCI1_TX PDMA channel number */ +#endif + +#if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) || defined(USE_HT32F12364) +#define PDMA_I2C0_RX PDMA_CH2 /*!< I2C0_RX PDMA channel number */ +#define PDMA_I2C0_TX PDMA_CH4 /*!< I2C0_TX PDMA channel number */ +#elif defined(USE_HT32F12365_66) || defined(USE_HT32F12345) +#define PDMA_I2C0_RX PDMA_CH10 /*!< I2C0_RX PDMA channel number */ +#define PDMA_I2C0_TX PDMA_CH11 /*!< I2C0_TX PDMA channel number */ +#endif +#if defined(USE_HT32F12364) +#define PDMA_I2C1_RX PDMA_CH3 /*!< I2C1_RX PDMA channel number */ +#define PDMA_I2C1_TX PDMA_CH5 /*!< I2C1_TX PDMA channel number */ +#else +#define PDMA_I2C1_RX PDMA_CH6 /*!< I2C1_RX PDMA channel number */ +#define PDMA_I2C1_TX PDMA_CH7 /*!< I2C1_TX PDMA channel number */ +#endif + +#if !(LIBCFG_NO_MCTM0) +#define PDMA_MCTM0_CH0 PDMA_CH0 /*!< MCTM0_CH0 PDMA channel number */ +#define PDMA_MCTM0_TRIG PDMA_CH1 /*!< MCTM0_TRIG PDMA channel number */ +#define PDMA_MCTM0_CH1 PDMA_CH2 /*!< MCTM0_CH1 PDMA channel number */ +#define PDMA_MCTM0_CH3 PDMA_CH3 /*!< MCTM0_CH3 PDMA channel number */ +#define PDMA_MCTM0_CH2 PDMA_CH4 /*!< MCTM0_CH2 PDMA channel number */ +#define PDMA_MCTM0_UEV1 PDMA_CH5 /*!< MCTM0_UEV1 PDMA channel number */ +#define PDMA_MCTM0_UEV2 PDMA_CH7 /*!< MCTM0_UEV2 PDMA channel number */ + +#define PDMA_MCTM1_CH0 PDMA_CH1 /*!< MCTM1_CH0 PDMA channel number */ +#define PDMA_MCTM1_CH2 PDMA_CH2 /*!< MCTM1_CH2 PDMA channel number */ +#define PDMA_MCTM1_UEV1 PDMA_CH3 /*!< MCTM1_UEV1 PDMA channel number */ +#define PDMA_MCTM1_CH1 PDMA_CH4 /*!< MCTM1_CH1 PDMA channel number */ +#define PDMA_MCTM1_CH3 PDMA_CH5 /*!< MCTM1_CH3 PDMA channel number */ +#define PDMA_MCTM1_UEV2 PDMA_CH6 /*!< MCTM1_UEV2 PDMA channel number */ +#define PDMA_MCTM1_TRIG PDMA_CH7 /*!< MCTM1_TRIG PDMA channel number */ +#endif + +#if defined(USE_HT32F12364) +#define PDMA_GPTM0_CH0 PDMA_CH2 /*!< GPTM0_CH0 PDMA channel number */ +#define PDMA_GPTM0_CH1 PDMA_CH0 /*!< GPTM0_CH1 PDMA channel number */ +#define PDMA_GPTM0_CH2 PDMA_CH1 /*!< GPTM0_CH2 PDMA channel number */ +#define PDMA_GPTM0_CH3 PDMA_CH0 /*!< GPTM0_CH3 PDMA channel number */ +#define PDMA_GPTM0_TRIG PDMA_CH2 /*!< GPTM0_TRIG PDMA channel number */ +#define PDMA_GPTM0_UEV PDMA_CH1 /*!< GPTM0_UEV PDMA channel number */ +#else +#define PDMA_GPTM0_CH1 PDMA_CH0 /*!< GPTM0_CH1 PDMA channel number */ +#define PDMA_GPTM0_CH3 PDMA_CH0 /*!< GPTM0_CH3 PDMA channel number */ +#define PDMA_GPTM0_UEV PDMA_CH1 /*!< GPTM0_UEV PDMA channel number */ +#define PDMA_GPTM0_CH2 PDMA_CH2 /*!< GPTM0_CH2 PDMA channel number */ +#define PDMA_GPTM0_CH0 PDMA_CH3 /*!< GPTM0_CH0 PDMA channel number */ +#define PDMA_GPTM0_TRIG PDMA_CH3 /*!< GPTM0_TRIG PDMA channel number */ +#endif + +#if defined(USE_HT32F1653_54) || defined(USE_HT32F1655_56) +#define PDMA_GPTM1_CH0 PDMA_CH4 /*!< GPTM1_CH0 PDMA channel number */ +#define PDMA_GPTM1_CH1 PDMA_CH5 /*!< GPTM1_CH1 PDMA channel number */ +#define PDMA_GPTM1_UEV PDMA_CH5 /*!< GPTM1_UEV PDMA channel number */ +#define PDMA_GPTM1_CH2 PDMA_CH6 /*!< GPTM1_CH2 PDMA channel number */ +#define PDMA_GPTM1_TRIG PDMA_CH6 /*!< GPTM1_TRIG PDMA channel number */ +#define PDMA_GPTM1_CH3 PDMA_CH7 /*!< GPTM1_CH3 PDMA channel number */ +#endif +#if defined(USE_HT32F12365_66) || defined(USE_HT32F12345) +#define PDMA_GPTM1_CH0 PDMA_CH8 /*!< GPTM1_CH0 PDMA channel number */ +#define PDMA_GPTM1_CH1 PDMA_CH9 /*!< GPTM1_CH1 PDMA channel number */ +#define PDMA_GPTM1_UEV PDMA_CH9 /*!< GPTM1_UEV PDMA channel number */ +#define PDMA_GPTM1_CH2 PDMA_CH10 /*!< GPTM1_CH2 PDMA channel number */ +#define PDMA_GPTM1_TRIG PDMA_CH10 /*!< GPTM1_TRIG PDMA channel number */ +#define PDMA_GPTM1_CH3 PDMA_CH11 /*!< GPTM1_CH3 PDMA channel number */ +#endif + +#if (LIBCFG_PWM0) +#define PDMA_PWM0_CH0 PDMA_CH5 /*!< PWM0_CH0 PDMA channel number */ +#define PDMA_PWM0_CH1 PDMA_CH3 /*!< PWM0_CH1 PDMA channel number */ +#define PDMA_PWM0_CH2 PDMA_CH4 /*!< PWM0_CH2 PDMA channel number */ +#define PDMA_PWM0_CH3 PDMA_CH3 /*!< PWM0_CH3 PDMA channel number */ +#define PDMA_PWM0_TRIG PDMA_CH5 /*!< PWM0_TRIG PDMA channel number */ +#define PDMA_PWM0_UEV PDMA_CH4 /*!< PWM0_UEV PDMA channel number */ +#endif + + +#define PDMA_I2S_RX PDMA_CH2 /*!< I2S_RX PDMA channel number */ +#define PDMA_I2S_TX PDMA_CH3 /*!< I2S_TX PDMA channel number */ + +#if defined(USE_HT32F12365_66) +#define PDMA_CSIF PDMA_CH0 /*!< CSIF PDMA channel number */ +#endif + +#if defined(USE_HT32F12365_66) || defined(USE_HT32F12345) +#define PDMA_SDIO_RX PDMA_CH6 /*!< SDIO_RX PDMA channel number */ +#define PDMA_SDIO_TX PDMA_CH7 /*!< SDIO_TX PDMA channel number */ +#endif + +#if defined(USE_HT32F12364) +#define PDMA_AES_OUT PDMA_CH4 /*!< AES_OUT PDMA channel number */ +#define PDMA_AES_IN PDMA_CH5 /*!< AES_IN PDMA channel number */ +#elif defined(USE_HT32F12365_66) +#define PDMA_AES_OUT PDMA_CH10 /*!< AES_OUT PDMA channel number */ +#define PDMA_AES_IN PDMA_CH11 /*!< AES_IN PDMA channel number */ +#endif + +/* flag */ +#define PDMA_FLAG_GE (1UL << 0) /*!< PDMA channel global event flag */ +#define PDMA_FLAG_BE (1UL << 1) /*!< PDMA channel block end flag */ +#define PDMA_FLAG_HT (1UL << 2) /*!< PDMA channel half transfer flag */ +#define PDMA_FLAG_TC (1UL << 3) /*!< PDMA channel transfer complete flag */ +#define PDMA_FLAG_TE (1UL << 4) /*!< PDMA channel transfer error flag */ + +#define IS_PDMA_FLAG(FLAG) (((FLAG & 0xFFFFFFE0) == 0) && (FLAG != 0)) +#define IS_PDMA_CLEAR_FLAG(FLAG) (((FLAG & 0xFFFFFFE0) == 0) && (FLAG != 0)) + +/* interrupt */ +#define PDMA_INT_GE (1UL << 0) /*!< PDMA channel global event interrupt */ +#define PDMA_INT_BE (1UL << 1) /*!< PDMA channel block end interrupt */ +#define PDMA_INT_HT (1UL << 2) /*!< PDMA channel half transfer interrupt */ +#define PDMA_INT_TC (1UL << 3) /*!< PDMA channel transfer complete interrupt */ +#define PDMA_INT_TE (1UL << 4) /*!< PDMA channel transfer error interrupt */ + +#define IS_PDMA_INT(INT) (((INT & 0xFFFFFFE0) == 0) && (INT != 0)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Functions PDMA exported functions + * @{ + */ +void PDMA_DeInit(void); +void PDMA_Config(u32 PDMA_CHn, PDMACH_InitTypeDef *PDMACH_InitStruct); +void PDMA_AddrConfig(u32 PDMA_CHn, u32 SrcAddr, u32 DstAddr); +void PDMA_SrcAddrConfig(u32 PDMA_CHn, u32 SrcAddr); +void PDMA_DstAddrConfig(u32 PDMA_CHn, u32 DstAddr); +void PDMA_TranSizeConfig(u32 PDMA_CHn, u16 BlkCnt, u16 BlkLen); +void PDMA_EnaCmd(u32 PDMA_CHn, ControlStatus NewState); +void PDMA_SwTrigCmd(u32 PDMA_CHn, ControlStatus NewState); + +void PDMA_IntConfig(u32 PDMA_CHn, u32 PDMA_INT_x, ControlStatus NewState); +FlagStatus PDMA_GetFlagStatus(u32 PDMA_CHn, u32 PDMA_FLAG_x); +void PDMA_ClearFlag(u32 PDMA_CHn, u32 PDMA_FLAG_x); +u16 PDMA_GetRemainBlkCnt(u32 PDMA_CHn); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pwrcu.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pwrcu.h new file mode 100644 index 0000000000..267e7be448 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_pwrcu.h @@ -0,0 +1,285 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_pwrcu.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the Power Control Unit library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_PWRCU_H +#define __HT32F1XXXX_PWRCU_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup PWRCU + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Types PWRCU exported types + * @{ + */ + +/** + * @brief Status of Power control unit + */ +typedef enum +{ + PWRCU_OK = 0, /*!< Ready for access or backup domain power-on reset is released */ + PWRCU_TIMEOUT, /*!< Time out */ + PWRCU_ERROR /*!< Error */ +} PWRCU_Status; +/** + * @brief DMOS status + */ +typedef enum +{ + PWRCU_DMOS_STS_ON = 0, /*!< DMOS on */ + PWRCU_DMOS_STS_OFF, /*!< DMOS off */ + PWRCU_DMOS_STS_OFF_BY_BODRESET /*!< DMOS off caused by brow out reset */ +} PWRCU_DMOSStatus; +/** + * @brief LVD level selection + */ +typedef enum +{ + PWRCU_LVDS_LV1 = 0x00000000, /*!< LVD level 1 */ + PWRCU_LVDS_LV2 = 0x00020000, /*!< LVD level 2 */ + PWRCU_LVDS_LV3 = 0x00040000, /*!< LVD level 3 */ + PWRCU_LVDS_LV4 = 0x00060000, /*!< LVD level 4 */ + PWRCU_LVDS_LV5 = 0x00400000, /*!< LVD level 5 */ + PWRCU_LVDS_LV6 = 0x00420000, /*!< LVD level 6 */ + PWRCU_LVDS_LV7 = 0x00440000, /*!< LVD level 7 */ + PWRCU_LVDS_LV8 = 0x00460000 /*!< LVD level 8 */ +} PWRCU_LVDS_Enum; +#if (LIBCFG_PWRCU_LVDS_27_35) + #define PWRCU_LVDS_2V7 PWRCU_LVDS_LV1 + #define PWRCU_LVDS_2V8 PWRCU_LVDS_LV2 + #define PWRCU_LVDS_2V9 PWRCU_LVDS_LV3 + #define PWRCU_LVDS_3V PWRCU_LVDS_LV4 + #define PWRCU_LVDS_3V1 PWRCU_LVDS_LV5 + #define PWRCU_LVDS_3V2 PWRCU_LVDS_LV6 + #define PWRCU_LVDS_3V4 PWRCU_LVDS_LV7 + #define PWRCU_LVDS_3V5 PWRCU_LVDS_LV8 +#elif (LIBCFG_PWRCU_LVDS_17_31) + #define PWRCU_LVDS_1V75 PWRCU_LVDS_LV1 + #define PWRCU_LVDS_1V95 PWRCU_LVDS_LV2 + #define PWRCU_LVDS_2V15 PWRCU_LVDS_LV3 + #define PWRCU_LVDS_2V35 PWRCU_LVDS_LV4 + #define PWRCU_LVDS_2V55 PWRCU_LVDS_LV5 + #define PWRCU_LVDS_2V75 PWRCU_LVDS_LV6 + #define PWRCU_LVDS_2V95 PWRCU_LVDS_LV7 + #define PWRCU_LVDS_3V15 PWRCU_LVDS_LV8 +#else + #define PWRCU_LVDS_2V25 PWRCU_LVDS_LV1 + #define PWRCU_LVDS_2V4 PWRCU_LVDS_LV2 + #define PWRCU_LVDS_2V55 PWRCU_LVDS_LV3 + #define PWRCU_LVDS_2V7 PWRCU_LVDS_LV4 + #define PWRCU_LVDS_2V85 PWRCU_LVDS_LV5 + #define PWRCU_LVDS_3V PWRCU_LVDS_LV6 + #define PWRCU_LVDS_3V15 PWRCU_LVDS_LV7 + #define PWRCU_LVDS_3V3 PWRCU_LVDS_LV8 +#endif +/** + * @brief BOD reset or interrupt selection + */ +typedef enum +{ + PWRCU_BODRIS_RESET = 0, /*!< Reset the whole chip */ + PWRCU_BODRIS_INT = 1, /*!< Assert interrupt */ +} PWRCU_BODRIS_Enum; +/** + * @brief Sleep entry instruction selection + */ +typedef enum +{ + PWRCU_SLEEP_ENTRY_WFE = 0, /*!< Sleep then wait for event */ + PWRCU_SLEEP_ENTRY_WFI /*!< Sleep then wait for interrupt */ +} PWRCU_SLEEP_ENTRY_Enum; +#if (!LIBCFG_NO_BACK_DOMAIN) +/** + * @brief Backup register selection + */ +typedef enum +{ + PWRCU_BAKREG_0 = 0, + PWRCU_BAKREG_1, + PWRCU_BAKREG_2, + PWRCU_BAKREG_3, + PWRCU_BAKREG_4, + PWRCU_BAKREG_5, + PWRCU_BAKREG_6, + PWRCU_BAKREG_7, + PWRCU_BAKREG_8, + PWRCU_BAKREG_9 +} PWRCU_BAKREG_Enum; +#endif +/** + * @brief Vdd18/Vdd15 power good source selection + */ +typedef enum +{ + PWRCU_VRDYSC_BKISO = 0, /*!< Vdd18/Vdd15 power good source come from BK_ISO bit in CKCU unit */ + PWRCU_VRDYSC_VPOR /*!< Vdd18/Vdd15 power good source come from Vdd18 power on reset */ +} PWRCU_VRDYSC_Enum; +#if (!LIBCFG_PWRCU_LDO_LEGACY) +/** + * @brief LDO operation mode selection + */ +typedef enum +{ + PWRCU_LDO_NORMAL = 0, /*!< The LDO is operated in normal current mode */ + PWRCU_LDO_LOWCURRENT /*!< The LDO is operated in low current mode */ +} PWRCU_LDOMODE_Enum; +/** + * @brief LDO output offset selection + */ +typedef enum +{ + PWRCU_LDO_DEFAULT = 0x00000000, /*!< The LDO default output voltage */ + PWRCU_LDO_OFFSET_DEC5P = 0x00000010, /*!< The LDO default output voltage offset -5% */ + PWRCU_LDO_OFFSET_ADD3P = 0x00000020, /*!< The LDO default output voltage offset +3% */ + PWRCU_LDO_OFFSET_ADD7P = 0x00000030, /*!< The LDO default output voltage offset +7% */ +} PWRCU_LDOFTRM_Enum; +#endif +/** + * @brief HSI ready counter bit length selection + */ +typedef enum +{ + PWRCU_HSIRCBL_4 = 0, /*!< 4 bits */ + PWRCU_HSIRCBL_5, /*!< 5 bits */ + PWRCU_HSIRCBL_6, /*!< 5 bits */ + PWRCU_HSIRCBL_7 /*!< 7 bits (Default) */ +} PWRCU_HSIRCBL_Enum; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Constants PWRCU exported constants + * @{ + */ + +/* Definitions of PWRCU_FLAG */ +#define PWRCU_FLAG_PWRPOR 0x0001 /*!< Backup domain power-on reset flag */ +#define PWRCU_FLAG_PD 0x0002 /*!< Power-Down flag */ +#define PWRCU_FLAG_WUP 0x0100 /*!< External WAKEUP pin flag */ + +#define PWRCU_FLAG_BAKPOR PWRCU_FLAG_PWRPOR + +/* check PWRCU_LVDS parameter */ +#define IS_PWRCU_LVDS(x) ((x == PWRCU_LVDS_LV1) || (x == PWRCU_LVDS_LV2) || \ + (x == PWRCU_LVDS_LV3) || (x == PWRCU_LVDS_LV4) || \ + (x == PWRCU_LVDS_LV5) || (x == PWRCU_LVDS_LV6) || \ + (x == PWRCU_LVDS_LV7) || (x == PWRCU_LVDS_LV8)) + +/* check PWRCU_BODRIS parameter */ +#define IS_PWRCU_BODRIS(x) ((x == PWRCU_BODRIS_RESET) || (x == PWRCU_BODRIS_INT)) + +/* check PWRCU_HSIRCBL parameter */ +#define IS_PWRCU_HSIRCBL(x) (x <= 3) + +/* check PWRCU_SLEEP_ENTRY parameter */ +#define IS_PWRCU_SLEEP_ENTRY(x) ((x == PWRCU_SLEEP_ENTRY_WFI) || (x == PWRCU_SLEEP_ENTRY_WFE)) + +/* check PWRCU_BAKREG parameter */ +#define IS_PWRCU_BAKREG(x) (x < 10) + +/* check PWRCU_VRDY_SRC parameter */ +#define IS_PWRCU_VRDYSC(x) ((x == PWRCU_VRDYSC_BKISO) || (x == PWRCU_VRDYSC_VPOR)) + +#if (!LIBCFG_PWRCU_LDO_LEGACY) +/* check PWRCU_LDOMODE parameter */ +#define IS_PWRCU_LDOMODE(x) ((x == PWRCU_LDO_NORMAL) || (x == PWRCU_LDO_LOWCURRENT)) +#if (!LIBCFG_NO_PWRCU_LDO_CFG_VOLTAGE) +/* check PWRCU_LDOFTRM parameter */ +#define IS_PWRCU_LDOFTRM(x) ((x == PWRCU_LDO_DEFAULT) || (x == PWRCU_LDO_OFFSET_DEC5P) || \ + (x == PWRCU_LDO_OFFSET_ADD3P) || (x == PWRCU_LDO_OFFSET_ADD7P)) +#endif +#endif +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Functions PWRCU exported functions + * @{ + */ +void PWRCU_DeInit(void); +PWRCU_Status PWRCU_CheckReadyAccessed(void); +u16 PWRCU_GetFlagStatus(void); +#if (!LIBCFG_NO_BACK_DOMAIN) +u32 PWRCU_ReadBackupRegister(PWRCU_BAKREG_Enum BAKREGx); +void PWRCU_WriteBackupRegister(PWRCU_BAKREG_Enum BAKREGx, u32 DATA); +#endif +void PWRCU_Sleep(PWRCU_SLEEP_ENTRY_Enum SleepEntry); +void PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_Enum SleepEntry); +void PWRCU_DeepSleep2(PWRCU_SLEEP_ENTRY_Enum SleepEntry); +void PWRCU_PowerDown(void); +void PWRCU_SetLVDS(PWRCU_LVDS_Enum Level); +#if (!LIBCFG_PWRCU_LDO_LEGACY) +void PWRCU_SetLDOFTRM(PWRCU_LDOFTRM_Enum VolOffset); +void PWRCU_LDOConfig(PWRCU_LDOMODE_Enum Sel); +#endif +void PWRCU_LVDCmd(ControlStatus NewState); +void PWRCU_BODCmd(ControlStatus NewState); +void PWRCU_BODRISConfig(PWRCU_BODRIS_Enum Selection); +FlagStatus PWRCU_GetLVDFlagStatus(void); +FlagStatus PWRCU_GetBODFlagStatus(void); +PWRCU_DMOSStatus PWRCU_GetDMOSStatus(void); +void PWRCU_DMOSCmd(ControlStatus NewState); +void PWRCU_VRDYSourceConfig(PWRCU_VRDYSC_Enum Sel); +void PWRCU_LVDIntWakeupConfig(ControlStatus NewState); +void PWRCU_LVDEventWakeupConfig(ControlStatus NewState); +void PWRCU_WakeupPinCmd(ControlStatus NewState); +void PWRCU_WakeupPinIntConfig(ControlStatus NewState); +void PWRCU_HSIReadyCounterBitLengthConfig(PWRCU_HSIRCBL_Enum BitLength); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rstcu.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rstcu.h new file mode 100644 index 0000000000..c6870ab8bf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rstcu.h @@ -0,0 +1,266 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_rstcu.h + * @version $Rev:: 2973 $ + * @date $Date:: 2023-10-30 #$ + * @brief The header file of the Reset Control Unit library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_RSTCU_H +#define __HT32F1XXXX_RSTCU_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup RSTCU + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Types RSTCU exported types + * @{ + */ + +/** + * @brief Enumeration of Global reset status. + */ +typedef enum +{ + RSTCU_FLAG_SYSRST = 0, + RSTCU_FLAG_EXTRST, + RSTCU_FLAG_WDTRST, + RSTCU_FLAG_PORST +} RSTCU_RSTF_TypeDef; + +/** + * @brief Definition of initial structure of peripheral reset. + */ +typedef union +{ + struct + { + /* Definitions of AHB peripheral reset */ + unsigned long PDMA :1; // Bit 0 + unsigned long :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 +#if (LIBCFG_CSIF) + unsigned long CSIF :1; // Bit 4 +#else + unsigned long :1; // Bit 4 +#endif + unsigned long USBD :1; // Bit 5 + unsigned long EBI :1; // Bit 6 + unsigned long CRC :1; // Bit 7 + + unsigned long PA :1; // Bit 8 + unsigned long PB :1; // Bit 9 + unsigned long PC :1; // Bit 10 + unsigned long PD :1; // Bit 11 +#if (LIBCFG_GPIOE) + unsigned long PE :1; // Bit 12 +#else + unsigned long :1; // Bit 12 +#endif +#if (LIBCFG_GPIOF) + unsigned long PF :1; // Bit 13 +#else + unsigned long :1; // Bit 13 +#endif +#if (LIBCFG_SDIO) + unsigned long SDIO :1; // Bit 14 +#else + unsigned long :1; // Bit 14 +#endif +#if (LIBCFG_AES) + unsigned long AES :1; // Bit 15 +#else + unsigned long :1; // Bit 15 +#endif + + unsigned long :1; // Bit 16 + unsigned long :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 + unsigned long :1; // Bit 22 + unsigned long :1; // Bit 23 + + unsigned long :1; // Bit 24 + unsigned long :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long :1; // Bit 28 + unsigned long :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB peripheral 0 reset */ + unsigned long I2C0 :1; // Bit 0 + unsigned long I2C1 :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long SPI0 :1; // Bit 4 + unsigned long SPI1 :1; // Bit 5 + unsigned long :1; // Bit 6 + unsigned long :1; // Bit 7 + + unsigned long USART0 :1; // Bit 8 + unsigned long USART1 :1; // Bit 9 + unsigned long UART0 :1; // Bit 10 + unsigned long UART1 :1; // Bit 11 + unsigned long :1; // Bit 12 + unsigned long :1; // Bit 13 + unsigned long AFIO :1; // Bit 14 + unsigned long EXTI :1; // Bit 15 + + unsigned long :1; // Bit 16 + unsigned long :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 + unsigned long :1; // Bit 22 + unsigned long :1; // Bit 23 + +#if (LIBCFG_SCI0) + unsigned long SCI0 :1; // Bit 24 +#else + unsigned long :1; // Bit 24 +#endif + unsigned long I2S :1; // Bit 25 + unsigned long :1; // Bit 26 +#if (LIBCFG_SCI1) + unsigned long SCI1 :1; // Bit 27 +#else + unsigned long :1; // Bit 27 +#endif + unsigned long :1; // Bit 28 + unsigned long :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB peripheral 1 reset */ + unsigned long MCTM0 :1; // Bit 0 + unsigned long MCTM1 :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long WDT :1; // Bit 4 + unsigned long :1; // Bit 5 + unsigned long :1; // Bit 6 + unsigned long :1; // Bit 7 + + unsigned long GPTM0 :1; // Bit 8 + unsigned long GPTM1 :1; // Bit 9 + unsigned long :1; // Bit 10 + unsigned long :1; // Bit 11 + unsigned long PWM0 :1; // Bit 12 + unsigned long :1; // Bit 13 + unsigned long :1; // Bit 14 + unsigned long :1; // Bit 15 + + unsigned long BFTM0 :1; // Bit 16 + unsigned long BFTM1 :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 +#if (LIBCFG_CMP_OPA) + unsigned long OPA0 :1; // Bit 22 +#else + unsigned long CMP :1; // Bit 22 +#endif +#if (LIBCFG_CMP_OPA) + unsigned long OPA1 :1; // Bit 23 +#else + unsigned long :1; // Bit 23 +#endif + + unsigned long ADC0 :1; // Bit 24 + unsigned long :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long SCTM0 :1; // Bit 28 + unsigned long SCTM1 :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + } Bit; + u32 Reg[3]; +} RSTCU_PeripReset_TypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Constants RSTCU exported constants + * @{ + */ + +/* Other definitions */ +#define IS_RSTCU_FLAG(FLAG) ((FLAG == RSTCU_FLAG_SYSRST) || \ + (FLAG == RSTCU_FLAG_EXTRST) || \ + (FLAG == RSTCU_FLAG_WDTRST) || \ + (FLAG == RSTCU_FLAG_PORST)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Functions RSTCU exported functions + * @{ + */ +FlagStatus RSTCU_GetResetFlagStatus(RSTCU_RSTF_TypeDef RSTCU_RSTF); +void RSTCU_ClearResetFlag(RSTCU_RSTF_TypeDef RSTCU_RSTF); +void RSTCU_ClearAllResetFlag(void); +void RSTCU_PeripReset(RSTCU_PeripReset_TypeDef Reset, ControlStatus Cmd); + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rtc.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rtc.h new file mode 100644 index 0000000000..f2e50b49f9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_rtc.h @@ -0,0 +1,245 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_rtc.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the RTC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_RTC_H +#define __HT32F1XXXX_RTC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup RTC + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Types RTC exported types + * @{ + */ + +/** + * @brief Selection of RTC clock source + */ +typedef enum +{ + RTC_SRC_LSI = 0, /*!< Low speed internal clock, about 32 kHz */ + RTC_SRC_LSE /*!< Low speed external 32768 Hz clock */ +} RTC_SRC_Enum; +/** + * @brief Selection of RTC LSE startup mode + */ +typedef enum +{ + RTC_LSESM_NORMAL = 0, /*!< Little power consumption but longer startup time. */ + RTC_LSESM_FAST /*!< Shortly startup time but higher power consumption. */ +} RTC_LSESM_Enum; +/** + * @brief Selection of RTC prescaler + */ +typedef enum +{ + RTC_RPRE_1 = 0x0000, /*!< CK_SECOND = CK_RTC */ + RTC_RPRE_2 = 0x0100, /*!< CK_SECOND = CK_RTC / 2 */ + RTC_RPRE_4 = 0x0200, /*!< CK_SECOND = CK_RTC / 4 */ + RTC_RPRE_8 = 0x0300, /*!< CK_SECOND = CK_RTC / 8 */ + RTC_RPRE_16 = 0x0400, /*!< CK_SECOND = CK_RTC / 16 */ + RTC_RPRE_32 = 0x0500, /*!< CK_SECOND = CK_RTC / 32 */ + RTC_RPRE_64 = 0x0600, /*!< CK_SECOND = CK_RTC / 64 */ + RTC_RPRE_128 = 0x0700, /*!< CK_SECOND = CK_RTC / 128 */ + RTC_RPRE_256 = 0x0800, /*!< CK_SECOND = CK_RTC / 256 */ + RTC_RPRE_512 = 0x0900, /*!< CK_SECOND = CK_RTC / 512 */ + RTC_RPRE_1024 = 0x0A00, /*!< CK_SECOND = CK_RTC / 1024 */ + RTC_RPRE_2048 = 0x0B00, /*!< CK_SECOND = CK_RTC / 2048 */ + RTC_RPRE_4096 = 0x0C00, /*!< CK_SECOND = CK_RTC / 4096 */ + RTC_RPRE_8192 = 0x0D00, /*!< CK_SECOND = CK_RTC / 8192 */ + RTC_RPRE_16384 = 0x0E00, /*!< CK_SECOND = CK_RTC / 16384 */ + RTC_RPRE_32768 = 0x0F00 /*!< CK_SECOND = CK_RTC / 32768 */ +} RTC_RPRE_Enum; +/** + * @brief Active polarity of RTC output + */ +typedef enum +{ + RTC_ROAP_HIGH = 0, /*!< Active level is high */ + RTC_ROAP_LOW /*!< Active level is low */ +} RTC_ROAP_Enum; +/** + * @brief Waveform mode of RTC output + */ +typedef enum +{ + RTC_ROWM_PULSE = 0, /*!< Pulse mode. */ + RTC_ROWM_LEVEL /*!< Level mode. */ +} RTC_ROWM_Enum; +/** + * @brief Waveform mode of RTC output + */ +typedef enum +{ + RTC_ROES_MATCH = 0, /*!< Selected RTC compare match. */ + RTC_ROES_SECOND /*!< Selected RTC second clock. */ +} RTC_ROES_Enum; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Constants RTC exported constants + * @{ + */ + +/** @defgroup RTC_WAKEUP Selection of RTC wakeup source + * @{ + */ +#define RTC_WAKEUP_CSEC 0x00000100 +#define RTC_WAKEUP_CM 0x00000200 +#define RTC_WAKEUP_OV 0x00000400 +/** + * @} + */ + +/** @defgroup RTC_IT RTC Selection of interrupt source + * @{ + */ +#define RTC_INT_CSEC 0x00000001 +#define RTC_INT_CM 0x00000002 +#define RTC_INT_OV 0x00000004 +/** + * @} + */ + +/** @defgroup RTC_FLAG RTC Definitions of flags + * @{ + */ +#define RTC_FLAG_CSEC 0x00000001 +#define RTC_FLAG_CM 0x00000002 +#define RTC_FLAG_OV 0x00000004 +/** + * @} + */ + +/** @defgroup RTC_Check_Parameter Selection of Vdd18 power good + * @{ + */ + +/** + * @brief Used to check RTC_SRC_Enum parameter + */ +#define IS_RTC_SRC(x) ((x == RTC_SRC_LSI) || (x == RTC_SRC_LSE)) +/** + * @brief Used to check RTC_LSESM_Enum parameter + */ +#define IS_RTC_LSESM(x) ((x == RTC_LSESM_NORMAL) || (x == RTC_LSESM_FAST)) +/** + * @brief Used to check RTC_RPRE_Enum parameter + */ +#define IS_RTC_PSC(x) ((x == RTC_RPRE_1) || (x == RTC_RPRE_2) || (x == RTC_RPRE_4) ||\ + (x == RTC_RPRE_8) || (x == RTC_RPRE_16) || (x == RTC_RPRE_32) ||\ + (x == RTC_RPRE_64) || (x == RTC_RPRE_128) || (x == RTC_RPRE_256) ||\ + (x == RTC_RPRE_512) || (x == RTC_RPRE_1024) || (x == RTC_RPRE_2048) ||\ + (x == RTC_RPRE_4096) || (x == RTC_RPRE_8192) || (x == RTC_RPRE_16384) ||\ + (x == RTC_RPRE_32768)) +/** + * @brief Used to check RTC_ROAP_Enum parameter + */ +#define IS_RTC_ROAP(x) ((x == RTC_ROAP_HIGH) || (x == RTC_ROAP_LOW)) +/** + * @brief Used to check RTC_ROWM_Enum parameter + */ +#define IS_RTC_ROWM(x) ((x == RTC_ROWM_PULSE) || (x == RTC_ROWM_LEVEL)) +/** + * @brief Used to check RTC_ROES_Enum parameter + */ +#define IS_RTC_ROES(x) ((x == RTC_ROES_MATCH) || (x == RTC_ROES_SECOND)) +/** + * @brief Used to check RTC_WAKEUP parameter + */ +#define IS_RTC_WAKEUP(x) ((((x) & (u32)0xFFFFF8FF) == 0x00) && ((x) != 0x00)) +/** + * @brief Used to check RTC_INT parameter + */ +#define IS_RTC_INT(x) ((((x) & (u32)0xFFFFFFF8) == 0x00) && ((x) != 0x00)) +/** + * @brief Used to check RTC_FLAG parameter + */ +#define IS_RTC_FLAG(x) ((((x) & (u32)0xFFFFFFF8) == 0x00) && ((x) != 0x00)) +/** + * @} + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Functions RTC exported functions + * @{ + */ +void RTC_DeInit(void); +void RTC_ClockSourceConfig(RTC_SRC_Enum Source); +void RTC_LSESMConfig(RTC_LSESM_Enum Mode); +void RTC_LSECmd(ControlStatus NewState); +void RTC_CMPCLRCmd(ControlStatus NewState); +void RTC_SetPrescaler(RTC_RPRE_Enum Psc); +u16 RTC_GetPrescaler(void); +void RTC_Cmd(ControlStatus NewState); +u32 RTC_GetCounter(void); +void RTC_SetCompare(u32 Compare); +u32 RTC_GetCompare(void); +void RTC_WakeupConfig(u32 RTC_WAKEUP, ControlStatus NewState); +void RTC_IntConfig(u32 RTC_INT, ControlStatus NewState); +u8 RTC_GetFlagStatus(void); +void RTC_OutConfig(RTC_ROWM_Enum WMode, RTC_ROES_Enum EventSel, RTC_ROAP_Enum Pol); +void RTC_OutCmd(ControlStatus NewState); +FlagStatus RTC_GetOutStatus(void); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sci.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sci.h new file mode 100644 index 0000000000..7118c1c42c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sci.h @@ -0,0 +1,278 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_sci.h + * @version $Rev:: 122 $ + * @date $Date:: 2017-06-13 #$ + * @brief The header file of the SCI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_SCI_H +#define __HT32F1XXXX_SCI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup SCI + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Types SCI exported types + * @{ + */ +typedef struct +{ + u32 SCI_Mode; + u32 SCI_Retry; + u32 SCI_Convention; + u32 SCI_CardPolarity; + u32 SCI_ClockPrescale; +} SCI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Constants SCI exported constants + * @{ + */ +#define SCI_MODE_MANUAL ((u32)0x00000000) +#define SCI_MODE_SCI ((u32)0x00000008) + +#define IS_SCI_MODE(MODE) ((MODE == SCI_MODE_MANUAL) || \ + (MODE == SCI_MODE_SCI)) + + +#define SCI_RETRY_NO ((u32)0x00000000) +#define SCI_RETRY_4 ((u32)0x00000012) +#define SCI_RETRY_5 ((u32)0x00000002) + +#define IS_SCI_RETRY(RETRY) ((RETRY == SCI_RETRY_NO) || \ + (RETRY == SCI_RETRY_4) || \ + (RETRY == SCI_RETRY_5)) + + +#define SCI_CONVENTION_DIRECT ((u32)0x00000000) +#define SCI_CONVENTION_INVERSE ((u32)0x00000001) + +#define IS_SCI_CONVENTION(CONVENTION) ((CONVENTION == SCI_CONVENTION_DIRECT) || \ + (CONVENTION == SCI_CONVENTION_INVERSE)) + + +#define SCI_CARDPOLARITY_LOW ((u32)0x00000000) +#define SCI_CARDPOLARITY_HIGH ((u32)0x00000040) + +#define IS_SCI_CARD_POLARITY(POLARITY) ((POLARITY == SCI_CARDPOLARITY_LOW) || \ + (POLARITY == SCI_CARDPOLARITY_HIGH)) + + +#define SCI_CLKPRESCALER_1 ((u32)0x00000000) +#define SCI_CLKPRESCALER_2 ((u32)0x00000001) +#define SCI_CLKPRESCALER_4 ((u32)0x00000002) +#define SCI_CLKPRESCALER_6 ((u32)0x00000003) +#define SCI_CLKPRESCALER_8 ((u32)0x00000004) +#define SCI_CLKPRESCALER_10 ((u32)0x00000005) +#define SCI_CLKPRESCALER_12 ((u32)0x00000006) +#define SCI_CLKPRESCALER_14 ((u32)0x00000007) +#define SCI_CLKPRESCALER_16 ((u32)0x00000008) +#define SCI_CLKPRESCALER_18 ((u32)0x00000009) +#define SCI_CLKPRESCALER_20 ((u32)0x0000000A) +#define SCI_CLKPRESCALER_22 ((u32)0x0000000B) +#define SCI_CLKPRESCALER_24 ((u32)0x0000000C) +#define SCI_CLKPRESCALER_26 ((u32)0x0000000D) +#define SCI_CLKPRESCALER_28 ((u32)0x0000000E) +#define SCI_CLKPRESCALER_30 ((u32)0x0000000F) +#define SCI_CLKPRESCALER_32 ((u32)0x00000010) +#define SCI_CLKPRESCALER_34 ((u32)0x00000011) +#define SCI_CLKPRESCALER_36 ((u32)0x00000012) +#define SCI_CLKPRESCALER_38 ((u32)0x00000013) +#define SCI_CLKPRESCALER_40 ((u32)0x00000014) +#define SCI_CLKPRESCALER_42 ((u32)0x00000015) +#define SCI_CLKPRESCALER_44 ((u32)0x00000016) +#define SCI_CLKPRESCALER_46 ((u32)0x00000017) +#define SCI_CLKPRESCALER_48 ((u32)0x00000018) +#define SCI_CLKPRESCALER_50 ((u32)0x00000019) +#define SCI_CLKPRESCALER_52 ((u32)0x0000001A) +#define SCI_CLKPRESCALER_54 ((u32)0x0000001B) +#define SCI_CLKPRESCALER_56 ((u32)0x0000001C) +#define SCI_CLKPRESCALER_58 ((u32)0x0000001D) +#define SCI_CLKPRESCALER_60 ((u32)0x0000001E) +#define SCI_CLKPRESCALER_62 ((u32)0x0000001F) +#define SCI_CLKPRESCALER_64 ((u32)0x00000020) +#define SCI_CLKPRESCALER_66 ((u32)0x00000021) +#define SCI_CLKPRESCALER_68 ((u32)0x00000022) +#define SCI_CLKPRESCALER_70 ((u32)0x00000023) +#define SCI_CLKPRESCALER_72 ((u32)0x00000024) +#define SCI_CLKPRESCALER_74 ((u32)0x00000025) +#define SCI_CLKPRESCALER_76 ((u32)0x00000026) +#define SCI_CLKPRESCALER_78 ((u32)0x00000027) +#define SCI_CLKPRESCALER_80 ((u32)0x00000028) +#define SCI_CLKPRESCALER_82 ((u32)0x00000029) +#define SCI_CLKPRESCALER_84 ((u32)0x0000002A) +#define SCI_CLKPRESCALER_86 ((u32)0x0000002B) +#define SCI_CLKPRESCALER_88 ((u32)0x0000002C) +#define SCI_CLKPRESCALER_90 ((u32)0x0000002D) +#define SCI_CLKPRESCALER_92 ((u32)0x0000002E) +#define SCI_CLKPRESCALER_94 ((u32)0x0000002F) +#define SCI_CLKPRESCALER_96 ((u32)0x00000030) +#define SCI_CLKPRESCALER_98 ((u32)0x00000031) +#define SCI_CLKPRESCALER_100 ((u32)0x00000032) +#define SCI_CLKPRESCALER_102 ((u32)0x00000033) +#define SCI_CLKPRESCALER_104 ((u32)0x00000034) +#define SCI_CLKPRESCALER_106 ((u32)0x00000035) +#define SCI_CLKPRESCALER_108 ((u32)0x00000036) +#define SCI_CLKPRESCALER_110 ((u32)0x00000037) +#define SCI_CLKPRESCALER_112 ((u32)0x00000038) +#define SCI_CLKPRESCALER_114 ((u32)0x00000039) +#define SCI_CLKPRESCALER_116 ((u32)0x0000003A) +#define SCI_CLKPRESCALER_118 ((u32)0x0000003B) +#define SCI_CLKPRESCALER_120 ((u32)0x0000003C) +#define SCI_CLKPRESCALER_122 ((u32)0x0000003D) +#define SCI_CLKPRESCALER_124 ((u32)0x0000003E) +#define SCI_CLKPRESCALER_126 ((u32)0x0000003F) + +#define IS_SCI_CLOCK_PRESCALER(PRESCALER) (PRESCALER <= 0x3F) + + +#define SCI_COMPENSATION_ENABLE ((u32)0x00008000) +#define SCI_COMPENSATION_DISABLE ((u32)0x00000000) + +#define IS_SCI_ETU_COMPENSATION(COMPENSATION) ((COMPENSATION == SCI_COMPENSATION_ENABLE) || \ + (COMPENSATION == SCI_COMPENSATION_DISABLE)) + + +#define SCI_CLK_HARDWARE ((u32)0x00000080) +#define SCI_CLK_SOFTWARE ((u32)0xFFFFFF7F) + +#define IS_SCI_CLK_MODE(MODE) ((MODE == SCI_CLK_HARDWARE) || \ + (MODE == SCI_CLK_SOFTWARE)) + + +#define SCI_CLK_HIGH ((u32)0x00000004) +#define SCI_CLK_LOW ((u32)0xFFFFFFFB) + +#define IS_SCI_CLK(CLK) ((CLK == SCI_CLK_HIGH) || \ + (CLK == SCI_CLK_LOW)) + + +#define SCI_DIO_HIGH ((u32)0x00000008) +#define SCI_DIO_LOW ((u32)0xFFFFFFF7) + +#define IS_SCI_DIO(DIO) ((DIO == SCI_DIO_HIGH) || \ + (DIO == SCI_DIO_LOW)) + + +#define SCI_INT_PAR ((u32)0x00000001) +#define SCI_INT_RXC ((u32)0x00000002) +#define SCI_INT_TXC ((u32)0x00000004) +#define SCI_INT_WT ((u32)0x00000008) +#define SCI_INT_CARD ((u32)0x00000040) +#define SCI_INT_TXBE ((u32)0x00000080) +#define SCI_INT_ALL ((u32)0x000000CF) + +#define IS_SCI_INT(INT) (((INT & 0xFFFFFF30) == 0x0) && (INT != 0)) + + + +#define SCI_FLAG_PAR ((u32)0x00000001) +#define SCI_FLAG_RXC ((u32)0x00000002) +#define SCI_FLAG_TXC ((u32)0x00000004) +#define SCI_FLAG_WT ((u32)0x00000008) +#define SCI_FLAG_CARD ((u32)0x00000040) +#define SCI_FLAG_TXBE ((u32)0x00000080) + +#define IS_SCI_FLAG(FLAG) ((FLAG == SCI_FLAG_PAR) || \ + (FLAG == SCI_FLAG_RXC) || \ + (FLAG == SCI_FLAG_TXC) || \ + (FLAG == SCI_FLAG_WT) || \ + (FLAG == SCI_FLAG_CARD) || \ + (FLAG == SCI_FLAG_TXBE)) + +#define IS_SCI_CLEAR_FLAG(FLAG) ((FLAG == SCI_FLAG_PAR) || \ + (FLAG == SCI_FLAG_TXC) || \ + (FLAG == SCI_FLAG_WT)) + + +#define SCI_PDMAREQ_TX ((u32)0x00000100) +#define SCI_PDMAREQ_RX ((u32)0x00000200) + +#define IS_SCI_PDMA_REQ(REQ) (((REQ & 0xFFFFFCFF) == 0x0) && (REQ != 0)) + + +#define IS_SCI_ETU(ETU) ((ETU >= 12) & (ETU <= 2047)) + +#define IS_SCI_GUARDTIME(GUARDTIME) ((GUARDTIME >= 11) & (GUARDTIME <= 511)) + +#define IS_SCI_WAITING_TIME(TIME) ((TIME >= 372) & (TIME <= 16777215)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Functions SCI exported functions + * @{ + */ +void SCI_DeInit(HT_SCI_TypeDef* SCIx); +void SCI_Init(HT_SCI_TypeDef* SCIx, SCI_InitTypeDef* SCI_InitStruct); +void SCI_StructInit(SCI_InitTypeDef* SCI_InitStruct); +void SCI_Cmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState); +void SCI_ETUConfig(HT_SCI_TypeDef* SCIx, u32 SCI_ETU, u32 SCI_Compensation); +void SCI_SetGuardTimeValue(HT_SCI_TypeDef* SCIx, u16 SCI_GuardTime); +void SCI_SetWaitingTimeValue(HT_SCI_TypeDef* SCIx, u32 SCI_WaitingTime); +void SCI_WaitingTimeCounterCmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState); +void SCI_SendData(HT_SCI_TypeDef* SCIx, u8 SCI_Data); +u8 SCI_ReceiveData(HT_SCI_TypeDef* SCIx); +void SCI_ClockModeConfig(HT_SCI_TypeDef* SCIx, u32 SCI_CLKMode); +void SCI_SoftwareClockCmd(HT_SCI_TypeDef* SCIx, u32 SCI_CLK); +void SCI_OutputDIO(HT_SCI_TypeDef* SCIx, u32 SCI_DIO); +void SCI_IntConfig(HT_SCI_TypeDef* SCIx, u32 SCI_Int, ControlStatus NewState); +FlagStatus SCI_GetFlagStatus(HT_SCI_TypeDef* SCIx, u32 SCI_Flag); +void SCI_ClearFlag(HT_SCI_TypeDef* SCIx, u32 SCI_Flag); +void SCI_PDMACmd(HT_SCI_TypeDef* SCIx, u32 SCI_PDMAREQ, ControlStatus NewState); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sdio.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sdio.h new file mode 100644 index 0000000000..4a62ce7db4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_sdio.h @@ -0,0 +1,413 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_sdio.h + * @version $Rev:: 2458 $ + * @date $Date:: 2021-08-05 #$ + * @brief The header file of the SDIO library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_SDIO_H +#define __HT32F1XXXX_SDIO_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup SDIO + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup SDIO_Exported_Types SDIO exported types + * @{ + */ +typedef struct +{ + u32 SDIO_ClockDiv; /*!< Specify the SDIO clock divider value. + This parameter can be a value between 1 and 256. */ + + u32 SDIO_ClockPeriod; /*!< Specify whether SDIO clock has longer or shorter low period + when the SDIO clock divider value is odd. + This parameter can be a value of @ref SDIO_Clock_Period */ + + u32 SDIO_ClockPowerSave; /*!< Specify whether SDIO clock output is enabled or disabled + when the bus is idle. + This parameter can be a value of @ref SDIO_Clock_Power_Save */ + + u32 SDIO_BusWide; /*!< Specify the SDIO bus width. + This parameter can be a value of @ref SDIO_Bus_Wide */ + + u32 SDIO_BusMode; /*!< Specify the SDIO bus Mode. + This parameter can be a value of @ref SDIO_Bus_Mode */ +} SDIO_InitTypeDef; + + +typedef struct +{ + u32 SDIO_Argument; /*!< Specify the SDIO command argument which is sent + to a card as part of a command message. If a command + contains an argument, it must be loaded into this register + before writing the command to the command register */ + + u32 SDIO_CmdIndex; /*!< Specify the SDIO command index. It must be lower than 0x40. */ + + u32 SDIO_Response; /*!< Specify the SDIO response type. + This parameter can be a value of @ref SDIO_Response_Type */ + + u32 SDIO_DatPresent; /*!< Specify whether data is present on the SDIO data line + after SDIO command or not. + This parameter can be a value of @ref SDIO_Data_Present */ + + u32 SDIO_CmdIdxChk; /*!< Specify whether SDIO command index check function is enabled or not. + This parameter can be a value of @ref SDIO_CmdIdx_Check */ + + u32 SDIO_CmdCrcChk; /*!< Specify whether SDIO command CRC check function is enabled or not. + This parameter can be a value of @ref SDIO_CmdCrc_Check */ +} SDIO_CmdInitTypeDef; + + +typedef struct +{ + u32 SDIO_DataBlockCount; /*!< Specify the number of data block count to be transferred. + This parameter can be a value between 1 and 65535. */ + + u32 SDIO_DataBlockSize; /*!< Specify the data block size for block transfer. + This parameter can be a value between 1 and 2048. */ + + u32 SDIO_TransferDir; /*!< Specify the data transfer direction, whether the transfer + is a read or write. + This parameter can be a value of @ref SDIO_Transfer_Direction */ + + u32 SDIO_TransferMode; /*!< Specify whether data transfer is in single block or multi-block mode. + This parameter can be a value of @ref SDIO_Transfer_Mode */ + + u32 SDIO_DataTimeOut; /*!< Specify the data timeout period in card bus clock periods. + This parameter can be a value between 0x1 and 0x00ffffff. */ + +} SDIO_DataInitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup SDIO_Exported_Constants SDIO exported constants + * @{ + */ + +/** @defgroup SDIO_Clock_Div SDIO Clock Div + * @{ + */ +#define IS_SDIO_CLOC_DIV(DIV) ((DIV > 0) && (DIV < 256)) +/** + * @} + */ + +/** @defgroup SDIO_Clock_Period SDIO Clock Period + * @{ + */ +#define SDIO_Clock_LowPeriod_Shorter (0x00000000) +#define SDIO_Clock_LowPeriod_Longer (0x00000008) + +#define IS_SDIO_CLOCK_PERIOD(PERIOD) (((PERIOD) == SDIO_Clock_LowPeriod_Shorter) || \ + ((PERIOD) == SDIO_Clock_LowPeriod_Longer)) +/** + * @} + */ + +/** @defgroup SDIO_Clock_Power_Save SDIO Clock Power Save + * @{ + */ +#define SDIO_Clock_PowerSave_Disable (0x00000000) +#define SDIO_Clock_PowerSave_StopLow (0x00000002) +#define SDIO_Clock_PowerSave_StopHigh (0x00000003) + +#define IS_SDIO_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDIO_Clock_PowerSave_Disable) || \ + ((SAVE) == SDIO_Clock_PowerSave_StopLow) || \ + ((SAVE) == SDIO_Clock_PowerSave_StopHigh)) +/** + * @} + */ + +/** @defgroup SDIO_Bus_Wide SDIO Bus Wide + * @{ + */ +#define SDIO_BusWide_1b (0x00000000) +#define SDIO_BusWide_4b (0x00000002) + +#define IS_SDIO_BUS_WIDE(WIDE) (((WIDE) == SDIO_BusWide_1b) || \ + ((WIDE) == SDIO_BusWide_4b)) +/** + * @} + */ + +/** @defgroup SDIO_Bus_Mode SDIO Bus Mode + * @{ + */ +#define SDIO_BusMode_NormalSpeed (0x00000000) +#define SDIO_BusMode_HighSpeed (0x00000004) + +#define IS_SDIO_BUS_MODE(MODE) (((MODE) == SDIO_BusMode_NormalSpeed) || \ + ((MODE) == SDIO_BusMode_HighSpeed)) +/** + * @} + */ + +/** @defgroup SDIO_Command_Index SDIO Command Index + * @{ + */ +#define IS_SDIO_CMD_INDEX(INDEX) ((INDEX) < 0x40) +/** + * @} + */ + +/** @defgroup SDIO_Response_Type SDIO Response Type + * @{ + */ +#define SDIO_Response_No (0x00000000) +#define SDIO_Response_Long (0x00000001) +#define SDIO_Response_Short (0x00000002) + +#define IS_SDIO_RESPONSE(RESPONSE) (((RESPONSE) == SDIO_Response_No) || \ + ((RESPONSE) == SDIO_Response_Short) || \ + ((RESPONSE) == SDIO_Response_Long)) +/** + * @} + */ + +/** @defgroup SDIO_Data_Present SDIO Data Present + * @{ + */ +#define SDIO_Data_Present_No (0x00000000) +#define SDIO_Data_Present_Yes (0x00000020) + +#define IS_SDIO_DATA_PRESENT(PRESENT) (((PRESENT) == SDIO_Data_Present_No) || \ + ((PRESENT) == SDIO_Data_Present_Yes)) +/** + * @} + */ + +/** @defgroup SDIO_CmdIdx_Check SDIO CmdIdx Check + * @{ + */ +#define SDIO_CmdIdxChk_No (0x00000000) +#define SDIO_CmdIdxChk_Yes (0x00000010) + +#define IS_SDIO_CMD_IDX_CHK(CHK) (((CHK) == SDIO_CmdIdxChk_No) || \ + ((CHK) == SDIO_CmdIdxChk_Yes)) +/** + * @} + */ + +/** @defgroup SDIO_CmdCrc_Check SDIO CmdCrc Check + * @{ + */ +#define SDIO_CmdCrcChk_No (0x00000000) +#define SDIO_CmdCrcChk_Yes (0x00000008) + +#define IS_SDIO_CMD_CRC_CHK(CHK) (((CHK) == SDIO_CmdCrcChk_No) || \ + ((CHK) == SDIO_CmdCrcChk_Yes)) +/** + * @} + */ + +/** @defgroup SDIO_Data_Block_Count SDIO Data Block Count + * @{ + */ +#define IS_SDIO_DATA_BLOCK_COUNT(COUNT) ((COUNT > 0) && (COUNT <= 65535)) +/** + * @} + */ + +/** @defgroup SDIO_Data_Block_Size SDIO Data Block Size + * @{ + */ +#define IS_SDIO_DATA_BLOCK_SIZE(SIZE) ((SIZE > 0) && (SIZE <= 2048)) +/** + * @} + */ + +/** @defgroup SDIO_Transfer_Mode SDIO Transfer Mode + * @{ + */ +#define SDIO_SingleBlock_Transfer (0x00000000) +#define SDIO_MultiBlock_Transfer (0x00000022) +#define SDIO_SingleBlock_DMA_Transfer (0x00000100) +#define SDIO_MultiBlock_DMA_Transfer (0x00000122) + +#define IS_SDIO_TRANSFER_MODE(MODE) (((MODE) == SDIO_SingleBlock_Transfer) || \ + ((MODE) == SDIO_MultiBlock_Transfer) || \ + ((MODE) == SDIO_SingleBlock_DMA_Transfer) || \ + ((MODE) == SDIO_MultiBlock_DMA_Transfer)) +/** + * @} + */ +/** @defgroup SDIO_Transfer_Direction SDIO Transfer Direction + * @{ + */ +#define SDIO_TransferDir_ToCard (0x00000000) +#define SDIO_TransferDir_ToSDIO (0x00000010) + +#define IS_SDIO_TRANSFER_DIR(DIR) (((DIR) == SDIO_TransferDir_ToCard) || \ + ((DIR) == SDIO_TransferDir_ToSDIO)) +/** + * @} + */ + + +/** @defgroup SDIO_Data_TimeOut SDIO Data TimeOut + * @{ + */ +#define IS_SDIO_DATA_TIMEOUT(TIME) ((TIME > 0) && (TIME <= 0x00ffffff)) +/** + * @} + */ + +/** @defgroup SDIO_Flags SDIO Flags + * @{ + */ +#define SDIO_FLAG_CMD_SEND (0x00000001) +#define SDIO_FLAG_TRANS_END (0x00000002) +#define SDIO_FLAG_BUF_OVERFLOW (0x00000008) +#define SDIO_FLAG_BUF_UNDERFLOW (0x00000010) +#define SDIO_FLAG_BUF_HALF (0x00000020) +#define SDIO_FLAG_BUF_FULL (0x00000040) +#define SDIO_FLAG_BUF_EMPTY (0x00000080) +#define SDIO_FLAG_ERR (0x00008000) +#define SDIO_FLAG_CMD_TIMEOUT (0x00010000) +#define SDIO_FLAG_CMD_CRCERR (0x00020000) +#define SDIO_FLAG_CMD_ENDERR (0x00040000) +#define SDIO_FLAG_CMD_IDXERR (0x00080000) +#define SDIO_FLAG_DATA_TIMEOUT (0x00100000) +#define SDIO_FLAG_DATA_CRCERR (0x00200000) +#define SDIO_FLAG_DATA_ENDERR (0x00400000) +#define SDIO_FLAG_CARD_INT (0x01000000) +#define SDIO_FLAG_DAT_ERR (0x02000000) +#define SDIO_FLAG_CMD_ERR (0x04000000) + +#define IS_SDIO_FLAG(FLAG) (((FLAG) != 0) && (((FLAG) & 0x077F80FB) != 0)) +/** + * @} + */ + +/** @defgroup SDIO_Response_Registers SDIO Response Registers + * @{ + */ +#define SDIO_RESP1 (0x00000000) +#define SDIO_RESP2 (0x00000004) +#define SDIO_RESP3 (0x00000008) +#define SDIO_RESP4 (0x0000000C) + +#define IS_SDIO_RESP(RESP) (((RESP) == SDIO_RESP1) || \ + ((RESP) == SDIO_RESP2) || \ + ((RESP) == SDIO_RESP3) || \ + ((RESP) == SDIO_RESP4)) +/** + * @} + */ + +/** @defgroup SDIO_Interrupt_sources SDIO Interrupt sources + * @{ + */ +#define SDIO_INT_CMD_SEND (0x00000001) +#define SDIO_INT_TRANS_END (0x00000002) +#define SDIO_INT_BUF_OVERFLOW (0x00000008) +#define SDIO_INT_BUF_UNDERFLOW (0x00000010) +#define SDIO_INT_BUF_HALF (0x00000020) +#define SDIO_INT_BUF_FULL (0x00000040) +#define SDIO_INT_BUF_EMPTY (0x00000080) +#define SDIO_INT_CMD_TIMEOUT (0x00010000) +#define SDIO_INT_CMD_CRCERR (0x00020000) +#define SDIO_INT_CMD_IDXERR (0x00080000) +#define SDIO_INT_DATA_TIMEOUT (0x00100000) +#define SDIO_INT_DATA_CRCERR (0x00200000) +#define SDIO_INT_CARD_INT (0x01000000) + +#define IS_SDIO_INT(INT) (((INT) != 0) && (((INT) & 0x013B00FB) != 0)) +/** + * @} + */ + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup SDIO_Exported_Macro SDIO exported macro + * @{ + */ +#define RESET_CPSM() {\ + HT_SDIO->SWRST |= (1UL << 1);\ + while (HT_SDIO->SWRST & (1UL << 1));\ + } + +#define RESET_DPSM() {\ + HT_SDIO->SWRST |= (1UL << 2);\ + while (HT_SDIO->SWRST & (1UL << 2));\ + } +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SDIO_Exported_Functions SDIO exported functions + * @{ + */ +void SDIO_DeInit(void); +void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct); +void SDIO_ClockCmd(ControlStatus Cmd); +u32 SDIO_ReadData(void); +void SDIO_WriteData(u32 Data); +u32 SDIO_GetFIFOCount(void); +void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct); +u32 SDIO_GetResponse(u32 SDIO_RESP); +void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct); +void SDIO_FlagConfig(u32 SDIO_FLAG, ControlStatus NewState); +FlagStatus SDIO_GetFlagStatus(u32 SDIO_FLAG); +void SDIO_ClearFlag(u32 SDIO_FLAG); +void SDIO_IntConfig(u32 SDIO_INT, ControlStatus NewState); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_spi.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_spi.h new file mode 100644 index 0000000000..d69c32afbf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_spi.h @@ -0,0 +1,297 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_spi.h + * @version $Rev:: 2797 $ + * @date $Date:: 2022-11-28 #$ + * @brief The header file of the SPI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_SPI_H +#define __HT32F1XXXX_SPI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup SPI + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Types SPI exported types + * @{ + */ +typedef u16 SPI_DataTypeDef; +typedef u16 SPI_TimeoutTypeDef; + +typedef struct +{ + u32 SPI_Mode; + u32 SPI_FIFO; + u32 SPI_DataLength; + u32 SPI_SELMode; + u32 SPI_SELPolarity; + u32 SPI_CPOL; + u32 SPI_CPHA; + u32 SPI_FirstBit; + u32 SPI_RxFIFOTriggerLevel; + u32 SPI_TxFIFOTriggerLevel; + u32 SPI_ClockPrescaler; +} SPI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Constants SPI exported constants + * @{ + */ +#define SPI_FIFO_ENABLE ((u32)0x00000400) +#define SPI_FIFO_DISABLE ((u32)0x00000000) + +#define IS_SPI_FIFO_SET(FIFO) ((FIFO == SPI_FIFO_ENABLE) || \ + (FIFO == SPI_FIFO_DISABLE)) + +#define SPI_DATALENGTH_1 ((u32)0x00000001) +#define SPI_DATALENGTH_2 ((u32)0x00000002) +#define SPI_DATALENGTH_3 ((u32)0x00000003) +#define SPI_DATALENGTH_4 ((u32)0x00000004) +#define SPI_DATALENGTH_5 ((u32)0x00000005) +#define SPI_DATALENGTH_6 ((u32)0x00000006) +#define SPI_DATALENGTH_7 ((u32)0x00000007) +#define SPI_DATALENGTH_8 ((u32)0x00000008) +#define SPI_DATALENGTH_9 ((u32)0x00000009) +#define SPI_DATALENGTH_10 ((u32)0x0000000A) +#define SPI_DATALENGTH_11 ((u32)0x0000000B) +#define SPI_DATALENGTH_12 ((u32)0x0000000C) +#define SPI_DATALENGTH_13 ((u32)0x0000000D) +#define SPI_DATALENGTH_14 ((u32)0x0000000E) +#define SPI_DATALENGTH_15 ((u32)0x0000000F) +#define SPI_DATALENGTH_16 ((u32)0x00000000) + +#define IS_SPI_DATALENGTH(DATALENGTH) ((DATALENGTH <= 0xF)) + + +#define SPI_MASTER ((u32)0x00004000) +#define SPI_SLAVE ((u32)0x00000000) + +#define IS_SPI_MODE(MODE) ((MODE == SPI_MASTER) || \ + (MODE == SPI_SLAVE)) + + +#define SPI_SEL_HARDWARE ((u32)0x00002000) +#define SPI_SEL_SOFTWARE ((u32)0x00000000) + +#define IS_SPI_SEL_MODE(SELMODE) ((SELMODE == SPI_SEL_HARDWARE) || \ + (SELMODE == SPI_SEL_SOFTWARE)) + + +#define SPI_SEL_ACTIVE ((u32)0x00000010) +#define SPI_SEL_INACTIVE ((u32)0xFFFFFFEF) + +#define IS_SPI_SOFTWARE_SEL(SEL) ((SEL == SPI_SEL_ACTIVE) || \ + (SEL == SPI_SEL_INACTIVE)) + + +#define SPI_SELPOLARITY_HIGH ((u32)0x00000800) +#define SPI_SELPOLARITY_LOW ((u32)0x00000000) + +#define IS_SPI_SEL_POLARITY(POLARITY) ((POLARITY == SPI_SELPOLARITY_HIGH) || \ + (POLARITY == SPI_SELPOLARITY_LOW)) + + +#define SPI_CPOL_HIGH ((u32)0x00000400) +#define SPI_CPOL_LOW ((u32)0x00000000) + +#define IS_SPI_CPOL(CPOL) ((CPOL == SPI_CPOL_HIGH) || \ + (CPOL == SPI_CPOL_LOW)) + + +#define SPI_CPHA_FIRST ((u32)0x00000000) +#define SPI_CPHA_SECOND ((u32)0x00000001) + +#define IS_SPI_CPHA(CPHA) ((CPHA == SPI_CPHA_FIRST) || \ + (CPHA == SPI_CPHA_SECOND)) + + +#define SPI_FIRSTBIT_LSB ((u32)0x00001000) +#define SPI_FIRSTBIT_MSB ((u32)0x00000000) + +#define IS_SPI_FIRST_BIT(BIT) ((BIT == SPI_FIRSTBIT_LSB) || \ + (BIT == SPI_FIRSTBIT_MSB)) + + +#define SPI_FLAG_TXBE ((u32)0x00000001) +#define SPI_FLAG_TXE ((u32)0x00000002) +#define SPI_FLAG_RXBNE ((u32)0x00000004) +#define SPI_FLAG_WC ((u32)0x00000008) +#define SPI_FLAG_RO ((u32)0x00000010) +#define SPI_FLAG_MF ((u32)0x00000020) +#define SPI_FLAG_SA ((u32)0x00000040) +#define SPI_FLAG_TOUT ((u32)0x00000080) +#define SPI_FLAG_BUSY ((u32)0x00000100) + +#define IS_SPI_FLAG(FLAG) ((FLAG == SPI_FLAG_TXBE) || \ + (FLAG == SPI_FLAG_TXE) || \ + (FLAG == SPI_FLAG_RXBNE) || \ + (FLAG == SPI_FLAG_WC) || \ + (FLAG == SPI_FLAG_RO) || \ + (FLAG == SPI_FLAG_MF) || \ + (FLAG == SPI_FLAG_SA) || \ + (FLAG == SPI_FLAG_TOUT) || \ + (FLAG == SPI_FLAG_BUSY)) + +#define IS_SPI_FLAG_CLEAR(CLEAR) ((CLEAR == SPI_FLAG_WC) || \ + (CLEAR == SPI_FLAG_RO) || \ + (CLEAR == SPI_FLAG_MF) || \ + (CLEAR == SPI_FLAG_SA) || \ + (CLEAR == SPI_FLAG_TOUT)) + + +#define SPI_INT_TXBE ((u32)0x00000001) +#define SPI_INT_TXE ((u32)0x00000002) +#define SPI_INT_RXBNE ((u32)0x00000004) +#define SPI_INT_WC ((u32)0x00000008) +#define SPI_INT_RO ((u32)0x00000010) +#define SPI_INT_MF ((u32)0x00000020) +#define SPI_INT_SA ((u32)0x00000040) +#define SPI_INT_TOUT ((u32)0x00000080) +#define SPI_INT_ALL ((u32)0x000000FF) + +#define IS_SPI_INT(SPI_INT) (((SPI_INT & 0xFFFFFF00) == 0x0) && (SPI_INT != 0x0)) + + +#define SPI_FIFO_TX ((u32)0x00000100) +#define SPI_FIFO_RX ((u32)0x00000200) + +#define IS_SPI_FIFO_DIRECTION(DIRECTION) (((DIRECTION & 0xFFFFFCFF) == 0) && (DIRECTION != 0)) + + +#define SPI_PDMAREQ_TX ((u32)0x00000002) +#define SPI_PDMAREQ_RX ((u32)0x00000004) + +#define IS_SPI_PDMA_REQ(REQ) (((REQ & 0xFFFFFFF9) == 0x0) && (REQ != 0x0)) + + +#define IS_SPI(SPI) ((SPI == HT_SPI0) || (SPI == HT_SPI1)) + +#define IS_SPI_DATA(DATA) (DATA <= 0xffff) + +#define IS_SPI_FIFO_LEVEL(LEVEL) (LEVEL <= 8) + +#define IS_SPI_CLOCK_PRESCALER(PRESCALER) (PRESCALER >= 2) + +#define SPI_GUADTIME_1_SCK ((u16)0x0000) +#define SPI_GUADTIME_2_SCK ((u16)0x0001) +#define SPI_GUADTIME_3_SCK ((u16)0x0002) +#define SPI_GUADTIME_4_SCK ((u16)0x0003) +#define SPI_GUADTIME_5_SCK ((u16)0x0004) +#define SPI_GUADTIME_6_SCK ((u16)0x0005) +#define SPI_GUADTIME_7_SCK ((u16)0x0006) +#define SPI_GUADTIME_8_SCK ((u16)0x0007) +#define SPI_GUADTIME_9_SCK ((u16)0x0008) +#define SPI_GUADTIME_10_SCK ((u16)0x0009) +#define SPI_GUADTIME_11_SCK ((u16)0x000A) +#define SPI_GUADTIME_12_SCK ((u16)0x000B) +#define SPI_GUADTIME_13_SCK ((u16)0x000C) +#define SPI_GUADTIME_14_SCK ((u16)0x000D) +#define SPI_GUADTIME_15_SCK ((u16)0x000E) +#define SPI_GUADTIME_16_SCK ((u16)0x000F) + +#define IS_SPI_GUADTIME(GUADTIMEPERIOD) ((GUADTIMEPERIOD <= 0x000F)) + + +#define SPI_SELHOLDTIME_HALF_SCK ((u16)0x0000) +#define SPI_SELHOLDTIME_1_SCK ((u16)0x0001) +#define SPI_SELHOLDTIME_1_HALF_SCK ((u16)0x0002) +#define SPI_SELHOLDTIME_2_SCK ((u16)0x0003) +#define SPI_SELHOLDTIME_2_HALF_SCK ((u16)0x0004) +#define SPI_SELHOLDTIME_3_SCK ((u16)0x0005) +#define SPI_SELHOLDTIME_3_HALF_SCK ((u16)0x0006) +#define SPI_SELHOLDTIME_4_SCK ((u16)0x0007) +#define SPI_SELHOLDTIME_4_HALF_SCK ((u16)0x0008) +#define SPI_SELHOLDTIME_5_SCK ((u16)0x0009) +#define SPI_SELHOLDTIME_5_HALF_SCK ((u16)0x000A) +#define SPI_SELHOLDTIME_6_SCK ((u16)0x000B) +#define SPI_SELHOLDTIME_6_HALF_SCK ((u16)0x000C) +#define SPI_SELHOLDTIME_7_SCK ((u16)0x000D) +#define SPI_SELHOLDTIME_7_HALF_SCK ((u16)0x000E) +#define SPI_SELHOLDTIME_8_SCK ((u16)0x000F) + +#define IS_SPI_SELHOLDTIME(SELHOLDTIME) ((SELHOLDTIME <= 0x000F)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Functions SPI exported functions + * @{ + */ +void SPI_DeInit(HT_SPI_TypeDef* SPIx); +void SPI_Init(HT_SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct); +void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct); +void SPI_Cmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void SPI_SELOutputCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void SPI_FIFOCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void SPI_SetDataLength(HT_SPI_TypeDef* SPIx, u16 SPI_DataLength); +void SPI_SELModeConfig(HT_SPI_TypeDef* SPIx, u32 SPI_SELMode); +void SPI_SoftwareSELCmd(HT_SPI_TypeDef* SPIx, u32 SPI_SoftwareSEL); +void SPI_SendData(HT_SPI_TypeDef* SPIx, SPI_DataTypeDef SPI_Data); +SPI_DataTypeDef SPI_ReceiveData(HT_SPI_TypeDef* SPIx); +void SPI_SetTimeOutValue(HT_SPI_TypeDef* SPIx, SPI_TimeoutTypeDef SPI_Timeout); +void SPI_IntConfig(HT_SPI_TypeDef* SPIx, u32 SPI_Int, ControlStatus NewState); +FlagStatus SPI_GetFlagStatus(HT_SPI_TypeDef* SPIx, u32 SPI_Flag); +u8 SPI_GetFIFOStatus(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection); +void SPI_ClearFlag(HT_SPI_TypeDef* SPIx, u32 SPI_FlagClear); +void SPI_FIFOTriggerLevelConfig(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection, u8 SPI_FIFOLevel); +void SPI_PDMACmd(HT_SPI_TypeDef* SPIx, u32 SPI_PDMAREQ, ControlStatus NewState); +void SPI_DUALCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void SPI_GUARDTCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void SPI_GUARDTConfig(HT_SPI_TypeDef* SPIx, u32 Guard_Time); +void SPI_SELHTConfig(HT_SPI_TypeDef* SPIx, u32 CS_Hold_Time); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm.h new file mode 100644 index 0000000000..b15bbbdbd0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm.h @@ -0,0 +1,623 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_tm.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the TM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_TM_H +#define __HT32F1XXXX_TM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup TM + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Types TM exported types + * @{ + */ +/** + * @brief Enumeration of TM counter mode. + */ +typedef enum +{ + TM_CNT_MODE_UP = 0x00000000, /*!< Edge up-counting mode */ + TM_CNT_MODE_CA1 = 0x00010000, /*!< Center-align mode 1 */ + TM_CNT_MODE_CA2 = 0x00020000, /*!< Center-align mode 2 */ + TM_CNT_MODE_CA3 = 0x00030000, /*!< Center-align mode 3 */ + TM_CNT_MODE_DOWN = 0x01000000 /*!< Edge down-counting mode */ +} TM_CNT_MODE_Enum; +/** + * @brief Enumeration of TM prescaler reload time. + */ +typedef enum +{ + TM_PSC_RLD_UPDATE = 0x0000, /*!< Reload prescaler at next update event */ + TM_PSC_RLD_IMMEDIATE = 0x0100 /*!< Reload prescaler immediately */ +} TM_PSC_RLD_Enum; +/** + * @brief Enumeration of TM channel output mode. + */ +typedef enum +{ + TM_OM_MATCH_NOCHANGE = 0x0000, /*!< TM channel output no change on match */ + TM_OM_MATCH_INACTIVE = 0x0001, /*!< TM channel output inactive level on match */ + TM_OM_MATCH_ACTIVE = 0x0002, /*!< TM channel output active level on match */ + TM_OM_MATCH_TOGGLE = 0x0003, /*!< TM channel output toggle on match */ + TM_OM_FORCED_INACTIVE = 0x0004, /*!< TM channel output forced inactive level */ + TM_OM_FORCED_ACTIVE = 0x0005, /*!< TM channel output forced active level */ + TM_OM_PWM1 = 0x0006, /*!< TM channel pwm1 output mode */ + TM_OM_PWM2 = 0x0007, /*!< TM channel pwm2 output mode */ + TM_OM_ASYMMETRIC_PWM1 = 0x0106, /*!< TM channel asymmetric pwm1 output mode */ + TM_OM_ASYMMETRIC_PWM2 = 0x0107 /*!< TM channel asymmetric pwm2 output mode */ +} TM_OM_Enum; +/** + * @brief Enumeration of TM channel capture source selection. + */ +typedef enum +{ + TM_CHCCS_DIRECT = 0x00010000, /*!< TM channel capture selection direct input */ + TM_CHCCS_INDIRECT = 0x00020000, /*!< TM channel capture selection indirect input */ + TM_CHCCS_TRCED = 0x00030000 /*!< TM channel capture selection TRCED of trigger control block */ +} TM_CHCCS_Enum; +/** + * @brief Enumeration of TM channel capture prescaler. + */ +typedef enum +{ + TM_CHPSC_OFF = 0x00000000, /*!< TM channel capture no prescaler, capture is done each event */ + TM_CHPSC_2 = 0x00040000, /*!< TM channel capture is done once every 2 event */ + TM_CHPSC_4 = 0x00080000, /*!< TM channel capture is done once every 4 event */ + TM_CHPSC_8 = 0x000C0000 /*!< TM channel capture is done once every 8 event */ +} TM_CHPSC_Enum; +/** + * @brief Enumeration of TM fDTS clock divider. + */ +typedef enum +{ + TM_CKDIV_OFF = 0x0000, /*!< fDTS = fCLKIN */ + TM_CKDIV_2 = 0x0100, /*!< fDTS = fCLKIN / 2 */ + TM_CKDIV_4 = 0x0200 /*!< fDTS = fCLKIN / 4 */ +} TM_CKDIV_Enum; +/** + * @brief Enumeration of TM ETI input prescaler. + */ +typedef enum +{ + TM_ETIPSC_OFF = 0x00000000, /*!< ETI prescaler off */ + TM_ETIPSC_2 = 0x00001000, /*!< ETIP frequency divided by 2 */ + TM_ETIPSC_4 = 0x00002000, /*!< ETIP frequency divided by 4 */ + TM_ETIPSC_8 = 0x00003000 /*!< ETIP frequency divided by 8 */ +} TM_ETIPSC_Enum; +/** + * @brief Enumeration of TM ETI input polarity. + */ +typedef enum +{ + TM_ETIPOL_NONINVERTED = 0x00000000, /*!< TM ETI polarity is active high or rising edge */ + TM_ETIPOL_INVERTED = 0x00010000 /*!< TM ETI polarity is active low or falling edge */ +} TM_ETIPOL_Enum; +/** + * @brief Enumeration of TM slave trigger input selection. + */ +typedef enum +{ + TM_TRSEL_UEVG = 0x0, /*!< Software trigger by setting UEVG bit */ + TM_TRSEL_TI0S0 = 0x1, /*!< Filtered channel 0 input */ + TM_TRSEL_TI1S1 = 0x2, /*!< Filtered channel 1 input */ + TM_TRSEL_ETIF = 0x3, /*!< External Trigger input */ + TM_TRSEL_TI0BED = 0x8, /*!< Trigger input 0 both edge detector */ + TM_TRSEL_ITI0 = 0x9, /*!< Internal trigger input 0 */ + TM_TRSEL_ITI1 = 0xA, /*!< Internal trigger input 1 */ + TM_TRSEL_ITI2 = 0xB /*!< Internal trigger input 2 */ +} TM_TRSEL_Enum; +/** + * @brief Enumeration of TM slave mode selection. + */ +typedef enum +{ + TM_SMSEL_DISABLE = 0x0000, /*!< The prescaler is clocked directly by the internal clock */ + TM_SMSEL_DECODER1 = 0x0100, /*!< Counter counts up/down on CH0 edge depending on CH1 level */ + TM_SMSEL_DECODER2 = 0x0200, /*!< Counter counts up/down on CH1 edge depending on CH0 level */ + TM_SMSEL_DECODER3 = 0x0300, /*!< Counter counts up/down on both CH0 & CH1 edges depending on the + level of the other input */ + TM_SMSEL_RESTART = 0x0400, /*!< Slave restart mode */ + TM_SMSEL_PAUSE = 0x0500, /*!< Slave pause mode */ + TM_SMSEL_TRIGGER = 0x0600, /*!< Slave trigger mode */ + TM_SMSEL_STIED = 0x0700 /*!< Rising edge of the selected trigger(STI) clock the counter */ +} TM_SMSEL_Enum; +/** + * @brief Enumeration of TM master mode selection. + */ +typedef enum +{ + TM_MMSEL_RESET = 0x00000000, /*!< Send trigger signal when S/W setting UEVG or slave restart */ + TM_MMSEL_ENABLE = 0x00010000, /*!< The counter enable signal is used as trigger output. */ + TM_MMSEL_UPDATE = 0x00020000, /*!< The update event is used as trigger output. */ + TM_MMSEL_CH0CC = 0x00030000, /*!< Channel 0 capture or compare match occurred as trigger output. */ + TM_MMSEL_CH0OREF = 0x00040000, /*!< The CH0OREF signal is used as trigger output. */ + TM_MMSEL_CH1OREF = 0x00050000, /*!< The CH1OREF signal is used as trigger output. */ + TM_MMSEL_CH2OREF = 0x00060000, /*!< The CH2OREF signal is used as trigger output. */ + TM_MMSEL_CH3OREF = 0x00070000 /*!< The CH3OREF signal is used as trigger output. */ +} TM_MMSEL_Enum; +/** + * @brief Enumeration of TM channel Capture / Compare PDMA selection. + */ +typedef enum +{ + TM_CHCCDS_CHCCEV = 0, /*!< Send CHx PDMA request when channel capture/compare event occurs */ + TM_CHCCDS_UEV /*!< Send CHx PDMA request when update event occurs */ +} TM_CHCCDS_Enum; +/** + * @brief Definition of TM timebase init structure. + */ +typedef struct +{ + u16 CounterReload; /*!< Period (Value for CRR register) */ + u16 Prescaler; /*!< Prescaler (Value for PSCR register) */ + u8 RepetitionCounter; /*!< Repetition counter */ + TM_CNT_MODE_Enum CounterMode; /*!< Counter mode refer to \ref TM_CNT_MODE_Enum */ + TM_PSC_RLD_Enum PSCReloadTime; /*!< Prescaler reload mode refer to \ref TM_PSC_RLD_Enum */ +} TM_TimeBaseInitTypeDef; +/** + * @brief Definition of TM channel output init structure. + */ +typedef struct +{ + TM_CH_Enum Channel; /*!< Channel selection refer to \ref TM_CH_Enum */ + TM_OM_Enum OutputMode; /*!< Channel output mode selection refer to \ref TM_OM_Enum */ + TM_CHCTL_Enum Control; /*!< CHxO output state refer to \ref TM_CHCTL_Enum */ + TM_CHCTL_Enum ControlN; /*!< CHxO output state refer to \ref TM_CHCTL_Enum */ + TM_CHP_Enum Polarity; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + TM_CHP_Enum PolarityN; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + MCTM_OIS_Enum IdleState; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + MCTM_OIS_Enum IdleStateN; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + u16 Compare; /*!< Value for CHxCCR register */ + u16 AsymmetricCompare; /*!< Value for CHxACR register */ +} TM_OutputInitTypeDef; +/** + * @brief Definition of TM channel input init structure. + */ +typedef struct +{ + TM_CH_Enum Channel; /*!< Channel selection refer to \ref TM_CH_Enum */ + TM_CHP_Enum Polarity; /*!< Channel input polarity refer to \ref TM_CHP_Enum */ + TM_CHCCS_Enum Selection; /*!< Channel capture source selection refer to \ref TM_CHCCS_Enum */ + TM_CHPSC_Enum Prescaler; /*!< Channel Capture prescaler refer to \ref TM_CHPSC_Enum */ + u8 Filter; /*!< Digital filter Configuration, it must between 0x0 ~ 0xF. */ +} TM_CaptureInitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Constants TM exported constants + * @{ + */ + +/** @defgroup TM_INT Definitions of TM_INT + * @{ + */ +#define TM_INT_CH0CC 0x0001 /*!< Channel 0 capture/compare interrupt */ +#define TM_INT_CH1CC 0x0002 /*!< Channel 1 capture/compare interrupt */ +#define TM_INT_CH2CC 0x0004 /*!< Channel 2 capture/compare interrupt */ +#define TM_INT_CH3CC 0x0008 /*!< Channel 3 capture/compare interrupt */ +#define TM_INT_UEV 0x0100 /*!< Update interrupt */ +#define TM_INT_UEV2 0x0200 /*!< Update interrupt 2 */ +#define TM_INT_TEV 0x0400 /*!< Trigger interrupt */ +#define TM_INT_BRKEV 0x0800 /*!< Break interrupt */ +/** + * @} + */ + +/** @defgroup TM_PDMA Definitions of TM_PDMA + * @{ + */ +#define TM_PDMA_CH0CC 0x00010000 /*!< Channel 0 capture/compare PDMA request */ +#define TM_PDMA_CH1CC 0x00020000 /*!< Channel 1 capture/compare PDMA request */ +#define TM_PDMA_CH2CC 0x00040000 /*!< Channel 2 capture/compare PDMA request */ +#define TM_PDMA_CH3CC 0x00080000 /*!< Channel 3 capture/compare PDMA request */ +#define TM_PDMA_UEV 0x01000000 /*!< Update PDMA request */ +#define TM_PDMA_UEV2 0x02000000 /*!< Update 2 PDMA request */ +#define TM_PDMA_TEV 0x04000000 /*!< Trigger PDMA request */ +/** + * @} + */ + +/** @defgroup TM_EVENT Definitions of TM_EVENT + * @{ + */ +#define TM_EVENT_CH0CC 0x0001 /*!< Channel 0 capture/compare event */ +#define TM_EVENT_CH1CC 0x0002 /*!< Channel 1 capture/compare event */ +#define TM_EVENT_CH2CC 0x0004 /*!< Channel 2 capture/compare event */ +#define TM_EVENT_CH3CC 0x0008 /*!< Channel 3 capture/compare event */ +#define TM_EVENT_UEV 0x0100 /*!< Update event */ +#define TM_EVENT_UEV2 0x0200 /*!< Update event 2 */ +#define TM_EVENT_TEV 0x0400 /*!< Trigger event */ +#define TM_EVENT_BRKEV 0x0800 /*!< Break event */ +/** + * @} + */ + +/** @defgroup TM_FLAG Definitions of TM_FLAG + * @{ + */ +#define TM_FLAG_CH0CC 0x0001 /*!< Channel 0 capture/compare flag */ +#define TM_FLAG_CH1CC 0x0002 /*!< Channel 1 capture/compare flag */ +#define TM_FLAG_CH2CC 0x0004 /*!< Channel 2 capture/compare flag */ +#define TM_FLAG_CH3CC 0x0008 /*!< Channel 3 capture/compare flag */ +#define TM_FLAG_CH0OC 0x0010 /*!< Channel 0 over capture flag */ +#define TM_FLAG_CH1OC 0x0020 /*!< Channel 1 over capture flag */ +#define TM_FLAG_CH2OC 0x0040 /*!< Channel 2 over capture flag */ +#define TM_FLAG_CH3OC 0x0080 /*!< Channel 3 over capture flag */ +#define TM_FLAG_UEV 0x0100 /*!< Update flag */ +#define TM_FLAG_UEV2 0x0200 /*!< Update 2 flag */ +#define TM_FLAG_TEV 0x0400 /*!< Trigger flag */ +#define TM_FLAG_BRK0 0x0800 /*!< Break 0 flag */ +#define TM_FLAG_BRK1 0x1000 /*!< Break 1 flag */ +/** + * @} + */ + +/** @defgroup TM_Check_Parameter Check parameter + * @{ + */ + +/** + * @brief Used to check parameter of the TMx. + */ +#define IS_TM(x) (IS_GPTM0(x) || IS_GPTM1(x) || IS_MCTM0(x) || IS_MCTM1(x) || IS_SCTM(x)) +#define IS_GPTM0(x) (x == HT_GPTM0) + +#define IS_GPTM1(x) (0) +#define IS_MCTM0(x) (0) +#define IS_MCTM1(x) (0) + +#if !(LIBCFG_NO_GPTM1) +#undef IS_GPTM1 +#define IS_GPTM1(x) (x == HT_GPTM1) +#endif + +#if !(LIBCFG_NO_MCTM0) +#undef IS_MCTM0 +#define IS_MCTM0(x) (x == HT_MCTM0) +#endif + +#if !(LIBCFG_NO_MCTM1) +#undef IS_MCTM1 +#define IS_MCTM1(x) (x == HT_MCTM1) +#endif + +#define IS_SCTM(x) (IS_SCTM0(x) || IS_SCTM1(x)) + +#define IS_SCTM0(x) (0) +#define IS_SCTM1(x) (0) + +#if (LIBCFG_SCTM0) +#undef IS_SCTM0 +#define IS_SCTM0(x) (x == HT_SCTM0) +#endif + +#if (LIBCFG_SCTM1) +#undef IS_SCTM1 +#define IS_SCTM1(x) (x == HT_SCTM1) +#endif + + +/** + * @brief Used to check parameter of the output compare mode. + */ +#define IS_TM_OM_CMP(x) (((x) == TM_OM_MATCH_NOCHANGE) || \ + ((x) == TM_OM_MATCH_INACTIVE) || \ + ((x) == TM_OM_MATCH_ACTIVE) || \ + ((x) == TM_OM_MATCH_TOGGLE) || \ + ((x) == TM_OM_PWM1) || \ + ((x) == TM_OM_PWM2)) +/** + * @brief Used to check parameter of the output mode. + */ +#define IS_TM_OM(x) (((x) == TM_OM_MATCH_NOCHANGE) || \ + ((x) == TM_OM_MATCH_INACTIVE) || \ + ((x) == TM_OM_MATCH_ACTIVE) || \ + ((x) == TM_OM_MATCH_TOGGLE) || \ + ((x) == TM_OM_PWM1) || \ + ((x) == TM_OM_PWM2) || \ + ((x) == TM_OM_FORCED_INACTIVE) || \ + ((x) == TM_OM_FORCED_ACTIVE) || \ + ((x) == TM_OM_ASYMMETRIC_PWM1) || \ + ((x) == TM_OM_ASYMMETRIC_PWM2)) +/** + * @brief Used to check parameter of the channel. + */ +#define IS_TM_CH(x) (((x) == TM_CH_0) || ((x) == TM_CH_1) || \ + ((x) == TM_CH_2) || ((x) == TM_CH_3)) +/** + * @brief Used to check parameter of the channel for PWM input function. + */ +#define IS_TM_CH_PWMI(x) (((x) == TM_CH_0) || ((x) == TM_CH_1)) +/** + * @brief Used to check parameter of the clock divider. + */ +#define IS_TM_CKDIV(x) ((x == TM_CKDIV_OFF) || \ + (x == TM_CKDIV_2) || \ + (x == TM_CKDIV_4)) +/** + * @brief Used to check parameter of the counter mode. + */ +#define IS_TM_CNT_MODE(x) ((x == TM_CNT_MODE_UP) || \ + (x == TM_CNT_MODE_CA1) || \ + (x == TM_CNT_MODE_CA2) || \ + (x == TM_CNT_MODE_CA3) || \ + (x == TM_CNT_MODE_DOWN)) +/** + * @brief Used to check parameter of the channel polarity. + */ +#define IS_TM_CHP(x) ((x == TM_CHP_NONINVERTED) || (x == TM_CHP_INVERTED)) +/** + * @brief Used to check parameter of the channel control. + */ +#define IS_TM_CHCTL(x) ((x == TM_CHCTL_DISABLE) || (x == TM_CHCTL_ENABLE)) +/** + * @brief Used to check parameter of the channel capture / compare PDMA selection. + */ +#define IS_TM_CHCCDS(x) ((x == TM_CHCCDS_CHCCEV) || (x == TM_CHCCDS_UEV)) +/** + * @brief Used to check parameter of the channel input selection. + */ +#define IS_TM_CHCCS(x) ((x == TM_CHCCS_DIRECT) || \ + (x == TM_CHCCS_INDIRECT) || \ + (x == TM_CHCCS_TRCED)) +/** + * @brief Used to check parameter of the channel capture prescaler. + */ +#define IS_TM_CHPSC(x) ((x == TM_CHPSC_OFF) || \ + (x == TM_CHPSC_2) || \ + (x == TM_CHPSC_4) || \ + (x == TM_CHPSC_8)) +/** + * @brief Used to check parameter of the ETI prescaler. + */ +#define IS_TM_ETIPSC(x) ((x == TM_ETIPSC_OFF) || \ + (x == TM_ETIPSC_2) || \ + (x == TM_ETIPSC_4) || \ + (x == TM_ETIPSC_8)) +/** + * @brief Used to check parameter of the TM interrupt. + */ +#define IS_TM_INT(x) (((x & 0xFFFFF0F0) == 0x0) && (x != 0)) +/** + * @brief Used to check parameter of the TM PDMA request. + */ +#define IS_TM_PDMA(x) (((x & 0xF8F0FFFF) == 0x0) && (x != 0)) +/** + * @brief Used to check parameter of the TM interrupt for \ref TM_GetIntStatus function. + */ +#define IS_TM_GET_INT(x) ((x == TM_INT_CH0CC) || \ + (x == TM_INT_CH1CC) || \ + (x == TM_INT_CH2CC) || \ + (x == TM_INT_CH3CC) || \ + (x == TM_INT_UEV) || \ + (x == TM_INT_UEV2) || \ + (x == TM_INT_TEV) || \ + (x == TM_INT_BRKEV)) +/** + * @brief Used to check parameter of the TM STI selection. + */ +#define IS_TM_TRSEL(x) ((x == TM_TRSEL_UEVG) || \ + (x == TM_TRSEL_TI0S0) || \ + (x == TM_TRSEL_TI1S1) || \ + (x == TM_TRSEL_ETIF) || \ + (x == TM_TRSEL_TI0BED) || \ + (x == TM_TRSEL_ITI0) || \ + (x == TM_TRSEL_ITI1) || \ + (x == TM_TRSEL_ITI2)) +/** + * @brief Used to check parameter of the ITI. + */ +#define IS_TM_ITI(x) ((x == TM_TRSEL_ITI0) || (x == TM_TRSEL_ITI1) || (x == TM_TRSEL_ITI2)) +/** + * @brief Used to check parameter of the TM_TRSEL for \ref TM_ChExternalClockConfig function. + */ +#define IS_TM_TRSEL_CH(x) ((x == TM_TRSEL_TI0S0) || (x == TM_TRSEL_TI1S1) || \ + (x == TM_TRSEL_TI0BED)) +/** + * @brief Used to check parameter of the TM ETI polarity. + */ +#define IS_TM_ETIPOL(x) ((x == TM_ETIPOL_NONINVERTED) || (x == TM_ETIPOL_INVERTED)) +/** + * @brief Used to check parameter of the TM prescaler reload time. + */ +#define IS_TM_PSC_RLD(x) ((x == TM_PSC_RLD_UPDATE) || (x == TM_PSC_RLD_IMMEDIATE)) +/** + * @brief Used to check parameter of the forced action. + */ +#define IS_TM_OM_FORCED(x) ((x == TM_OM_FORCED_ACTIVE) || (x == TM_OM_FORCED_INACTIVE)) +/** + * @brief Used to check parameter of the decoder mode. + */ +#define IS_TM_SMSEL_DECODER(x) ((x == TM_SMSEL_DECODER1) || (x == TM_SMSEL_DECODER2) || \ + (x == TM_SMSEL_DECODER3)) +/** + * @brief Used to check parameter of the event. + */ +#define IS_TM_EVENT(x) (((x & 0xFFFFF0F0) == 0x0000) && (x != 0x0000)) +/** + * @brief Used to check parameter of the TM master mode selection. + */ +#define IS_TM_MMSEL(x) (((x) == TM_MMSEL_RESET) || \ + ((x) == TM_MMSEL_ENABLE) || \ + ((x) == TM_MMSEL_UPDATE) || \ + ((x) == TM_MMSEL_CH0CC) || \ + ((x) == TM_MMSEL_CH0OREF) || \ + ((x) == TM_MMSEL_CH1OREF) || \ + ((x) == TM_MMSEL_CH2OREF) || \ + ((x) == TM_MMSEL_CH3OREF)) +/** + * @brief Used to check parameter of the TM slave mode. + */ +#define IS_TM_SLAVE_MODE(x) ((x == TM_SMSEL_RESTART) || (x == TM_SMSEL_PAUSE) || \ + (x == TM_SMSEL_TRIGGER) || (x == TM_SMSEL_STIED)) +/** + * @brief Used to check parameter of the TM flag. + */ +#define IS_TM_FLAG(x) ((x == TM_FLAG_CH0CC) || \ + (x == TM_FLAG_CH1CC) || \ + (x == TM_FLAG_CH2CC) || \ + (x == TM_FLAG_CH3CC) || \ + (x == TM_FLAG_CH0OC) || \ + (x == TM_FLAG_CH1OC) || \ + (x == TM_FLAG_CH2OC) || \ + (x == TM_FLAG_CH3OC) || \ + (x == TM_FLAG_UEV) || \ + (x == TM_FLAG_UEV2) || \ + (x == TM_FLAG_TEV) || \ + (x == TM_FLAG_BRK0) || \ + (x == TM_FLAG_BRK1)) + +/** + * @brief Used to check parameter of the TM flag for \ref TM_ClearFlag function. + */ +#define IS_TM_FLAG_CLR(x) (((x & 0xFFFFE000) == 0) && (x != 0)) +/** + * @brief Used to check value of TM digital filter. + */ +#define IS_TM_FILTER(x) (x <= 0xF) + +/** + * @} + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Functions TM exported functions + * @{ + */ +#define TM_SetCaptureCompare0(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_0, Cmp) +#define TM_SetCaptureCompare1(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_1, Cmp) +#define TM_SetCaptureCompare2(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_2, Cmp) +#define TM_SetCaptureCompare3(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_3, Cmp) + +#define TM_ForcedOREF0(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_0, ForcedAction) +#define TM_ForcedOREF1(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_1, ForcedAction) +#define TM_ForcedOREF2(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_2, ForcedAction) +#define TM_ForcedOREF3(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_3, ForcedAction) + +#define TM_SetAsymmetricCompare0(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_0, Cmp) +#define TM_SetAsymmetricCompare1(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_1, Cmp) +#define TM_SetAsymmetricCompare2(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_2, Cmp) +#define TM_SetAsymmetricCompare3(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_3, Cmp) + +#define TM_GetCaptureCompare0(TMx) TM_GetCaptureCompare(TMx,TM_CH_0) +#define TM_GetCaptureCompare1(TMx) TM_GetCaptureCompare(TMx,TM_CH_1) +#define TM_GetCaptureCompare2(TMx) TM_GetCaptureCompare(TMx,TM_CH_2) +#define TM_GetCaptureCompare3(TMx) TM_GetCaptureCompare(TMx,TM_CH_3) + +void TM_DeInit(HT_TM_TypeDef* TMx); +void TM_TimeBaseInit(HT_TM_TypeDef* TMx, TM_TimeBaseInitTypeDef* TimeBaseInit); +void TM_OutputInit(HT_TM_TypeDef* TMx, TM_OutputInitTypeDef* OutInit); +void TM_CaptureInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit); +void TM_PwmInputInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit); +void TM_TimeBaseStructInit(TM_TimeBaseInitTypeDef* TimeBaseInit); +void TM_OutputStructInit(TM_OutputInitTypeDef* OutInit); +void TM_CaptureStructInit(TM_CaptureInitTypeDef* CapInit); +void TM_Cmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_ItiExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Iti); +void TM_ChExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel, TM_CHP_Enum Pol, u8 Filter); +void TM_EtiExternalClockConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter); +void TM_EtiConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter); +void TM_PrescalerConfig(HT_TM_TypeDef* TMx, u16 Psc, TM_PSC_RLD_Enum PscReloadTime); +void TM_CounterModeConfig(HT_TM_TypeDef* TMx, TM_CNT_MODE_Enum Mod); +void TM_StiConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel); +void TM_DecoderConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum DecoderMod, TM_CHP_Enum CH0P, TM_CHP_Enum CH1P); + +void TM_ForcedOREF(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, TM_OM_Enum ForcedAction); +void TM_CRRPreloadCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_CHCCRPreloadConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState); +void TM_ClearOREFConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState); +void TM_ChPolarityConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHP_Enum Pol); + +void TM_ImmActiveConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState); +void TM_ChannelConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control); + +void TM_OutputModeConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_OM_Enum Mod); +void TM_UpdateCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_UEVG_IntConfig(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_HallInterfaceCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_SinglePulseModeCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_MMSELConfig(HT_TM_TypeDef* TMx, TM_MMSEL_Enum Sel); +void TM_SlaveModeConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum Sel); +void TM_TimSyncCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_SetCounter(HT_TM_TypeDef* TMx, u16 Counter); +void TM_SetCounterReload(HT_TM_TypeDef* TMx, u16 Reload); +void TM_SetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp); +void TM_SetAsymmetricCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp); + +void TM_CHPSCConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHPSC_Enum Psc); +void TM_CKDIVConfig(HT_TM_TypeDef* TMx, TM_CKDIV_Enum Div); +u32 TM_GetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n); +u32 TM_GetCounter(HT_TM_TypeDef* TMx); +u32 TM_GetPrescaler(HT_TM_TypeDef* TMx); +void TM_GenerateEvent(HT_TM_TypeDef* TMx, u32 TM_EVENT); +FlagStatus TM_GetFlagStatus(HT_TM_TypeDef* TMx, u32 TM_FLAG); +void TM_ClearFlag(HT_TM_TypeDef* TMx, u32 TM_FLAG); +void TM_IntConfig(HT_TM_TypeDef* TMx, u32 TM_INT, ControlStatus NewState); +FlagStatus TM_GetIntStatus(HT_TM_TypeDef* TMx, u32 TM_INT); +void TM_ClearIntPendingBit(HT_TM_TypeDef* TMx, u32 TM_INT); +void TM_InternalClockConfig(HT_TM_TypeDef* TMx); + +void TM_CHCCDSConfig(HT_TM_TypeDef* TMx, TM_CHCCDS_Enum Selection); +void TM_PDMAConfig(HT_TM_TypeDef* TMx, u32 TM_PDMA, ControlStatus NewState); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm_type.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm_type.h new file mode 100644 index 0000000000..19cac328c5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_tm_type.h @@ -0,0 +1,113 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_tm_type.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the TM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_TM_TYPE_H +#define __HT32F1XXXX_TM_TYPE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup TM + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Types TM exported types + * @{ + */ +/** + * @brief Enumeration of TM channel. + */ +typedef enum +{ + TM_CH_0 = 0, /*!< TM channel 0 */ + TM_CH_1, /*!< TM channel 1 */ + TM_CH_2, /*!< TM channel 2 */ + TM_CH_3 /*!< TM channel 3 */ +} TM_CH_Enum; +/** + * @brief Enumeration of TM channel control. + */ +typedef enum +{ + TM_CHCTL_DISABLE = 0, /*!< TM channel disable */ + TM_CHCTL_ENABLE /*!< TM channel enable */ +} TM_CHCTL_Enum; +/** + * @brief Enumeration of TM channel polarity. + */ +typedef enum +{ + TM_CHP_NONINVERTED = 0, /*!< TM channel polarity is active high or rising edge */ + TM_CHP_INVERTED /*!< TM channel polarity is active low or falling edge */ +} TM_CHP_Enum; +/** + * @brief Enumeration of MCTM channel output idle state. + */ +typedef enum +{ + MCTM_OIS_LOW = 0, /*!< MCTM channel output low when CHMOE equal to 0 */ + MCTM_OIS_HIGH /*!< MCTM channel output high when CHMOE equal to 0 */ +} MCTM_OIS_Enum; +/** + * @brief Enumeration of MCTM COMUS. + */ +typedef enum +{ + MCTM_COMUS_STIOFF = 0, /*!< MCTM capture/compare control bits are updated by + setting the UEV2G bit only */ + MCTM_COMUS_STION /*!< MCTM capture/compare control bits are updated by both + setting the UEV2G bit or when a rising edge occurs on STI */ +} MCTM_COMUS_Enum; +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usart.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usart.h new file mode 100644 index 0000000000..6e0c5332b2 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usart.h @@ -0,0 +1,585 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_usart.h + * @version $Rev:: 2797 $ + * @date $Date:: 2022-11-28 #$ + * @brief The header file of the USART library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_USART_H +#define __HT32F1XXXX_USART_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup USART + * @{ + */ + + +#define LIBCFG_USART_V01_LEGACY (0) + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Types USART exported types + * @{ + */ +/* Definition of USART Init Structure ---------------------------------------------------------------------*/ +typedef struct +{ + u32 USART_BaudRate; + u16 USART_WordLength; + u16 USART_StopBits; + u16 USART_Parity; + u16 USART_Mode; +} USART_InitTypeDef; + +typedef struct +{ + u16 USART_ClockEnable; + u16 USART_ClockPhase; + u16 USART_ClockPolarity; + u16 USART_TransferSelectMode; +} USART_SynClock_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Constants USART exported constants + * @{ + */ + +#define USART_CMD_TX (0) +#define USART_CMD_RX (1) + +#define USART_CMD_OUT (0) +#define USART_CMD_IN (1) + +/* USART Word Length ---------------------------------------------------------------------------------------*/ +/** @defgroup USART_Word_Length Definitions of USART word length + * @{ + */ +#if (LIBCFG_USART_V01) +#define USART_WORDLENGTH_7B ((u32)0x00000000) +#define USART_WORDLENGTH_8B ((u32)0x00000001) +#define USART_WORDLENGTH_9B ((u32)0x00000002) +#else +#define USART_WORDLENGTH_7B ((u32)0x00000000) +#define USART_WORDLENGTH_8B ((u32)0x00000100) +#define USART_WORDLENGTH_9B ((u32)0x00000200) +#endif + +#define IS_USART_WORD_LENGTH(LENGTH) ((LENGTH == USART_WORDLENGTH_9B) || \ + (LENGTH == USART_WORDLENGTH_8B) || \ + (LENGTH == USART_WORDLENGTH_7B)) +/** + * @} + */ + +/* USART Stop Bits -----------------------------------------------------------------------------------------*/ +/** @defgroup USART_Stop_Bit Definitions of USART stop bit + * @{ + */ +#if (LIBCFG_USART_V01) +#define USART_STOPBITS_1 ((u32)0x00000000) +#define USART_STOPBITS_2 ((u32)0x00000004) +#else +#define USART_STOPBITS_1 ((u32)0x00000000) +#define USART_STOPBITS_2 ((u32)0x00000400) +#endif + + +#define IS_USART_STOPBITS(STOPBITS) ((STOPBITS == USART_STOPBITS_1) || \ + (STOPBITS == USART_STOPBITS_2)) +/** + * @} + */ + +/* USART Parity --------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Parity Definitions of USART parity + * @{ + */ +#if (LIBCFG_USART_V01) +#define USART_PARITY_NO ((u32)0x00000000) +#define USART_PARITY_EVEN ((u32)0x00000018) +#define USART_PARITY_ODD ((u32)0x00000008) +#else +#define USART_PARITY_NO ((u32)0x00000000) +#define USART_PARITY_EVEN ((u32)0x00001800) +#define USART_PARITY_ODD ((u32)0x00000800) +#define USART_PARITY_MARK ((u32)0x00002800) +#define USART_PARITY_SPACE ((u32)0x00003800) +#endif + +#define IS_USART_PARITY(PARITY) ((PARITY == USART_PARITY_NO) || \ + (PARITY == USART_PARITY_EVEN) || \ + (PARITY == USART_PARITY_ODD)) +/** + * @} + */ + +/* USART Mode ----------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Mode Definitions of USART mode + * @{ + */ +#define USART_MODE_NORMAL ((u32)0x00000000) +#define USART_MODE_IRDA ((u32)0x00000001) +#define USART_MODE_RS485 ((u32)0x00000002) +#define USART_MODE_SYNCHRONOUS ((u32)0x00000003) + +#define IS_USART_MODE(MODE) ((MODE == USART_MODE_NORMAL) || \ + (MODE == USART_MODE_IRDA) || \ + (MODE == USART_MODE_RS485) || \ + (MODE == USART_MODE_SYNCHRONOUS)) +/** + * @} + */ + +/* USART Transfer Select Mode ------------------------------------------------------------------------------*/ +/** @defgroup USART_LSB Definitions of USART LSB + * @{ + */ +#define USART_LSB_FIRST ((u32)0x00000000) +#define USART_MSB_FIRST ((u32)0x00000004) + +#define IS_USART_TRANSFER_MODE(TMODE) ((TMODE == USART_LSB_FIRST) || \ + (TMODE == USART_MSB_FIRST)) +/** + * @} + */ + + +/* USART Synchronous Clock ---------------------------------------------------------------------------------*/ +/** @defgroup USART_Synchronous_Clock Definitions of USART synchronous clock + * @{ + */ +#define USART_SYN_CLOCK_DISABLE ((u32)0x00000000) +#define USART_SYN_CLOCK_ENABLE ((u32)0x00000001) + +#define IS_USART_SYNCHRONOUS_CLOCK(SYNCLOCK) ((SYNCLOCK == USART_SYN_CLOCK_DISABLE) || \ + (SYNCLOCK == USART_SYN_CLOCK_ENABLE)) +/** + * @} + */ + +/* USART Synchronous Clock Phase ---------------------------------------------------------------------------*/ +/** @defgroup USART_Synchronous_Clock_Phase Definitions of USART Synchronous clock phase + * @{ + */ +#define USART_SYN_CLOCK_PHASE_FIRST ((u32)0x00000000) +#define USART_SYN_CLOCK_PHASE_SECOND ((u32)0x00000004) + +#define IS_USART_SYNCHRONOUS_PHASE(PHASE) ((PHASE == USART_SYN_CLOCK_PHASE_FIRST) || \ + (PHASE == USART_SYN_CLOCK_PHASE_SECOND)) +/** + * @} + */ + +/* USART Clock Polarity ------------------------------------------------------------------------------------*/ +/** @defgroup USART_Clock_Polarity Definitions of USART clock polarity + * @{ + */ +#define USART_SYN_CLOCK_POLARITY_LOW ((u32)0x00000000) +#define USART_SYN_CLOCK_POLARITY_HIGH ((u32)0x00000008) + +#define IS_USART_SYNCHRONOUS_POLARITY(POLARITY) ((POLARITY == USART_SYN_CLOCK_POLARITY_LOW) || \ + (POLARITY == USART_SYN_CLOCK_POLARITY_HIGH)) +/** + * @} + */ + +/* USART IrDA ---------------------------------------------------------------------------------------------*/ +/** @defgroup USART_IrDA Definitions of USART IrDA + * @{ + */ +#define USART_IRDA_LOWPOWER ((u32)0x00000002) +#define USART_IRDA_NORMAL ((u32)0xFFFFFFFD) + +#define IS_USART_IRDA_MODE(MODE) ((MODE == USART_IRDA_LOWPOWER) || \ + (MODE == USART_IRDA_NORMAL)) + +#define USART_IRDA_TX ((u32)0x00000004) +#define USART_IRDA_RX ((u32)0xFFFFFFFB) + +#define IS_USART_IRDA_DIRECTION(DIRECTION) ((DIRECTION == USART_IRDA_TX) || \ + (DIRECTION == USART_IRDA_RX)) +/** + * @} + */ + +#define IS_USART_TL(x) (IS_USART_RXTL(x) || IS_USART_TXTL(x)) + +/* USART Rx FIFO Interrupt Trigger Level -------------------------------------------------------------------*/ +/** @defgroup USART_RX_FIFO_Trigger_Level Definitions of USART Rx FIFO interrupts + * @{ + */ +#if (LIBCFG_USART_V01) +#define USART_RXTL_01 ((u32)0x00000000) +#define USART_RXTL_04 ((u32)0x00000010) +#define USART_RXTL_08 ((u32)0x00000020) +#define USART_RXTL_14 ((u32)0x00000030) + +#define IS_USART_RXTL(RXTL) ((RXTL == USART_RXTL_01) || \ + (RXTL == USART_RXTL_04) || \ + (RXTL == USART_RXTL_08) || \ + (RXTL == USART_RXTL_14)) +#else +#define USART_RXTL_01 ((u32)0x00000000) +#define USART_RXTL_02 ((u32)0x00000010) +#define USART_RXTL_04 ((u32)0x00000020) +#define USART_RXTL_06 ((u32)0x00000030) + +#define IS_USART_RXTL(RXTL) ((RXTL == USART_RXTL_01) || \ + (RXTL == USART_RXTL_02) || \ + (RXTL == USART_RXTL_04) || \ + (RXTL == USART_RXTL_06)) +#endif +/** + * @} + */ + +/* USART Tx FIFO Interrupt Trigger Level -------------------------------------------------------------------*/ +/** @defgroup USART_TX_FIFO_Trigger_Level Definitions of USART Tx FIFO interrupts + * @{ + */ +#if (LIBCFG_USART_V01) +#define USART_TXTL_00 ((u32)0x00000000) +#define USART_TXTL_02 ((u32)0x00000010) +#define USART_TXTL_04 ((u32)0x00000020) +#define USART_TXTL_08 ((u32)0x00000030) + +#define IS_USART_TXTL(TXTL) ((TXTL == USART_TXTL_00) || \ + (TXTL == USART_TXTL_02) || \ + (TXTL == USART_TXTL_04) || \ + (TXTL == USART_TXTL_08)) +#else +#define USART_TXTL_00 ((u32)0x00000000) +#define USART_TXTL_02 ((u32)0x00000010) +#define USART_TXTL_04 ((u32)0x00000020) +#define USART_TXTL_06 ((u32)0x00000030) + +#define IS_USART_TXTL(TXTL) ((TXTL == USART_TXTL_00) || \ + (TXTL == USART_TXTL_02) || \ + (TXTL == USART_TXTL_04) || \ + (TXTL == USART_TXTL_06)) +#endif +/** + * @} + */ + +/* USART Interrupt definition ------------------------------------------------------------------------------*/ +/** @defgroup USART_Interrupt_Enable Definitions of USART interrupt Enable bits + * @{ + */ +#if (LIBCFG_USART_V01) +#define USART_INT_RXDR ((u32)0x00000001) +#define USART_INT_TXDE ((u32)0x00000002) +#define USART_INT_RLSIE ((u32)0x00000004) +#define USART_INT_MSIE ((u32)0x00000008) +#define USART_INT_TOUT ((u32)0x00000100) + +#if (LIBCFG_USART_V01_LEGACY) +#define USART_IER_RDAIE (USART_INT_RXDR) +#define USART_IER_THREIE (USART_INT_TXDE) +#define USART_IER_RLSIE (USART_INT_RLSIE) +#define USART_IER_MSIE (USART_INT_MSIE) +#endif + +#define IS_USART_INT(INT) ((((INT) & 0xFFFFFFF0) == 0) && ((INT) != 0)) + +#define USART_IID_RLS ((u8)0x06) +#define USART_IID_RDA ((u8)0x04) +#define USART_IID_CTI ((u8)0x0C) +#define USART_IID_THRE ((u8)0x02) +#define USART_IID_MS ((u8)0x00) +#define USART_IID_NON ((u8)0x01) + +#define IS_USART_IID(IID) ((IID == USART_IID_RLS) || \ + (IID == USART_IID_RDA) || \ + (IID == USART_IID_CTI) || \ + (IID == USART_IID_THRE) || \ + (IID == USART_IID_MS) || \ + (IID == USART_IID_NON)) + +#else +#define USART_INT_RXDR ((u32)0x00000001) +#define USART_INT_TXDE ((u32)0x00000002) +#define USART_INT_TXC ((u32)0x00000004) +#define USART_INT_OE ((u32)0x00000008) +#define USART_INT_PE ((u32)0x00000010) +#define USART_INT_FE ((u32)0x00000020) +#define USART_INT_BI ((u32)0x00000040) +#define USART_INT_RSADD ((u32)0x00000080) +#define USART_INT_TOUT ((u32)0x00000100) +#define USART_INT_CTS ((u32)0x00000200) + +#define IS_USART_INT(INT) ((((INT) & 0xFFFFFC00) == 0) && ((INT) != 0)) +#endif +/** + * @} + */ + +/* USART Flags ---------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Flag Definitions of USART flags + * @{ + */ +#if (LIBCFG_USART_V01) +#define USART_FLAG_RXDNE ((u32)0x00000001) +#define USART_FLAG_THRE ((u32)0x00000020) +#define USART_FLAG_TXC ((u32)0x00000040) +#define USART_FLAG_ERR ((u32)0x00000080) + +#define USART_FLAG_FROM_IIR ((u32)0x00000800) +#define USART_FLAG_MODIS ((u32)0x00000800) +#define USART_FLAG_TXDE ((u32)0x00000802) +#define USART_FLAG_RXDR ((u32)0x00000804) +#define USART_FLAG_RLSI ((u32)0x00000806) +#define USART_FLAG_TOUT ((u32)0x0000080C) + +#if (LIBCFG_USART_V01_LEGACY) +#define USART_LSR_RFDR (USART_FLAG_RXDNE) +#define USART_LSR_THRE (USART_FLAG_THRE) +#define USART_LSR_TE (USART_FLAG_TXC) +#define USART_LSR_ERR (USART_FLAG_ERR) +#endif + +#define IS_USART_FLAG(FLAG) ((FLAG == USART_FLAG_RXDNE) || \ + (FLAG == USART_FLAG_THRE) || \ + (FLAG == USART_FLAG_TXC) || \ + (FLAG == USART_FLAG_ERR) || \ + (FLAG == USART_FLAG_TXDE) || \ + (FLAG == USART_FLAG_RXDR) || \ + (FLAG == USART_FLAG_TOUT)) + +#define USART_LSR_OE ((u32)0x00000002) +#define USART_LSR_PE ((u32)0x00000004) +#define USART_LSR_FE ((u32)0x00000008) +#define USART_LSR_BI ((u32)0x00000010) +#define USART_LSR_RSADD ((u32)0x00000100) + +#else +#define USART_FLAG_RXDNE ((u32)0x00000001) +#define USART_FLAG_OE ((u32)0x00000002) +#define USART_FLAG_PE ((u32)0x00000004) +#define USART_FLAG_FE ((u32)0x00000008) +#define USART_FLAG_BI ((u32)0x00000010) +#define USART_FLAG_RXDR ((u32)0x00000020) +#define USART_FLAG_TOUT ((u32)0x00000040) +#define USART_FLAG_TXDE ((u32)0x00000080) +#define USART_FLAG_TXC ((u32)0x00000100) +#define USART_FLAG_RSADD ((u32)0x00000200) +#define USART_FLAG_CTSC ((u32)0x00000400) +#define USART_FLAG_CTSS ((u32)0x00000800) + +#define IS_USART_FLAG(FLAG) ((FLAG == USART_FLAG_RXDNE) || (FLAG == USART_FLAG_OE) || \ + (FLAG == USART_FLAG_PE) || (FLAG == USART_FLAG_FE) || \ + (FLAG == USART_FLAG_BI) || (FLAG == USART_FLAG_RXDR) || \ + (FLAG == USART_FLAG_TOUT) || (FLAG == USART_FLAG_TXDE) || \ + (FLAG == USART_FLAG_TXC) || (FLAG == USART_FLAG_RSADD) || \ + (FLAG == USART_FLAG_CTSC) || (FLAG == USART_FLAG_CTSS)) + +#define IS_USART_CLEAR_FLAG(FLAG) ((FLAG == USART_FLAG_OE) || (FLAG == USART_FLAG_PE) || \ + (FLAG == USART_FLAG_FE) || (FLAG == USART_FLAG_BI) || \ + (FLAG == USART_FLAG_TOUT) || (FLAG == USART_FLAG_RSADD) || \ + (FLAG == USART_FLAG_CTSC)) +#endif +/** + * @} + */ + +/* USART RS485 definition ----------------------------------------------------------------------------------*/ +/** @defgroup USART_RS485 Definitions of USART RS485 + * @{ + */ +#define USART_RS485POLARITY_LOW ((u32)0x00000001) +#define USART_RS485POLARITY_HIGH ((u32)0xFFFFFFFE) + +#define IS_USART_RS485_POLARITY(POLARITY) ((POLARITY == USART_RS485POLARITY_LOW) || \ + (POLARITY == USART_RS485POLARITY_HIGH)) +/** + * @} + */ +#if (LIBCFG_USART_V01) +#define USART_FIFO_TX ((u32)0x00000004) +#define USART_FIFO_RX ((u32)0x00000002) +#else +#define USART_FIFO_TX ((u32)0x00000001) +#define USART_FIFO_RX ((u32)0x00000002) +#endif + +#define IS_USART_FIFO_DIRECTION(DIRECTION) ((DIRECTION == USART_FIFO_TX) || \ + (DIRECTION == USART_FIFO_RX)) + +#if (LIBCFG_USART_V01) +#define USART_STICK_LOW ((u32)0x00000010) +#define USART_STICK_HIGH ((u32)0xFFFFFFEF) +#else +#define USART_STICK_LOW ((u32)0x00001000) +#define USART_STICK_HIGH ((u32)0xFFFFEFFF) +#endif + +#define IS_USART_STICK_PARITY(PARITY) ((PARITY == USART_STICK_LOW) || (PARITY == USART_STICK_HIGH)) + +#if (LIBCFG_USART_V01) +#define USART_PDMAREQ_TX ((u32)0x00000010) +#define USART_PDMAREQ_RX ((u32)0x00000020) +#else +#define USART_PDMAREQ_TX ((u32)0x00000040) +#define USART_PDMAREQ_RX ((u32)0x00000080) +#endif + +#define IS_USART_PDMA_REQ(REQ) ((REQ == USART_PDMAREQ_TX) || (REQ == USART_PDMAREQ_RX)) + +#define IS_USART(USART) ((USART == HT_USART0) || \ + (IS_USART1(USART)) || \ + (USART == HT_UART0) || \ + (USART == HT_UART1)) + +#if (LIBCFG_NO_USART1) +#define IS_USART1(x) (0) +#else +#define IS_USART1(x) (x == HT_USART1) +#endif + +#define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE > 0) && (BAUDRATE < 0x0044AA21)) +#define IS_USART_DATA(DATA) (DATA <= 0x1FF) +#define IS_USART_GUARD_TIME(TIME) (TIME <= 0xFF) +#define IS_USART_IRDA_PRESCALER(PRESCALER) (PRESCALER <= 0xFF) +#define IS_USART_TIMEOUT(TIMEOUT) (TIMEOUT <= 0x7F) +#define IS_USART_ADDRESS_MATCH_VALUE(VALUE) (VALUE <= 0xFF) +/** + * @} + */ + +#if (LIBCFG_USART_V01) +/* USART Modem definition ----------------------------------------------------------------------------------*/ +/** @defgroup USART_MODEM Definitions of USART Modem + * @{ + */ +#define USART_MODEM_DTR ((u32)0x00000000) +#define USART_MODEM_RTS ((u32)0x00000001) + +#define IS_USART_MODEM_PIN(PIN) ((PIN == USART_MODEM_DTR) || (PIN == USART_MODEM_RTS)) + +#define USART_MODEMSTATE_HIGH ((u32)0x00000000) +#define USART_MODEMSTATE_LOW ((u32)0x00000001) + +#define IS_USART_MODEM_STATE(STATE) ((STATE == USART_MODEMSTATE_HIGH) || (STATE == USART_MODEMSTATE_LOW)) +/** + * @} + */ +#endif + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Functions USART exported functions + * @{ + */ +#define USART_TxCmd(USARTx, NewState) USART_TxRxCmd(USARTx, USART_CMD_TX, NewState) +#define USART_RxCmd(USARTx, NewState) USART_TxRxCmd(USARTx, USART_CMD_RX, NewState) + +#define USART_TxPDMACmd(USARTx, NewState) USART_PDMACmd(USARTx, USART_PDMAREQ_TX, NewState) +#define USART_RxPDMACmd(USARTx, NewState) USART_PDMACmd(USARTx, USART_PDMAREQ_RX, NewState) + +#define USART_RXTLConfig(USARTx, USART_tl) USART_TXRXTLConfig(USARTx, USART_CMD_RX, USART_tl) +#define USART_TXTLConfig(USARTx, USART_tl) USART_TXRXTLConfig(USARTx, USART_CMD_TX, USART_tl) + +#define USART_IrDAInvtOutputCmd(USARTx, NewState) USART_IrDAInvtCmd(USARTx, USART_CMD_OUT, NewState) +#define USART_IrDAInvtInputCmd(USARTx, NewState) USART_IrDAInvtCmd(USARTx, USART_CMD_IN, NewState) + +void USART_DeInit(HT_USART_TypeDef* USARTx); +void USART_Init(HT_USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStructure); +void USART_StructInit(USART_InitTypeDef* USART_InitStructure); +void USART_SendData(HT_USART_TypeDef* USARTx, u16 Data); +u16 USART_ReceiveData(HT_USART_TypeDef* USARTx); +FlagStatus USART_GetFlagStatus(HT_USART_TypeDef* USARTx, u32 USART_FLAG_x); +#if (LIBCFG_USART_V01) +#else +FlagStatus USART_GetIntStatus(HT_USART_TypeDef* USARTx, u32 USART_FLAG_x); +void USART_ClearFlag(HT_USART_TypeDef* USARTx, u32 USART_Flag); +#endif +void USART_IntConfig(HT_USART_TypeDef* USARTx, u32 USART_INT_x, ControlStatus NewState); +void USART_TxRxCmd(HT_USART_TypeDef* USARTx,u32 TxRx, ControlStatus NewState); +void USART_PDMACmd(HT_USART_TypeDef* USARTx, u32 USART_PDMAREQ, ControlStatus NewState); +void USART_ForceBreakCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_StickParityCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_StickParityConfig(HT_USART_TypeDef* USARTx, u32 USART_StickParity); + +void USART_SetGuardTime(HT_USART_TypeDef* USARTx, u32 USART_GuardTime); +void USART_TXRXTLConfig(HT_USART_TypeDef* USARTx, u32 TxRx, u32 USART_tl); +void USART_SetTimeOutValue(HT_USART_TypeDef* USARTx, u32 USART_TimeOut); +void USART_FIFOReset(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection); +u8 USART_GetFIFOStatus(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection); +void USART_HardwareFlowControlCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); + +void USART_IrDACmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_IrDAConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDAMode); +void USART_SetIrDAPrescaler(HT_USART_TypeDef* USARTx, u32 USART_IrDAPrescaler); +void USART_IrDADirectionConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDADirection); +void USART_IrDAInvtCmd(HT_USART_TypeDef* USARTx, u32 inout, ControlStatus NewState); + +void USART_RS485TxEnablePolarityConfig(HT_USART_TypeDef* USARTx, u32 USART_RS485Polarity); +void USART_RS485NMMCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_RS485AADCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_SetAddressMatchValue(HT_USART_TypeDef* USARTx, u32 USART_AddressMatchValue); + +void USART_SynClockInit(HT_USART_TypeDef* USARTx, USART_SynClock_InitTypeDef* USART_SynClock_InitStruct); +void USART_SynClockStructInit(USART_SynClock_InitTypeDef* USART_SynClock_InitStruct); + +#if (LIBCFG_USART_V01) +#if (LIBCFG_USART_V01_LEGACY) +#define USART_GetLineStatus USART_GetFlagStatus +#endif + +void USART_ForceModemPinState(HT_USART_TypeDef* USARTx, u32 USART_ModemPin, u32 USART_ModemState); +u8 USART_GetModemStatus(HT_USART_TypeDef* USARTx); +#define USART_TimeOutIntConfig(USARTx, NewState) USART_IntConfig(USARTx, USART_INT_TOUT, NewState) +//void USART_TimeOutIntConfig(HT_USART_TypeDef* USARTx, ControlStatus NewState); +u8 USART_GetIntID(HT_USART_TypeDef* USARTx); +u32 USART_GetLineStatusValue(HT_USART_TypeDef* USARTx); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbd.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbd.h new file mode 100644 index 0000000000..8f616a245b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbd.h @@ -0,0 +1,325 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_usbd.h + * @version $Rev:: 1670 $ + * @date $Date:: 2019-04-09 #$ + * @brief The header file of the USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_USBD_H +#define __HT32F1XXXX_USBD_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_01_usbdconf.h" +#include "ht32f1xxxx_usbdinit.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup USBDevice USB Device + * @brief USB Device driver modules + * @{ + */ + + +/* Settings ------------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Settings USB Device settings + * @{ + */ +#define MAX_EP_NUM (8) +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Types USB Device exported types + * @{ + */ +/* USB Endpoint number */ +typedef enum +{ + USBD_EPT0 = 0, + USBD_EPT1 = 1, + USBD_EPT2 = 2, + USBD_EPT3 = 3, + USBD_EPT4 = 4, + USBD_EPT5 = 5, + USBD_EPT6 = 6, + USBD_EPT7 = 7, + USBD_NOEPT = -1, +} USBD_EPTn_Enum; + +typedef enum +{ + USBD_TCR_0 = 0, + USBD_TCR_1 = 16, +} USBD_TCR_Enum; + +typedef enum +{ + USBD_NAK = 0, + USBD_ACK = 1 +} USBD_Handshake_Enum; + +/* Endpoint CFGR Register */ +typedef struct _EPTCFGR_BIT +{ + vu32 EPBUFA: 10; + vu32 EPLEN : 10; + vu32 _RES0 : 3; + vu32 SDBS : 1; + vu32 EPADR : 4; + vu32 EPDIR : 1; + vu32 EPTYPE: 1; + vu32 _RES1 : 1; + vu32 EPEN : 1; +} USBD_EPTCFGR_Bit; + +typedef union _EPTCFGR_TYPEDEF +{ + USBD_EPTCFGR_Bit bits; + u32 word; +} USBD_EPTCFGR_TypeDef; + +/* Endpoint CFGR and IER Register */ +typedef struct +{ + USBD_EPTCFGR_TypeDef CFGR; + u32 IER; +} USBD_EPTInit_TypeDef; + +/* Endpoint 0 ~ MAX_EP_NUM */ +typedef struct +{ + u32 uInterruptMask; + USBD_EPTInit_TypeDef ept[MAX_EP_NUM]; +} USBD_Driver_TypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Constants USB Device exported constants + * @{ + */ + +/* USB Interrupt Enable Register (USBIER) */ +#define UGIE ((u32)0x00000001) /*!< USB global Interrupt Enable */ +#define SOFIE ((u32)0x00000002) /*!< Start Of Frame Interrupt Enable */ +#define URSTIE ((u32)0x00000004) /*!< USB Reset Interrupt Enable */ +#define RSMIE ((u32)0x00000008) /*!< Resume Interrupt Enable */ +#define SUSPIE ((u32)0x00000010) /*!< Suspend Interrupt Enable */ +#define ESOFIE ((u32)0x00000020) /*!< Expected Start Of Frame Interrupt Enable */ +#define FRESIE ((u32)0x00000040) /*!< Force USB Reset Control Interrupt Enable */ +#define EP0IE ((u32)0x00000100) /*!< Endpoint 0 Interrupt Enable */ +#define EP1IE ((u32)0x00000200) /*!< Endpoint 1 Interrupt Enable */ +#define EP2IE ((u32)0x00000400) /*!< Endpoint 2 Interrupt Enable */ +#define EP3IE ((u32)0x00000800) /*!< Endpoint 3 Interrupt Enable */ +#define EP4IE ((u32)0x00001000) /*!< Endpoint 4 Interrupt Enable */ +#define EP5IE ((u32)0x00002000) /*!< Endpoint 5 Interrupt Enable */ +#define EP6IE ((u32)0x00004000) /*!< Endpoint 6 Interrupt Enable */ +#define EP7IE ((u32)0x00008000) /*!< Endpoint 7 Interrupt Enable */ + +/* USB Interrupt Status Register (USBISR) */ +#define SOFIF ((u32)0x00000002) /*!< Start Of Frame Interrupt Flag */ +#define URSTIF ((u32)0x00000004) /*!< USB Reset Interrupt Flag */ +#define RSMIF ((u32)0x00000008) /*!< Resume Interrupt Flag */ +#define SUSPIF ((u32)0x00000010) /*!< Suspend Interrupt Flag */ +#define ESOFIF ((u32)0x00000020) /*!< Expected Start Of Frame Interrupt Flag */ +#define FRESIF ((u32)0x00000040) /*!< Force USB Reset Control Interrupt Flag */ +#define EP0IF ((u32)0x00000100) /*!< Endpoint 0 Interrupt flag */ +#define EP1IF ((u32)0x00000200) /*!< Endpoint 1 Interrupt flag */ +#define EP2IF ((u32)0x00000400) /*!< Endpoint 2 Interrupt flag */ +#define EP3IF ((u32)0x00000800) /*!< Endpoint 3 Interrupt flag */ +#define EP4IF ((u32)0x00001000) /*!< Endpoint 4 Interrupt flag */ +#define EP5IF ((u32)0x00002000) /*!< Endpoint 5 Interrupt flag */ +#define EP6IF ((u32)0x00004000) /*!< Endpoint 6 Interrupt flag */ +#define EP7IF ((u32)0x00008000) /*!< Endpoint 7 Interrupt flag */ +#define EPnIF ((u32)0x0000FF00) /*!< Endpoint n Interrupt flag */ + +/* USB Endpoint n Interrupt Enable Register (USBEPnIER) */ +#define OTRXIE ((u32)0x00000001) /*!< OUT Token Received Interrupt Enable */ +#define ODRXIE ((u32)0x00000002) /*!< OUT Data Received Interrupt Enable */ +#define ODOVIE ((u32)0x00000004) /*!< OUT Data Buffer Overrun Interrupt Enable */ +#define ITRXIE ((u32)0x00000008) /*!< IN Token Received Interrupt Enable */ +#define IDTXIE ((u32)0x00000010) /*!< IN Data Transmitted Interrupt Enable */ +#define NAKIE ((u32)0x00000020) /*!< NAK Transmitted Interrupt Enable */ +#define STLIE ((u32)0x00000040) /*!< STALL Transmitted Interrupt Enable */ +#define UERIE ((u32)0x00000080) /*!< USB Error Interrupt Enable */ +#define STRXIE ((u32)0x00000100) /*!< SETUP Token Received Interrupt Enable */ +#define SDRXIE ((u32)0x00000200) /*!< SETUP Data Received Interrupt Enable */ +#define SDERIE ((u32)0x00000400) /*!< SETUP Data Error Interrupt Enable */ +#define ZLRXIE ((u32)0x00000800) /*!< Zero Length Data Received Interrupt Enable */ + +/* USB Endpoint n Interrupt Status Register (USBEPnISR) */ +#define OTRXIF ((u32)0x00000001) /*!< OUT Token Received Interrupt Flag */ +#define ODRXIF ((u32)0x00000002) /*!< OUT Data Received Interrupt Flag */ +#define ODOVIF ((u32)0x00000004) /*!< OUT Data Buffer Overrun Interrupt Flag */ +#define ITRXIF ((u32)0x00000008) /*!< IN Token Received Interrupt Flag */ +#define IDTXIF ((u32)0x00000010) /*!< IN Data Transmitted Interrupt Flag */ +#define NAKIF ((u32)0x00000020) /*!< NAK Transmitted Interrupt Flag */ +#define STLIF ((u32)0x00000040) /*!< STALL Transmitted Interrupt Flag */ +#define UERIF ((u32)0x00000080) /*!< USB Error Interrupt Flag */ +#define STRXIF ((u32)0x00000100) /*!< SETUP Token Received Interrupt Flag */ +#define SDRXIF ((u32)0x00000200) /*!< SETUP Data Received Interrupt Flag */ +#define SDERIF ((u32)0x00000400) /*!< SETUP Data Error Interrupt Flag */ +#define ZLRXIF ((u32)0x00000800) /*!< Zero Length Data Received Interrupt Flag */ + +/* USB Endpoint n Control and Status Register (USBEPnCSR) */ +#define DTGTX ((u32)0x00000001) /*!< Data Toggle Status, for IN transfer */ +#define NAKTX ((u32)0x00000002) /*!< NAK Status, for IN transfer */ +#define STLTX ((u32)0x00000004) /*!< STALL Status, for IN transfer */ +#define DTGRX ((u32)0x00000008) /*!< Data Toggle Status, for OUT transfer */ +#define NAKRX ((u32)0x00000010) /*!< NAK Status, for OUT transfer */ +#define STLRX ((u32)0x00000020) /*!< STALL Status, for OUT transfer */ + +/* For USBD_EPTGetTranssferCount function */ +#define USBD_CNTB0 (USBD_TCR_0) +#define USBD_CNTB1 (USBD_TCR_1) +#define USBD_CNTIN (USBD_TCR_0) +#define USBD_CNTOUT (USBD_TCR_1) +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Macro USB Device exported macro + * @{ + */ +/* API macro for USB Core - Global event and operation */ +#define API_USB_INIT(driver) (USBD_Init(driver)) +#define API_USB_DEINIT() (USBD_DeInit()) +#define API_USB_POWER_UP(driver, power) (USBD_PowerUp(driver, power)) +#define API_USB_POWER_OFF() (USBD_PowerOff()) +#define API_USB_POWER_ON() (USBD_PowerOn()) +#define API_USB_REMOTE_WAKEUP() (USBD_RemoteWakeup()) +#define API_USB_READ_SETUP(buffer) (USBD_ReadSETUPData((u32 *)(buffer))) +#define API_USB_SET_ADDR(addr) (USBD_SetAddress(addr)) +#define API_USB_GET_CTRL_IN_LEN() (USBD_EPTGetBufferLen(USBD_EPT0)) +#define API_USB_ENABLE_INT(flag) (USBD_EnableINT(flag)) +#define API_USB_GET_INT() (USBD_GetINT()) +#define API_USB_GET_EPT_NUM(flag) (USBD_GetEPTnINTNumber(flag)) +#define API_USB_IS_SETUP_INT(flag) (flag & SDRXIF) +#define API_USB_CLR_SETUP_INT() (USBD_EPTClearINT(USBD_EPT0, SDRXIF)) +#define API_USB_IS_RESET_INT(flag) (flag & URSTIF) +#define API_USB_CLR_RESET_INT() (USBD_ClearINT(URSTIF)) +#define API_USB_IS_SOF_INT(flag) (flag & SOFIF) +#define API_USB_CLR_SOF_INT() (USBD_ClearINT(SOFIF)) +#define API_USB_IS_FRES_INT(flag) (flag & FRESIF) +#define API_USB_CLR_FRES_INT() (USBD_ClearINT(FRESIF)) +#define API_USB_IS_RESUME_INT(flag) (flag & RSMIF) +#define API_USB_CLR_RESUME_INT() (USBD_ClearINT(RSMIF)) +#define API_USB_IS_SUSPEND_INT(flag) (flag & SUSPIF) +#define API_USB_CLR_SUSPEND_INT() (USBD_ClearINT(SUSPIF)) +#define API_USB_IS_EPTn_INT(flag, EPTn) (flag & (EP0IF << EPTn)) +#define API_USB_CLR_EPTn_INT(EPTn) (USBD_ClearINT(EP0IF << EPTn)) + +/* API macro for USB Core - Endpoint event and operation */ +#define API_USB_EPTn_INIT(EPTn, driver) (USBD_EPTInit(EPTn, driver)) +#define API_USB_EPTn_RESET(EPTn) (USBD_EPTReset(EPTn)) +#define API_USB_EPTn_SEND_STALL(EPTn) (USBD_EPTSendSTALL(EPTn)) +#define API_USB_EPTn_GET_INT(EPTn) (USBD_EPTGetINT(EPTn)) +#define API_USB_EPTn_IS_IN_INT(flag) (flag & IDTXIF) +#define API_USB_EPTn_CLR_IN_INT(EPTn) (USBD_EPTClearINT(EPTn, IDTXIF)) +#define API_USB_EPTn_IS_OUT_INT(flag) (flag & ODRXIF) +#define API_USB_EPTn_CLR_OUT_INT(EPTn) (USBD_EPTClearINT(EPTn, ODRXIF)) +#define API_USB_EPTn_IS_INT(flag) (flag & (ODRXIF | IDTXIF)) +#define API_USB_EPTn_CLR_INT(EPTn) (USBD_EPTClearINT(EPTn, (ODRXIF | IDTXIF))) +#define API_USB_EPTn_GET_HALT(EPTn) (USBD_EPTGetHalt(EPTn)) +#define API_USB_EPTn_SET_HALT(EPTn) (USBD_EPTSetHalt(EPTn)) +#define API_USB_EPTn_CLR_HALT(EPTn) (USBD_EPTClearHalt(EPTn)) +#define API_USB_EPTn_WAIT_STALL_SENT(EPTn) (USBD_EPTWaitSTALLSent(EPTn)) +#define API_USB_EPTn_CLR_DTG(EPTn) (USBD_EPTClearDTG(EPTn)) +#define API_USB_EPTn_GET_BUFFLEN(EPTn) (USBD_EPTGetBufferLen(EPTn)) +#define API_USB_EPTn_GET_CNT(EPTn, type) (USBD_EPTGetTransferCount(EPTn, type)) +#define API_USB_EPTn_WRITE_IN(EPTn, from, len) (USBD_EPTWriteINData(EPTn, from, len)) +#define API_USB_EPTn_READ_OUT(EPTn, to, len) (USBD_EPTReadOUTData(EPTn, to, len)) +#define API_USB_EPTn_READ_MEM(EPTn, to, len) (USBD_EPTReadMemory(EPTn, to, len)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Functions USB Device exported functions + * @{ + */ +void USBD_Init(u32 *pDriver); +void USBD_PreInit(USBD_Driver_TypeDef *pDriver); +void USBD_DPpullupCmd(ControlStatus NewState); +void USBD_DPWakeUpCmd(ControlStatus NewState); +void USBD_DeInit(void); +void USBD_PowerUp(u32 *pDriver, u32 uIsSelfPowered); +void USBD_PowerOff(void); +void USBD_PowerOn(void); +void USBD_SRAMResetConditionCmd(ControlStatus NewState); +void USBD_DisableDefaultPull(void); +void USBD_RemoteWakeup(void); +void USBD_ReadSETUPData(u32 *pBuffer); +void USBD_SetAddress(u32 address); +void USBD_EnableINT(u32 INTFlag); +void USBD_DisableINT(u32 INTFlag); +u32 USBD_GetINT(void); +void USBD_ClearINT(u32 INTFlag); +USBD_EPTn_Enum USBD_GetEPTnINTNumber(u32 INTFlag); + +void USBD_EPTInit(USBD_EPTn_Enum USBD_EPTn, u32 *pDriver); +void USBD_EPTReset(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTEnableINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag); +u32 USBD_EPTGetINT(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTClearINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag); +void USBD_EPTSendSTALL(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetHalt(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTSetHalt(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTClearHalt(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTWaitSTALLSent(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTClearDTG(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetBuffer0Addr(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetBuffer1Addr(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetBufferLen(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetTransferCount(USBD_EPTn_Enum USBD_EPTn, USBD_TCR_Enum USBD_TCR_0or1); +u32 USBD_EPTWriteINData(USBD_EPTn_Enum USBD_EPTn, u32 *pFrom, u32 len); +u32 USBD_EPTReadOUTData(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +u32 USBD_EPTReadMemory(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdchk.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdchk.h new file mode 100644 index 0000000000..0109747eb3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdchk.h @@ -0,0 +1,504 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_usbdchk.h + * @version $Rev:: 122 $ + * @date $Date:: 2017-06-13 #$ + * @brief The header file of the USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_USBDCHK_H +#define __HT32F1XXXX_USBDCHK_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup USBDevice + * @{ + */ + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint 0 ~ 7 and checking */ +/* !!! DO NOT MODIFY !!! */ +/*----------------------------------------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP0LEN != 8 && _EP0LEN != 16 && _EP0LEN != 32 && _EP0LEN != 64) + #error "USB Buffer Length (EPLEN) of Control Endpoint0 must be 8, 16, 32, or 64 bytes." +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration and checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP1_ENABLE == 1) + #if (_EP1_TYPR == EP_TYPE_BULK) + #if (_EP1LEN != 8 && _EP1LEN != 16 && _EP1LEN != 32 && _EP1LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint1 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP1LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint1 must be less than 64 bytes." + #endif + #if (_EP1LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint1 cannot be 0 byte." + #endif + #if ((_EP1LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint1 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP2_ENABLE == 1) + #if (_EP2_TYPR == EP_TYPE_BULK) + #if (_EP2LEN != 8 && _EP2LEN != 16 && _EP2LEN != 32 && _EP2LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint2 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP2LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint2 must be less than 64 bytes." + #endif + #if (_EP2LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint2 cannot be 0 byte." + #endif + #if ((_EP2LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint2 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP3_ENABLE == 1) + #if (_EP3_TYPR == EP_TYPE_BULK) + #if (_EP3LEN != 8 && _EP3LEN != 16 && _EP3LEN != 32 && _EP3LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint3 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP3LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint3 must be less than 64 bytes." + #endif + #if (_EP3LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint3 cannot be 0 byte." + #endif + #if ((_EP3LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint3 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP4_ENABLE == 1) + #if (_EP4_TYPR == EP_TYPE_BULK) + #if (_EP4LEN != 8 && _EP4LEN != 16 && _EP4LEN != 32 && _EP4LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP4_TYPR == EP_TYPE_INT) + #if (_EP4LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP4_TYPR == EP_TYPE_ISO) + #if (_EP4LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP4LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint4 cannot be 0 byte." + #endif + #if ((_EP4LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP5_ENABLE == 1) + #if (_EP5_TYPR == EP_TYPE_BULK) + #if (_EP5LEN != 8 && _EP5LEN != 16 && _EP5LEN != 32 && _EP5LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP5_TYPR == EP_TYPE_INT) + #if (_EP5LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP5_TYPR == EP_TYPE_ISO) + #if (_EP5LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP5LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint5 cannot be 0 byte." + #endif + #if ((_EP5LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP6_ENABLE == 1) + #if (_EP6_TYPR == EP_TYPE_BULK) + #if (_EP6LEN != 8 && _EP6LEN != 16 && _EP6LEN != 32 && _EP6LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP6_TYPR == EP_TYPE_INT) + #if (_EP6LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP6_TYPR == EP_TYPE_ISO) + #if (_EP6LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP6LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint6 cannot be 0 byte." + #endif + #if ((_EP6LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP7_ENABLE == 1) + #if (_EP7_TYPR == EP_TYPE_BULK) + #if (_EP7LEN != 8 && _EP7LEN != 16 && _EP7LEN != 32 && _EP7LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP7_TYPR == EP_TYPE_INT) + #if (_EP7LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP7_TYPR == EP_TYPE_ISO) + #if (_EP7LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP7LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint7 cannot be 0 byte." + #endif + #if ((_EP7LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be a multiple of 4 (word-aligned)." + #endif +#endif + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Check the endpoint address */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP1_ENABLE == 1) + #if (_EP1_CFG_EPADR == 0) + #error "The address of Endpoint1 (EPADR) cannot be 0." + #endif + #if (_EP2_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint7." + #endif + #endif +#endif + +#if (_EP2_ENABLE == 1) + #if (_EP2_CFG_EPADR == 0) + #error "The address of Endpoint2 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint7." + #endif + #endif +#endif + +#if (_EP3_ENABLE == 1) + #if (_EP3_CFG_EPADR == 0) + #error "The address of Endpoint3 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint7." + #endif + #endif +#endif + +#if (_EP4_ENABLE == 1) + #if (_EP4_CFG_EPADR == 0) + #error "The address of Endpoint4 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint7." + #endif + #endif +#endif + +#if (_EP5_ENABLE == 1) + #if (_EP5_CFG_EPADR == 0) + #error "The address of Endpoint5 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint7." + #endif + #endif +#endif + +#if (_EP6_ENABLE == 1) + #if (_EP6_CFG_EPADR == 0) + #error "The address of Endpoint6 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint7." + #endif + #endif +#endif + +#if (_EP7_ENABLE == 1) + #if (_EP7_CFG_EPADR == 0) + #error "The address of Endpoint1 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint6." + #endif + #endif +#endif + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Check Buffer size */ +/*----------------------------------------------------------------------------------------------------------*/ +#if ((_EP0LEN_T + _EP1LEN + _EP2LEN + _EP3LEN + _EP4LEN_T + _EP5LEN_T + _EP6LEN_T + _EP7LEN_T) > 1024) + #error "Total buffer size of Endpoint 0 ~ 7 must be less than 1024 bytes." +#endif + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdinit.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdinit.h new file mode 100644 index 0000000000..b0cd17e96f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_usbdinit.h @@ -0,0 +1,283 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_usbdinit.h + * @version $Rev:: 2971 $ + * @date $Date:: 2023-10-25 #$ + * @brief The header file of the USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_USBDINIT_H +#define __HT32F1XXXX_USBDINIT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32_retarget_usbdconf.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup USBDevice + * @{ + */ + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint 0 ~ 7 Configuration */ +/* !!! DO NOT MODIFY !!! */ +/*----------------------------------------------------------------------------------------------------------*/ + +#define EP_TYPE_ISO (1) +#define EP_TYPE_BULK (2) +#define EP_TYPE_INT (3) + +#ifndef _UIER_ALL + #define _UIER_ALL _UIER +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP0_CFG_EPEN (1UL) +#define _EP0STADR (HT_USB_SRAM_BASE + 0x8) +#define _EP0INTADR (_EP0STADR) +#define _EP0OUTTADR (_EP0STADR + _EP0LEN) +#define _EP0_CFG ((_EP0_CFG_EPEN << 31) | \ + (_EP0LEN << 10) | \ + (_EP0STADR & EPBUFA_MASK)) +#define _EP0LEN_T (_EP0LEN * 2) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP1STADR (_EP0STADR + (_EP0LEN * 2)) + +#if (_EP1_ENABLE == 1) + #define _EP1LEN (_EP1LEN_TMP) +#else + #define _EP1LEN (0) +#endif + +#if (_EP1_CFG_EPEN_TMP == 1) + #define _EP1_CFG_EPEN (1UL) +#else + #define _EP1_CFG_EPEN (0UL) +#endif + +#define _EP1_CFG ((_EP1_CFG_EPEN << 31) | \ + (_EP1_CFG_EPDIR << 28) | \ + (_EP1_CFG_EPADR << 24) | \ + (_EP1LEN << 10) | \ + (_EP1STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP2STADR (_EP1STADR + _EP1LEN) + +#if (_EP2_ENABLE == 1) + #define _EP2LEN (_EP2LEN_TMP) +#else + #define _EP2LEN (0) +#endif + +#if (_EP2_CFG_EPEN_TMP == 1) + #define _EP2_CFG_EPEN (1UL) +#else + #define _EP2_CFG_EPEN (0UL) +#endif + +#define _EP2_CFG ((_EP2_CFG_EPEN << 31) | \ + (_EP2_CFG_EPDIR << 28) | \ + (_EP2_CFG_EPADR << 24) | \ + (_EP2LEN << 10) | \ + (_EP2STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP3STADR (_EP2STADR + _EP2LEN) + +#if (_EP3_ENABLE == 1) + #define _EP3LEN (_EP3LEN_TMP) +#else + #define _EP3LEN (0) +#endif + +#if (_EP3_CFG_EPEN_TMP == 1) + #define _EP3_CFG_EPEN (1UL) +#else + #define _EP3_CFG_EPEN (0UL) +#endif + +#define _EP3_CFG ((_EP3_CFG_EPEN << 31) | \ + (_EP3_CFG_EPDIR << 28) | \ + (_EP3_CFG_EPADR << 24) | \ + (_EP3LEN << 10) | \ + (_EP3STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP4STADR (_EP3STADR + _EP3LEN) + +#if (_EP4_ENABLE == 1) + #define _EP4LEN (_EP4LEN_TMP) + #define _EP4LEN_T (_EP4LEN_TMP * (_EP4_CFG_SDBS + 1)) +#else + #define _EP4LEN (0) + #define _EP4LEN_T (0) +#endif +#if (_EP4_TYPR == EP_TYPE_ISO) + #define _EP4_CFG_EPTYPE (1) +#else + #define _EP4_CFG_EPTYPE (0) +#endif + +#if (_EP4_CFG_EPEN_TMP == 1) + #define _EP4_CFG_EPEN (1UL) +#else + #define _EP4_CFG_EPEN (0UL) +#endif + +#define _EP4_CFG ((_EP4_CFG_EPEN << 31) | \ + (_EP4_CFG_EPTYPE << 29) | \ + (_EP4_CFG_EPDIR << 28) | \ + (_EP4_CFG_EPADR << 24) | \ + (_EP4_CFG_SDBS << 23) | \ + (_EP4LEN << 10) | \ + (_EP4STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP5STADR (_EP4STADR + _EP4LEN_T) + +#if (_EP5_ENABLE == 1) + #define _EP5LEN (_EP5LEN_TMP) + #define _EP5LEN_T (_EP5LEN_TMP * (_EP5_CFG_SDBS + 1)) +#else + #define _EP5LEN (0) + #define _EP5LEN_T (0) +#endif +#if (_EP5_TYPR == EP_TYPE_ISO) + #define _EP5_CFG_EPTYPE (1) +#else + #define _EP5_CFG_EPTYPE (0) +#endif + +#if (_EP5_CFG_EPEN_TMP == 1) + #define _EP5_CFG_EPEN (1UL) +#else + #define _EP5_CFG_EPEN (0UL) +#endif + +#define _EP5_CFG ((_EP5_CFG_EPEN << 31) | \ + (_EP5_CFG_EPTYPE << 29) | \ + (_EP5_CFG_EPDIR << 28) | \ + (_EP5_CFG_EPADR << 24) | \ + (_EP5_CFG_SDBS << 23) | \ + (_EP5LEN << 10) | \ + (_EP5STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP6STADR (_EP5STADR + _EP5LEN_T) + +#if (_EP6_ENABLE == 1) + #define _EP6LEN (_EP6LEN_TMP) + #define _EP6LEN_T (_EP6LEN_TMP * (_EP6_CFG_SDBS + 1)) +#else + #define _EP6LEN (0) + #define _EP6LEN_T (0) +#endif +#if (_EP6_TYPR == EP_TYPE_ISO) + #define _EP6_CFG_EPTYPE (1) +#else + #define _EP6_CFG_EPTYPE (0) +#endif + +#if (_EP6_CFG_EPEN_TMP == 1) + #define _EP6_CFG_EPEN (1UL) +#else + #define _EP6_CFG_EPEN (0UL) +#endif + +#define _EP6_CFG ((_EP6_CFG_EPEN << 31) | \ + (_EP6_CFG_EPTYPE << 29) | \ + (_EP6_CFG_EPDIR << 28) | \ + (_EP6_CFG_EPADR << 24) | \ + (_EP6_CFG_SDBS << 23) | \ + (_EP6LEN << 10) | \ + (_EP6STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP7STADR (_EP6STADR + _EP6LEN_T) + +#if (_EP7_ENABLE == 1) + #define _EP7LEN (_EP7LEN_TMP) + #define _EP7LEN_T (_EP7LEN_TMP * (_EP7_CFG_SDBS + 1)) +#else + #define _EP7LEN (0) + #define _EP7LEN_T (0) +#endif +#if (_EP7_TYPR == EP_TYPE_ISO) + #define _EP7_CFG_EPTYPE (1) +#else + #define _EP7_CFG_EPTYPE (0) +#endif + +#if (_EP7_CFG_EPEN_TMP == 1) + #define _EP7_CFG_EPEN (1UL) +#else + #define _EP7_CFG_EPEN (0UL) +#endif + +#define _EP7_CFG ((_EP7_CFG_EPEN << 31) | \ + (_EP7_CFG_EPTYPE << 29) | \ + (_EP7_CFG_EPDIR << 28) | \ + (_EP7_CFG_EPADR << 24) | \ + (_EP7_CFG_SDBS << 23) | \ + (_EP7LEN << 10) | \ + (_EP7STADR & EPBUFA_MASK)) + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_wdt.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_wdt.h new file mode 100644 index 0000000000..c0a9c03951 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f1xxxx_wdt.h @@ -0,0 +1,148 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_wdt.h + * @version $Rev:: 122 $ + * @date $Date:: 2017-06-13 #$ + * @brief The header file of the WDT library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F1XXXX_WDT_H +#define __HT32F1XXXX_WDT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup WDT + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Exported_Constants WDT exported constants + * @{ + */ + +/* WDT prescaler */ +#define WDT_PRESCALER_1 ((u16)0x0000) +#define WDT_PRESCALER_2 ((u16)0x1000) +#define WDT_PRESCALER_4 ((u16)0x2000) +#define WDT_PRESCALER_8 ((u16)0x3000) +#define WDT_PRESCALER_16 ((u16)0x4000) +#define WDT_PRESCALER_32 ((u16)0x5000) +#define WDT_PRESCALER_64 ((u16)0x6000) +#define WDT_PRESCALER_128 ((u16)0x7000) + +#define IS_WDT_PRESCALER(PRESCALER) ((PRESCALER == WDT_PRESCALER_1) || \ + (PRESCALER == WDT_PRESCALER_2) || \ + (PRESCALER == WDT_PRESCALER_4) || \ + (PRESCALER == WDT_PRESCALER_8) || \ + (PRESCALER == WDT_PRESCALER_16) || \ + (PRESCALER == WDT_PRESCALER_32) || \ + (PRESCALER == WDT_PRESCALER_64) || \ + (PRESCALER == WDT_PRESCALER_128)) + + +/* WDT runs or halts in sleep and deep sleep1 mode */ +/* WDT WDTSHLT mask */ +#define MODE0_WDTSHLT_BOTH ((u32)0x00000000) +#define MODE0_WDTSHLT_SLEEP ((u32)0x00004000) +#define MODE0_WDTSHLT_HALT ((u32)0x00008000) + +#define IS_WDT_WDTSHLT_MODE(WDT_Mode) ((WDT_Mode == MODE0_WDTSHLT_BOTH) || \ + (WDT_Mode == MODE0_WDTSHLT_SLEEP) || \ + (WDT_Mode == MODE0_WDTSHLT_HALT)) + + + +/* WDT Flag */ +#define WDT_FLAG_UNDERFLOW ((u32)0x00000001) +#define WDT_FLAG_ERROR ((u32)0x00000002) + + +#define IS_WDT_FLAG(WDT_FLAG) ((WDT_FLAG == WDT_FLAG_UNDERFLOW) || \ + (WDT_FLAG == WDT_FLAG_ERROR)) + + +#define IS_WDT_RELOAD(WDTV) ((WDTV <= 0xFFF)) + +#define IS_WDT_DELTA(WDTD) ((WDTD <= 0xFFF)) + +/* WDT Source Select */ +#define WDT_SOURCE_LSI ((u32)0x00000000) +#define WDT_SOURCE_LSE ((u32)0x00000001) + + +#define IS_WDT_SOURCE_SELECT(WDT_SOURCE) ((WDT_SOURCE == WDT_SOURCE_LSI) || \ + (WDT_SOURCE == WDT_SOURCE_LSE)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Exported_Functions WDT exported functions + * @{ + */ +void WDT_DeInit(void); +void WDT_Cmd(ControlStatus NewState); +#if (LIBCFG_WDT_INT) +void WDT_IntConfig(ControlStatus NewState); +#endif +void WDT_HaltConfig(u32 WDT_Mode); +void WDT_ResetCmd(ControlStatus NewState); +void WDT_ProtectCmd(ControlStatus NewState); +void WDT_SetReloadValue(u16 WDTV); +u16 WDT_GetReloadValue(void); +void WDT_SetDeltaValue(u16 WDTD); +u16 WDT_GetDeltaValue(void); +void WDT_SetPrescaler(u16 WDT_PRESCALER); +u8 WDT_GetPrescaler(void); +void WDT_Restart(void); +FlagStatus WDT_GetFlagStatus (u32 WDT_FLAG); +void WDT_LockCmd(ControlStatus NewState); +void WDT_SourceConfig(u32 WDT_SOURCE); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f2xxxx_csif.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f2xxxx_csif.h new file mode 100644 index 0000000000..2460b561ba --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/inc/ht32f2xxxx_csif.h @@ -0,0 +1,302 @@ +/*********************************************************************************************************//** + * @file ht32f2xxxx_csif.h + * @version $Rev:: 122 $ + * @date $Date:: 2017-06-13 #$ + * @brief The header file of the CSIF library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F2XXXX_CSIF_H +#define __HT32F2XXXX_CSIF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CSIF + * @{ + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ + +/** @defgroup CSIF_Exported_Types CSIF exported types + * @{ + */ + +typedef struct +{ + u32 CSIF_Format; + u32 CSIF_VSYNCType; + u32 CSIF_HSYNCType; + u32 CSIF_SampleEdge; + u32 CSIF_VSYNCPolarity; + u32 CSIF_HSYNCPolarity; + u32 CSIF_LineDelay; + u32 CSIF_FrameDelay; + u32 CSIF_ImageWidth; + u32 CSIF_ImageHeight; +}CSIF_BasicInitTypeDef; + + +typedef struct +{ + u32 CSIF_Window; + u32 CSIF_HorizontalStartPoint; + u32 CSIF_VerticalStartPoint; + u32 CSIF_WindowWidth; + u32 CSIF_WindowHeight; +}CSIF_WindowInitTypeDef; + + +typedef struct +{ + u32 CSIF_SubSample; + u32 CSIF_ColumnSkipMaskLength; + u32 CSIF_RowSkipMaskLength; + u32 CSIF_ColumnSkipMask; + u32 CSIF_RowSkipMask; +}CSIF_SubSampleInitTypeDef; + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CSIF_Exported_Constants CSIF exported constants + * @{ + */ + +#define CSIF_FORMAT_RAWRGB ((u32)0x00000000) +#define CSIF_FORMAT_YUV422 ((u32)0x00000010) + +#define IS_CSIF_FORMAT(FORMAT) ((FORMAT == CSIF_FORMAT_RAWRGB) || \ + (FORMAT == CSIF_FORMAT_YUV422)) + + +#define CSIF_VSYNCTYPE_PULSE ((u32)0x00000000) +#define CSIF_VSYNCTYPE_OVERLAP ((u32)0x00000002) + +#define IS_CSIF_VSYNC_TYPE(TYPE) ((TYPE == CSIF_VSYNCTYPE_PULSE) || \ + (TYPE == CSIF_VSYNCTYPE_OVERLAP)) + + +#define CSIF_HSYNCTYPE_CONTINUOUS ((u32)0x00000000) +#define CSIF_HSYNCTYPE_DISCONTINUOUS ((u32)0x00000004) + +#define IS_CSIF_HSYNC_TYPE(TYPE) ((TYPE == CSIF_HSYNCTYPE_CONTINUOUS) || \ + (TYPE == CSIF_HSYNCTYPE_DISCONTINUOUS)) + + +#define CSIF_SAMPLEEDGE_FALLING ((u32)0x00000000) +#define CSIF_SAMPLEEDGE_RISING ((u32)0x00000008) + +#define IS_CSIF_SAMPLE_EDGE(EDGE) ((EDGE == CSIF_SAMPLEEDGE_FALLING) || \ + (EDGE == CSIF_SAMPLEEDGE_RISING)) + + +#define CSIF_VSYNCPOLARITY_HIGH ((u32)0x00000000) +#define CSIF_VSYNCPOLARITY_LOW ((u32)0x00000040) + +#define IS_CSIF_VSYNC_POLARITY(POLARITY) ((POLARITY == CSIF_VSYNCPOLARITY_HIGH) || \ + (POLARITY == CSIF_VSYNCPOLARITY_LOW)) + + +#define CSIF_HSYNCPOLARITY_HIGH ((u32)0x00000000) +#define CSIF_HSYNCPOLARITY_LOW ((u32)0x00000080) + +#define IS_CSIF_HSYNC_POLARITY(POLARITY) ((POLARITY == CSIF_HSYNCPOLARITY_HIGH) || \ + (POLARITY == CSIF_HSYNCPOLARITY_LOW)) + + +#define CSIF_WINDOW_ENABLE ((u32)0x80000000) +#define CSIF_WINDOW_DISABLE ((u32)0x00000000) + +#define IS_CSIF_WINDOW(WINDOW) ((WINDOW == CSIF_WINDOW_ENABLE) || \ + (WINDOW == CSIF_WINDOW_DISABLE)) + + +#define CSIF_SUBSAMPLE_ENABLE ((u32)0x80000000) +#define CSIF_SUBSAMPLE_DISABLE ((u32)0x00000000) + +#define IS_CSIF_SUB_SAMPLE(SAMPLE) ((SAMPLE == CSIF_SUBSAMPLE_ENABLE) || \ + (SAMPLE == CSIF_SUBSAMPLE_DISABLE)) + + +#define CSIF_MASKLENGTH_1B ((u32)0x00000000) +#define CSIF_MASKLENGTH_2B ((u32)0x00000001) +#define CSIF_MASKLENGTH_3B ((u32)0x00000002) +#define CSIF_MASKLENGTH_4B ((u32)0x00000003) +#define CSIF_MASKLENGTH_5B ((u32)0x00000004) +#define CSIF_MASKLENGTH_6B ((u32)0x00000005) +#define CSIF_MASKLENGTH_7B ((u32)0x00000006) +#define CSIF_MASKLENGTH_8B ((u32)0x00000007) +#define CSIF_MASKLENGTH_9B ((u32)0x00000008) +#define CSIF_MASKLENGTH_10B ((u32)0x00000009) +#define CSIF_MASKLENGTH_11B ((u32)0x0000000A) +#define CSIF_MASKLENGTH_12B ((u32)0x0000000B) +#define CSIF_MASKLENGTH_13B ((u32)0x0000000C) +#define CSIF_MASKLENGTH_14B ((u32)0x0000000D) +#define CSIF_MASKLENGTH_15B ((u32)0x0000000E) +#define CSIF_MASKLENGTH_16B ((u32)0x0000000F) +#define CSIF_MASKLENGTH_17B ((u32)0x00000010) +#define CSIF_MASKLENGTH_18B ((u32)0x00000011) +#define CSIF_MASKLENGTH_19B ((u32)0x00000012) +#define CSIF_MASKLENGTH_20B ((u32)0x00000013) +#define CSIF_MASKLENGTH_21B ((u32)0x00000014) +#define CSIF_MASKLENGTH_22B ((u32)0x00000015) +#define CSIF_MASKLENGTH_23B ((u32)0x00000016) +#define CSIF_MASKLENGTH_24B ((u32)0x00000017) +#define CSIF_MASKLENGTH_25B ((u32)0x00000018) +#define CSIF_MASKLENGTH_26B ((u32)0x00000019) +#define CSIF_MASKLENGTH_27B ((u32)0x0000001A) +#define CSIF_MASKLENGTH_28B ((u32)0x0000001B) +#define CSIF_MASKLENGTH_29B ((u32)0x0000001C) +#define CSIF_MASKLENGTH_30B ((u32)0x0000001D) +#define CSIF_MASKLENGTH_31B ((u32)0x0000001E) +#define CSIF_MASKLENGTH_32B ((u32)0x0000001F) + +#define IS_CSIF_MASK_LENGTH(LENGTH) (LENGTH <= 0x1F) + + +#define CSIF_FIFO_0 ((u8)0x20) +#define CSIF_FIFO_1 ((u8)0x24) +#define CSIF_FIFO_2 ((u8)0x28) +#define CSIF_FIFO_3 ((u8)0x2C) +#define CSIF_FIFO_4 ((u8)0x30) +#define CSIF_FIFO_5 ((u8)0x34) +#define CSIF_FIFO_6 ((u8)0x38) +#define CSIF_FIFO_7 ((u8)0x3C) + +#define IS_CSIF_FIFO(FIFO) ((FIFO == CSIF_FIFO_0) || \ + (FIFO == CSIF_FIFO_1) || \ + (FIFO == CSIF_FIFO_2) || \ + (FIFO == CSIF_FIFO_3) || \ + (FIFO == CSIF_FIFO_4) || \ + (FIFO == CSIF_FIFO_5) || \ + (FIFO == CSIF_FIFO_6) || \ + (FIFO == CSIF_FIFO_7)) + +#define CSIF_INT_SOFFLG ((u32)0x00000001) +#define CSIF_INT_EOFFLG ((u32)0x00000002) +#define CSIF_INT_CAPSTA ((u32)0x00000004) +#define CSIF_INT_CAPSTS ((u32)0x00000008) +#define CSIF_INT_BADFRAME ((u32)0x00000010) +#define CSIF_INT_FIFOOVR ((u32)0x00000100) +#define CSIF_INT_FIFOEMP ((u32)0x00000200) +#define CSIF_INT_FIFOFUL ((u32)0x00000400) +#define CSIF_INT_ALL ((u32)0x0000071F) + +#define IS_CSIF_INT(INT) (((INT & 0xFFFFF8E0) == 0x0) && (INT != 0x0)) + + + +#define CSIF_FLAG_SOFFLG ((u32)0x00000001) +#define CSIF_FLAG_EOFFLG ((u32)0x00000002) +#define CSIF_FLAG_CAPSTA ((u32)0x00000004) +#define CSIF_FLAG_CAPSTS ((u32)0x00000008) +#define CSIF_FLAG_BADFRAME ((u32)0x00000010) +#define CSIF_FLAG_FIFOOVR ((u32)0x00000100) +#define CSIF_FLAG_FIFOEMP ((u32)0x00000200) +#define CSIF_FLAG_FIFOFUL ((u32)0x00000400) + +#define IS_CSIF_FLAG(FLAG) ((FLAG == CSIF_FLAG_SOFFLG) || \ + (FLAG == CSIF_FLAG_EOFFLG) || \ + (FLAG == CSIF_FLAG_CAPSTA) || \ + (FLAG == CSIF_FLAG_CAPSTS) || \ + (FLAG == CSIF_FLAG_BADFRAME) || \ + (FLAG == CSIF_FLAG_FIFOOVR) || \ + (FLAG == CSIF_FLAG_FIFOEMP) || \ + (FLAG == CSIF_FLAG_FIFOFUL)) + +#define IS_CSIF_CLEAR_FLAG(FLAG) ((FLAG == CSIF_FLAG_SOFFLG) || \ + (FLAG == CSIF_FLAG_EOFFLG) || \ + (FLAG == CSIF_FLAG_CAPSTA) || \ + (FLAG == CSIF_FLAG_CAPSTS) || \ + (FLAG == CSIF_FLAG_BADFRAME)) + + +#define IS_CSIF_LINE_DELAY(DELAY) (DELAY <= 0xFF) + +#define IS_CSIF_FRAME_DELAY(DELAY) (DELAY <= 0xFF) + +#define IS_CSIF_IMAGE_WIDTH(WIDTH) (WIDTH <= 0x800) + +#define IS_CSIF_IMAGE_HEIGHT(HEIGHT) (HEIGHT <= 0x800) + +#define IS_CSIF_HORSTART_POINT(POINT) (POINT <= 0x7FF) + +#define IS_CSIF_VERSTART_POINT(POINT) (POINT <= 0x7FF) + +#define IS_CSIF_WINDOW_WIDTH(WIDTH) (WIDTH <= 0x800) + +#define IS_CSIF_WINDOW_HEIGHT(HEIGHT) (HEIGHT <= 0x800) + +#define IS_CSIF_PRESCALER(PRESCALER) ((PRESCALER%2 == 0) && (PRESCALER != 0)) + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CSIF_Exported_Functions CSIF exported functions + * @{ + */ +void CSIF_DeInit(void); +void CSIF_BasicInit(CSIF_BasicInitTypeDef* CSIF_BasicInitStruct); +void CSIF_BasicStructInit(CSIF_BasicInitTypeDef* CSIF_BasicInitStruct); +void CSIF_WindowInit(CSIF_WindowInitTypeDef* CSIF_WindowInitStruct); +void CSIF_WindowStructInit(CSIF_WindowInitTypeDef* CSIF_WindowInitStruct); +void CSIF_SubSampleInit(CSIF_SubSampleInitTypeDef* CSIF_SubSampleInitStruct); +void CSIF_SunSampleStructInit(CSIF_SubSampleInitTypeDef* CSIF_SubSampleInitStruct); +void CSIF_Cmd(ControlStatus NewState); +void CSIF_IntConfig(u32 CSIF_Int, ControlStatus NewState); +FlagStatus CSIF_GetFlagStatus(u32 CSIF_Flag); +void CSIF_ClearFlag(u32 CSIF_Flag); +u32 CSIF_ReceiveData(u8 CSIF_FIFO); +void CSIF_MasterClockCmd(ControlStatus NewState); +void CSIF_SetMasterClockPrescaler(u8 CSIF_Prescaler); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_cm3_misc.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_cm3_misc.c new file mode 100644 index 0000000000..c9632a267d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_cm3_misc.c @@ -0,0 +1,232 @@ +/*********************************************************************************************************//** + * @file ht32_cm3_misc.c + * @version $Rev:: 2437 $ + * @date $Date:: 2021-06-01 #$ + * @brief This file provides all the miscellaneous firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32_cm3_misc.h" +#include "ht32_rand.c" +#ifdef HTCFG_TIME_IPSEL +#include "ht32_time.c" +#endif + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup MISC MISC + * @brief MISC driver modules + * @{ + */ + + +/* Private definitions -------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Private_Define MISC private definitions + * @{ + */ +#define AIRCR_VECTKEY_MASK ((u32)0x05FA0000) +#define CTRL_TICKINT_SET ((u32)0x00000002) +#define CTRL_TICKINT_RESET ((u32)0xFFFFFFFD) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Exported_Functions MISC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Set the vector table location and Offset. + * @param NVIC_VectTable: Specify if the vector table is in FLASH or RAM. + * This parameter can be one of the following values: + * @arg NVIC_VECTTABLE_RAM + * @arg NVIC_VECTTABLE_FLASH + * @param NVIC_Offset: Vector Table base offset field. + * This value must be a multiple of 0x100. + * @retval None + ***********************************************************************************************************/ +void NVIC_SetVectorTable(u32 NVIC_VectTable, u32 NVIC_Offset) +{ + /* Check the parameters */ + Assert_Param(IS_NVIC_VECTTABLE(NVIC_VectTable)); + Assert_Param(IS_NVIC_OFFSET(NVIC_Offset)); + + SCB->VTOR = NVIC_VectTable | (NVIC_Offset & (u32)0x1FFFFF80); +} + +/*********************************************************************************************************//** + * @brief Select which low power mode to execute to the system. + * @param NVIC_LowPowerMode: Specify the new low power mode to execute to the system. + * This parameter can be one of the following values: + * @arg NVIC_LOWPOWER_SEVONPEND + * @arg NVIC_LOWPOWER_SLEEPDEEP + * @arg NVIC_LOWPOWER_SLEEPONEXIT + * @param NewState: new state of low power condition. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void NVIC_LowPowerConfig(u8 NVIC_LowPowerMode, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_NVIC_LOWPOWER(NVIC_LowPowerMode)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCB->SCR |= NVIC_LowPowerMode; + } + else + { + SCB->SCR &= (u32)(~(u32)NVIC_LowPowerMode); + } +} + +/*********************************************************************************************************//** + * @brief Generate a Core (Core + NVIC) reset. + * @retval None + ***********************************************************************************************************/ +void NVIC_CoreReset(void) +{ + SCB->AIRCR = AIRCR_VECTKEY_MASK | (u32)0x01; +} + +/*********************************************************************************************************//** + * @brief Set the pending bit for a system handler. + * @param SystemHandler: Specify the system handler pending bit to be set. + * This parameter can be one of the following values: + * @arg SYSTEMHANDLER_NMI + * @arg SYSTEMHANDLER_PSV + * @arg SYSTEMHANDLER_SYSTICK + * @retval None + ***********************************************************************************************************/ +void NVIC_SetPendingSystemHandler(u32 SystemHandler) +{ + /* Check the parameters */ + Assert_Param(IS_NVIC_SYSTEMHANDLER(SystemHandler)); + + /* Set the corresponding System Handler pending bit */ + SCB->ICSR |= SystemHandler; +} + +/*********************************************************************************************************//** + * @brief Configure the SysTick clock source. + * @param SysTick_ClockSource: Specify the SysTick clock source. + * This parameter can be one of the following values: + * @arg SYSTICK_SRC_STCLK : External reference clock is selected as SysTick clock source. + * @arg SYSTICK_SRC_FCLK : AHB clock is selected as SysTick clock source. + * @retval None + ***********************************************************************************************************/ +void SYSTICK_ClockSourceConfig(u32 SysTick_ClockSource) +{ + /* Check the parameters */ + Assert_Param(IS_SYSTICK_CLOCK_SOURCE(SysTick_ClockSource)); + + if (SysTick_ClockSource == SYSTICK_SRC_FCLK) + { + SysTick->CTRL |= SYSTICK_SRC_FCLK; + } + else + { + SysTick->CTRL &= SYSTICK_SRC_STCLK; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SysTick counter. + * @param SysTick_Counter: new state of the SysTick counter. + * This parameter can be one of the following values: + * @arg SYSTICK_COUNTER_DISABLE : Disable counter + * @arg SYSTICK_COUNTER_ENABLE : Enable counter + * @arg SYSTICK_COUNTER_CLEAR : Clear counter value to 0 + * @retval None + ***********************************************************************************************************/ +void SYSTICK_CounterCmd(u32 SysTick_Counter) +{ + /* Check the parameters */ + Assert_Param(IS_SYSTICK_COUNTER(SysTick_Counter)); + + if (SysTick_Counter == SYSTICK_COUNTER_CLEAR) + { + SysTick->VAL = SYSTICK_COUNTER_CLEAR; + } + else + { + if (SysTick_Counter == SYSTICK_COUNTER_ENABLE) + { + SysTick->CTRL |= SYSTICK_COUNTER_ENABLE; + } + else + { + SysTick->CTRL &= SYSTICK_COUNTER_DISABLE; + } + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SysTick Interrupt. + * @param NewState: new state of the SysTick Interrupt. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void SYSTICK_IntConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SysTick->CTRL |= CTRL_TICKINT_SET; + } + else + { + SysTick->CTRL &= CTRL_TICKINT_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Set SysTick counter reload value. + * @param SysTick_Reload: SysTick reload new value. + * This parameter must be a number between 1 and 0xFFFFFF. + * @retval None + ***********************************************************************************************************/ +void SYSTICK_SetReloadValue(u32 SysTick_Reload) +{ + /* Check the parameters */ + Assert_Param(IS_SYSTICK_RELOAD(SysTick_Reload)); + + SysTick->LOAD = SysTick_Reload; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_rand.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_rand.c new file mode 100644 index 0000000000..5b47d8884f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_rand.c @@ -0,0 +1,106 @@ +/*********************************************************************************************************//** + * @file ht32_rand.c + * @version $Rev:: 1736 $ + * @date $Date:: 2019-06-25 #$ + * @brief The rundom number function. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include + +/* Global variables ----------------------------------------------------------------------------------------*/ +#if !(LIBCFG_ADC_V01) +__ALIGN4 static uc32 RandData[] = +{ + 0x4fffe92d, 0xb0844948, 0x94016a4c, 0x94006b0c, + 0xf4446a4c, 0x624c3440, 0x4d446b0c, 0x630c432c, + 0x2135ea4f, 0xf004688c, 0xf5a40480, 0x608c4479, + 0x2403ea42, 0x4402ea44, 0x6403ea44, 0xea42610c, + 0xea442402, 0xea444403, 0x614c6403, 0x0282eb01, + 0x67142417, 0x0283eb01, 0x22016714, 0x2100f8c1, + 0xf042688a, 0x608a0280, 0x90c4f8df, 0x2004f8d9, + 0x4a309202, 0x93036853, 0x73fff64f, 0x3004f8c9, + 0xf8d96053, 0x69d7601c, 0x2104f8d1, 0x0201f042, + 0x2104f8c1, 0x2134f8d1, 0xd5fb0752, 0x2fb0f851, + 0x0b0ff002, 0xf002684a, 0x688a0e0f, 0x0a0ff002, + 0xf00268ca, 0x690a050f, 0x040ff002, 0xf002694a, + 0x698a030f, 0xf00269c9, 0xf8d0020f, 0xf8d9c000, + 0x44c4801c, 0xeb064466, 0x4f164607, 0xf8d76006, + 0xea4bc01c, 0xeb06180e, 0xea4f460c, 0xea4c2c0a, + 0xea483505, 0xea480805, 0xea444404, 0xea435303, + 0xea426202, 0x9a057101, 0x44114431, 0x98026001, + 0x0004f8c9, 0x60789803, 0x99014803, 0x99006241, + 0xb0086301, 0x8ff0e8bd, 0x40088000, 0x01000040, + 0x400b0000, 0x400b2000 +}; +#else +__ALIGN4 static uc32 RandData[] = +{ + 0x4946b5ff, 0x6a4cb087, 0x6b0c9404, 0x6a4c9403, + 0x042d2503, 0x624c432c, 0x4d416b0c, 0x630c432c, + 0x68394f40, 0x2580463c, 0x402926f9, 0x1b890236, + 0x021e6039, 0x04114316, 0x0619430e, 0x607e430e, + 0x43160216, 0x4316041a, 0x60a6430e, 0x62212117, + 0x22014934, 0x630a3140, 0x432b6823, 0x4e326023, + 0x93056873, 0x685c4b31, 0x4c319406, 0x605c6074, + 0x69dd69f4, 0x43136b4b, 0x4a2a634b, 0x68533280, + 0xd5fc075b, 0x463a6b3b, 0x0f1b071b, 0x6b7b9302, + 0x071b6bbf, 0x073f0f1b, 0x97010f3f, 0x07176bd2, + 0x680a0f3f, 0x071746bc, 0x97000f3f, 0x0717684a, + 0x688a0f3f, 0x071246be, 0x0f1268c9, 0x68074e1a, + 0x042d69f6, 0x193419be, 0x4d181964, 0x69ed6004, + 0x011b9e02, 0x431e9f01, 0x023b042d, 0x46671964, + 0x432b033d, 0x431e9f00, 0x431e043b, 0x053b4677, + 0x0612431e, 0x07094316, 0x9a08430e, 0x18891931, + 0x48096001, 0x60419905, 0x99064808, 0x48036041, + 0x62419904, 0x63019903, 0xbdf0b00b, 0x40088000, + 0x01000040, 0x40010000, 0x400b0000, 0x400b2000, + 0x0000ffff +}; +#endif +__ALIGN4 static uc32 RandData2[] = +{ + 0x4604b510, 0x18406800, 0x46216020, 0x68084a03, + 0x4a034350, 0x60081880, 0xbd100840, 0x41c64e6d, + 0x00003039 +}; + +typedef void (*Randinit_TypeDef) (u32 *, u32, u32, u32); +u32 (*Rand_Get)(u32 *, u32); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/*********************************************************************************************************//** + * @brief Rand init. + * @param uSeed + * @param uCount + * @param a + * @param b + * @retval none + ***********************************************************************************************************/ +void Rand_Init(u32 *uSeed, u32 uCount, u32 a, u32 b) +{ + Randinit_TypeDef Randinit = (Randinit_TypeDef)((u32)RandData | 0x1); + Rand_Get = (u32 (*)(u32 *, u32))((u32)RandData2 | 0x1); + Randinit(uSeed, uCount, a, b); +} diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget.c new file mode 100644 index 0000000000..27ea3a0dfd --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget.c @@ -0,0 +1,413 @@ +/*********************************************************************************************************//** + * @file ht32_retarget.c + * @version $Rev:: 2922 $ + * @date $Date:: 2023-06-07 #$ + * @brief Retarget layer for target-dependent low level functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_board.h" + +#if defined (__CC_ARM) + #pragma import(__use_no_semihosting_swi) +#endif + +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #ifndef __MICROLIB + __asm(".global __use_no_semihosting"); + #endif +#endif + +#if (_RETARGET == 1) +#include + +#if defined (__CC_ARM) + #include +#endif + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup RETARGET Retarget + * @brief Retarget related functions + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup RETARGET_Private_Define Retarget private definitions + * @{ + */ + +#if (RETARGET_PORT == RETARGET_ITM) +#define ITM_PORT8(n) (*((vu8 *)(0xE0000000 + 4 * n))) +#define ITM_PORT16(n) (*((vu16 *)(0xE0000000 + 4 * n))) +#define ITM_PORT32(n) (*((vu32 *)(0xE0000000 + 4 * n))) + +#define DEMCR (*((vu32 *)(0xE000EDFC))) +#define TRCENA (0x01000000) +volatile int32_t ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* For Keil MDK-ARM only */ +#endif +/** + * @} + */ + +/* Global variables ----------------------------------------------------------------------------------------*/ +/** @defgroup RETARGET_Global_Variable Retarget global variables + * @{ + */ +#if defined (__CC_ARM) +struct __FILE { int handle; /* Add whatever you need here */ }; +FILE __stdout; +FILE __stdin; +#endif + +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #ifndef __MICROLIB + FILE __stdout; + FILE __stdin; + FILE __stderr; + #endif +#endif + +#if defined (__SES_ARM) && defined(__SEGGER_RTL_VERSION) +struct __SEGGER_RTL_FILE_impl { // NOTE: Provides implementation for FILE + int stub; // only needed so impl has size != 0. +}; +static FILE __SEGGER_RTL_stdin_file = { 0 }; // stdin reads from UART +static FILE __SEGGER_RTL_stdout_file = { 0 }; // stdout writes to UART +static FILE __SEGGER_RTL_stderr_file = { 0 }; // stderr writes to UART + +FILE *stdin = &__SEGGER_RTL_stdin_file; // NOTE: Provide implementation of stdin for RTL. +FILE *stdout = &__SEGGER_RTL_stdout_file; // NOTE: Provide implementation of stdout for RTL. +FILE *stderr = &__SEGGER_RTL_stderr_file; // NOTE: Provide implementation of stderr for RTL. + +static int _stdin_ungot = EOF; +#endif +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup RETARGET_Exported_Functions Retarget exported functions + * @{ + */ + +void RETARGET_Configuration(void) +{ +#ifdef RETARGET_IS_UART + /* !!! NOTICE !!! + Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below in this function. + */ + USART_InitTypeDef USART_InitStructure; + #ifdef RETARGET_UxART_BAUDRATE + USART_InitStructure.USART_BaudRate = RETARGET_UxART_BAUDRATE; + #else + USART_InitStructure.USART_BaudRate = 115200; + #endif + USART_InitStructure.USART_WordLength = USART_WORDLENGTH_8B; + USART_InitStructure.USART_StopBits = USART_STOPBITS_1; + USART_InitStructure.USART_Parity = USART_PARITY_NO; + USART_InitStructure.USART_Mode = USART_MODE_NORMAL; + + #ifdef RETARGET_COM_PORT + HT32F_DVB_COMInit(RETARGET_COM_PORT, &USART_InitStructure); + #else + { /* Enable peripheral clock of UxART */ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + CKCUClock.Bit.RETARGET_UxART_IPN = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + } + + USART_Init(RETARGET_USART_PORT, &USART_InitStructure); + USART_TxCmd(RETARGET_USART_PORT, ENABLE); + USART_RxCmd(RETARGET_USART_PORT, ENABLE); + #if (RETARGET_INT_MODE == 1) + NVIC_EnableIRQ(RETARGET_UART_IRQn); + #endif + #endif +#endif + +#if (RETARGET_PORT == RETARGET_ITM) + CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }}; + CKCUClock.Bit.AFIO = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + CKCU_MCUDBGConfig(CKCU_DBG_TRACE_ON, ENABLE); + AFIO_GPxConfig(TRACESWO_GPIO_ID, TRACESWO_AFIO_PIN, TRACESWO_AFIO_MODE); +#endif + +#ifdef NON_USB_IN_APP + SERIAL_USBDInit(); +#endif +} + +int __backspace(FILE *stream) +{ + if (stream == 0) // Remove the compiler warning + { + } + return 0; +} + +/* + Keil and IAR before 9.20 share fputc() to implement printf +*/ +int fputc (int ch, FILE *f) +{ + #if 0 + if (f == 0) // Remove the compiler warning + { + } + #endif + #if (RETARGET_PORT == RETARGET_ITM) + if (DEMCR & TRCENA) + { + while (ITM_PORT32(0) == 0); + ITM_PORT8(0) = ch; + } + return (ch); + #else + #ifdef AUTO_RETURN + if (ch == '\n') + { + SERIAL_PutChar('\r'); + } + #endif + return (SERIAL_PutChar(ch)); + #endif +} + +#if defined (__ICCARM__) +#if (__VER__ > 9010000) +/* + IAR's version after 9.20 use write to implement printf +*/ +int __write(int Handle, + const unsigned char * Buf, + int Bufsize) +{ + size_t nChars = 0; + if (Handle == -1) + { + return 0; + } + /* Check for stdout and stderr + (only necessary if FILE descriptors are enabled.) */ + if (Handle != 1 && Handle != 2) + { + return -1; + } + for (/*Empty */; Bufsize > 0; --Bufsize) + { + SERIAL_PutChar(*Buf++); + ++nChars; + } + return nChars; +} +#endif +int __read(int Handle, unsigned char *Buf, size_t BufSize) +{ + #if (RETARGET_PORT != RETARGET_ITM) + int nChars = 0; + + if (Handle != 0) + { + return -1; + } + + for (/* Empty */; BufSize > 0; --BufSize) + { + unsigned char c = NULL; + c = SERIAL_GetChar(); + if (c == 0) + break; + *Buf++ = c; + ++nChars; + } + #endif + return nChars; +} + +#elif defined(__SES_ARM) +#if defined(__SEGGER_RTL_VERSION) +/* + SES's version after 6.20 use RTL to implement printf. +*/ +/*********************************************************************************************************//** + * @brief Get character from standard input.. + * @retval Character received. + ************************************************************************************************************/ +static char _stdin_getc(void) { + unsigned char c; + + if (_stdin_ungot != EOF) { + c = _stdin_ungot; + _stdin_ungot = EOF; + } else { + c = SERIAL_GetChar(); + } + return c; +} + +/*********************************************************************************************************//** + * @brief Get file status. + * @param Pointer to file. + * @retval -1: Failure, stream is not a valid file. 0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_stat(FILE *stream) { + if (stream == stdin || stream == stdout || stream == stderr) { + return 0; // NOTE: stdin, stdout, and stderr are assumed to be valid. + } else { + return EOF; + } +} + +/*********************************************************************************************************//** + * @brief Get stream buffer size. + * @param stream: Pointer to file. + * @retval Nonzero number of characters to use for buffered I/O; for unbuffered I/O, return 1. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_bufsize(FILE *stream) { + (void)stream; + return 1; +} + +/*********************************************************************************************************//** + * @brief Read data from file. + * @param stream: Pointer to file to read from. + * @param s: Pointer to object that receives the input. + * @param len: Number of characters to read from file. + * @retval -1: Failure, stream is not a valid file. >0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_read(FILE *stream, char *s, unsigned len) { + int c; + + if (stream == stdin) { + c = 0; + while (len > 0) { + *s = _stdin_getc(); + ++s; + ++c; + --len; + } + } else { + c = EOF; + } + return c; +} + +/*********************************************************************************************************//** + * @brief Write data to file. + * @param stream: Pointer to file to write to. + * @param s:Pointer to object to write to file. + * @param len:Number of characters to write to the file. + * @retval -1: Failure, stream is not a valid file. >0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_write(FILE *stream, const char *s, unsigned len) { + if ((stream == stdout) || (stream == stderr)) { + //BSP_UART_WriteBlocking(_UART_Port, (const unsigned char*) s, len); + for (/*Empty */; len > 0; --len) + { + SERIAL_PutChar(*s++); + } + return len; + } else { + return EOF; + } +} + +/*********************************************************************************************************//** + * @brief ush character back to stream. + * @param stream: Pointer to file to push back to. + * @param c: Character to push back. + * @retval -1: Failure, stream is not a valid file. >0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_unget(FILE *stream, int c) { + if (stream == stdin) { + if (c != EOF && _stdin_ungot == EOF) { + _stdin_ungot = c; + } else { + c = EOF; + } + } else { + c = EOF; + } + return c; +} +#endif +#else +int fgetc (FILE *f) +{ + #if 0 + if (f == 0) // Remove the compiler warning + { + } + #endif + #if (RETARGET_PORT == RETARGET_ITM) + /* For Keil MDK-ARM only */ + while (ITM_CheckChar() == 0); + return (ITM_ReceiveChar()); + #else + return (SERIAL_GetChar()); + #endif +} +#endif + +void _ttywrch(int ch) +{ + #if (RETARGET_PORT == RETARGET_ITM) + if (DEMCR & TRCENA) + { + while (ITM_PORT32(0) == 0); + ITM_PORT8(0) = ch; + } + #else + SERIAL_PutChar(ch); + #endif +} +#endif + +void _sys_exit(int return_code) +{ + if (return_code == 0) // Remove the compiler warning + { + } + +label: goto label; /* endless loop */ +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget_desc.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget_desc.c new file mode 100644 index 0000000000..2b955b173d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_retarget_desc.c @@ -0,0 +1,272 @@ +/*********************************************************************************************************//** + * @file ht32_retarget_desc.c + * @version $Rev:: 41 $ + * @date $Date:: 2017-05-23 #$ + * @brief The The USB Descriptor of retarget. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Includes ------------------------------------------------------------------------------------------------*/ + +#define DESC_LEN_CONFN_T (u16)(DESC_LEN_CONFN) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Device descriptor setting +// USB Specification Release number (bcdUSB) +// <0x0200=> USB 2.0 +// <0x0110=> USB 1.1 +// <0x0100=> USB 1.0 +// USB Class code (assigned by the USB-IF) +// <0x00=> Use class information in the Interface Descriptors (0x00) +// <0x02=> Communications and CDC Control (CDC, 0x02) +// <0xDC=> Diagnostic Device (0xDC) +// <0xEF=> Miscellaneous (0xEF) +// <0xFF=> Vendor Specific (0xFF) +// USB Subclass code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Protocol code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Vendor ID <0x0-0xFFFF:1> +// USB Product ID <0x0-0xFFFF:1> +// USB Device Version <0x0-0xFFFF:1> +// USB String descriptor - Manufacturer +// USB String descriptor - Product +// USB String descriptor - Device serial number +// USB Number of possible configurations <0-255:1> +#define DESC_BCDUSB (0x0110) +#define DESC_BDEVCLASS (0x00) +#define DESC_BDEVSUBCLASS (0x00) +#define DESC_BDEVPROTOCOL (0x00) +#define DESC_IDVENDOR (0x04D9) +#define DESC_IDPRODUCT (0x8008) +#define DESC_BCDDEVICE (0x0100) +#define DESC_IMANUFACTURE (1) +#define DESC_IPRODUCT (1) +#define DESC_ISERIALNUM (1) +#define DESC_INUMCONFN (1) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (DESC_BDEVCLASS == 0x0 & DESC_BDEVSUBCLASS != 0x0) +#error "DESC_BDEVSUBCLASS must be reset to zero when the DESC_BDEVCLASS is equal to zero." +#endif +#define DESC_WMAXPACKETSIZE0 (_EP0LEN) +#define DESC_STR_MAN (1 * DESC_IMANUFACTURE) +#define DESC_STR_PRD (2 * DESC_IPRODUCT) +#define DESC_STR_SER (3 * DESC_ISERIALNUM) +#define DESC_NUM_STRING (1 + 3) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_DeviceDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Device descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_DEV, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_01_DEV, // bDescriptorType 1 DEVICE Descriptor Type + DESC_H2B(DESC_BCDUSB), // bcdUSB 2 USB Specification Release Number + DESC_BDEVCLASS, // bDeviceClass 1 Class code (assigned by the USB-IF) + DESC_BDEVSUBCLASS, // bDeviceSubClass 1 Subclass code (assigned by the USB-IF) + DESC_BDEVPROTOCOL, // bDeviceProtocol 1 Protocol code (assigned by the USB-IF) + DESC_WMAXPACKETSIZE0, // wMaxPacketSize0 1 Maximum packet size for endpoint zero + DESC_H2B(DESC_IDVENDOR), // idVendor 2 Vendor ID (assigned by USB-IF) + DESC_H2B(DESC_IDPRODUCT), // idProduct 2 Product ID (assigned by manufacturer) + DESC_H2B(DESC_BCDDEVICE), // bcdDevice 2 Device release number + DESC_STR_MAN, // iManufacturer 1 Index of string descriptor (Manufacturer) + DESC_STR_PRD, // iProduct 1 Index of string descriptor (Product) + DESC_STR_SER, // iSerialNumber 1 Index of string descriptor (Serial Number) + DESC_INUMCONFN, // iNumConfigurations 1 Number of possible configuration +}; + + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Configuration descriptor setting +// Self-powered +// Bit 6 of bmAttributes +// Remote Wakeup +// Bit 5 of bmAttributes +// USB Device maximum power (mA) < 2-512:2> +#define DESC_BMATTR_SELF_POWER (0) +#define DESC_BMATTR_REMOTE_WAKEUP (0) +#define DESC_BMAXPOWER (100) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#define DESC_BMATTRIBUTES (0x80 | (DESC_BMATTR_SELF_POWER << 6) | (DESC_BMATTR_REMOTE_WAKEUP << 5)) +#define DESC_TOTAL_LEN DESC_H2B((DESC_LEN_CONFN_T + RETARGET_DLEN)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_ConfnDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Configuration descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_CONFN, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_02_CONFN, // bDescriptorType 1 CONFIGURATION Descriptor Type + DESC_TOTAL_LEN, // wTotalLength 2 Total length of data returned for this configuration + RETARGET_INF, // bNumberInterface 1 Number of interfaces supported by this configuration + 0x01, // bConfigurationValue 1 Value to use as an argument to the SetConfiguration() + 0x00, // iConfiguration 1 Index of string descriptor describing this configuration + DESC_BMATTRIBUTES, // bmAttributes 1 Configuration characteristics + // D6: Self-powered, D5: RemoteWakeup + DESC_POWER(DESC_BMAXPOWER), // bMaxPower 1 Maximum power consumption of the USB device (2 mA units) + + #ifdef RETARGET_IS_USB + #include "ht32_retarget_desc.h" + #endif + +}; + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB String Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_StringDescLANGID[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* LANGID (Index = 0) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(1), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_H2B(0x0409), // wLANGID[0] 2 LANGID code zero +}; + +#if (DESC_IMANUFACTURE == 1) +__ALIGN4 static uc8 guUSB_StringDescManufacture[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Manufacture (Index = 1) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(6), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('H'), // bString N UNICODE encoded string + DESC_CHAR('O'), + DESC_CHAR('L'), + DESC_CHAR('T'), + DESC_CHAR('E'), + DESC_CHAR('K'), +}; +#endif + +#if (DESC_IPRODUCT == 1) +__ALIGN4 static uc8 guUSB_StringDescProduct[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Product (Index = 2) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(7), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('U'), // bString N UNICODE encoded string + DESC_CHAR('S'), + DESC_CHAR('B'), + DESC_CHAR('-'), + DESC_CHAR('V'), + DESC_CHAR('C'), + DESC_CHAR('P'), +}; +#endif + + +#if (DESC_ISERIALNUM == 1) +__ALIGN4 static uc8 guUSB_StringDescSerialNum[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Serial Number (Index = 3) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(12), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('S'), // bString N UNICODE encoded string + DESC_CHAR('N'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('1'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), +}; +#endif + +uc8 *gpStringDesc[DESC_NUM_STRING] = +{ + + guUSB_StringDescLANGID, + + #if (DESC_IMANUFACTURE == 1) + guUSB_StringDescManufacture, + #else + NULL, + #endif + + #if (DESC_IPRODUCT == 1) + guUSB_StringDescProduct, + #else + NULL, + #endif + + #if (DESC_ISERIALNUM == 1) + guUSB_StringDescSerialNum + #else + NULL, + #endif + +}; + +/*********************************************************************************************************//** + * @brief USB Descriptor pointer initialization. + * @param pDesc: pointer of USBDCore_Desc_TypeDef + * @retval None + ***********************************************************************************************************/ +void USBDDesc_Init(USBDCore_Desc_TypeDef *pDesc) +{ + pDesc->pDeviceDesc = guUSB_DeviceDesc; + pDesc->pConfnDesc = guUSB_ConfnDesc; + pDesc->ppStringDesc = gpStringDesc; + pDesc->uStringDescNumber = DESC_NUM_STRING; + + return; +} diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_serial.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_serial.c new file mode 100644 index 0000000000..7eded142f3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_serial.c @@ -0,0 +1,549 @@ +/*********************************************************************************************************//** + * @file ht32_serial.c + * @version $Rev:: 2794 $ + * @date $Date:: 2022-11-25 #$ + * @brief This file provides all the Low level serial routines for HT32. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_board.h" + +#if (_RETARGET == 1) + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup SERIAL SERIAL + * @brief Serial related functions + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Exported_Functions Serial exported functions + * @{ + */ + +#ifdef RETARGET_IS_UART + +#if (RETARGET_INT_MODE == 1) +__ALIGN4 static u8 uSerialBuffer[RETARGET_INT_BUFFER_SIZE]; +static vu32 uReadIndex; +static vu32 uWriteIndex; + +#define IS_BUFFER_FULL(LEN) (((uWriteIndex + LEN) >= RETARGET_INT_BUFFER_SIZE) ? ((uWriteIndex + LEN - RETARGET_INT_BUFFER_SIZE) == uReadIndex) : ((uWriteIndex + LEN) == uReadIndex)) +#define IS_BUFFER_EMPTY() (uReadIndex == uWriteIndex) +#define BUFFER_FREE_LEN() ((uWriteIndex >= uReadIndex) ? (RETARGET_INT_BUFFER_SIZE - uWriteIndex + uReadIndex - 1) : (uReadIndex - uWriteIndex - 1)) + +/*********************************************************************************************************//** + * @brief UART IRQ handler. + * @retval None + ************************************************************************************************************/ +void RETARGET_UART_IRQHandler(void) +{ + if (((RETARGET_USART_PORT->SR) & USART_FLAG_TXDE)) + { + if (IS_BUFFER_EMPTY()) + { + RETARGET_USART_PORT->IER &= ~USART_INT_TXDE; + } + else + { + RETARGET_USART_PORT->DR = uSerialBuffer[uReadIndex++]; + if (uReadIndex == RETARGET_INT_BUFFER_SIZE) + { + uReadIndex = 0; + } + } + } + +} +#endif + +/*********************************************************************************************************//** + * @brief Put char to USART. + * @param ch: The char put to USART. + * @retval The char put to USART. + ************************************************************************************************************/ +u32 SERIAL_PutChar(u32 ch) +{ +#if (RETARGET_INT_MODE == 1) + + while (IS_BUFFER_FULL(1)); + + uSerialBuffer[uWriteIndex++] = ch; + if (uWriteIndex == RETARGET_INT_BUFFER_SIZE) + { + uWriteIndex = 0; + } + RETARGET_USART_PORT->IER |= USART_INT_TXDE; + +#else + + USART_SendData(RETARGET_USART_PORT, (u8)ch); + while (USART_GetFlagStatus(RETARGET_USART_PORT, USART_FLAG_TXC) == RESET) + { + } + +#endif + + return ch; +} + +/*********************************************************************************************************//** + * @brief Get char from USART. + * @retval The char got from USART. + ************************************************************************************************************/ +u32 SERIAL_GetChar(void) +{ + #if (LIBCFG_USART_V01) + while (USART_GetFlagStatus(RETARGET_USART_PORT, USART_FLAG_RXDNE) == RESET) + { + } + #else + while (USART_GetFlagStatus(RETARGET_USART_PORT, USART_FLAG_RXDR) == RESET) + { + } + #endif + return USART_ReceiveData(RETARGET_USART_PORT); +} +#endif + + +#ifdef RETARGET_IS_USB +/* Private types -------------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_TypesDefinitions Serial private types definitions + * @{ + */ +typedef struct _VCP_LINE_CODING +{ + u32 dwDTERate; //Bit rate; + u8 bCharFormat; //Stop bits: + //0 = 1 Stop bit + //1 = 1.5 Stop bit + //2 = 2 Stop bit + u8 bParityType; //parity: + //0 = None + //1 = Odd + //2 = Even + //3 = Mark + //4 = Space + u8 bDataBits; //Number of data bits (7, 8, 9) +} USBDClass_VCP_LINE_CODING; +/** + * @} + */ + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_Define Serial private definitions + * @{ + */ +#define CLASS_REQ_20_SET_LINE_CODING (0x20) +#define CLASS_REQ_21_GET_LINE_CODING (0x21) +#define CLASS_REQ_22_SET_CONTROL_LINE_STATE (0x22) + +#ifndef RETARGET_TXBUFFER_SIZE + #define RETARGET_TXBUFFER_SIZE (1) +#endif + +#define RETARGET_USB_MODE_BLOCK (0) +#define RETARGET_USB_MODE_NONBLOCK (1) +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_Macro Serial private macros + * @{ + */ +#define IS_BUFFER_FULL(LEN) (((uWriteIndex + LEN) >= RETARGET_BUFFER_SIZE) ? ((uWriteIndex + LEN - RETARGET_BUFFER_SIZE) == uReadIndex) : ((uWriteIndex + LEN) == uReadIndex)) +#define IS_BUFFER_EMPTY() (uReadIndex == uWriteIndex) +#define BUFFER_FREE_LEN() ((uWriteIndex >= uReadIndex) ? (RETARGET_BUFFER_SIZE - uWriteIndex + uReadIndex - 1) : (uReadIndex - uWriteIndex - 1)) +/** + * @} + */ + +/* Private variables ---------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_Variable Serial private variables + * @{ + */ +static USBDClass_VCP_LINE_CODING USBDClassVCPLineCoding; +__ALIGN4 static u8 uSerialBuffer[RETARGET_BUFFER_SIZE]; +static vu32 uReadIndex; +static vu32 uWriteIndex; +static vu32 uDTRState = 0; +static vu32 gIsINEmpty = TRUE; + +static u32 TxCount = 0; +__ALIGN4 static u8 TxBuffer[RETARGET_TXBUFFER_SIZE]; +/** + * @} + */ + +#if (RETARGET_RX_EPT == RETARGET_TX_EPT) + #error USB Endpoint of retarget Rx and Tx must different. Please check RETARGET_RX_EPT/RETARGET_TX_EPT "ht32_retarget_usbdconf.h". +#endif + +#if (RETARGET_CTRL_EPT == RETARGET_TX_EPT) + #error USB Endpoint of retarget Control and Tx must different. Please check RETARGET_CTRL_EPT/RETARGET_TX_EPT "ht32_retarget_usbdconf.h". +#endif + +#if (RETARGET_CTRL_EPT == RETARGET_RX_EPT) + #error USB Endpoint of retarget Control and Rx must different. Please check RETARGET_CTRL_EPT/RETARGET_RX_EPT "ht32_retarget_usbdconf.h". +#endif + +#ifdef _RERATGET1_ERR + #error Endpoint 1 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET2_ERR + #error Endpoint 2 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET3_ERR + #error Endpoint 3 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET4_ERR + #error Endpoint 4 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET5_ERR + #error Endpoint 5 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET6_ERR + #error Endpoint 6 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET7_ERR + #error Endpoint 7 already used by other USB class. Retarget can not overwrite it. +#endif + +/*********************************************************************************************************//** + * @brief Put char to USB. + * @param ch: The char put to USB. + * @retval The char put to USB. + ************************************************************************************************************/ +u32 SERIAL_PutChar(u32 ch) +{ + #if (RETARGET_TXBUFFER_SIZE > 63) + #error RETARGET_TXBUFFER_SIZE shall less than 63 (define in ht32fxxxxx_conf.h). + #endif + + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_BLOCK) + while (uDTRState == 0); /* Wait until user open the virtual COM port by PC UI such as Hyper Terminal */ + #elif (RETARGET_USB_MODE == RETARGET_USB_MODE_NONBLOCK) + if (uDTRState == 0) /* Drop data if USB or terminal software is not ready */ + { + return ch; + } + #endif + + TxBuffer[TxCount++] = ch; + + if (TxCount == RETARGET_TXBUFFER_SIZE) + { + TxCount = 0; + + while (gIsINEmpty == FALSE) + { + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_NONBLOCK) + if (uDTRState == 0) + { + return ch; + } + #endif + } + + gIsINEmpty = FALSE; + USBDCore_EPTWriteINData((USBD_EPTn_Enum)RETARGET_TX_EPT, (u32 *)&TxBuffer, RETARGET_TXBUFFER_SIZE); + } + + return ch; +} + +/*********************************************************************************************************//** + * @brief Get char from USB. + * @retval The char got from USB. + ************************************************************************************************************/ +u32 SERIAL_GetChar(void) +{ + u32 value = 0; + + while (IS_BUFFER_EMPTY()); + value = uSerialBuffer[uReadIndex++]; + if (uReadIndex == RETARGET_BUFFER_SIZE) + { + uReadIndex = 0; + } + + return value; +} + +/*********************************************************************************************************//** + * @brief Flush the Tx Buffer + * @retval None + ************************************************************************************************************/ +void SERIAL_Flush(void) +{ + do + { + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_NONBLOCK) + if (uDTRState == 0) + { + return; + } + #endif + } while (USBDCore_EPTGetTransferCount((USBD_EPTn_Enum)RETARGET_TX_EPT, USBD_TCR_0)); + + gIsINEmpty = FALSE; + USBDCore_EPTWriteINData((USBD_EPTn_Enum)RETARGET_TX_EPT, (u32 *)&TxBuffer, TxCount); + TxCount = 0; +} + +#ifdef NON_USB_IN_APP +#include "ht32_retarget_desc.c" +__ALIGN4 USBDCore_TypeDef gUSBCore; +USBD_Driver_TypeDef gUSBDriver; + +/*********************************************************************************************************//** + * @brief This function handles USB interrupt. + * @retval None + ************************************************************************************************************/ +void USB_IRQHandler(void) +{ + USBDCore_IRQHandler(&gUSBCore); +} + +/*********************************************************************************************************//** + * @brief USB Class initialization. + * @param pClass: pointer of USBDCore_Class_TypeDef + * @retval None + ************************************************************************************************************/ +void USBDClass_Init(USBDCore_Class_TypeDef *pClass) +{ + pClass->CallBack_ClassRequest = SERIAL_USBDClass_Request; + pClass->CallBack_EPTn[RETARGET_RX_EPT] = SERIAL_USBDClass_RXHandler; + pClass->CallBack_EPTn[RETARGET_TX_EPT] = SERIAL_USBDClass_TXHandler; + return; +} + +#if (LIBCFG_CKCU_USB_PLL) +/*********************************************************************************************************//** + * @brief Configure USB PLL + * @retval None + ************************************************************************************************************/ +void USBPLL_Configuration(void) +{ + if ((HT_CKCU->GCCR & (1 << 11)) == 0) + { + CKCU_HSICmd(ENABLE); + } + + { /* USB PLL configuration */ + + /* !!! NOTICE !!! + Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below in this function. + */ + CKCU_PLLInitTypeDef PLLInit; + + PLLInit.ClockSource = CKCU_PLLSRC_HSI; + #if (LIBCFG_CKCU_USB_PLL_96M) + PLLInit.CFG = CKCU_USBPLL_8M_96M; + #else + PLLInit.CFG = CKCU_USBPLL_8M_48M; + #endif + PLLInit.BYPASSCmd = DISABLE; + CKCU_USBPLLInit(&PLLInit); + } + + CKCU_USBPLLCmd(ENABLE); + + while (CKCU_GetClockReadyStatus(CKCU_FLAG_USBPLLRDY) == RESET); + CKCU_USBClockConfig(CKCU_CKUSBPLL); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure USB for retarget. + * @retval None + ************************************************************************************************************/ +void SERIAL_USBDInit(void) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + CKCUClock.Bit.USBD = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + #if (LIBCFG_CKCU_USB_PLL) + USBPLL_Configuration(); + #else + { + u32 uPLL; + uPLL = CKCU_GetPLLFrequency(); + // uPLL=48000000, CKCU_USBPRE_DIV1 + // uPLL=96000000, CKCU_USBPRE_DIV2 + // uPLL=144000000, CKCU_USBPRE_DIV3 + CKCU_SetUSBPrescaler((CKCU_USBPRE_TypeDef)((uPLL / 48000000) - 1)); + #endif + +#if (LIBCFG_CKCU_HSI_NO_AUTOTRIM) +#else + /* !!! NOTICE !!! + Must turn on if the USB clock source is from HSI (PLL clock Source) + */ + #if (RETARGET_HSI_ATM) + CKCU_HSIAutoTrimClkConfig(CKCU_ATC_USB); + CKCU_HSIAutoTrimCmd(ENABLE); + #endif +#endif + + gUSBCore.pDriver = (u32 *)&gUSBDriver; /* Initiate memory pointer of USB driver */ + USBDDesc_Init(&gUSBCore.Device.Desc); /* Initiate memory pointer of descriptor */ + USBDClass_Init(&gUSBCore.Class); /* Initiate USB Class layer */ + USBDCore_Init(&gUSBCore); /* Initiate USB Core layer */ + NVIC_EnableIRQ(USB_IRQn); /* Enable USB device interrupt */ + USBD_DPpullupCmd(ENABLE); + + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_BLOCK) + USBDCore_MainRoutine(&gUSBCore); /* USB core main routine */ + while (USBDCore_GetStatus() != USB_STATE_CONFIGURED); + #else + gUSBCore.Info.CurrentFeature.Bits.bSelfPowered = TRUE; + USBDCore_MainRoutine(&gUSBCore); /* USB core main routine */ + #endif +} +#endif + +/*********************************************************************************************************//** + * @brief USB Device Class Request for USB retarget + * @param pDev: pointer of USB Device + * @retval None + ************************************************************************************************************/ +void SERIAL_USBDClass_Request(USBDCore_Device_TypeDef *pDev) +{ + u8 USBCmd = *((u8 *)(&(pDev->Request.bRequest))); + u16 len = *((u16 *)(&(pDev->Request.wLength))); + u32 inf = pDev->Request.wIndex; + u32 uIsCmdOK = 0; + + if (inf != 11) + { + return; + } + + if (USBCmd == CLASS_REQ_22_SET_CONTROL_LINE_STATE) + { + if (len == 0) + { + uDTRState = pDev->Request.wValueL & 0x1; + pDev->Transfer.pData = 0; + pDev->Transfer.sByteLength = 0; + pDev->Transfer.Action = USB_ACTION_DATAOUT; + } + } + else + { + if (USBCmd == CLASS_REQ_20_SET_LINE_CODING) + { + pDev->Transfer.Action = USB_ACTION_DATAOUT; + uIsCmdOK = 1; + } + else if (USBCmd == CLASS_REQ_21_GET_LINE_CODING) + { + pDev->Transfer.Action = USB_ACTION_DATAIN; + uIsCmdOK = 1; + } + + if (uIsCmdOK == 1) + { + pDev->Transfer.pData = (uc8*)&USBDClassVCPLineCoding; + pDev->Transfer.sByteLength = (sizeof(USBDClassVCPLineCoding) > pDev->Request.wLength) ? (pDev->Request.wLength) : (sizeof(USBDClassVCPLineCoding)); + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Received handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None +************************************************************************************************************/ +void SERIAL_USBDClass_RXHandler(USBD_EPTn_Enum EPTn) +{ + u32 uLen; + u32 uFreeLen = BUFFER_FREE_LEN(); + u8 uTempBuffer[64]; + u32 i; + + /* Read Receive data */ + uLen = USBDCore_EPTReadOUTData(EPTn, (u32*)uTempBuffer, 64); + + if (uLen > uFreeLen) + { + uLen = uFreeLen; + } + + for (i = 0; i < uLen; i++) + { + uSerialBuffer[uWriteIndex++] = uTempBuffer[i]; + if (uWriteIndex == RETARGET_BUFFER_SIZE) + { + uWriteIndex = 0; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Tx handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None +************************************************************************************************************/ +void SERIAL_USBDClass_TXHandler(USBD_EPTn_Enum EPTn) +{ + gIsINEmpty = TRUE; + return; +} + +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_time.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_time.c new file mode 100644 index 0000000000..ff50187484 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32_time.c @@ -0,0 +1,185 @@ +/*********************************************************************************************************//** + * @file ht32_time.c + * @version $Rev:: 2888 $ + * @date $Date:: 2023-03-03 #$ + * @brief The time functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_time.h" + +/* + Tick Range: 0 ~ 2^32 / HTCFG_TIME_TICKHZ (maximum tick time) + Interrupt Time: _HTCFG_TIME_OVERFLOW_VALUE / (HTCFG_TIME_TICKHZ * HTCFG_TIME_MULTIPLE) Second (not apply for BFTM) + + Example: 32-bit BFTM with 48 MHz Timer Clock + HTCFG_TIME_TICKHZ = HTCFG_TIME_CLKSRC = 48000000 + Tick Range: 0 ~ 2^32 / 48000000 = 0 ~ 89.478485 Second (maximum tick time, return to 0 every 89.478485 Second) + BFTM do not use interrupt + + Example: 16-bit SCTM with 1 us tick + HTCFG_TIME_TICKHZ = 1000000 (Hz) + HTCFG_TIME_MULTIPLE = 1 (1 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 1000000 = 0 ~ 4294 Second = 0 ~ 71.58 Minute (maximum tick time, return to 0 every 71.58 Minute) + Interrupt Time: 65536 / (1000000 * 1) = 65.536 ms (Trigger interrupt every 65.536 ms) + + Example: 16-bit SCTM with 10 us tick + HTCFG_TIME_TICKHZ = 100000 (Hz) + HTCFG_TIME_MULTIPLE = 4 (4 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 100000 = 0 ~ 42949 Second = 0 ~ 715.82 Minute = 11.93 Hour (maximum tick time, return to 0 every 11.93 Hour) + Interrupt Time: 65536 / (100000 * 4) = 163.84 ms (Trigger interrupt every 163.84 ms) + + Example: 16-bit GPTM with 1 ms tick + HTCFG_TIME_TICKHZ = 1000 (Hz) + HTCFG_TIME_MULTIPLE = 4 (4 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 1000 = 0 ~ 4294967 Second = 0 ~ 49.7 Day (maximum tick time, return to 0 every 49.7 Day) + Interrupt Time: 65536 / (1000 * 4) = 16.384 Second (Trigger interrupt every 16.384 Second) +*/ + +/* Private constants ---------------------------------------------------------------------------------------*/ +#define _HTCFG_TIME_CKCU_PCLK STRCAT2(CKCU_PCLK_, HTCFG_TIME_IPN) + +#if (IS_IPN_TM(HTCFG_TIME_IPN)) +// SCTM/PWM/GPTM/MCTM +#define _HTCFG_TIME_IRQn STRCAT2(HTCFG_TIME_IPN, _IRQn) +#define _HTCFG_TIME_IRQHandler STRCAT2(HTCFG_TIME_IPN, _IRQHandler) +#define _HTCFG_TIME_CLKDIV (HTCFG_TIME_CLKSRC / HTCFG_TIME_TICKHZ / HTCFG_TIME_MULTIPLE) +#define _HTCFG_TIME_OVERFLOW_VALUE (65536) // 16-bit = 2^16 + +#if (_HTCFG_TIME_CLKDIV <= 0) + #error "_HTCFG_TIME_CLKDIV is not correct (must >= 1)!" +#endif + +#if (_HTCFG_TIME_CLKDIV > 65536) + #error "_HTCFG_TIME_CLKDIV is not correct (must <= 65536)!" +#endif + +#if ((_HTCFG_TIME_CLKDIV * HTCFG_TIME_MULTIPLE) != (HTCFG_TIME_CLKSRC / HTCFG_TIME_TICKHZ)) + #error "_HTCFG_TIME_CLKDIV is not correct (must be integer)!" +#endif +#endif + +/* Private variables ---------------------------------------------------------------------------------------*/ +#if (IS_IPN_TM(HTCFG_TIME_IPN)) +u32 gTotalTick = 0x00000000; +u8 gIsTimeInt = FALSE; +#endif + +/* Global functions ----------------------------------------------------------------------------------------*/ +/*********************************************************************************************************//** + * @brief Time Init function. + * @retval None + ***********************************************************************************************************/ +void Time_Init(void) +{ + { /* Enable peripheral clock */ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }}; + CKCUClock.Bit.HTCFG_TIME_IPN = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + } + + #if (LIBCFG_CKCU_NO_APB_PRESCALER == 0) + CKCU_SetPeripPrescaler(_HTCFG_TIME_CKCU_PCLK, (CKCU_APBCLKPRE_TypeDef)HTCFG_TIME_PCLK_DIV); + #endif + + #if (IS_IPN_TM(HTCFG_TIME_IPN)) + + { /* Time base configuration */ + /* !!! NOTICE !!! + Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below in this function. + */ + TM_TimeBaseInitTypeDef TimeBaseInit; + + TimeBaseInit.Prescaler = _HTCFG_TIME_CLKDIV - 1; + TimeBaseInit.CounterReload = _HTCFG_TIME_OVERFLOW_VALUE -1; + TimeBaseInit.RepetitionCounter = 0; + TimeBaseInit.CounterMode = TM_CNT_MODE_UP; + TimeBaseInit.PSCReloadTime = TM_PSC_RLD_IMMEDIATE; + TM_TimeBaseInit(_HTCFG_TIME_PORT, &TimeBaseInit); + + /* Clear Update Event Interrupt flag since the "TM_TimeBaseInit()" writes the UEV1G bit */ + TM_ClearFlag(_HTCFG_TIME_PORT, TM_FLAG_UEV); + } + + /* Enable Update Event interrupt */ + TM_IntConfig(_HTCFG_TIME_PORT, TM_INT_UEV, ENABLE); + NVIC_EnableIRQ(_HTCFG_TIME_IRQn); + + TM_SetCounter(_HTCFG_TIME_PORT, 0x0000); + TM_Cmd(_HTCFG_TIME_PORT, ENABLE); + + #else + + BFTM_SetCounter(_HTCFG_TIME_PORT, 0x00000000); + BFTM_EnaCmd(_HTCFG_TIME_PORT, ENABLE); + #endif +} + +/*********************************************************************************************************//** + * @brief Time delay function. + * @param uDelayTick: Delay count based on tick. + * @retval None + ***********************************************************************************************************/ +void Time_Delay(u32 uDelayTick) +{ + u32 uCurrent; + u32 uStart = Time_GetTick(); + + do + { + uCurrent = Time_GetTick(); + } while (TIME_TICKDIFF(uStart, uCurrent) < uDelayTick); +} + +#if (IS_IPN_TM(HTCFG_TIME_IPN)) +/*********************************************************************************************************//** + * @brief Gets the current time tick. + * @retval Time Tick + ***********************************************************************************************************/ +u32 Time_GetTick(void) +{ + u32 uCount = GET_CNT(); + + if (gIsTimeInt == TRUE) + { + gIsTimeInt = FALSE; + uCount = GET_CNT(); + gTotalTick += (_HTCFG_TIME_OVERFLOW_VALUE / HTCFG_TIME_MULTIPLE); + } + + return (gTotalTick + (uCount / HTCFG_TIME_MULTIPLE)); +} + +/*********************************************************************************************************//** + * @brief This function handles Timer interrupt. + * @retval None + ************************************************************************************************************/ +void _HTCFG_TIME_IRQHandler(void) +{ + TM_ClearFlag(_HTCFG_TIME_PORT, TM_INT_UEV); + + gIsTimeInt = TRUE; +} +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc.c new file mode 100644 index 0000000000..501d394756 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc.c @@ -0,0 +1,724 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_adc.c + * @version $Rev:: 2972 $ + * @date $Date:: 2023-10-28 #$ + * @brief This file provides all the ADC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_adc.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup ADC ADC + * @brief ADC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Private_Define ADC private definitions + * @{ + */ +#define ADC_ENABLE_BIT (0x00000080) +#define ADC_SOFTWARE_RESET (0x00000001) +#define LST_SEQ_SET (0x0000001F) +#define TCR_SC_SET (0x00000001) + +#define HLST_SEQ_SET (0x0000001F) +#define HTCR_SC_SET (0x00000001) + +#define OFR_ADOF_MASK (0x00000FFF) +#define OFR_ADAL (1 << 14) +#define OFR_ADOFE (1 << 15) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup ADC_Exported_Functions ADC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the HT_ADCn peripheral registers to their default reset values. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_DeInit(HT_ADC_TypeDef* HT_ADCn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + if (HT_ADCn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.ADC0 = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Reset ADC. + * @param HT_ADCn: is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_Reset(HT_ADC_TypeDef* HT_ADCn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + HT_ADCn->RST |= ADC_SOFTWARE_RESET; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_Cmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + #if (LIBCFG_ADC_NOENBIT) + #else + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->CONV |= ADC_ENABLE_BIT; + ADC_Reset(HT_ADCn); + } + else + { + HT_ADCn->CONV &= ~(ADC_ENABLE_BIT); + } + #endif +} + +/*********************************************************************************************************//** + * @brief Configure conversion mode and length of list queue for regular group. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_MODE: ADC Cyclic Conversion Mode. + * This parameter can be one of the following values: + * @arg ONE_SHOT_MODE : + * @arg CONTINUOUS_MODE : + * @arg DISCONTINUOUS_MODE : + * @param Length: must between 1 ~ 16 + * @param SubLength: must between 1 ~ 16, only valid for DISCONTINUOUS_MODE. + * @retval None + ************************************************************************************************************/ +void ADC_RegularGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CONVERSION_MODE(ADC_MODE)); + Assert_Param(IS_ADC_REGULAR_LENGTH(Length)); + if (ADC_MODE == DISCONTINUOUS_MODE) + { + Assert_Param(IS_ADC_REGULAR_SUB_LENGTH(SubLength)); + } + + /* Config cyclic conversion mode and length of list queue and sub length for regular group */ + #if (LIBCFG_ADC_NOENBIT) + HT_ADCn->CONV = ((u32)(SubLength - 1) << 16) | ((u32)(Length - 1) << 8) | ADC_MODE; + #else + HT_ADCn->CONV = ((u32)(SubLength - 1) << 16) | ((u32)(Length - 1) << 8) | ADC_MODE | (HT_ADCn->CONV & ADC_ENABLE_BIT); + #endif +} + +/*********************************************************************************************************//** + * @brief Configure conversion mode and length of list queue for high priority group. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_MODE: ADC Cyclic Conversion Mode. + * This parameter can be one of the following values: + * @arg ONE_SHOT_MODE : + * @arg CONTINUOUS_MODE : + * @arg DISCONTINUOUS_MODE : + * @param Length: must between 1 ~ 4 + * @param SubLength: must between 1 ~ 4 + * @retval None + ************************************************************************************************************/ +void ADC_HPGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CONVERSION_MODE(ADC_MODE)); + Assert_Param(IS_ADC_HP_LENGTH(Length)); + Assert_Param(IS_ADC_HP_SUB_LENGTH(SubLength)); + + /* Config cyclic conversion mode and length of list queue and sub length for regular group */ + HT_ADCn->HCONV = ((u32)(SubLength - 1) << 16) | ((u32)(Length - 1) << 8) | ADC_MODE; +} + +/*********************************************************************************************************//** + * @brief Configure the corresponding rank in the sequencer and the sampling time for the regular channel + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected, x must between 0 ~ 11 + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param Rank: The rank in the regular group sequencer. + * This parameter must be between 0 to 15. + * @param SampleClock: Number of sampling clocks. + * This parameter must be between 0x00 to 0xFF. + * @retval None + ************************************************************************************************************/ +void ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock) +{ + u32 tmpreg1, tmpreg2; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_REGULAR_RANK(Rank)); + Assert_Param(IS_ADC_INPUT_SAMPLING_TIME(SampleClock)); + + /* config sampling clock of correspond ADC input channel */ + HT_ADCn->STR[ADC_CH_n] = SampleClock; + + /* Get the old register value */ + tmpreg1 = HT_ADCn->LST[Rank >> 2]; + /* Calculate the mask to clear */ + tmpreg2 = LST_SEQ_SET << (8 * (Rank & 0x3)); + /* Clear the old SEQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (u32)ADC_CH_n << (8 * (Rank & 0x3)); + /* Set the SEQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + HT_ADCn->LST[Rank >> 2] = tmpreg1; +} + +/*********************************************************************************************************//** + * @brief Configure the corresponding rank in the sequencer and the sample time for the High Priority channel + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected, x must between 0 ~ 11 + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param Rank: The rank in the high priority group sequencer. + * This parameter must be between 0 to 3. + * @param SampleClock: Number of sampling clocks. + * This parameter must be between 0x00 to 0xFF. + * @retval None + ************************************************************************************************************/ +void ADC_HPChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock) +{ + u32 tmpreg1, tmpreg2; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_HP_RANK(Rank)); + Assert_Param(IS_ADC_INPUT_SAMPLING_TIME(SampleClock)); + + /* config sampling clock of correspond ADC input channel */ + HT_ADCn->STR[ADC_CH_n] = SampleClock; + + /* Get the old register value */ + tmpreg1 = HT_ADCn->HLST; + /* Calculate the mask to clear */ + tmpreg2 = HLST_SEQ_SET << (8 * (Rank & 0x3)); + /* Clear the old SEQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (u32)ADC_CH_n << (8 * (Rank & 0x3)); + /* Set the SEQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + HT_ADCn->HLST = tmpreg1; +} + +/*********************************************************************************************************//** + * @brief Configure the ADC trigger source for regular channels conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_TRIG_x: + * This parameter can be one of the following values: + * @arg ADC_TRIG_SOFTWARE : S/W trigger + * @arg ADC_TRIG_EXTI_n : where n can be 0 ~ 15 + * @arg ADC_TRIG_MCTMn_MTO : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_GPTMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_TRIG_BFTMn : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_TRIG_CMPn : where n can be 0 ~ 1 + * @retval None + ************************************************************************************************************/ +void ADC_RegularTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_TRIG(ADC_TRIG_x)); + + /* Config external trigger conversion source of regular group */ + HT_ADCn->TCR = ADC_TRIG_x & 0x0000001F; + HT_ADCn->TSR = ADC_TRIG_x & (~0x0000001F); +} + +/*********************************************************************************************************//** + * @brief Configure the ADC trigger source for high priority channels conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_TRIG_x: + * This parameter can be one of the following values: + * @arg ADC_TRIG_EXTI_n : where n can be 0 ~ 15 + * @arg ADC_TRIG_MCTMn_MTO : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_GPTMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_TRIG_BFTMn : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_HPTRIG_CMPn : where n can be 0 ~ 1 + * @retval None + ************************************************************************************************************/ +void ADC_HPTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_HPTRIG(ADC_TRIG_x)); + + HT_ADCn->HTCR = ADC_TRIG_x & 0x0000001F; + HT_ADCn->HTSR = ADC_TRIG_x & (~0x0000001F); +} + +/*********************************************************************************************************//** + * @brief Configure the channel data alignment format. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected + * @arg ADC_CH_OPAn : ADC channel for OPAn + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param ADC_ALIGN_x: ADC_ALIGN_RIGHT or ADC_ALIGN_LEFT + * @retval None + ************************************************************************************************************/ +void ADC_ChannelDataAlign(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ADC_ALIGN_Enum ADC_ALIGN_x) +{ + u32 OFRValue; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_ALIGN(ADC_ALIGN_x)); + + OFRValue = HT_ADCn->OFR[ADC_CH_n] & (~(OFR_ADAL)); + OFRValue |= ADC_ALIGN_x; + + HT_ADCn->OFR[ADC_CH_n] = OFRValue; +} + +/*********************************************************************************************************//** + * @brief Configure the offset value for channel offset cancellation. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected + * @arg ADC_CH_OPAn : ADC channel for OPAn + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param OffsetValue: The offset value + * @retval None + ************************************************************************************************************/ +void ADC_ChannelOffsetValue(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u16 OffsetValue) +{ + u32 OFRValue; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_OFFSET(OffsetValue)); + + OFRValue = HT_ADCn->OFR[ADC_CH_n] & (~OFR_ADOF_MASK); + OFRValue |= (OffsetValue & 0xFFF); + HT_ADCn->OFR[ADC_CH_n] = OFRValue; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the channel offset cancellation function. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected + * @arg ADC_CH_OPAn : ADC channel for OPAn + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param NewState: ENABLE DISABLE + * @retval None + ************************************************************************************************************/ +void ADC_ChannelOffsetCmd(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ControlStatus NewState) +{ + u32 OFRValue; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + OFRValue = HT_ADCn->OFR[ADC_CH_n] & (~(OFR_ADOFE)); + + if (NewState == ENABLE) + { + OFRValue |= OFR_ADOFE; + } + + HT_ADCn->OFR[ADC_CH_n] = OFRValue; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable software start of the regular channel conversion of the selected ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_SoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Start Conversion */ + if (NewState != DISABLE) + { + HT_ADCn->TSR |= TCR_SC_SET; + } + else + { + HT_ADCn->TSR &= ~TCR_SC_SET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable software start of the high priority channel conversion of the selected ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_HPSoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Start Conversion */ + if (NewState != DISABLE) + { + HT_ADCn->HTSR |= HTCR_SC_SET; + } + else + { + HT_ADCn->HTSR &= ~HTCR_SC_SET; + } +} + +/*********************************************************************************************************//** + * @brief Return the result of ADC regular channel conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_REGULAR_DATAn: where n can be 0 ~ 15 + * @retval The Value of data conversion. + ************************************************************************************************************/ +u16 ADC_GetConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_REGULAR_DATAn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_REGULAR_DATA(ADC_REGULAR_DATAn)); + + return ((u16)HT_ADCn->DR[ADC_REGULAR_DATAn]); +} + +/*********************************************************************************************************//** + * @brief Return the result of ADC high priority channel conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_HP_DATAn: where x can be 0 ~ 3 + * @retval The Value of data conversion. + ************************************************************************************************************/ +u16 ADC_GetHPConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_HP_DATAn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_HP_DATA(ADC_HP_DATAn)); + + return ((u16)HT_ADCn->HDR[ADC_HP_DATAn]); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC interrupts. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the ADC interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_HP_SINGLE_EOC : + * @arg ADC_INT_HP_SUB_GROUP_EOC : + * @arg ADC_INT_HP_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_HP_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_IntConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->IER |= ADC_INT_x; + } + else + { + HT_ADCn->IER &= ~ADC_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC interrupt has occurred. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_HP_SINGLE_EOC : + * @arg ADC_INT_HP_SUB_GROUP_EOC : + * @arg ADC_INT_HP_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_HP_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetIntStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + if ((HT_ADCn->ISR & ADC_INT_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Clear the ADC interrupt pending bits. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt pending bits to be cleared. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_HP_SINGLE_EOC : + * @arg ADC_INT_HP_SUB_GROUP_EOC : + * @arg ADC_INT_HP_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_HP_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_ClearIntPendingBit(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + HT_ADCn->ICLR = ADC_INT_x; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC flag has been set. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_FLAG_x: Specify the flag to check. + * This parameter can be any combination of the following values: + * @arg ADC_FLAG_SINGLE_EOC : + * @arg ADC_FLAG_SUB_GROUP_EOC : + * @arg ADC_FLAG_CYCLE_EOC : + * @arg ADC_FLAG_HP_SINGLE_EOC : + * @arg ADC_FLAG_HP_SUB_GROUP_EOC : + * @arg ADC_FLAG_HP_CYCLE_EOC : + * @arg ADC_FLAG_DATA_OVERWRITE : + * @arg ADC_FLAG_HP_DATA_OVERWRITE : + * @arg ADC_FLAG_AWD_LOWER : + * @arg ADC_FLAG_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetFlagStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_FLAG_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_FLAG(ADC_FLAG_x)); + + if ((HT_ADCn->IRAW & ADC_FLAG_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable Lower/Upper threshold warning of the analog watchdog on single/all channels. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_AWD_x: + * This parameter can be any combination of the following values: + * @arg ADC_AWD_DISABLE : + * @arg ADC_AWD_ALL_LOWER : + * @arg ADC_AWD_ALL_UPPER : + * @arg ADC_AWD_ALL_LOWER_UPPER : + * @arg ADC_AWD_SINGLE_LOWER : + * @arg ADC_AWD_SINGLE_UPPER : + * @arg ADC_AWD_SINGLE_LOWER_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_AWDConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_AWD_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_AWD(ADC_AWD_x)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFFFF8) | ADC_AWD_x; +} + +/*********************************************************************************************************//** + * @brief Configure the analog watchdog that guards single channel. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: where n must between 0 ~ 11 + * @retval None + ************************************************************************************************************/ +void ADC_AWDSingleChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INPUT_CHANNEL(ADC_CH_n)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFF0FF) | ((u32)ADC_CH_n << 8); +} + +/*********************************************************************************************************//** + * @brief Configure the high and low thresholds of the analog watchdog. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param UPPER: must between 0x0000 ~ 0x0FFF + * @param LOWER: must between 0x0000 ~ 0x0FFF + * @retval None + ************************************************************************************************************/ +void ADC_AWDThresholdsConfig(HT_ADC_TypeDef* HT_ADCn, u16 UPPER, u16 LOWER) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_THRESHOLD(UPPER)); + Assert_Param(IS_ADC_THRESHOLD(LOWER)); + + HT_ADCn->LTR = LOWER; + HT_ADCn->UTR = UPPER; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified PDMA request. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_PDMA_x: Specify the ADC PDMA request that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_PDMA_REGULAR_SINGLE : + * @arg ADC_PDMA_REGULAR_SUBGROUP : + * @arg ADC_PDMA_REGULAR_CYCLE : + * @arg ADC_PDMA_HP_SINGLE : + * @arg ADC_PDMA_HP_SUBGROUP : + * @arg ADC_PDMA_HP_CYCLE : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_PDMAConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_PDMA_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_PDMA(ADC_PDMA_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->PDMAR |= ADC_PDMA_x; + } + else + { + HT_ADCn->PDMAR &= ~ADC_PDMA_x; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc_02.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc_02.c new file mode 100644 index 0000000000..8d22863d7b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_adc_02.c @@ -0,0 +1,559 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_adc_02.c + * @version $Rev:: 2972 $ + * @date $Date:: 2023-10-28 #$ + * @brief This file provides all the ADC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_adc.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup ADC ADC + * @brief ADC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Private_Define ADC private definitions + * @{ + */ +#define ADC_ENABLE_BIT (0x00000080) +#define ADC_SOFTWARE_RESET (0x00000040) +#define LST_SEQ_SET (0x0000001F) +#define TCR_SC_SET (0x00000001) + +#define HLST_SEQ_SET (0x0000001F) +#define HTCR_SC_SET (0x00000001) + +#if (LIBCFG_ADC_IVREF) +#define ADC_VREF_MVDDAEN (0x00000100) +#endif +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup ADC_Exported_Functions ADC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the HT_ADCn peripheral registers to their default reset values. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_DeInit(HT_ADC_TypeDef* HT_ADCn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + if (HT_ADCn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.ADC0 = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Reset ADC. + * @param HT_ADCn: is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_Reset(HT_ADC_TypeDef* HT_ADCn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + HT_ADCn->CR |= ADC_SOFTWARE_RESET; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_Cmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->CR |= ADC_ENABLE_BIT; + ADC_Reset(HT_ADCn); + } + else + { + HT_ADCn->CR &= ~(ADC_ENABLE_BIT); + } +} + +/*********************************************************************************************************//** + * @brief Configure conversion mode and length of list queue for regular group. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_MODE: ADC Cyclic Conversion Mode. + * This parameter can be one of the following values: + * @arg ONE_SHOT_MODE : + * @arg CONTINUOUS_MODE : + * @arg DISCONTINUOUS_MODE : + * @param Length: must between 1 ~ 8 + * @param SubLength: must between 1 ~ 8, only valid for DISCONTINUOUS_MODE. + * @retval None + ************************************************************************************************************/ +void ADC_RegularGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CONVERSION_MODE(ADC_MODE)); + Assert_Param(IS_ADC_REGULAR_LENGTH(Length)); + if (ADC_MODE == DISCONTINUOUS_MODE) + { + Assert_Param(IS_ADC_REGULAR_SUB_LENGTH(SubLength)); + } + + /* Config cyclic conversion mode and length of list queue and sub length for regular group */ + HT_ADCn->CR = ((u32)(SubLength - 1) << 16) | ((u32)(Length - 1) << 8) | ADC_MODE | (HT_ADCn->CR & ADC_ENABLE_BIT); +} + +/*********************************************************************************************************//** + * @brief Configure the corresponding rank in the sequencer and the sampling time for the regular channel + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel n selected, n must between 0 ~ m (m represent the maximum external ADC input channel). + * @arg ADC_CH_DAC1 : ADC DAC1 selected + * @arg ADC_CH_DAC0 : ADC DAC0 selected + * @arg ADC_CH_IVREF : ADC Internal VREF selected + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @arg ADC_CH_MVDDA : ADC MVDDA selected + * @param Rank: The rank in the regular group sequencer. + * This parameter must be between 0 to 7. + * @param SampleClock: must between 0 ~ 255. + * @retval None + ************************************************************************************************************/ +void ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock) +{ + u32 tmpreg1, tmpreg2; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_REGULAR_RANK(Rank)); + Assert_Param(IS_ADC_INPUT_SAMPLING_TIME(SampleClock)); + + /* config sampling clock of ADC input channel */ + HT_ADCn->STR = SampleClock; + /* Get the old register value */ + tmpreg1 = HT_ADCn->LST[Rank >> 2]; + /* Calculate the mask to clear */ + tmpreg2 = LST_SEQ_SET << (8 * (Rank & 0x3)); + /* Clear the old SEQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (u32)ADC_CH_n << (8 * (Rank & 0x3)); + /* Set the SEQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + HT_ADCn->LST[Rank >> 2] = tmpreg1; +} + +/*********************************************************************************************************//** + * @brief Configure the ADC trigger source for regular channels conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_TRIG_x: + * This parameter can be one of the following values: + * @arg ADC_TRIG_SOFTWARE : S/W trigger + * @arg ADC_TRIG_EXTI_n : where n can be 0 ~ 15 + * @arg ADC_TRIG_MCTMn_MTO : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_GPTMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_TRIG_BFTMn : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_TRIG_CMPn : where n can be 0 ~ 1 + * @retval None + ************************************************************************************************************/ +void ADC_RegularTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_TRIG(ADC_TRIG_x)); + + /* Config external trigger conversion source of regular group */ + HT_ADCn->TCR = ADC_TRIG_x & 0x0000001F; + HT_ADCn->TSR = ADC_TRIG_x & (~0x0000001F); +} + +/*********************************************************************************************************//** + * @brief Configure the sampling time for the ADC input channel. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param SampleClock: must between 0 ~ 255. + * @retval None + ************************************************************************************************************/ +void ADC_SamplingTimeConfig(HT_ADC_TypeDef* HT_ADCn, u8 SampleClock) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + /* config sampling clock of ADC input channel */ + HT_ADCn->STR = SampleClock; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable software start of the regular channel conversion of the selected ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_SoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Start Conversion */ + if (NewState != DISABLE) + { + HT_ADCn->TSR |= TCR_SC_SET; + } + else + { + HT_ADCn->TSR &= ~TCR_SC_SET; + } +} + +/*********************************************************************************************************//** + * @brief Return the result of ADC regular channel conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_REGULAR_DATAn: where n can be 0 ~ 7 + * @retval The Value of data conversion. + ************************************************************************************************************/ +u16 ADC_GetConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_REGULAR_DATAn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_REGULAR_DATA(ADC_REGULAR_DATAn)); + + return ((u16)HT_ADCn->DR[ADC_REGULAR_DATAn]); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC interrupts. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the ADC interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_IntConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->IER |= ADC_INT_x; + } + else + { + HT_ADCn->IER &= ~ADC_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC interrupt has occurred. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetIntStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + if ((HT_ADCn->ISR & ADC_INT_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Clear the ADC interrupt pending bits. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt pending bits to be cleared. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_ClearIntPendingBit(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + HT_ADCn->ICLR = ADC_INT_x; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC flag has been set. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_FLAG_x: Specify the flag to check. + * This parameter can be any combination of the following values: + * @arg ADC_FLAG_SINGLE_EOC : + * @arg ADC_FLAG_SUB_GROUP_EOC : + * @arg ADC_FLAG_CYCLE_EOC : + * @arg ADC_FLAG_DATA_OVERWRITE : + * @arg ADC_FLAG_AWD_LOWER : + * @arg ADC_FLAG_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetFlagStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_FLAG_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_FLAG(ADC_FLAG_x)); + + if ((HT_ADCn->IRAW & ADC_FLAG_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable Lower/Upper threshold warning of the analog watchdog on single/all channels. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_AWD_x: + * This parameter can be any combination of the following values: + * @arg ADC_AWD_DISABLE : + * @arg ADC_AWD_ALL_LOWER : + * @arg ADC_AWD_ALL_UPPER : + * @arg ADC_AWD_ALL_LOWER_UPPER : + * @arg ADC_AWD_SINGLE_LOWER : + * @arg ADC_AWD_SINGLE_UPPER : + * @arg ADC_AWD_SINGLE_LOWER_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_AWDConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_AWD_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_AWD(ADC_AWD_x)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFFFF8) | ADC_AWD_x; +} + +/*********************************************************************************************************//** + * @brief Configure the analog watchdog that guards single channel. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: where n must between 0 ~ m (m represent the maximum external ADC input channel). + * @retval None + ************************************************************************************************************/ +void ADC_AWDSingleChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INPUT_CHANNEL(ADC_CH_n)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFF0FF) | ((u32)ADC_CH_n << 8); +} + +/*********************************************************************************************************//** + * @brief Configure the high and low thresholds of the analog watchdog. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param UPPER: must between 0x0000 ~ 0x0FFF + * @param LOWER: must between 0x0000 ~ 0x0FFF + * @retval None + ************************************************************************************************************/ +void ADC_AWDThresholdsConfig(HT_ADC_TypeDef* HT_ADCn, u16 UPPER, u16 LOWER) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_THRESHOLD(UPPER)); + Assert_Param(IS_ADC_THRESHOLD(LOWER)); + + HT_ADCn->WTR = (UPPER << 16) | LOWER; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified PDMA request. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_PDMA_x: Specify the ADC PDMA request that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_PDMA_REGULAR_SINGLE : + * @arg ADC_PDMA_REGULAR_SUBGROUP : + * @arg ADC_PDMA_REGULAR_CYCLE : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_PDMAConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_PDMA_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_PDMA(ADC_PDMA_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->PDMAR |= ADC_PDMA_x; + } + else + { + HT_ADCn->PDMAR &= ~ADC_PDMA_x; + } +} + +#if (LIBCFG_ADC_IVREF) +/*********************************************************************************************************//** + * @brief Enable or Disable the VREF. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_VREFCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->VREFCR |= 0x00000001; + } + else + { + HT_ADCn->VREFCR &= ~(0x00000001); + } +} + +/*********************************************************************************************************//** + * @brief Configure the VREF output voltage. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_VREF_x: + * This parameter can be one of the following value: + * @arg ADC_VREF_1V215 : + * @arg ADC_VREF_2V0 : + * @arg ADC_VREF_2V5 : + * @arg ADC_VREF_2V7 : + * @retval None + ************************************************************************************************************/ +void ADC_VREFConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_VREF_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_VREF_SEL(ADC_VREF_x)); + + HT_ADCn->VREFCR = (HT_ADCn->VREFCR & ~(3ul << 4)) | (ADC_VREF_x); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the power of MVDDA (VDDA/2) + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_MVDDACmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->VREFCR |= ADC_VREF_MVDDAEN; + } + else + { + HT_ADCn->VREFCR &= ~(ADC_VREF_MVDDAEN); + } +} + +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_aes.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_aes.c new file mode 100644 index 0000000000..c6e8ea2a5b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_aes.c @@ -0,0 +1,550 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_aes.c + * @version $Rev:: 2788 $ + * @date $Date:: 2022-11-24 #$ + * @brief This file provides all the AES firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_aes.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup AES AES + * @brief AES driver modules + * @{ + */ + + +/* Global variables ----------------------------------------------------------------------------------------*/ +u32 *gpu32OutputBuff; +u32 gu32OutputIndex = 0; + +u32 *gpu32InputBuff; +u32 gu32InputSize = 0; +u32 gu32InputIndex = 0; + +/* Private functions ---------------------------------------------------------------------------------------*/ +static void _AES_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Functions AES exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the AES peripheral registers to their default reset values. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AES_DeInit(HT_AES_TypeDef* HT_AESn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + if (HT_AESn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.AES = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Flush the FIFO. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AES_FIFOFlush(HT_AES_TypeDef* HT_AESn) +{ + AES_Cmd(HT_AESn, DISABLE); + HT_AESn->CR |= AES_FLUSH_ENABLE; + AES_Cmd(HT_AESn, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified AES. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void AES_Cmd(HT_AES_TypeDef* HT_AESn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_AESn->CR |= AES_ENABLE; + } + else + { + HT_AESn->CR &= ~AES_ENABLE; + } +} + +/*********************************************************************************************************//** + * @brief Start the AES key. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AES_StartKey(HT_AES_TypeDef* HT_AESn) +{ + HT_AESn->CR |= (1 << 4); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where AES is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void _AES_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_KEY_SIZE(AES_InitStruct->AES_KeySize)); + Assert_Param(IS_AES_DIR(AES_InitStruct->AES_Dir)); + Assert_Param(IS_AES_MODE(AES_InitStruct->AES_Mode)); + Assert_Param(IS_AES_SWAP(AES_InitStruct->AES_Swap)); + + HT_AESn->CR = (HT_AESn->CR & 0xFFFFFE81) | AES_InitStruct->AES_KeySize | + AES_InitStruct->AES_Dir | AES_InitStruct->AES_Mode | + AES_InitStruct->AES_Swap; + + AES_Cmd(HT_AESn, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral on ECB mode according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where AES is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void AES_ECB_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + AES_InitStruct->AES_Mode = AES_MODE_ECB; + _AES_Init(HT_AESn, AES_InitStruct); + + AES_IntConfig(HT_AESn, AES_IER_OFINTEN, ENABLE); + NVIC_EnableIRQ(AES_IRQn); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral on CBC mode according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where AES is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void AES_CBC_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + AES_InitStruct->AES_Mode = AES_MODE_CBC; + _AES_Init(HT_AESn, AES_InitStruct); + + AES_IntConfig(HT_AESn, AES_IER_OFINTEN, ENABLE); + NVIC_EnableIRQ(AES_IRQn); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral on CTR mode according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where HT_AESn is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void AES_CTR_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + AES_InitStruct->AES_Mode = AES_MODE_CTR; + _AES_Init(HT_AESn, AES_InitStruct); + + AES_IntConfig(HT_AESn, AES_IER_OFINTEN, ENABLE); + NVIC_EnableIRQ(AES_IRQn); +} + +/*********************************************************************************************************//** + * @brief Check whether the specified AES status has been set. + * @param HT_AESn: where HT_AESn is the selected AES peripheral. + * @param AES_SR_x: specify the flag to be check. + * This parameter can be one of the following values: + * @arg AES_SR_IFEMPTY : AES Input FIFO is Empty + * @arg AES_SR_IFNFULL : AES Input FIFO is not Full + * @arg AES_SR_OFNEMPTY : AES Output FIFO is not Empty + * @arg AES_SR_OFFULL : AES Output FIFO is Full + * @arg AES_SR_BUSY : AES is busy when AES is in encrypt/decrypt action and key expansion + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus AES_GetStatus(HT_AES_TypeDef* HT_AESn, u32 AES_SR_x) +{ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_STATUS(AES_SR_x)); + + if ((HT_AESn->SR & AES_SR_x) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the AES PDMA interface. + * @param HT_AESn: where HT_AESn is the selected HT_AESn peripheral. + * @param AES_PDMA_xFDMAEN: specify the AES FIFO DMA to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg AES_PDMA_IFDMAEN : input FIFO PDMA + * @arg AES_PDMA_OFDMAEN : Output FIFO PDMA + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void AES_PDMACmd(HT_AES_TypeDef* HT_AESn, u32 AES_PDMA_xFDMAEN, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_AESn->PDMAR |= AES_PDMA_xFDMAEN; + } + else + { + HT_AESn->PDMAR &= ~AES_PDMA_xFDMAEN; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified AES interrupt has occurred. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param AES_INTSR_x: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * @arg AES_INTSR_IFINT : + * @arg AES_INTSR_OFINT : + * @return SET or RESET + ************************************************************************************************************/ +FlagStatus AES_GetIntStatus(HT_AES_TypeDef* HT_AESn, u32 AES_INTSR_x) +{ + FlagStatus Status; + u32 aes_isr = HT_AESn->ISR; + u32 aes_ier = HT_AESn->IER; + + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_INTSR(AES_INTSR_x)); + + Status = (FlagStatus)(aes_isr & aes_ier); + if ((Status & AES_INTSR_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified AES interrupts. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param AES_IER_x: Specify the AES interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg AES_IER_IFINTEN : + * @arg AES_IER_OFINTEN : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void AES_IntConfig(HT_AES_TypeDef* HT_AESn, u32 AES_IER_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_IER(AES_IER_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_AESn->IER |= AES_IER_x; + } + else + { + HT_AESn->IER &= ~AES_IER_x; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified AES Input data. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param AES_Data: Data input + * @retval None + ************************************************************************************************************/ +void AES_SetInputData(HT_AES_TypeDef* HT_AESn, uc32 AES_Data) +{ + Assert_Param(IS_AES(HT_AESn)); + #if (LIBCFG_AES_SWAP) + HT_AESn->DINR = __REV(AES_Data); + #else + HT_AESn->DINR = AES_Data; + #endif +} + +/*********************************************************************************************************//** + * @brief Get the specified AES output data. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @retval Output Data + ************************************************************************************************************/ +u32 AES_GetOutputData(HT_AES_TypeDef* HT_AESn) +{ + Assert_Param(IS_AES(HT_AESn)); + #if (LIBCFG_AES_SWAP) + return __REV(HT_AESn->DOUTR); + #else + return HT_AESn->DOUTR; + #endif +} + +/*********************************************************************************************************//** + * @brief Set the specified AES key table. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param Key: Key table + * @param keySize: Key table's size + * @retval None + ************************************************************************************************************/ +void AES_SetKeyTable(HT_AES_TypeDef* HT_AESn, uc8* Key, u32 keySize) +{ + u32 i; + u32 uCRTemp = HT_AESn->CR & (~(0x00000060UL)); + if (keySize == 128/8) + { + uCRTemp |= AES_KEYSIZE_128B; + } + else if (keySize == 192/8) + { + uCRTemp |= AES_KEYSIZE_192B; + } + else if (keySize == 256/8) + { + uCRTemp |= AES_KEYSIZE_256B; + } + else + { + return; + } + HT_AESn->CR = uCRTemp; + + for (i = 0; i < keySize; i += 4) + { + #if (LIBCFG_AES_SWAP) + HT_AESn->KEYR[i >> 2] = __REV(*(u32*)&Key[i]); + #else + HT_AESn->KEYR[i >> 2] = *(u32*)&Key[i]; + #endif + } + + AES_StartKey(HT_AES); +} + +/*********************************************************************************************************//** + * @brief Set the specified AES Vector table. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param Vector: + * @retval None + ************************************************************************************************************/ +void AES_SetVectorTable(HT_AES_TypeDef* HT_AESn, uc8* Vector) +{ + int i; + Assert_Param(IS_AES(HT_AESn)); + + for (i = 0; i < 16; i += 4) + { + #if (LIBCFG_AES_SWAP) + HT_AESn->IVR[i >> 2] = __REV(*(u32*)&Vector[i]); + #else + HT_AESn->IVR[i >> 2] = *(u32*)&Vector[i]; + #endif + } +} + +/*********************************************************************************************************//** + * @brief AES Crypt Data + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param dir: Crypt Data's direction + * @param iv: initial vector table + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus _AES_CryptData(HT_AES_TypeDef* HT_AESn, + AES_DIR_Enum dir, + uc8 *iv, + u32 length, + uc8 *inputData, + u8 *outputData) +{ + /*AES Data blocks 16 byte */ + if ((length % 16) != 0) + { + /* Data size can not be divisible by 16. */ + return ERROR; + } + + /*Set inital Vector */ + if (iv != NULL) + { + AES_SetVectorTable(HT_AESn, iv); + } + + /*FIFO Flush */ + AES_FIFOFlush(HT_AES); + + /*Set direction */ + HT_AESn->CR = (HT_AESn->CR & 0xFFFFFFFD) | dir; + + /*Create input/output data */ + gpu32InputBuff = (u32*)inputData; + gpu32OutputBuff = (u32*)outputData; + + /*Init Index */ + gu32OutputIndex = 0; + gu32InputSize = length/4; + + /*Set input data */ + AES_IntConfig(HT_AES, AES_IER_IFINTEN, ENABLE); + + /*Waitting for conversion */ + while (AES_GetStatus(HT_AES, AES_SR_OFNEMPTY)); + return SUCCESS; +} + +#if 0 +/*********************************************************************************************************//** + * @brief AES Crypt Data on ECB mode + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param dir: Crypt Data's direction + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus AES_ECB_CryptData(HT_AES_TypeDef* HT_AESn, + AES_DIR_Enum dir, + u32 length, + uc8 *inputData, + u8 *outputData) +{ + return _AES_CryptData(HT_AESn, + dir, + NULL, + length, + inputData, + outputData); +} + +/*********************************************************************************************************//** + * @brief AES Crypt Data on CBC mode + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param dir: Crypt Data's direction + * @param iv: initial vector table + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus AES_CBC_CryptData(HT_AES_TypeDef* HT_AESn, + AES_DIR_Enum dir, + uc8 *iv, + u32 length, + uc8 *inputData, + u8 *outputData) +{ + return _AES_CryptData(HT_AESn, + dir, + iv, + length, + inputData, + outputData); +} + +/*********************************************************************************************************//** + * @brief AES Crypt Data on CTR mode + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param iv: initial vector table + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus AES_CTR_CryptData(HT_AES_TypeDef* HT_AESn, + uc8 *iv, + u32 length, + uc8 *inputData, + u8 *outputData) +{ + return _AES_CryptData(HT_AESn, + AES_DIR_ENCRYPT, + iv, + length, + inputData, + outputData); +} +#endif + +/*********************************************************************************************************//** + * @brief This function handles AES Core interrupt. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AESCore_IRQHandler(HT_AES_TypeDef* HT_AESn) +{ + if (AES_GetIntStatus(HT_AES, AES_INTSR_OFINT)) + { + gpu32OutputBuff[gu32OutputIndex++] = AES_GetOutputData(HT_AES); + } + if (AES_GetIntStatus(HT_AES, AES_INTSR_IFINT)) + { + if (gu32InputIndex < gu32InputSize) + { + AES_SetInputData(HT_AES, gpu32InputBuff[gu32InputIndex]); + gu32InputIndex++; + } + else + { + AES_IntConfig(HT_AES, AES_IER_IFINTEN, DISABLE); + gu32InputIndex = 0; + } + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_bftm.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_bftm.c new file mode 100644 index 0000000000..c38bebac7e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_bftm.c @@ -0,0 +1,240 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_bftm.c + * @version $Rev:: 2789 $ + * @date $Date:: 2022-11-24 #$ + * @brief This file provides all the BFTM firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_bftm.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup BFTM BFTM + * @brief BFTM driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Functions BFTM exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the specified BFTM registers to their default values. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval None + ************************************************************************************************************/ +void BFTM_DeInit(HT_BFTM_TypeDef* HT_BFTMn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + if (HT_BFTMn == HT_BFTM0) + { + RSTCUReset.Bit.BFTM0 = 1; + } + else if (HT_BFTMn == HT_BFTM1) + { + RSTCUReset.Bit.BFTM1 = 1; + } + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void BFTM_EnaCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_BFTMn->CR |= (1UL << 2); + } + else + { + HT_BFTMn->CR &= ~(1UL << 2); + } +} + +/*********************************************************************************************************//** + * @brief Configure the CMP register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param uCompare: Specify a value to the CMP register. + * @retval None + ************************************************************************************************************/ +void BFTM_SetCompare(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCompare) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + HT_BFTMn->CMP = uCompare; +} + +/*********************************************************************************************************//** + * @brief Get the CMP register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval The value of the CMP register + ************************************************************************************************************/ +u32 BFTM_GetCompare(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + return HT_BFTMn->CMP; +} + +/*********************************************************************************************************//** + * @brief Set the CNTR register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param uCounter: Specify a new value to the CNTR register. + * @retval None + ************************************************************************************************************/ +void BFTM_SetCounter(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCounter) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + HT_BFTMn->CNTR = uCounter; +} + +/*********************************************************************************************************//** + * @brief Get the CNTR register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval The value of the CNTR register + ************************************************************************************************************/ +u32 BFTM_GetCounter(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + return HT_BFTMn->CNTR; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the one shot mode of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void BFTM_OneShotModeCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_BFTMn->CR |= (1UL << 1); + } + else + { + HT_BFTMn->CR &= ~(1UL << 1); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified BFTM interrupt. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void BFTM_IntConfig(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_BFTMn->CR |= BFTM_INT_MATCH; + } + else + { + HT_BFTMn->CR &= ~BFTM_INT_MATCH; + } +} + +/*********************************************************************************************************//** + * @brief Get the flag status of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus BFTM_GetFlagStatus(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + if (HT_BFTMn->SR & BFTM_FLAG_MATCH) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the interrupt flag of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval None + ************************************************************************************************************/ +void BFTM_ClearFlag(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + HT_BFTMn->SR &= ~BFTM_FLAG_MATCH; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ckcu.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ckcu.c new file mode 100644 index 0000000000..81e7f8f143 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ckcu.c @@ -0,0 +1,1076 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_ckcu.c + * @version $Rev:: 2972 $ + * @date $Date:: 2023-10-28 #$ + * @brief This file provides all the Clock Control Unit firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_ckcu.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CKCU CKCU + * @brief CKCU driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Private_Define CKCU private definitions + * @{ + */ + +/* GCFGR bit field definition */ +#define CKCU_POS_CKOUTSRC 0 +#define CKCU_MASK_CKOUTSRC ((u32)0x7 << CKCU_POS_CKOUTSRC) + +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_POS_USBSRC 10 +#define CKCU_MASK_USBSRC ((u32)0x1 << CKCU_POS_USBSRC) +#endif + +#define CKCU_POS_CKREFPRE 11 +#define CKCU_MASK_CKREFPRE ((u32)0x1F << CKCU_POS_CKREFPRE) + +#if (LIBCFG_CKCU_USART_PRESCALER) +#define CKCU_POS_URPRE 20 +#define CKCU_MASK_URPRE ((u32)0x3 << CKCU_POS_URPRE) +#endif + +#if (!LIBCFG_NO_CKCU_USBPRE) +#define CKCU_POS_USBPRE 22 +#define CKCU_MASK_USBPRE ((u32)0x3 << CKCU_POS_USBPRE) +#endif + +/* GCCR bit field definition */ +#define CKCU_POS_SW 0 +#if (LIBCFG_CKCU_NO_HCLK_LOW_SPEED) +#define CKCU_MASK_SW ((u32)0x3 << CKCU_POS_SW) +#else +#define CKCU_MASK_SW ((u32)0x7 << CKCU_POS_SW) +#endif + +/* PLLCFGR bit field definition */ +#define CKCU_POS_POTD 21 +#define CKCU_MASK_POTD ((u32)0x3 << CKCU_POS_POTD) + +#define CKCU_POS_PFBD 23 +#if (LIBCDG_CKCU_PLL_144M) +#define CKCU_MASK_PFBD ((u32)0x3F << CKCU_POS_PFBD) +#else +#define CKCU_MASK_PFBD ((u32)0x1F << CKCU_POS_PFBD) +#endif + +/* APBCFGR bit field definition */ +#define CKCU_POS_ADCDIV 16 +#define CKCU_MASK_ADCDIV ((u32)0x7 << CKCU_POS_ADCDIV) + +/* CKST bit field definition */ +#define CKCU_POS_PLLST 8 +#define CKCU_MASK_PLLST ((u32)0xF << CKCU_POS_PLLST) + +#define CKCU_POS_HSEST 16 +#define CKCU_MASK_HSEST ((u32)0x3 << CKCU_POS_HSEST) + +#define CKCU_POS_HSIST 24 +#define CKCU_MASK_HSIST ((u32)0x7 << CKCU_POS_HSIST) + +#if (LIBCFG_CKCU_CKSWST_LEGACY) +#define CKCU_POS_CKSWST 30 +#define CKCU_MASK_CKSWST ((u32)0x3 << CKCU_POS_CKSWST) +#else +#define CKCU_POS_CKSWST 0 +#define CKCU_MASK_CKSWST ((u32)0x7 << CKCU_POS_CKSWST) +#endif + +/* GCFGR Bit Band Alias */ +#define CKCU_BB_PLLSRC BitBand((u32)&HT_CKCU->GCFGR, 8) +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_BB_USBPLLSRC BitBand((u32)&HT_CKCU->GCFGR, 9) +#endif + +/* GCCR Bit Band Alias */ +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_BB_USBPLLEN BitBand((u32)&HT_CKCU->GCCR, 3) +#endif +#define CKCU_BB_PLLEN BitBand((u32)&HT_CKCU->GCCR, 9) +#define CKCU_BB_HSEEN BitBand((u32)&HT_CKCU->GCCR, 10) +#define CKCU_BB_HSIEN BitBand((u32)&HT_CKCU->GCCR, 11) +#define CKCU_BB_CKMEN BitBand((u32)&HT_CKCU->GCCR, 16) +#define CKCU_BB_PSRCEN BitBand((u32)&HT_CKCU->GCCR, 17) + +/* GCIR Bit Band Alias */ +#define CKCU_BB_CKSF BitBand((u32)&HT_CKCU->GCIR, 0) +#define CKCU_BB_CKSIE BitBand((u32)&HT_CKCU->GCIR, 16) + +/* PLLCR Bit Band Alias */ +#define CKCU_BB_PLLBYPASS BitBand((u32)&HT_CKCU->PLLCR, 31) + +#if (!LIBCFG_NO_BACK_DOMAIN) +/* LPCR Bit Band Alias */ +#define CKCU_BB_BKISO BitBand((u32)&HT_CKCU->LPCR, 0) +#endif + +#if (!LIBCFG_CKCU_HSI_NO_AUTOTRIM) +/* HSICR Bit Band Alias */ +#define CKCU_BB_TRIMEN BitBand((u32)&HT_CKCU->HSICR, 0) +#define CKCU_BB_ATCEN BitBand((u32)&HT_CKCU->HSICR, 1) +#define CKCU_BB_REFCLKSEL0 BitBand((u32)&HT_CKCU->HSICR, 5) +#define CKCU_BB_REFCLKSEL1 BitBand((u32)&HT_CKCU->HSICR, 6) +#endif + +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Private_Macro CKCU private macros + * @{ + */ +#define CKCU_BF_WRITE(Reg, Mask, Pos, WriteValue) (Reg = ((Reg & ~((u32)Mask)) | ((u32)WriteValue << Pos))) +#define CKCU_BF_READ(Reg, Mask, Pos) ((Reg & (u32)Mask) >> Pos) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup CKCU_Exported_Functions CKCU exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CKCU registers to the reset values. + * @retval None + ************************************************************************************************************/ +void CKCU_DeInit(void) +{ + /* Reset system clock */ + CKCU_HSICmd(ENABLE); + while (CKCU_GetClockReadyStatus(CKCU_FLAG_HSIRDY) == RESET); + CKCU_SysClockConfig(CKCU_SW_HSI); + +#if (LIBCFG_CKCU_USB_PLL) + HT_CKCU->GCFGR = 0x00000302; /* Reset value of GCFGR */ +#else + HT_CKCU->GCFGR = 0x00000102; /* Reset value of GCFGR */ +#endif + HT_CKCU->GCCR = 0x00000803; /* Reset value of GCCR */ +#if (LIBCFG_CKCU_USB_PLL) + HT_CKCU->GCIR = 0x0000007F; /* Clear all interrupt flags */ +#else + HT_CKCU->GCIR = 0x0000007D; /* Clear all interrupt flags */ +#endif + + HT_CKCU->PLLCR = 0; /* Reset value of PLLCR */ + HT_CKCU->AHBCFGR = 0; /* Reset value of AHBCFGR */ + HT_CKCU->AHBCCR = 0x000000E5; /* Reset value of AHBCCR */ + HT_CKCU->APBCFGR = 0x00010000; /* Reset value of APBCFGR */ + HT_CKCU->APBCCR0 = 0; /* Reset value of APBCCR0 */ + HT_CKCU->APBCCR1 = 0; /* Reset value of APBCCR1 */ +#if (LIBCFG_CKCU_NO_APB_PRESCALER) +#else + HT_CKCU->APBPCSR0 = 0; /* Reset value of APBPCSR0 */ + HT_CKCU->APBPCSR1 = 0; /* Reset value of APBPCSR1 */ +#endif +#if (LIBCFG_CKCU_APBPCSR2) + HT_CKCU->APBPCSR2 = 0; /* Reset value of APBPCSR2 */ +#endif +#if (LIBCFG_CKCU_HSI_NO_AUTOTRIM) +#else + HT_CKCU->HSICR = 0; /* Reset value of HSICR */ + HT_CKCU->HSIATCR = 0; /* Reset value of HSIATCR */ +#endif + HT_CKCU->LPCR = 0; /* Reset value of LPCR */ + HT_CKCU->MCUDBGCR = 0; /* Reset value of MCUDBGCR */ +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the external high speed oscillator (HSE). + * @note HSE can not be stopped if it is used by system clock or PLL. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_HSECmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BB_HSEEN = Cmd; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the internal high speed oscillator (HSI). + * @note HSI can not be stopped if it is used by system clock or PLL. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_HSICmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BB_HSIEN = Cmd; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the PLL clock. + * @note PLL can not be stopped if it is used by system clock or CK_REF. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_PLLCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BB_PLLEN = Cmd; +} + +#if (LIBCFG_CKCU_USB_PLL) +/*********************************************************************************************************//** + * @brief Enable or Disable the USBPLL clock. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_USBPLLCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BB_USBPLLEN = Cmd; +} +#endif + +/*********************************************************************************************************//** + * @brief Wait for HSE is ready to be used. + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus CKCU_WaitHSEReady(void) +{ + u32 ReadyCnt = 0; + + /* Wait until HSE is ready or time-out occurred */ + while (CKCU_GetClockReadyStatus(CKCU_FLAG_HSERDY) != SET) + { + if (++ReadyCnt >= HSE_READY_TIME) + { + return ERROR; + } + } + + return SUCCESS; +} + +/*********************************************************************************************************//** + * @brief Check whether the specific clock ready flag is set or not. + * @param CKCU_FLAG: specify the clock ready flag. + * This parameter can be one of the following values: + * @arg CKCU_FLAG_USBPLLRDY : USB PLL ready flag + * @arg CKCU_FLAG_PLLRDY : PLL ready flag + * @arg CKCU_FLAG_HSERDY : HSE ready flag + * @arg CKCU_FLAG_HSIRDY : HSI ready flag + * @arg CKCU_FLAG_LSERDY : LSE ready flag + * @arg CKCU_FLAG_LSIRDY : LSI ready flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CKCU_GetClockReadyStatus(u32 CKCU_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_FLAG(CKCU_FLAG)); + + if (HT_CKCU->GCSR & CKCU_FLAG) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief This function is used to configure PLL. + * @param PLL_InitStruct: pointer to CKCU_PLLInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_PLLInit(CKCU_PLLInitTypeDef *PLL_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_PLL_CLKSRC(PLL_InitStruct->ClockSource)); + Assert_Param(IS_CONTROL_STATUS(PLL_InitStruct->BYPASSCmd)); + Assert_Param(IS_PLL_CFG(PLL_InitStruct->CFG)); + + CKCU_BB_PLLSRC = PLL_InitStruct->ClockSource; + CKCU_BB_PLLBYPASS = PLL_InitStruct->BYPASSCmd; + HT_CKCU->PLLCFGR = (HT_CKCU->PLLCFGR & 0x0000FFFF) | PLL_InitStruct->CFG; +} + +#if (LIBCFG_CKCU_USB_PLL) +/*********************************************************************************************************//** + * @brief This function is used to configure USBPLL. + * @param USBPLL_InitStruct: pointer to CKCU_PLLInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_USBPLLInit(CKCU_PLLInitTypeDef *USBPLL_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_PLL_CLKSRC(USBPLL_InitStruct->ClockSource)); + Assert_Param(IS_USBPLL_CFG(USBPLL_InitStruct->CFG)); + + CKCU_BB_USBPLLSRC = USBPLL_InitStruct->ClockSource; + HT_CKCU->PLLCFGR = (HT_CKCU->PLLCFGR & 0xFFFF0000) | USBPLL_InitStruct->CFG; +} + +/*********************************************************************************************************//** + * @brief Configure the CK_USB clock source. + * @param USBSRC: specify the USB clock source. + * This parameter can be one of the following values: + * @arg CKCU_CKPLL : CK_USB = CK_PLL + * @arg CKCU_CKUSBPLL : CK_USB = CK_USBPLL + * @retval None + ************************************************************************************************************/ +void CKCU_USBClockConfig(CKCU_USBSRC_TypeDef USBSRC) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_USBSRC, CKCU_POS_USBSRC, USBSRC); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure the CK_SYS source. + * @param CLKSRC: specify the system clock source. + * This parameter can be one of the following values: + * @arg CKCU_SW_PLL : PLL is selected as CK_SYS + * @arg CKCU_SW_HSE : HSE is selected as CK_SYS + * @arg CKCU_SW_HSI : HSI is selected as CK_SYS + * @arg CKCU_SW_LSE : LSE is selected as CK_SYS + * @arg CKCU_SW_LSI : LSI is selected as CK_SYS + * @retval None + ************************************************************************************************************/ +ErrStatus CKCU_SysClockConfig(CKCU_SW_TypeDef CLKSRC) +{ + u32 cnt = 0xFF; + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_SW, CKCU_POS_SW, CLKSRC); + + /* Wait until new system clock source is applied or time-out */ + while (--cnt) + { + if (CKCU_GetSysClockSource() == (u32)CLKSRC) + { + return SUCCESS; + } + } + + return ERROR; +} + +/*********************************************************************************************************//** + * @brief Return the source clock which is used as system clock. + * @retval The source clock used as system clock. + * 0x01: PLL is selected as system clock + * 0x02: HSE is selected as system clock + * 0x03: HSI is selected as system clock + * 0x06: LSE is selected as system clock + * 0x07: LSI is selected as system clock + ************************************************************************************************************/ +u32 CKCU_GetSysClockSource(void) +{ + return ((u32)CKCU_BF_READ(HT_CKCU->CKST, CKCU_MASK_CKSWST, CKCU_POS_CKSWST)); +} + +/*********************************************************************************************************//** + * @brief Configure the CK_AHB prescaler. + * @param HCLKPRE: specify the value of divider. + * This parameter can be one of the following values: + * @arg CKCU_SYSCLK_DIV1 : HCLK = CK_SYS + * @arg CKCU_SYSCLK_DIV2 : HCLK = CK_SYS / 2 + * @arg CKCU_SYSCLK_DIV4 : HCLK = CK_SYS / 4 + * @arg CKCU_SYSCLK_DIV8 : HCLK = CK_SYS / 8 + * @arg CKCU_SYSCLK_DIV16 : HCLK = CK_SYS / 16 + * @arg CKCU_SYSCLK_DIV32 : HCLK = CK_SYS / 32 + * @retval None + ************************************************************************************************************/ +void CKCU_SetHCLKPrescaler(CKCU_SYSCLKDIV_TypeDef HCLKPRE) +{ + HT_CKCU->AHBCFGR = HCLKPRE; +} + +/*********************************************************************************************************//** + * @brief Configure the CK_REF prescaler. + * @param CKREFPRE: specify the value of divider. + * This parameter can be: CKCU_CKREFPRE_DIV2 to CKCU_CKREFPRE_DIV64 (CK_REF = CK_PLL / (2 * (N + 1)), N = 0 ~ 31) + * @retval None + ************************************************************************************************************/ +void CKCU_SetCKREFPrescaler(CKCU_CKREFPRE_TypeDef CKREFPRE) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_CKREFPRE, CKCU_POS_CKREFPRE, CKREFPRE); +} + +#if (LIBCFG_CKCU_USART_PRESCALER) +/********************************************************************************************************//** + * @brief Configure the CK_USART prescaler. + * @param URPRE: specify the prescaler value. + * This parameter can be: + * @arg CKCU_URPRE_DIV1: USART clock divided by 1 + * @arg CKCU_URPRE_DIV2: USART clock divided by 2 + * @retval None + ************************************************************************************************************/ +void CKCU_SetUSARTPrescaler(CKCU_URPRE_TypeDef URPRE) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_URPRE, CKCU_POS_URPRE, URPRE); +} +#endif + +#if (!LIBCFG_NO_CKCU_USBPRE) +/*********************************************************************************************************//** + * @brief Configure the CK_USB prescaler. + * @param USBPRE: specify the value of divider. + * This parameter can be one of the following values: + * @arg CKCU_USBPRE_DIV1 : CK_USB = CK_PLL / 1 + * @arg CKCU_USBPRE_DIV2 : CK_USB = CK_PLL / 2 + * @arg CKCU_USBPRE_DIV3 : CK_USB = CK_PLL / 3 (For HT32F165x only) + * @retval None + ************************************************************************************************************/ +void CKCU_SetUSBPrescaler(CKCU_USBPRE_TypeDef USBPRE) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_USBPRE, CKCU_POS_USBPRE, USBPRE); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure the CK_ADC prescaler. + * @param CKCU_ADCPRE_ADCn: specify the ADCn. + * @param CKCU_ADCPRE_DIVn: specify the prescaler value. + * This parameter can be one of the following values: + * @arg CKCU_ADCPRE_DIV1 : CK_ADC = HCLK / 1 (HT32F12364 Only) + * @arg CKCU_ADCPRE_DIV2 : CK_ADC = HCLK / 2 + * @arg CKCU_ADCPRE_DIV4 : CK_ADC = HCLK / 4 + * @arg CKCU_ADCPRE_DIV5 : CK_ADC = HCLK / 5 (HT32F12364 Only) + * @arg CKCU_ADCPRE_DIV6 : CK_ADC = HCLK / 6 + * @arg CKCU_ADCPRE_DIV8 : CK_ADC = HCLK / 8 + * @arg CKCU_ADCPRE_DIV16 : CK_ADC = HCLK / 16 + * @arg CKCU_ADCPRE_DIV32 : CK_ADC = HCLK / 32 + * @arg CKCU_ADCPRE_DIV64 : CK_ADC = HCLK / 64 + * @retval None + ************************************************************************************************************/ +void CKCU_SetADCnPrescaler(CKCU_ADCPRE_ADCn_TypeDef CKCU_ADCPRE_ADCn, CKCU_ADCPRE_TypeDef CKCU_ADCPRE_DIVn) +{ + HT_CKCU->APBCFGR = (HT_CKCU->APBCFGR & (~(0x07 << CKCU_ADCPRE_ADCn))) | (CKCU_ADCPRE_DIVn << CKCU_ADCPRE_ADCn); +} + +/*********************************************************************************************************//** + * @brief Return the frequency of the different clocks. + * @param CKCU_Clk: pointer to CKCU_ClocksTypeDef structure to get the clocks frequency. + * @retval None + ************************************************************************************************************/ +void CKCU_GetClocksFrequency(CKCU_ClocksTypeDef* CKCU_Clk) +{ + u32 div; + #if (LIBCFG_CKCU_CKSWST_LEGACY) + u32 SystemCoreClockSrc = (HT_CKCU->CKST >> 30) & 3UL; + #else + u32 SystemCoreClockSrc = (HT_CKCU->CKST >> 0) & 7UL; + #endif + + CKCU_Clk->PLL_Freq = CKCU_GetPLLFrequency(); + + /* Get system frequency */ + switch (SystemCoreClockSrc) + { + case CKCU_SW_PLL: + CKCU_Clk->SYSCK_Freq = CKCU_Clk->PLL_Freq; + break; + case CKCU_SW_HSE: + CKCU_Clk->SYSCK_Freq = HSE_VALUE; + break; + case CKCU_SW_HSI: + CKCU_Clk->SYSCK_Freq = HSI_VALUE; + break; + #if (LIBCFG_CKCU_NO_HCLK_LOW_SPEED) + #else + case CKCU_SW_LSE: + CKCU_Clk->SYSCK_Freq = LSE_VALUE; + break; + case CKCU_SW_LSI: + CKCU_Clk->SYSCK_Freq = LSI_VALUE; + break; + #endif + default: + CKCU_Clk->SYSCK_Freq = 0; + break; + } + + /* Get HCLK frequency */ + CKCU_Clk->HCLK_Freq = (CKCU_Clk->SYSCK_Freq) >> (HT_CKCU->AHBCFGR); + + #if (LIBCFG_CKCU_USART_PRESCALER) + /* Get USART frequency */ + { + u32 urpre; + urpre = CKCU_BF_READ(HT_CKCU->GCFGR, CKCU_MASK_URPRE, CKCU_POS_URPRE); + CKCU_Clk->USART_Freq = (CKCU_Clk->HCLK_Freq) >> urpre; + } + #endif + + /* Get ADC frequency */ + div = CKCU_BF_READ(HT_CKCU->APBCFGR, CKCU_MASK_ADCDIV, CKCU_POS_ADCDIV); + CKCU_Clk->ADC0_Freq = (div == 7) ? ((CKCU_Clk->HCLK_Freq) / 6) : ((CKCU_Clk->HCLK_Freq) >> div); +} + +/*********************************************************************************************************//** + * @brief Return the frequency of the PLL. + * @retval PLL Frequency + ************************************************************************************************************/ +u32 CKCU_GetPLLFrequency(void) +{ + u32 pllNO, pllNF, ClockSrc; + + /* Get PLL frequency */ + if (CKCU_BB_PLLEN == DISABLE) + { + return 0; + } + + ClockSrc = (CKCU_BB_PLLSRC == CKCU_PLLSRC_HSE) ? HSE_VALUE : HSI_VALUE; + + if (CKCU_BB_PLLBYPASS == ENABLE) + { + return ClockSrc; + } + + pllNF = CKCU_BF_READ(HT_CKCU->PLLCFGR, CKCU_MASK_PFBD, CKCU_POS_PFBD); + if (pllNF == 0) + pllNF = 64; + + pllNO = CKCU_BF_READ(HT_CKCU->PLLCFGR, CKCU_MASK_POTD, CKCU_POS_POTD); + pllNO = (u8)0x1 << pllNO; + + return ((ClockSrc / pllNO) * pllNF); +} + +#if (LIBCFG_CKCU_NO_APB_PRESCALER == 0) +/*********************************************************************************************************//** + * @brief Configure the APB peripheral prescaler. + * @param Perip: specify the APB peripheral. + * This parameter can be: + * @arg CKCU_PCLK_I2C0, CKCU_PCLK_I2C1, + * CKCU_PCLK_SPI0, CKCU_PCLK_SPI1, + * CKCU_PCLK_BFTM0, CKCU_PCLK_BFTM1, + * CKCU_PCLK_MCTM0, CKCU_PCLK_MCTM1, + * CKCU_PCLK_GPTM0, CKCU_PCLK_GPTM1, + * CKCU_PCLK_USART0, CKCU_PCLK_USART1, + * CKCU_PCLK_UART0, CKCU_PCLK_UART1, + * CKCU_PCLK_AFIO, CKCU_PCLK_EXTI, CKCU_PCLK_ADC, CKCU_PCLK_CMP, + * CKCU_PCLK_WDTR, CKCU_PCLK_BKPR, + * CKCU_PCLK_SCI0, CKCU_PCLK_SCI1, + * CKCU_PCLK_I2S, + * CKCU_PCLK_SCTM0, CKCU_PCLK_SCTM1, + * CKCU_PCLK_PWM0 + * @param PCLKPrescaler: specify the value of prescaler. + * This parameter can be: + * @arg CKCU_APBCLKPRE_DIV1: specific peripheral clock = PCLK / 1 (inapplicable to BKPRCLK) + * @arg CKCU_APBCLKPRE_DIV2: specific peripheral clock = PCLK / 2 (inapplicable to BKPRCLK) + * @arg CKCU_APBCLKPRE_DIV4: specific peripheral clock = PCLK / 4 + * @arg CKCU_APBCLKPRE_DIV8: specific peripheral clock = PCLK / 8 + * @arg CKCU_APBCLKPRE_DIV16: specific peripheral clock = PCLK / 16 (BKPRCLK only) + * @arg CKCU_APBCLKPRE_DIV32: specific peripheral clock = PCLK / 32 (BKPRCLK only) + * @retval None + ************************************************************************************************************/ +void CKCU_SetPeripPrescaler(CKCU_PeripPrescaler_TypeDef Perip, CKCU_APBCLKPRE_TypeDef PCLKPrescaler) +{ + u32 *PCSR = (u32 *)((&HT_CKCU->APBPCSR0) + (Perip >> CKCU_APBPCSR_OFFSET)); + u32 Prescaler = PCLKPrescaler; + if (Perip == CKCU_PCLK_BKPR) + { + Prescaler -= 2; + } + Perip &= 0x0000001F; + CKCU_BF_WRITE(*PCSR, (3UL << Perip), Perip, Prescaler); +} +#endif + +/*********************************************************************************************************//** + * @brief Return the operating frequency of the specific APB peripheral. + * @param Perip: specify the APB peripheral. + * This parameter can be: + * @arg CKCU_PCLK_I2C0, CKCU_PCLK_I2C1, + * CKCU_PCLK_SPI0, CKCU_PCLK_SPI1, + * CKCU_PCLK_BFTM0, CKCU_PCLK_BFTM1, + * CKCU_PCLK_MCTM0, CKCU_PCLK_MCTM1, + * CKCU_PCLK_GPTM0, CKCU_PCLK_GPTM1, + * CKCU_PCLK_USART0, CKCU_PCLK_USART1, + * CKCU_PCLK_UART0, CKCU_PCLK_UART1, + * CKCU_PCLK_AFIO, CKCU_PCLK_EXTI, CKCU_PCLK_ADC, CKCU_PCLK_CMP, + * CKCU_PCLK_WDTR, CKCU_PCLK_BKPR, + * CKCU_PCLK_SCI0, CKCU_PCLK_SCI1, + * CKCU_PCLK_I2S, + * CKCU_PCLK_I2S, + * CKCU_PCLK_SCTM0, CKCU_PCLK_SCTM1, + * CKCU_PCLK_PWM0 + * @retval Frequency in Hz + ************************************************************************************************************/ +u32 CKCU_GetPeripFrequency(CKCU_PeripPrescaler_TypeDef Perip) +{ + CKCU_ClocksTypeDef Clock; + + #if (LIBCFG_CKCU_NO_APB_PRESCALER) + CKCU_GetClocksFrequency(&Clock); + return Clock.HCLK_Freq; + #else + u32 *PCSR = (u32 *)(&HT_CKCU->APBPCSR0 + (Perip >> CKCU_APBPCSR_OFFSET)); + u32 PCLKPrescaler = 0; + + if (Perip == CKCU_PCLK_BKPR) + { + PCLKPrescaler = 2; + } + + Perip &= 0x0000001F; + PCLKPrescaler += CKCU_BF_READ(*PCSR, (3UL << Perip), Perip); + + CKCU_GetClocksFrequency(&Clock); + return (Clock.HCLK_Freq >> (PCLKPrescaler)); + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the HSE Clock Monitor function. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_CKMCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BB_CKMEN = Cmd; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the power saving wakeup RC clock. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_PSRCWKUPCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BB_PSRCEN = Cmd; +} + +/*********************************************************************************************************//** + * @brief Select the output clock source through the CKOUT pin. + * @param CKOUTInit: pointer to CKCU_CKOUTInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_CKOUTConfig(CKCU_CKOUTInitTypeDef *CKOUTInit) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_CKOUTSRC, CKCU_POS_CKOUTSRC, CKOUTInit->CKOUTSRC); +} + +/*********************************************************************************************************//** + * @brief Check whether the specific CKCU interrupt has occurred or not. + * @param CKCU_INT: specify the CKCU interrupt source. + * This parameter can be any combination of the following values: + * @arg CKCU_INT_CKS, CKCU_INT_PLLRDY, CKCU_INT_HSERDY, CKCU_INT_HSIRDY, CKCU_INT_LSERDY, CKCU_INT_LSIRDY + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CKCU_GetIntStatus(u32 CKCU_INT) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_INT_FLAG(CKCU_INT)); + + if (HT_CKCU->GCIR & CKCU_INT) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the CKCU interrupt flag. + * @param CKCU_INT: specify the CKCU interrupt flag to clear. + * This parameter can be any combination of the following values: + * @arg CKCU_INT_CKS : HSE clock failure interrupt flag (NMI) + * @arg CKCU_INT_USBPLLRDY : USB PLL ready interrupt flag + * @arg CKCU_INT_PLLRDY : PLL ready interrupt flag + * @arg CKCU_INT_HSERDY : HSE ready interrupt flag + * @arg CKCU_INT_HSIRDY : HSI ready interrupt flag + * @arg CKCU_INT_LSERDY : LSE ready interrupt flag + * @arg CKCU_INT_LSIRDY : LSI ready interrupt flag + * @retval None + ************************************************************************************************************/ +void CKCU_ClearIntFlag(u32 CKCU_INT) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_INT_FLAG(CKCU_INT)); + + HT_CKCU->GCIR |= CKCU_INT; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specific CKCU interrupts. + * @param CKCU_INT: specify the CKCU interrupt source which is enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CKCU_INT_CKSIE : HSE clock failure interrupt (NMI) + * @arg CKCU_INT_USBPLLRDYIE : USB PLL ready interrupt + * @arg CKCU_INT_PLLRDYIE : PLL ready interrupt + * @arg CKCU_INT_HSERDYIE : HSE ready interrupt + * @arg CKCU_INT_HSIRDYIE : HSI ready interrupt + * @arg CKCU_INT_LSERDYIE : LSE ready interrupt + * @arg CKCU_INT_LSIRDYIE : LSI ready interrupt + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_IntConfig(u32 CKCU_INT, ControlStatus Cmd) +{ + u32 tmp1 = HT_CKCU->GCIR; + + /* Check the parameters */ + Assert_Param(IS_CKCU_INT(CKCU_INT)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + tmp1 |= CKCU_INT; + } + else + { + tmp1 &= ~CKCU_INT; + } + + /* Note: CKCU interrupt flags will be cleared by writing "1" */ +#if (LIBCFG_CKCU_USB_PLL) + tmp1 &= ~0x0000007F; +#else + tmp1 &= ~0x0000007D; +#endif + HT_CKCU->GCIR = tmp1; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the AHB peripheral clock during SLEEP mode. + * @param CKCU_CLK: specify the clock which is enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CKCU_AHBEN_SLEEP_FMC, CKCU_AHBEN_SLEEP_SRAM, CKCU_AHBEN_SLEEP_BM, CKCU_AHBEN_SLEEP_APB0, + * CKCU_AHBEN_SLEEP_APB1 + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_SleepClockConfig(u32 CKCU_CLK, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_SLEEP_AHB(CKCU_CLK)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + HT_CKCU->AHBCCR |= CKCU_CLK; + } + else + { + HT_CKCU->AHBCCR &= ~CKCU_CLK; + } +} + +/*********************************************************************************************************//** + * @brief Check if PLL clock used by the specific target source or not. + * @param Target: specify the target clock. + * This parameter can be one of the following values: + * @arg CKCU_PLLST_SYSCK : Is PLL used by system clock + * @arg CKCU_PLLST_USB : Is PLL used by USB + * @arg CKCU_PLLST_REFCK : Is PLL used by CK_REF + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_IS_PLL_USED(CKCU_PLLST_TypeDef Target) +{ + if ((HT_CKCU->CKST >> CKCU_POS_PLLST) & (u32)Target) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/*********************************************************************************************************//** + * @brief Check HSI clock used by the specific target source or not. + * @param Target: specify the target clock. + * This parameter can be one of the following values: + * @arg CKCU_HSIST_SYSCK : Is HSI used by system clock + * @arg CKCU_HSIST_PLL : Is HSI used by PLL + * @arg CKCU_HSIST_CKM : Is HSI used by clock monitor + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_IS_HSI_USED(CKCU_HSIST_TypeDef Target) +{ + if ((HT_CKCU->CKST >> CKCU_POS_HSIST) & (u32)Target) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/*********************************************************************************************************//** + * @brief Check HSE clock used by the specific target source or not. + * @param Target: specify the target clock. + * This parameter can be one of the following values: + * @arg CKCU_HSEST_SYSCK : Is HSE used by system clock + * @arg CKCU_HSEST_PLL : Is HSE used by PLL + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_IS_HSE_USED(CKCU_HSEST_TypeDef Target) +{ + if ((HT_CKCU->CKST >> CKCU_POS_HSEST) & (u32)Target) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specific debug function. + * @param CKCU_DBGx: specify the debug functions to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CKCU_DBG_SLEEP, CKCU_DBG_DEEPSLEEP1, CKCU_DBG_DEEPSLEEP2, CKCU_DBG_POWERDOWN, + * CKCU_DBG_MCTM0_HALT, CKCU_DBG_MCTM1_HALT, + * CKCU_DBG_GPTM0_HALT, CKCU_DBG_GPTM1_HALT, + * CKCU_DBG_PWM_HALT, CKCU_DBG_SCTM0_HALT, CKCU_DBG_SCTM1_HALT, + * CKCU_DBG_BFTM0_HALT, CKCU_DBG_BFTM1_HALT, + * CKCU_DBG_USART0_HALT, CKCU_DBG_USART1_HALT, + * CKCU_DBG_UART0_HALT, CKCU_DBG_UART1_HALT, + * CKCU_DBG_SPI0_HALT, CKCU_DBG_SPI1_HALT, + * CKCU_DBG_I2C0_HALT, CKCU_DBG_I2C1_HALT, + * CKCU_DBG_SCI0_HALT, CKCU_DBG_SCI1_HALT, + * CKCU_DBG_WDT_HALT, CKCU_DBG_TRACE_ON + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_MCUDBGConfig(u32 CKCU_DBGx, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_DBG(CKCU_DBGx)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + HT_CKCU->MCUDBGCR |= CKCU_DBGx; + } + else + { + HT_CKCU->MCUDBGCR &= ~CKCU_DBGx; + } +} + +#if (!LIBCFG_NO_BACK_DOMAIN) +/*********************************************************************************************************//** + * @brief Enable or Disable the Backup domain isolation control. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_BKISOCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + CKCU_BB_BKISO = 0; /* Backup domain is isolated */ + } + else + { + CKCU_BB_BKISO = 1; /* Backup domain is accessible */ + } +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the peripheral clock. + * @param Clock: specify the peripheral clock enable bits. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_PeripClockConfig(CKCU_PeripClockConfig_TypeDef Clock, ControlStatus Cmd) +{ + u32 uAHBCCR; + u32 uAPBCCR0; + u32 uAPBCCR1; + + uAHBCCR = HT_CKCU->AHBCCR; + uAPBCCR0 = HT_CKCU->APBCCR0; + uAPBCCR1 = HT_CKCU->APBCCR1; + + uAHBCCR &= ~(Clock.Reg[0]); + uAPBCCR0 &= ~(Clock.Reg[1]); + uAPBCCR1 &= ~(Clock.Reg[2]); + + if (Cmd != DISABLE) + { + uAHBCCR |= Clock.Reg[0]; + uAPBCCR0 |= Clock.Reg[1]; + uAPBCCR1 |= Clock.Reg[2]; + } + + HT_CKCU->AHBCCR = uAHBCCR; + HT_CKCU->APBCCR0 = uAPBCCR0; + HT_CKCU->APBCCR1 = uAPBCCR1; +} + +#if (!LIBCFG_CKCU_HSI_NO_AUTOTRIM) +/*********************************************************************************************************//** + * @brief Configure the reference clock of HSI auto-trim function. + * @param CLKSRC: specify the clock source. + * This parameter can be: + * @arg CKCU_ATC_LSE: LSE is selected as reference clock + * @arg CKCU_ATC_USB: USB is selected as reference clock + * @arg CKCU_ATC_CKIN: External pin (CKIN) is selected as reference clock + * @retval None + ************************************************************************************************************/ +void CKCU_HSIAutoTrimClkConfig(CKCU_ATC_TypeDef CLKSRC) +{ + #if (LIBCFG_CKCU_AUTOTRIM_NOCKIN==1) + HT_CKCU->HSICR = (HT_CKCU->HSICR & (~(0x1 << 5))) | (CLKSRC << 5); + #else + HT_CKCU->HSICR = (HT_CKCU->HSICR & (~(0x3 << 5))) | (CLKSRC << 5); + #endif +} + +#if (LIBCFG_CKCU_ATM_V01) +/*********************************************************************************************************//** + * @brief Initialize the ATC according to the specified parameters in the ATC_InitStruct. + * @param ATC_InitStruct: pointer to a CKCU_ATCInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_ATCInit(CKCU_ATCInitTypeDef* ATC_InitStruct) +{ + HT_CKCU->HSICR &= 0xFFFFFFF3; + HT_CKCU->HSICR |= (u32)ATC_InitStruct->SearchAlgorithm | (u32)ATC_InitStruct->FrqTolerance; +} + +/*********************************************************************************************************//** + * @brief Automatic Trimming Algorithm Mode Selection. + * @param Algo: Search Algorithm. + * This parameter can be: + * @arg CKCU_ATC_BINARY_SEARCH: Auto Trimming Controller is used binary search to approach the target range + * @arg CKCU_ATC_LINEAR_SEARCH: Auto Trimming Controller is used linear search to approach the target range + * @retval None + ***********************************************************************************************************/ +void CKCU_HSIAutoTrimAlgorithm(u32 Algo) +{ + HT_CKCU->HSICR = (HT_CKCU->HSICR & (~(0x1 << 3))) | Algo; +} + +/*********************************************************************************************************//** + * @brief Lock Target Range Selection. + * @param Tolerance: Variation Tolerance. + * This parameter can be: + * @arg CKCU_ATC_DOUBLE_PRECISION: 0.2 % variation + * @arg CKCU_ATC_SINGLE_PRECISION: 0.1 % variation + * @retval None + ***********************************************************************************************************/ +void CKCU_HSIAutoTrimFreqTolerance(u32 Tolerance) +{ + HT_CKCU->HSICR = (HT_CKCU->HSICR & (~(0x1 << 2))) | Tolerance; +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the HSI auto-trim function. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_HSIAutoTrimCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BB_TRIMEN = Cmd; + CKCU_BB_ATCEN = Cmd; +} + +/*********************************************************************************************************//** + * @brief Check Auto Trim is ready or not. + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_HSIAutoTrimIsReady(void) +{ +#if (LIBCFG_CKCU_AUTO_TRIM_LEGACY) + u32 lower_bound, upper_bound, i; + static u32 ATCR = 0; + + if ((HT_CKCU->HSICR & (3ul << 5)) == 0) + { + lower_bound = 7812 - 19; + upper_bound = 7812 + 19; + } + else + { + lower_bound = 8000 - 20; + upper_bound = 8000 + 20; + } + + SystemCoreClockUpdate(); + for (i = SystemCoreClock / 8000; i > 0; i--){}; + ATCR += HT_CKCU->HSIATCR; + ATCR /= 2; + + if ((ATCR >= lower_bound) && (ATCR <= upper_bound)) + { + ATCR = 0; + return TRUE; + } + else + { + return FALSE; + } + +#else + return (HT_CKCU->HSICR & 0x80) ? TRUE : FALSE; +#endif +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp.c new file mode 100644 index 0000000000..ec0688153b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp.c @@ -0,0 +1,298 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_cmp.c + * @version $Rev:: 2794 $ + * @date $Date:: 2022-11-25 #$ + * @brief This file provides all the CMP firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_cmp.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CMP CMP + * @brief CMP driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Functions CMP exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CMP0 and CMP1 peripheral registers to their default reset values. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @retval None + ************************************************************************************************************/ +void CMP_DeInit(HT_CMP_TypeDef* HT_CMPn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + if (HT_CMPn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.CMP = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Unprotect the selected comparator configuration before setting the Comparator Control Register. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @retval None + ************************************************************************************************************/ +void CMP_UnprotectConfig(HT_CMP_TypeDef* HT_CMPn) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + + /* Set the unlock code corresponding to selected comparator */ + HT_CMPn->CR = CMP_PROTECT_KEY; +} + +/*********************************************************************************************************//** + * @brief Initialize the CMP peripheral according to the specified parameters in the CMP_InitStruct. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_InitStruct: pointer to a CMP_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CMP_Init(HT_CMP_TypeDef* HT_CMPn, CMP_InitTypeDef* CMP_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_Wakeup_Set(CMP_InitStruct->CMP_Wakeup)); + Assert_Param(IS_CMP_OutputSelection(CMP_InitStruct->CMP_OutputSelection)); + Assert_Param(IS_CMP_ScalerSource(CMP_InitStruct->CMP_ScalerSource)); + Assert_Param(IS_CMP_ScalerOutputBuf(CMP_InitStruct->CMP_ScalerOutputBuf)); + Assert_Param(IS_CMP_ScalerEnable(CMP_InitStruct->CMP_ScalerEnable)); + Assert_Param(IS_CMP_CoutSynchronized(CMP_InitStruct->CMP_CoutSync)); + Assert_Param(IS_CMP_OutputPol_Set(CMP_InitStruct->CMP_OutputPol)); + Assert_Param(IS_CMP_InvInputSelection(CMP_InitStruct->CMP_InvInputSelection)); + Assert_Param(IS_CMP_Hysteresis_Set(CMP_InitStruct->CMP_Hysteresis)); + Assert_Param(IS_CMP_Speed_Set(CMP_InitStruct->CMP_Speed)); + + HT_CMPn->CR |= CMP_InitStruct->CMP_Wakeup | CMP_InitStruct->CMP_OutputSelection | CMP_InitStruct->CMP_ScalerSource | \ + CMP_InitStruct->CMP_ScalerOutputBuf | CMP_InitStruct->CMP_ScalerEnable | CMP_InitStruct->CMP_CoutSync | \ + CMP_InitStruct->CMP_OutputPol | CMP_InitStruct->CMP_InvInputSelection | CMP_InitStruct->CMP_Hysteresis | \ + CMP_InitStruct->CMP_Speed; +} + +/*********************************************************************************************************//** + * @brief Fill each CMP_InitStruct member with its default value. + * @param CMP_InitStruct: pointer to an CMP_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CMP_StructInit(CMP_InitTypeDef* CMP_InitStruct) +{ + /* CMP_InitStruct members default value */ + CMP_InitStruct->CMP_Wakeup = CMP_WUP_DISABLE; + CMP_InitStruct->CMP_OutputSelection = CMP_TRIG_NONE; + CMP_InitStruct->CMP_ScalerSource = CMP_SCALER_SRC_VDDA; + CMP_InitStruct->CMP_ScalerOutputBuf = CMP_SCALER_OBUF_DISABLE; + CMP_InitStruct->CMP_ScalerEnable = CMP_SCALER_DISABLE; + CMP_InitStruct->CMP_CoutSync = CMP_ASYNC_OUTPUT; + CMP_InitStruct->CMP_OutputPol = CMP_NONINV_OUTPUT; + CMP_InitStruct->CMP_InvInputSelection = CMP_EXTERNAL_CN_IN; + CMP_InitStruct->CMP_Hysteresis = CMP_NO_HYSTERESIS; + CMP_InitStruct->CMP_Speed = CMP_LOW_SPEED; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP peripheral. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CMP_Cmd(HT_CMP_TypeDef* HT_CMPn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CMPn->CR |= CMP_ENABLE; + } + else + { + HT_CMPn->CR &= ~(u32)CMP_ENABLE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP interrupts. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_INT_x: specify the CMP interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CMP_INT_RE : CMP rising edge interrupt + * @arg CMP_INT_FE : CMP falling edge interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CMP_IntConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_INT(CMP_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CMPn->IER |= CMP_INT_x; + } + else + { + HT_CMPn->IER &= ~CMP_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP edge detection. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_xE_Detect: specify the CMP edge detection that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CMP_RE_Detect : CMP rising edge detection + * @arg CMP_FE_Detect : CMP falling edge detection + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CMP_EdgeDetectConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_xE_Detect, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_EdgeDetect(CMP_xE_Detect)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CMPn->TFR = (HT_CMPn->TFR | CMP_xE_Detect) & 0xfffffffc; + } + else + { + HT_CMPn->TFR = (HT_CMPn->TFR & (~CMP_xE_Detect)) & 0xfffffffc; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified CM flag has been set. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_FLAG_x: specify the flag to be checked. + * This parameter can be any combination of the following values: + * @arg CMP_FLAG_RE : CMP rising edge flag + * @arg CMP_FLAG_FE : CMP falling edge flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CMP_GetFlagStatus(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_FLAG(CMP_FLAG_x)); + + if ((HT_CMPn->TFR & CMP_FLAG_x) != 0) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear flags of the specified CMP. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_FLAG_x: specify the flag to be checked. + * This parameter can be any combination of the following values: + * @arg CMP_FLAG_RE : CMP rising edge flag + * @arg CMP_FLAG_FE : CMP falling edge flag + * @retval None + ************************************************************************************************************/ +void CMP_ClearFlag(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_FLAG(CMP_FLAG_x)); + + /* Clear the flags */ + HT_CMPn->TFR = (HT_CMPn->TFR & 0xfffffffc) | CMP_FLAG_x; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Get the output status of the specified CMP. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CMP_GetOutputStatus(HT_CMP_TypeDef* HT_CMPn) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + + if ((HT_CMPn-> CR & CMP_OUTPUT_HIGH) != 0) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified reference value in the data register of the scaler. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param Scaler_Value: value to be loaded in the selected data register + * @retval None + ************************************************************************************************************/ +void CMP_SetScalerValue(HT_CMP_TypeDef* HT_CMPn, u8 Scaler_Value) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_SCALER_VALUE(Scaler_Value)); + + /* Set the scaler reference value register */ + HT_CMPn->VALR = (u32)Scaler_Value; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp_op.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp_op.c new file mode 100644 index 0000000000..cd26f7a5d8 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_cmp_op.c @@ -0,0 +1,307 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_cmp_op.c + * @version $Rev:: 129 $ + * @date $Date:: 2017-06-14 #$ + * @brief This file provides all the CMP_OP firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_cmp_op.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CMP_OP CMP_OP + * @brief CMP_OP driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup CMP_OP_Private_Define CMP_OP private definitions + * @{ + */ +#define CMP_OP_ENABLE (0x00000001ul) +#define CMP_OP_CANCELLATION_MODE (0x00000004ul) +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CMP_OP_Exported_Functions CMP_OP exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CMP_OP peripheral registers to their default reset values. + * @param CMP_OPx: where x can be 0 or 1 to select the CMP_OP peripheral. + * @retval None + ************************************************************************************************************/ +void CMP_OP_DeInit(HT_CMP_OP_TypeDef* CMP_OPx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + + if (CMP_OPx == HT_CMP_OP0) + { + RSTCUReset.Bit.OPA0 = 1; + } + else + { + RSTCUReset.Bit.OPA1 = 1; + } + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure the CMP_OP peripheral as OPA or CMP mode and fill the cancellation value. + * @param CMP_OPx: where CMP_OP is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param mode: Specify the CMP_OPx peripheral mode + * This parameter can be any combination of the following values: + * @arg OP_MODE : Operational Amplifier mode + * @arg CMP_MODE : Comparator Mode Selection + * @param cancellation: Specify the input offset voltage cancellation value. + * @retval None +************************************************************************************************************/ +void CMP_OP_Config(HT_CMP_OP_TypeDef* CMP_OPx, u32 mode, u32 cancellation) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CMP_OP_MODE(mode)); + Assert_Param(IS_CMP_OP_IOVC(cancellation)); + + CMP_OPx->OPACR = (CMP_OPx->OPACR & CMP_OP_ENABLE) | mode; + CMP_OPx->OFVCR = cancellation; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP_OP peripheral. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param NewState: new state of the CMP_OPx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None +************************************************************************************************************/ +void CMP_OP_Cmd(HT_CMP_OP_TypeDef* CMP_OPx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected CMP_OPx peripheral */ + CMP_OPx->OPACR |= CMP_OP_ENABLE; + } + else + { + /* Disable the selected CMP_OPx peripheral */ + CMP_OPx->OPACR &= ~(u32)CMP_OP_ENABLE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the CMP_OP peripheral as cancellation mode and select the source of reference input. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param CMP_OP_REF_INPUT: Specify the the source of reference input. + * This parameter can be any combination of the following values: + * @arg CMP_OP_NEGATIVE_INPUT + * @arg CMP_OP_POSITIVE_INPUT + * @retval None +************************************************************************************************************/ +void CMP_OP_CancellationModeConfig(HT_CMP_OP_TypeDef* CMP_OPx, u16 CMP_OP_REF_INPUT) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CMP_OP_REF(CMP_OP_REF_INPUT)); + + CMP_OPx->OPACR = (CMP_OPx->OPACR & CMP_OP_ENABLE) | CMP_OP_CANCELLATION_MODE | CMP_OP_REF_INPUT; +} + +/*********************************************************************************************************//** + * @brief Set input offset voltage cancellation value. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param cancellation: Specify the input offset voltage cancellation value. + * @retval None +************************************************************************************************************/ +void CMP_OP_SetCancellationVaule(HT_CMP_OP_TypeDef* CMP_OPx, u32 cancellation) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CMP_OP_IOVC(cancellation)); + + CMP_OPx->OFVCR = cancellation; +} + +/*********************************************************************************************************//** + * @brief Get input offset voltage cancellation value. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @retval The input offset voltage cancellation value. +************************************************************************************************************/ +u32 CMP_OP_GetCancellationVaule(HT_CMP_OP_TypeDef* CMP_OPx) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + + return CMP_OPx->OFVCR; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP_OP interrupts. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param CMP_OP_INT: Specify the CMP_OP interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * - CMP_OP_INT_FALLING: + * - CMP_OP_INT_RISING: + * @param NewState new state of the specified ADC interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None +************************************************************************************************************/ +void CMP_OP_IntConfig(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_INT, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CMP_OP_INT(CMP_OP_INT)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + CMP_OPx->CMPIER |= CMP_OP_INT; + } + else + { + CMP_OPx->CMPIER &= ~CMP_OP_INT; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC interrupt has occurred. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param CMP_OP_INT: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * - CMP_OP_INT_FALLING: + * - CMP_OP_INT_RISING: + * @retval SET or RESET +************************************************************************************************************/ +FlagStatus CMP_OP_GetIntStatus(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_INT) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CMP_OP_INT(CMP_OP_INT)); + + if ((CMP_OPx->CMPISR & CMP_OP_INT) != 0x0) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified CMP_OP flag has been set. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param CMP_OP_FLAG: Specify the flag to check. + * This parameter can be any combination of the following values: + * - CMP_OP_FLAG_FALLING: + * - CMP_OP_FLAG_RISING: + * @retval SET or RESET +************************************************************************************************************/ +FlagStatus CMP_OP_GetFlagStatus(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_FLAG) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CMP_OP_FLAG(CMP_OP_FLAG)); + + if ((CMP_OPx->CMPRSR & CMP_OP_FLAG) != 0x0) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + + +/*********************************************************************************************************//** + * @brief Clear the CMP_OPx interrupt pending bits. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @param CMP_OP_INT: specifies the interrupt pending bits to be cleared. + * This parameter can be any combination of the following values: + * - CMP_OP_INT_FALLING: + * - CMP_OP_INT_RISING: + * @retval None +************************************************************************************************************/ +void CMP_OP_ClearIntPendingBit(HT_CMP_OP_TypeDef* CMP_OPx, u32 CMP_OP_INT) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + Assert_Param(IS_CMP_OP_INT(CMP_OP_INT)); + + CMP_OPx->CMPICLR = CMP_OP_INT; +} + +/*********************************************************************************************************//** + * @brief Get the output status of CMP_OPx. + * @param CMP_OPx: where CMP_OPx is the selected CMP_OP from the CMP_OP peripherals, x can be 0 or 1. + * @retval SET or RESET +************************************************************************************************************/ +FlagStatus CMP_OP_GetOutputStatus(HT_CMP_OP_TypeDef* CMP_OPx) +{ + /* Check the parameters */ + Assert_Param(IS_CMP_OP_ALL_PERIPH(CMP_OPx)); + + if ((CMP_OPx->OPACR & 0x00000100) != 0x0) + { + return SET; + } + else + { + return RESET; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_crc.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_crc.c new file mode 100644 index 0000000000..6630ae3023 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_crc.c @@ -0,0 +1,190 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_crc.c + * @version $Rev:: 2787 $ + * @date $Date:: 2022-11-23 #$ + * @brief This file provides all the CRC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_crc.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CRC CRC + * @brief CRC driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Functions CRC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CRC peripheral registers to their default reset values. + * @param HT_CRCn: where CRC is the selected CRC peripheral. + * @retval None + ************************************************************************************************************/ +void CRC_DeInit(HT_CRC_TypeDef* HT_CRCn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + if (HT_CRCn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.CRC = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the CRC peripheral according to the specified parameters in the CRC_InitStruct. + * @param HT_CRCn: Selected CRC peripheral. + * @param CRC_InitStruct: pointer to a CRC_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CRC_Init(HT_CRC_TypeDef* HT_CRCn, CRC_InitTypeDef* CRC_InitStruct) +{ + u32 uCRValue; + HT_CRCn->SDR = CRC_InitStruct->uSeed; + switch (CRC_InitStruct->Mode) + { + case CRC_CCITT_POLY: + { + uCRValue = CRC_CCITT_POLY | CRC_NORMAL_WR | CRC_NORMAL_SUM; + break; + } + case CRC_16_POLY: + { + uCRValue = CRC_16_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM; + break; + } + case CRC_32_POLY: + { + uCRValue = CRC_32_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM | CRC_CMPL_SUM; + break; + } + case CRC_USER_DEFINE: + default: + { + uCRValue = CRC_InitStruct->uCR; + break; + } + } + + HT_CRCn->CR = uCRValue; +} + +/*********************************************************************************************************//** + * @brief Get the CRC checksum from the given data + * @param HT_CRCn: Selected CRC peripheral. + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ***********************************************************************************************************/ +u32 CRC_Process(HT_CRC_TypeDef* HT_CRCn, u8 *buffer, u32 length) +{ + while (length--) + { + wb(&HT_CRCn->DR, *buffer++); // byte write + } + + return (HT_CRCn->CSR); +} + +/*********************************************************************************************************//** + * @brief Get the CRC-CCITT checksum from the given data + * @param seed: CRC initial data + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ************************************************************************************************************/ +u16 CRC_CCITT(u16 seed, u8 *buffer, u32 length) +{ + /* CRC-CCITT poly: 0x1021 */ + HT_CRC->SDR = seed; + HT_CRC->CR = CRC_CCITT_POLY | CRC_NORMAL_WR | CRC_NORMAL_SUM; + + while (length--) + { + wb(&HT_CRC->DR, *buffer++); // byte write + } + + return (u16)(HT_CRC->CSR); +} + +/*********************************************************************************************************//** + * @brief Get the CRC-16 checksum from the given data + * @param seed: CRC initial data + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ************************************************************************************************************/ +u16 CRC_16(u16 seed, u8 *buffer, u32 length) +{ + /* CRC-16 poly: 0x8005 */ + HT_CRC->SDR = seed; + HT_CRC->CR = CRC_16_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM; + + while (length--) + { + wb(&HT_CRC->DR, *buffer++); // byte write + } + + return (u16)(HT_CRC->CSR); +} + +/*********************************************************************************************************//** + * @brief Get the CRC-32 checksum from the given data + * @param seed: CRC initial data + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ************************************************************************************************************/ +u32 CRC_32(u32 seed, u8 *buffer, u32 length) +{ + /* CRC-32 poly: 0x04C11DB7 */ + HT_CRC->SDR = seed; + HT_CRC->CR = CRC_32_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM | CRC_CMPL_SUM; + + while (length--) + { + wb(&HT_CRC->DR, *buffer++); // byte write + } + + return (HT_CRC->CSR); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ebi.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ebi.c new file mode 100644 index 0000000000..55be3bc8dd --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_ebi.c @@ -0,0 +1,339 @@ +/********************************************************************************************************//** + * @file ht32f1xxxx_ebi.c + * @version $Rev:: 2788 $ + * @date $Date:: 2022-11-24 #$ + * @brief This file provides all the EBI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_ebi.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup EBI EBI + * @brief EBI driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Functions EBI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitializes the EBI peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void EBI_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.EBI = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initializes the EBI peripheral according to the specified parameters in the EBI_InitStruct. + * @param EBI_InitStruct: pointer to a EBI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void EBI_Init(EBI_InitTypeDef* EBI_InitStruct) +{ + u32 tmp; + u32 bank = EBI_InitStruct->EBI_Bank; + u32 offset = EBI_InitStruct->EBI_Bank * 0x10; + + /* Check the parameters */ + Assert_Param(IS_EBI_BANK(EBI_InitStruct->EBI_Bank)); + Assert_Param(IS_EBI_MODE(EBI_InitStruct->EBI_Mode)); + #if (LIBCFG_EBI_BYTELAND_ASYNCREADY) + Assert_Param(IS_EBI_BYTELANE(EBI_InitStruct->EBI_ByteLane)); + Assert_Param(IS_EBI_ARDY(EBI_InitStruct->EBI_AsynchronousReady)); + Assert_Param(IS_EBI_ARDY_TIMEOUT(EBI_InitStruct->EBI_ARDYTimeOut)); + Assert_Param(IS_EBI_BL_POLARITY(EBI_InitStruct->EBI_ByteLanePolarity)); + Assert_Param(IS_EBI_ARDY_POLARITY(EBI_InitStruct->EBI_ReadySignalPolarity)); + #endif + Assert_Param(IS_EBI_IDLECYCLE(EBI_InitStruct->EBI_IdleCycle)); + Assert_Param(IS_EBI_CS_POLARITY(EBI_InitStruct->EBI_ChipSelectPolarity)); + Assert_Param(IS_EBI_ALE_POLARITY(EBI_InitStruct->EBI_AddressLatchPolarity)); + Assert_Param(IS_EBI_WE_POLARITY(EBI_InitStruct->EBI_WriteEnablePolarity)); + Assert_Param(IS_EBI_RE_POLARITY(EBI_InitStruct->EBI_ReadEnablePolarity)); + Assert_Param(IS_EBI_IDLE_CYCLE_TIME(EBI_InitStruct->EBI_IdleCycleTime)); + Assert_Param(IS_EBI_ADDRESS_SETUP_TIME(EBI_InitStruct->EBI_AddressSetupTime)); + Assert_Param(IS_EBI_ADDRESS_HOLD_TIME(EBI_InitStruct->EBI_AddressHoldTime)); + Assert_Param(IS_EBI_WRITE_SETUP_TIME(EBI_InitStruct->EBI_WriteSetupTime)); + Assert_Param(IS_EBI_WRITE_STROBE_TIME(EBI_InitStruct->EBI_WriteStrobeTime)); + Assert_Param(IS_EBI_WRITE_HOLD_TIME(EBI_InitStruct->EBI_WriteHoldTime)); + Assert_Param(IS_EBI_READ_SETUP_TIME(EBI_InitStruct->EBI_ReadSetupTime)); + Assert_Param(IS_EBI_READ_STROBE_TIME(EBI_InitStruct->EBI_ReadStrobeTime)); + #if !(LIBCFG_EBI_V01) + Assert_Param(IS_EBI_PAGE_MODE(EBI_InitStruct->EBI_PageMode)); + Assert_Param(IS_EBI_PAGE_LENGTH(EBI_InitStruct->EBI_PageLength)); + Assert_Param(IS_EBI_PAGE_HIT_MODE(EBI_InitStruct->EBI_PageHitMode)); + Assert_Param(IS_EBI_PAGE_ACCESS_TIME(EBI_InitStruct->EBI_PageAccessTime)); + Assert_Param(IS_EBI_PAGE_OPEN_TIME(EBI_InitStruct->EBI_PageOpenTime)); + #endif + + + *((u32 *)((u32)&HT_EBI->ATR0 + offset)) = EBI_InitStruct->EBI_AddressSetupTime | + (EBI_InitStruct->EBI_AddressHoldTime << 8); +#if (LIBCFG_EBI_V01) +*((u32 *)((u32)&HT_EBI->RTR0 + offset)) = EBI_InitStruct->EBI_ReadSetupTime | + (EBI_InitStruct->EBI_ReadStrobeTime << 8) | + (EBI_InitStruct->EBI_ReadHoldTime << 16); +#else +*((u32 *)((u32)&HT_EBI->RTR0 + offset)) = EBI_InitStruct->EBI_ReadSetupTime | + (EBI_InitStruct->EBI_ReadStrobeTime << 8) | + (EBI_InitStruct->EBI_ReadHoldTime << 16) | + EBI_InitStruct->EBI_PageMode; +#endif + *((u32 *)((u32)&HT_EBI->WTR0 + offset)) = EBI_InitStruct->EBI_WriteSetupTime | + (EBI_InitStruct->EBI_WriteStrobeTime << 8) | + (EBI_InitStruct->EBI_WriteHoldTime << 16); + *((u32 *)((u32)&HT_EBI->PR0 + offset)) = EBI_InitStruct->EBI_ChipSelectPolarity | + (EBI_InitStruct->EBI_ReadEnablePolarity << 1) | + (EBI_InitStruct->EBI_AddressLatchPolarity << 3) | + #if (LIBCFG_EBI_BYTELAND_ASYNCREADY) + (EBI_InitStruct->EBI_ReadySignalPolarity << 4) | + (EBI_InitStruct->EBI_ByteLanePolarity << 5) | + #endif + (EBI_InitStruct->EBI_WriteEnablePolarity << 2); + + + /*------------------------- EBI Control Register Configuration -------------------------------------------*/ + tmp = (3 << (bank * 2)) | (0x00001000 << bank) | + (0x00010000 << (bank * 2)) | (0x00020000 << (bank * 2)) | + (0x01000000 << bank); + tmp = HT_EBI->CR & (~tmp); + HT_EBI->CR = (EBI_InitStruct->EBI_Mode << (bank * 2)) | + (EBI_InitStruct->EBI_IdleCycle << bank) | + #if (LIBCFG_EBI_BYTELAND_ASYNCREADY) + (EBI_InitStruct->EBI_AsynchronousReady << (bank * 2)) | + (EBI_InitStruct->EBI_ARDYTimeOut << (bank * 2)) | + (EBI_InitStruct->EBI_ByteLane << bank) | + #endif + (EBI_InitStruct->EBI_IdleCycleTime << 28) | tmp; + + #if !(LIBCFG_EBI_V01) + if (EBI_InitStruct->EBI_PageMode) + { + Assert_Param(IS_EBI_PAGE_LENGTH(EBI_InitStruct->EBI_PageLength)); + Assert_Param(IS_EBI_PAGE_HIT_MODE(EBI_InitStruct->EBI_PageHitMode)); + Assert_Param(IS_EBI_PAGE_ACCESS_TIME(EBI_InitStruct->EBI_PageAccessTime)); + Assert_Param(IS_EBI_PAGE_OPEN_TIME(EBI_InitStruct->EBI_PageOpenTime)); + + HT_EBI->PCR = EBI_InitStruct->EBI_PageLength | EBI_InitStruct->EBI_PageHitMode | + (EBI_InitStruct->EBI_PageAccessTime << 8) | (EBI_InitStruct->EBI_PageOpenTime << 16); + } + #endif +} + +/*********************************************************************************************************//** + * @brief Fills each EBI_InitStruct member with its default value. + * @param EBI_InitStruct: pointer to an EBI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void EBI_StructInit(EBI_InitTypeDef* EBI_InitStruct) +{ + /* Initialize the EBI structure parameters values */ + EBI_InitStruct->EBI_Bank = EBI_BANK_0; + EBI_InitStruct->EBI_Mode = EBI_MODE_D8A8; + #if (LIBCFG_EBI_BYTELAND_ASYNCREADY) + EBI_InitStruct->EBI_ByteLane = EBI_BYTELANE_DISABLE; + EBI_InitStruct->EBI_AsynchronousReady = EBI_ASYNCHRONOUSREADY_DISABLE; + EBI_InitStruct->EBI_ARDYTimeOut = EBI_ARDYTIMEOUT_DISABLE; + EBI_InitStruct->EBI_ByteLanePolarity = EBI_BYTELANEPOLARITY_LOW; + EBI_InitStruct->EBI_ReadySignalPolarity = EBI_READYSIGNALPOLARITY_LOW; + #endif + EBI_InitStruct->EBI_IdleCycle = EBI_IDLECYCLE_DISABLE; + EBI_InitStruct->EBI_ChipSelectPolarity = EBI_CHIPSELECTPOLARITY_LOW; + EBI_InitStruct->EBI_AddressLatchPolarity = EBI_ADDRESSLATCHPOLARITY_LOW; + EBI_InitStruct->EBI_WriteEnablePolarity = EBI_WRITEENABLEPOLARITY_LOW; + EBI_InitStruct->EBI_ReadEnablePolarity = EBI_READENABLEPOLARITY_LOW; + EBI_InitStruct->EBI_IdleCycleTime = 0xF; + EBI_InitStruct->EBI_AddressSetupTime = 0xF; + EBI_InitStruct->EBI_AddressHoldTime = 0xF; + EBI_InitStruct->EBI_WriteSetupTime = 0xF; + EBI_InitStruct->EBI_WriteStrobeTime = 0x3F; + EBI_InitStruct->EBI_WriteHoldTime = 0xF; + EBI_InitStruct->EBI_ReadSetupTime = 0xF; + EBI_InitStruct->EBI_ReadStrobeTime = 0x3F; + EBI_InitStruct->EBI_ReadHoldTime = 0xF; + #if !(LIBCFG_EBI_V01) + EBI_InitStruct->EBI_PageMode = EBI_PAGEMODE_DISABLE; + EBI_InitStruct->EBI_PageLength = EBI_PAGELENGTH_4; + EBI_InitStruct->EBI_PageHitMode = EBI_PAGEHITMODE_ADDINC; + EBI_InitStruct->EBI_PageAccessTime = 0xF; + EBI_InitStruct->EBI_PageOpenTime = 0xFF; + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the EBI peripheral. + * @param EBI_Bank: EBI Bank. + * This parameter can be one of the following values: + * @arg EBI_BANK_0 : EBI Bank 0 + * @arg EBI_BANK_1 : EBI Bank 1 + * @arg EBI_BANK_2 : EBI Bank 2 + * @arg EBI_BANK_3 : EBI Bank 3 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EBI_Cmd(u32 EBI_Bank, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EBI_BANK(EBI_Bank)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_EBI->CR |= (0x100 << EBI_Bank); + } + else + { + HT_EBI->CR &= ~(0x100 << EBI_Bank); + } +} + +#if !(LIBCFG_EBI_V01) +/*********************************************************************************************************//** + * @brief Enable or Disable the specified EBI interrupt. + * @param EBI_Int: specify the EBI interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg EBI_INT_TOUT : ARDY time out interrupt + * @arg EBI_INT_ACCDIS : Access disabled bank interrupt + * @arg EBI_INT_ACCRES : Access under software reset interrupt + * @arg EBI_INT_ALL : All EBI interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void EBI_IntConfig(u32 EBI_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EBI_INT(EBI_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_EBI->IEN |= EBI_Int; + } + else + { + HT_EBI->IEN &= (u32)~EBI_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified EBI interrupt has been occurred. + * @param EBI_IntFlag: specify the EBI interrupt to be check. + * This parameter can be one of the following values: + * @arg EBI_INT_TOUT : ARDY time out interrupt + * @arg EBI_INT_ACCERR : Access disabled bank or under software reset interrupt + * @retval SET or RESET + ***********************************************************************************************************/ +FlagStatus EBI_GetIntStatus(u32 EBI_IntFlag) +{ + u32 status = 0; + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + Assert_Param(IS_EBI_INT_FLAG(EBI_IntFlag)); + + status = HT_EBI->IF; + + if ((status & EBI_IntFlag) != (u32)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Clear the specified EBI interrupt flag. + * @param EBI_IntFlag: specify the interrupt flag that is to be cleared. + * This parameter can be any combination of the following values: + * @arg EBI_INT_TOUT : ARDY time out interrupt flag + * @arg EBI_INT_ACCERR : Access disabled bank or under software reset interrupt flag + * @retval None + ***********************************************************************************************************/ +void EBI_ClearIntFlag(u32 EBI_IntFlag) +{ + /* Check the parameters */ + Assert_Param(IS_EBI_INT_FLAG(EBI_IntFlag)); + + HT_EBI->IFC = EBI_IntFlag; +} +#endif + +/*********************************************************************************************************//** + * @brief Check whether the specified EBI busy flag has been set. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EBI_GetBusyStatus(void) +{ + if (HT_EBI->SR & 0x1) + { + return SET; + } + else + { + return RESET; + } +} + +#if (LIBCFG_EBI_BYTELAND_ASYNCREADY) +/*********************************************************************************************************//** + * @brief Check whether the specified EBI ARDY flag has been set. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EBI_GetARDYStatus(void) +{ + if (HT_EBI->SR & 0x10) + { + return SET; + } + else + { + return RESET; + } +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_exti.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_exti.c new file mode 100644 index 0000000000..de263a613a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_exti.c @@ -0,0 +1,516 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_exti.c + * @version $Rev:: 2873 $ + * @date $Date:: 2023-02-23 #$ + * @brief This file provides all the EXTI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_exti.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup EXTI EXTI + * @brief EXTI driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Private_Define EXTI private definitions + * @{ + */ +/* EXTI EVWUPIEN mask */ +#define WAKUPCR_EVWUPIEN_SET ((u32)0x80000000) +#define WAKUPCR_EVWUPIEN_RESET ((u32)0x7FFFFFFF) + +const IRQn_Type gEXTIn_IRQn[16] = { + EXTI0_IRQn, EXTI1_IRQn, EXTI2_IRQn, EXTI3_IRQn, + EXTI4_IRQn, EXTI5_IRQn, EXTI6_IRQn, EXTI7_IRQn, + EXTI8_IRQn, EXTI9_IRQn, EXTI10_IRQn, EXTI11_IRQn, + EXTI12_IRQn, EXTI13_IRQn, EXTI14_IRQn, EXTI15_IRQn, +}; + +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Functions EXTI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the EXTI peripheral registers. + * @param EXTI_Channel: can be 0, 1 to 15 to select the EXTI Channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval None + ************************************************************************************************************/ +void EXTI_DeInit(u32 EXTI_Channel) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + tmp = 1 << EXTI_Channel; + + *((u32 *) HT_EXTI + EXTI_Channel) = 0x0; + HT_EXTI->CR &= (~tmp); + HT_EXTI->EDGEFLGR = tmp; + HT_EXTI->EDGESR = tmp; + HT_EXTI->SSCR &= (~tmp); + HT_EXTI->WAKUPCR &= (~tmp); + HT_EXTI->WAKUPPOLR &= (~tmp); + HT_EXTI->WAKUPFLG = tmp; +} + +/*********************************************************************************************************//** + * @brief Initialize the EXTI peripheral. + * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) +{ + u32 regval; + + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_InitStruct->EXTI_Channel)); + Assert_Param(IS_EXTI_DEBOUNCE_TYPE(EXTI_InitStruct->EXTI_Debounce)); + Assert_Param(IS_EXTI_DEBOUNCE_SIZE(EXTI_InitStruct->EXTI_DebounceCnt)); + Assert_Param(IS_EXTI_INT_TYPE(EXTI_InitStruct->EXTI_IntType)); + + /* Set EXTI interrupt configuration */ + regval = (EXTI_InitStruct->EXTI_Debounce << 31) | (EXTI_InitStruct->EXTI_IntType << 28) | (EXTI_InitStruct->EXTI_DebounceCnt); + *((u32 *) HT_EXTI + EXTI_InitStruct->EXTI_Channel) = regval; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified EXTI channelx interrupts. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_IntConfig(u32 EXTI_Channel, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Configure EXTI interrupt */ + if (NewState == ENABLE) + { + HT_EXTI->CR |= (1 << EXTI_Channel); + } + else + { + HT_EXTI->CR &= ~(1 << EXTI_Channel); + } +} + +/*********************************************************************************************************//** + * @brief Configure the EXTI channelx event wakeup function. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param EXTI_WakeUpType: determines the type of signal to trigger EXTI interrupt. + * This parameter can be one of the following values: + * @arg EXTI_WAKEUP_HIGH_LEVEL + * @arg EXTI_WAKEUP_LOW_LEVEL + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_WakeupEventConfig(u32 EXTI_Channel, u8 EXTI_WakeUpType, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_EXTI_WAKEUP_TYPE(EXTI_WakeUpType)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == ENABLE) + { + if (EXTI_WakeUpType == EXTI_WAKEUP_HIGH_LEVEL) + { + HT_EXTI->WAKUPPOLR &= ~(1 << EXTI_Channel); + } + else + { + HT_EXTI->WAKUPPOLR |= (1 << EXTI_Channel); + } + + HT_EXTI->WAKUPCR |= (1 << EXTI_Channel); + } + else + { + HT_EXTI->WAKUPCR &= ~(1 << EXTI_Channel); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the EXTI channelx event wakeup interrupt. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_WakeupEventIntConfig(ControlStatus NewState) +{ + if (NewState == ENABLE) + { + /* Set EVWUPIEN bit */ + HT_EXTI->WAKUPCR |= WAKUPCR_EVWUPIEN_SET; + } + else + { + /* Clear EVWUPIEN bit */ + HT_EXTI->WAKUPCR &= WAKUPCR_EVWUPIEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified EXTI channelx edge flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval None + ************************************************************************************************************/ +void EXTI_ClearEdgeFlag(u32 EXTI_Channel) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + tmp = 1 << EXTI_Channel; + + /* Write 1 to clear both edge detection flag */ + HT_EXTI->EDGEFLGR = tmp; + /* Write 1 to clear positive edge detection flag */ + HT_EXTI->EDGESR = tmp; +} + +/*********************************************************************************************************//** + * @brief Clear the specified EXTI channelx wakeup flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval None + ************************************************************************************************************/ +void EXTI_ClearWakeupFlag(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + /* Write 1 to clear wake up flag */ + HT_EXTI->WAKUPFLG = 1 << EXTI_Channel; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx edge flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetEdgeFlag(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + return ((HT_EXTI->EDGEFLGR & (1UL << EXTI_Channel)) ? SET : RESET); +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx edge status. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param EXTI_Edge: can be status of edge that user want to monitor. + * This parameter can be one of the following values: + * @arg EXTI_EDGE_POSITIVE + * @arg EXTI_EDGE_NEGATIVE + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetEdgeStatus(u32 EXTI_Channel, u32 EXTI_Edge) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_EXTI_EDGE(EXTI_Edge)); + + if (HT_EXTI->EDGEFLGR & (1UL << EXTI_Channel)) + { + if (((HT_EXTI->EDGESR >> EXTI_Channel) & 1UL) ^ EXTI_Edge) + { + return SET; + } + else + { + return RESET; + } + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx wakeup flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetWakeupFlagStatus(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + if (HT_EXTI->WAKUPFLG & (1 << EXTI_Channel)) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Activate or Deactivate an EXTI channelx interrupt by software. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_SWIntCmd(u32 EXTI_Channel, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == ENABLE) + { + HT_EXTI->SSCR = 1 << EXTI_Channel; + } + else + { + HT_EXTI->SSCR &= ~(1 << EXTI_Channel); + } +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx software command register bit. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetSWCmdStatus(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + if (HT_EXTI->SSCR & (1 << EXTI_Channel)) + { + return SET; + } + else + { + return RESET; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_flash.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_flash.c new file mode 100644 index 0000000000..301920da1d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_flash.c @@ -0,0 +1,603 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_flash.c + * @version $Rev:: 2972 $ + * @date $Date:: 2023-10-28 #$ + * @brief This file provides all the FLASH firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_flash.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup FLASH FLASH + * @brief FLASH driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Private_Define FLASH private definitions + * @{ + */ + +/* Delay definition */ +#define FLASH_TIMEOUT (0x000FFFFF) + +/* FLASH OCMR */ +#define FLASH_CMD_STADNBY (0x00000000) +#define FLASH_CMD_PROGRAM (0x00000004) +#define FLASH_CMD_PAGEERASE (0x00000008) +#define FLASH_CMD_MASSERASE (0x0000000A) + +/* FLASH OPCR */ +#define FLASH_READY (0x6UL << 1) +#define FLASH_SEND_MAIN (0x00000014) + +/* FLASH CFCR */ +#define CFCR_WAIT_MASK (0xFFFFFFF8) + +#define FLASH_PREFETCHBUF_ON (0x00000010) +#define FLASH_PREFETCHBUF_OFF (0xFFFFFFEF) + +#define FLASH_BRANCHCACHE_ON (0x00001000) +#define FLASH_BRANCHCACHE_OFF (0xFFFFEFFF) + +#define FLASH_DCODECACHE_ON (0xFFFFFF7F) +#define FLASH_DCODECACHE_OFF (0x00000080) + +#define FLASH_CFCR_MASK (0xFFFFEFE8) +#define FLASH_PREFETCHBUF_AND_BRANCHCACHE_ON (0x00001010) +#define FLASH_PREFETCHBUF_AND_BRANCHCACHE_OFF (0xFFFFEFEF) + +#if (LIBCFG_FLASH_HALFCYCYLE) +#define FLASH_HALFCYCLE_ON (0x00008000) +#define FLASH_HALFCYCLE_OFF (0xFFFF7FFF) +#endif +#if (LIBCFG_FLASH_ZWPWESAVING) +#define FLASH_ZWPWRSAVING_ON (0x00010000) +#define FLASH_ZWPWRSAVING_OFF (0xFFFEFFFF) +#endif +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Private_Macro FLASH private macros + * @{ + */ + +/** + * @brief Check parameter of the FLASH wait state. + */ + +#if (LIBCFG_FMC_WAIT_STATE_3) +#define IS_WAIT_STATE3(x) (x == FLASH_WAITSTATE_3) +#else +#define IS_WAIT_STATE3(x) (0) +#endif + +#define IS_FLASH_WAITSTATE(WAIT) ((WAIT == FLASH_WAITSTATE_0) || \ + (WAIT == FLASH_WAITSTATE_1) || \ + (WAIT == FLASH_WAITSTATE_2) || \ + (IS_WAIT_STATE3(WAIT))) + +/** + * @brief Check parameter of the FLASH vector mapping. + */ +#define IS_FLASH_VECTOR_MODE(MODE) ((MODE == FLASH_BOOT_LOADER) || \ + (MODE == FLASH_BOOT_SRAM) || \ + (MODE == FLASH_BOOT_MAIN)) +/** + * @brief Check parameter of the FLASH address. + */ +#define IS_FLASH_ADDRESS(ADDRESS) (ADDRESS < 0x20000000) /* Code 0.5GB Area */ + +/** + * @brief Check parameter of the FLASH interrupt status. + */ +#define IS_FLASH_WC_FLAG(FLAG) ((FLAG & 0x0000001F) != 0) + +/** + * @brief Check parameter of the FLASH interrupt flag. + */ +#define IS_FLASH_FLAG(FLAG) ((FLAG & 0x0003001F) != 0) + +/** + * @brief Check parameter of the FLASH interrupt. + */ +#define IS_FLASH_INT(IT) ((IT & 0x0000001F) != 0) + +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Functions FLASH exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Configure the FLASH wait state. + * @param FLASH_WAITSTATE_n: Setting of FLASH wait state. + * This parameter can be one of the following values: + * @arg \ref FLASH_WAITSTATE_0 : zero wait state + * @arg \ref FLASH_WAITSTATE_1 : one wait state + * @arg \ref FLASH_WAITSTATE_2 : two wait state + * @arg \ref FLASH_WAITSTATE_3 : three wait state (For HT32F1xxxx only) + * @retval None + ************************************************************************************************************/ +void FLASH_SetWaitState(u32 FLASH_WAITSTATE_n) +{ + u32 uCFCR; + /* Check the parameters */ + Assert_Param(IS_FLASH_WAITSTATE(FLASH_WAITSTATE_n)); + + /* !!! NOTICE !!! + Before changing wait state, both Pre-fetch function and Branch Cache function must be disabled. + */ + uCFCR = HT_FLASH->CFCR; /* Backup previous settings. */ + + /* Disable Pre-fetch function and Branch Cache. */ + HT_FLASH->CFCR = uCFCR & FLASH_PREFETCHBUF_AND_BRANCHCACHE_OFF; + /* Change wait state. */ + HT_FLASH->CFCR = (uCFCR & FLASH_CFCR_MASK) | FLASH_WAITSTATE_n; + /* Restore previous settings. */ + HT_FLASH->CFCR |= uCFCR & (FLASH_PREFETCHBUF_AND_BRANCHCACHE_ON); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable FLASH pre-fetch buffer. + * @param NewState: This parameter can be ENABLE or DISABLE + * @retval None + ************************************************************************************************************/ +void FLASH_PrefetchBufferCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_FLASH->CFCR |= FLASH_PREFETCHBUF_ON; + } + else + { + HT_FLASH->CFCR &= FLASH_PREFETCHBUF_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable FLASH DCODE cache mode. + * @param NewState: This parameter can be ENABLE or DISABLE + * @retval None + ************************************************************************************************************/ +void FLASH_DcodeCacheCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_FLASH->CFCR &= FLASH_DCODECACHE_ON; + } + else + { + HT_FLASH->CFCR |= FLASH_DCODECACHE_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable FLASH branch cache. + * @param NewState: This parameter can be ENABLE or DISABLE + * @retval None + ************************************************************************************************************/ +void FLASH_BranchCacheCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_FLASH->CFCR |= FLASH_BRANCHCACHE_ON; + } + else + { + HT_FLASH->CFCR &= FLASH_BRANCHCACHE_OFF; + } +} + +#if (LIBCFG_FLASH_HALFCYCYLE) +/*********************************************************************************************************//** + * @brief Enable or Disable FLASH half cycle access. + * @param NewState: new state of the FLASH half cycle access. + * This parameter can be: ENABLE or DISABLE + * @retval ERROR or SUCCESS + ************************************************************************************************************/ +ErrStatus FLASH_FlashHalfCycleCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if ((HT_FLASH->CFCR & ~CFCR_WAIT_MASK) == FLASH_WAITSTATE_0) + { + if (NewState != DISABLE) + { + HT_FLASH->CFCR |= FLASH_HALFCYCLE_ON; + } + else + { + HT_FLASH->CFCR &= FLASH_HALFCYCLE_OFF; + } + + return SUCCESS; + } + + return ERROR; +} +#endif + +#if (LIBCFG_FLASH_ZWPWESAVING) +/*********************************************************************************************************//** + * @brief Enable or Disable FLASH zero wait state power saving. + * @param NewState: new state of the FLASH zero wait state power saving. + * This parameter can be: ENABLE or DISABLE + * @retval ERROR or SUCCESS + ************************************************************************************************************/ +ErrStatus FLASH_FlashZwPwrSavingCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if ((HT_FLASH->CFCR & ~CFCR_WAIT_MASK) == FLASH_WAITSTATE_0) + { + if (NewState != DISABLE) + { + HT_FLASH->CFCR |= FLASH_ZWPWRSAVING_ON; + } + else + { + HT_FLASH->CFCR &= FLASH_ZWPWRSAVING_OFF; + } + + return SUCCESS; + } + + return ERROR; +} +#endif + +/*********************************************************************************************************//** + * @brief Set vector remapping mode. + * @param FLASH_BOOT_x: Booting mode. + * This parameter can be one of the following values: + * @arg \ref FLASH_BOOT_LOADER : Boot loader mode + * @arg \ref FLASH_BOOT_SRAM : SRAM booting mode + * @arg \ref FLASH_BOOT_MAIN : Main FLASH mode + * @retval None + ************************************************************************************************************/ +void FLASH_SetRemappingMode(FLASH_Vector FLASH_BOOT_x) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_VECTOR_MODE(FLASH_BOOT_x)); + + HT_FLASH->VMCR = FLASH_BOOT_x; +} + +/*********************************************************************************************************//** + * @brief Erase a specific FLASH page. + * @param PageAddress: Address of the erased page. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * - \ref FLASH_ERR_ADDR_OUT_OF_RANGE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_ErasePage(u32 PageAddress) +{ + FLASH_State status; + #if (AUTO_CMDVERIFY == 1) + u32 uData; + u32 uAddress; + PageAddress &= (~(FLASH_PAGE_SIZE - 1)); + uAddress = PageAddress; + #endif + + /* Check the parameters */ + Assert_Param(IS_FLASH_ADDRESS(PageAddress)); + + #if (AUTO_CMDVERIFY == 1) + do + { + if (uAddress - PageAddress == FLASH_PAGE_SIZE) + { + return FLASH_COMPLETE; + } + + uData = rw(uAddress); + uAddress += 4; + } while (uData == 0xFFFFFFFF); + #endif + + HT_FLASH->TADR = PageAddress; + HT_FLASH->OCMR = FLASH_CMD_PAGEERASE; + + #if (AUTO_CMDVERIFY == 1) + do { + #endif + status = FLASH_WaitForOperationEnd(); + #if (AUTO_CMDVERIFY == 1) + if (status != FLASH_COMPLETE) + break; + } while (rw(uAddress - 4) != 0xFFFFFFFF); + #endif + + return status; +} + +/*********************************************************************************************************//** + * @brief Erase FLASH Option Byte page. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_EraseOptionByte(void) +{ + return FLASH_ErasePage(OPTION_BYTE_BASE); +} + +/*********************************************************************************************************//** + * @brief Erase the entire FLASH. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_MassErase(void) +{ + HT_FLASH->OCMR = FLASH_CMD_MASSERASE; + + return FLASH_WaitForOperationEnd(); +} + +/*********************************************************************************************************//** + * @brief Program one word data. + * @param Address: The specific FLASH address to be programmed. + * @param Data: The specific FLASH data to be programmed. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * - \ref FLASH_ERR_ADDR_OUT_OF_RANGE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_ProgramWordData(u32 Address, u32 Data) +{ + FLASH_State status; + + /* Check the parameters */ + Assert_Param(IS_FLASH_ADDRESS(Address)); + + HT_FLASH->TADR = Address; + HT_FLASH->WRDR = Data; + HT_FLASH->OCMR = FLASH_CMD_PROGRAM; + + if (Data == 0xFFFFFFFF) + { + return FLASH_COMPLETE; + } + + #if (AUTO_CMDVERIFY == 1) + do { + #endif + status = FLASH_WaitForOperationEnd(); + #if (AUTO_CMDVERIFY == 1) + if (status != FLASH_COMPLETE) + break; + } while (rw(Address) == 0xFFFFFFFF); + #endif + + return status; +} + +/*********************************************************************************************************//** + * @brief Program FLASH Option Byte page. + * @param Option: Struct pointer of Option Bytes. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_ProgramOptionByte(FLASH_OptionByte *Option) +{ + s32 i; + u32 CP = ~(Option->MainSecurity | Option->OptionProtect << 1); + u32 checksum = 0; + + for (i = 3; i >= 0; i--) + { + FLASH_ProgramWordData(OB_PP0 + i * 4, ~(Option->WriteProtect[i])); + checksum += ~(Option->WriteProtect[i]); + } + + FLASH_ProgramWordData(OB_CP, CP); + checksum += CP; + + FLASH_ProgramWordData(OB_CHECKSUM, checksum); + + return FLASH_COMPLETE; +} + +/*********************************************************************************************************//** + * @brief Return security status of the FLASH. + * @param Option: Struct pointer of Option Bytes. + * @retval None + ************************************************************************************************************/ +void FLASH_GetOptionByteStatus(FLASH_OptionByte *Option) +{ + s32 i; + + for (i = 3; i >= 0; i--) + { + Option->WriteProtect[i] = ~HT_FLASH->PPSR[i]; + } + + Option->MainSecurity = !(HT_FLASH->CPSR & 1); + Option->OptionProtect = !((HT_FLASH->CPSR >> 1) & 1); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specific FLASH interrupts. + * @param FLASH_INT_x: The specific FLASH interrupt. + * This parameter can be any combination (|) of the following values: + * @arg \ref FLASH_INT_ORFIEN + * @arg \ref FLASH_INT_ITADIEN + * @arg \ref FLASH_INT_OBEIEN + * @arg \ref FLASH_INT_IOCMIEN + * @arg \ref FLASH_INT_OREIEN + * @arg \ref FLASH_INT_ALL + * @param Cmd: This parameter can be ENABLE or DISABLE + * @retval None + ************************************************************************************************************/ +void FLASH_IntConfig(u32 FLASH_INT_x, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_INT(FLASH_INT_x)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + HT_FLASH->OIER |= FLASH_INT_x; + } + else + { + HT_FLASH->OIER &= ~FLASH_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Return flag status of the FLASH interrupt. + * @param FLASH_FLAG_x: Flag of the FLASH interrupt. + * This parameter can be any combination (|) of the following values: + * @arg \ref FLASH_FLAG_OREF + * @arg \ref FLASH_FLAG_IOCMF + * @arg \ref FLASH_FLAG_OBEF + * @arg \ref FLASH_FLAG_ITADF + * @arg \ref FLASH_FLAG_ORFF + * @arg \ref FLASH_FLAG_PPEF + * @arg \ref FLASH_FLAG_RORFF + * @retval FlagStatus + * - \ref SET + * - \ref RESET + ************************************************************************************************************/ +FlagStatus FLASH_GetIntStatus(u32 FLASH_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_FLAG(FLASH_FLAG_x)); + + if ((HT_FLASH->OISR & FLASH_FLAG_x) != (u32)RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear specific interrupt flags of FLASH. + * @param FLASH_FLAG_x: interrupt flag of FLASH. + * This parameter can be any combination (|) of the following values: + * @arg \ref FLASH_FLAG_OREF + * @arg \ref FLASH_FLAG_IOCMF + * @arg \ref FLASH_FLAG_OBEF + * @arg \ref FLASH_FLAG_ITADF + * @arg \ref FLASH_FLAG_ORFF + * @retval None + ************************************************************************************************************/ +void FLASH_ClearIntFlag(u32 FLASH_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_WC_FLAG(FLASH_FLAG_x)); + + HT_FLASH->OISR = FLASH_FLAG_x; +} + +/*********************************************************************************************************//** + * @brief Wait untill the FLASH operation has finished or time-out has occurred. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * - \ref FLASH_ERR_ADDR_OUT_OF_RANGE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_WaitForOperationEnd(void) +{ + u32 Timeout = FLASH_TIMEOUT; + u32 Status; + + HT_FLASH->OIER |= (FLASH_INT_ITADIEN); + HT_FLASH->OPCR = FLASH_SEND_MAIN; + + /* Waits till the FLASH operation has finished or time-out has occurred */ + while (Timeout--) + { + if ((HT_FLASH->OPCR & FLASH_READY) == FLASH_READY) + { + break; + } + } + Status = HT_FLASH->OISR; + HT_FLASH->OISR &= ~(FLASH_INT_ITADIEN); + + if (Status & FLASH_FLAG_PPEF) + { + return FLASH_ERR_WRITE_PROTECTED; + } + if (Status & FLASH_FLAG_ITADF) + { + return FLASH_ERR_ADDR_OUT_OF_RANGE; + } + if (Timeout == 0) + { + return FLASH_TIME_OUT; + } + + return FLASH_COMPLETE; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gpio.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gpio.c new file mode 100644 index 0000000000..572d61055c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gpio.c @@ -0,0 +1,730 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_gpio.c + * @version $Rev:: 2797 $ + * @date $Date:: 2022-11-28 #$ + * @brief This file provides all the GPIO and AFIO firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_gpio.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup GPIO GPIO + * @brief GPIO driver modules + * @{ + */ + + +/* Private function prototypes -----------------------------------------------------------------------------*/ +u32 _GPIO_ClockControl(HT_GPIO_TypeDef* HT_GPIOx, ControlStatus Cmd); +u32 _AFIO_ClockControl(ControlStatus Cmd); + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Private_Macro GPIO private macros + * @{ + */ +#if (AUTO_CK_CONTROL == 1) + #define GPIO_CK_ST u32 isAlreadyOn + #define GPIO_CK_ON() (isAlreadyOn = _GPIO_ClockControl(HT_GPIOx, ENABLE)) + #define GPIO_CK_OFF() if (isAlreadyOn == FALSE) _GPIO_ClockControl(HT_GPIOx, DISABLE) + #define AFIO_CK_ST u32 isAlreadyOn + #define AFIO_CK_ON() (isAlreadyOn = _AFIO_ClockControl(ENABLE)) + #define AFIO_CK_OFF() if (isAlreadyOn == FALSE) _AFIO_ClockControl(DISABLE) +#else + #define GPIO_CK_ST + #define GPIO_CK_ON(...) + #define GPIO_CK_OFF(...) + #define AFIO_CK_ST + #define AFIO_CK_ON(...) + #define AFIO_CK_OFF(...) +#endif +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup GPIO_Exported_Functions GPIO exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitializes the GPIO peripheral registers to their default reset values. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval None + ************************************************************************************************************/ +void GPIO_DeInit(HT_GPIO_TypeDef* HT_GPIOx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + if (HT_GPIOx == HT_GPIOA) + { + RSTCUReset.Bit.PA = 1; + } + else if (HT_GPIOx == HT_GPIOB) + { + RSTCUReset.Bit.PB = 1; + } + else if (HT_GPIOx == HT_GPIOC) + { + RSTCUReset.Bit.PC = 1; + } + else if (HT_GPIOx == HT_GPIOD) + { + RSTCUReset.Bit.PD = 1; + } + #if (LIBCFG_GPIOE) + else if (HT_GPIOx == HT_GPIOE) + { + RSTCUReset.Bit.PE = 1; + } + #endif + #if (LIBCFG_GPIOF) + else if (HT_GPIOx == HT_GPIOF) + { + RSTCUReset.Bit.PF = 1; + } + #endif + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure the direction of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param GPIO_DIR_INorOUT: + * This parameter can be one of below: + * @arg GPIO_DIR_IN : The pins are input mode + * @arg GPIO_DIR_OUT : The pins are output mode + * @retval None + ************************************************************************************************************/ +void GPIO_DirectionConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DIR_Enum GPIO_DIR_INorOUT) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_GPIO_DIR(GPIO_DIR_INorOUT)); + + GPIO_CK_ON(); + + if (GPIO_DIR_INorOUT != GPIO_DIR_IN) + HT_GPIOx->DIRCR |= GPIO_PIN_nBITMAP; + else + HT_GPIOx->DIRCR &= ~GPIO_PIN_nBITMAP; + + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Configure the pull resistor of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param GPIO_PR_x: Selection of Pull resistor. + * This parameter can be one of below: + * @arg GPIO_PR_UP : The pins with internal pull-up resistor + * @arg GPIO_PR_DOWN : The pins with internal pull-down resistor + * @arg GPIO_PR_DISABLE : The pins without pull resistor + * @retval None + ************************************************************************************************************/ +void GPIO_PullResistorConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_PR_Enum GPIO_PR_x) +{ + u32 temp_up, temp_down; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_GPIO_PR(GPIO_PR_x)); + + GPIO_CK_ON(); + temp_up = HT_GPIOx->PUR; + temp_down = HT_GPIOx->PDR; + + temp_up &= ~GPIO_PIN_nBITMAP; + temp_down &= ~GPIO_PIN_nBITMAP; + + switch (GPIO_PR_x) + { + case GPIO_PR_UP: + temp_up |= GPIO_PIN_nBITMAP; + break; + case GPIO_PR_DOWN: + temp_down |= GPIO_PIN_nBITMAP; + break; + case GPIO_PR_DISABLE: + break; + default: + break; + } + + HT_GPIOx->PUR = temp_up; + HT_GPIOx->PDR = temp_down; + + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the input control of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void GPIO_InputConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + GPIO_CK_ON(); + if (Cmd != DISABLE) + HT_GPIOx->INER |= GPIO_PIN_nBITMAP; + else + HT_GPIOx->INER &= ~GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Select the driving current of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param GPIO_DV_nMA: + * This parameter can be one of below: + * @arg GPIO_DV_4MA : Select output driving current as 4 mA + * @arg GPIO_DV_8MA : Select output driving current as 8 mA + * @arg GPIO_DV_12MA : Select output driving current as 12 mA (For HT32F1xxxx only) + * @arg GPIO_DV_16MA : Select output driving current as 16 mA (For HT32F1xxxx only) + * @retval None + ************************************************************************************************************/ +void GPIO_DriveConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DV_Enum GPIO_DV_nMA) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_GPIO_DV(GPIO_DV_nMA)); + + GPIO_CK_ON(); +#if (LIBCFG_GPIO_DV_4_8MA_ONLY) + if (GPIO_DV_nMA != GPIO_DV_4MA) + HT_GPIOx->DRVR |= GPIO_PIN_nBITMAP; + else + HT_GPIOx->DRVR &= ~GPIO_PIN_nBITMAP; +#else +{ + u8 index = 0, temp = 0; + u32 CurrentMode = 0, PinPosition = 0; + for (index = 0; index < 16; index++) + { + if ((GPIO_PIN_nBITMAP & 0x0001) == 1) + { + temp = index << 1; + CurrentMode |= ((u32) GPIO_DV_nMA << temp); + PinPosition |= ((u32) 0x03 << temp); + } + GPIO_PIN_nBITMAP >>= 1; + } + + HT_GPIOx->DRVR &= ~PinPosition; + HT_GPIOx->DRVR |= CurrentMode; +} +#endif + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the open drain function of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void GPIO_OpenDrainConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + GPIO_CK_ON(); + if (Cmd != DISABLE) + HT_GPIOx->ODR |= GPIO_PIN_nBITMAP; + else + HT_GPIOx->ODR &= ~GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Get the input data of specified port pin. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_n: This parameter can be GPIO_PIN_x. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus GPIO_ReadInBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n) +{ + FlagStatus result; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->DINR & GPIO_PIN_n) != RESET) + result = SET; + else + result = RESET; + + GPIO_CK_OFF(); + return result; +} + +/*********************************************************************************************************//** + * @brief Get the input data of specified GPIO port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval The value of input data register. + ************************************************************************************************************/ +u16 GPIO_ReadInData(HT_GPIO_TypeDef* HT_GPIOx) +{ + u16 uValue; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + uValue = (u16)HT_GPIOx->DINR; + GPIO_CK_OFF(); + return (uValue); +} + +/*********************************************************************************************************//** + * @brief Get the output data of specified port pin. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_n: This parameter can be GPIO_PIN_x. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus GPIO_ReadOutBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n) +{ + FlagStatus result; + GPIO_CK_ST; + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->DOUTR & GPIO_PIN_n) != RESET) + result = SET; + else + result = RESET; + + GPIO_CK_OFF(); + return result; +} + +/*********************************************************************************************************//** + * @brief Get the output data of specified GPIO port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval The value of output data register. + ************************************************************************************************************/ +u16 GPIO_ReadOutData(HT_GPIO_TypeDef* HT_GPIOx) +{ + u32 uValue; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + uValue = (u16)HT_GPIOx->DOUTR; + GPIO_CK_OFF(); + return uValue; +} + +/*********************************************************************************************************//** + * @brief Set the selected port bits of output data. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bit to be set. + * This parameter can be any combination of GPIO_PIN_x. + * @retval None + ************************************************************************************************************/ +void GPIO_SetOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->SRR = GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Clear the selected port bits of output data. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bit to be clear. + * This parameter can be any combination of GPIO_PIN_x. + * @retval None + ************************************************************************************************************/ +void GPIO_ClearOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->RR = GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Set or Clear the selected port bits of data. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bits. + * This parameter can be any combination of GPIO_PIN_x. + * @param Status: This parameter can be SET or RESET. + * @retval None + ************************************************************************************************************/ +void GPIO_WriteOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, FlagStatus Status) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if (Status != RESET) + HT_GPIOx->SRR = GPIO_PIN_nBITMAP; + else + HT_GPIOx->RR = GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Put data to the specified GPIO data port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param Data: Specify the data to be written to the port data register. + * @retval None + ************************************************************************************************************/ +void GPIO_WriteOutData(HT_GPIO_TypeDef* HT_GPIOx, u16 Data) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->DOUTR = Data; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Lock configuration of GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bits. + * This parameter can be any combination of GPIO_PIN_x. + * @retval None + ************************************************************************************************************/ +void GPIO_PinLock(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->LOCKR = (u32)0x5FA00000 | GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Get the lock state of specified GPIO port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool GPIO_IsPortLocked(HT_GPIO_TypeDef* HT_GPIOx) +{ + bool result; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->LOCKR >> 16) == 0) + result = FALSE; + else + result = TRUE; + GPIO_CK_OFF(); + return result; +} + +/*********************************************************************************************************//** + * @brief Get the lock state of specified GPIO port pin. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_n: This parameter can be GPIO_PIN_x. + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool GPIO_IsPinLocked(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n) +{ + bool result; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->LOCKR & GPIO_PIN_n) == 0) + result = FALSE; + else + result = TRUE; + GPIO_CK_OFF(); + return result; +} + +/*********************************************************************************************************//** + * @brief Disable DEBUG port to prevent unexpected security lock. + * @retval None + ************************************************************************************************************/ +void GPIO_DisableDebugPort(void) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }}; + CKCUClock.Bit.PA = 1; + CKCUClock.Bit.AFIO = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + AFIO_GPxConfig(GPIO_PA, GPIO_PIN_13, AFIO_FUN_GPIO); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_13, GPIO_PR_DOWN); + GPIO_InputConfig(HT_GPIOA, GPIO_PIN_13, DISABLE); + + #if 0 + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + AFIO_GPxConfig(GPIO_PA, GPIO_PIN_12, AFIO_FUN_GPIO); + #endif +} + +/*********************************************************************************************************//** + * @brief Convert HT_GPIOx to GPIO_Px + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval GPIO_Px: GPIO ID + ************************************************************************************************************/ +u32 GPIO_GetID(HT_GPIO_TypeDef* HT_GPIOx) +{ + // Convert 0x400B0000 ~ 0x400C6000 to 0 ~ 11 + u32 GPIO_Px = (((u32)HT_GPIOx) >> (12 + 1)) & 0x7F; + GPIO_Px -= 0x58; // 0xB0000 >> 13 = 0x58 + + return GPIO_Px; +} + +/*********************************************************************************************************//** + * @brief Deinitialize the AFIO peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void AFIO_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.AFIO = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure alternated mode of GPIO with specified pins. + * @param GPIO_Px: GPIO_PA ~ GPIO_PE. + * @param AFIO_PIN_n: This parameter can be any combination of AFIO_PIN_x. + * @param AFIO_MODE_n: This parameter can be one of the following values: + * @arg AFIO_MODE_DEFAULT : The default I/O function + * @arg AFIO_MODE_1 : Alternated mode 1 + * @arg AFIO_MODE_2 : Alternated mode 2 + * @arg AFIO_MODE_3 : Alternated mode 3 + * @arg AFIO_MODE_4 : Alternated mode 4 + * @arg AFIO_MODE_5 : Alternated mode 5 + * @arg AFIO_MODE_6 : Alternated mode 6 + * @arg AFIO_MODE_7 : Alternated mode 7 + * @arg AFIO_MODE_8 : Alternated mode 8 + * @arg AFIO_MODE_9 : Alternated mode 9 + * @arg AFIO_MODE_10 : Alternated mode 10 + * @arg AFIO_MODE_11 : Alternated mode 11 + * @arg AFIO_MODE_12 : Alternated mode 12 + * @arg AFIO_MODE_13 : Alternated mode 13 + * @arg AFIO_MODE_14 : Alternated mode 14 + * @arg AFIO_MODE_15 : Alternated mode 15 + * @retval None + ************************************************************************************************************/ +void AFIO_GPxConfig(u32 GPIO_Px, u32 AFIO_PIN_n, AFIO_MODE_Enum AFIO_MODE_n) +{ + vu32* pGPxCFGR = ((vu32*)&HT_AFIO->GPACFGR[0]) + GPIO_Px * 2; + u32 index = 0; + u32 Mask = 0, PinMode = 0; + s32 i; + AFIO_CK_ST; + + Assert_Param(IS_AFIO_MODE(AFIO_MODE_n)); + AFIO_CK_ON(); + + for (i = 0; i <= 8; i += 8) + { + Mask = 0; + PinMode = 0; + if (AFIO_PIN_n & (0x00FF << i)) + { + for (index = 0; index < 8; index++) + { + if ((AFIO_PIN_n >> index) & (0x0001 << i)) + { + Mask |= (0xF << (index * 4)); + PinMode |= (AFIO_MODE_n << (index * 4)); + } + } + *pGPxCFGR = (*pGPxCFGR & (~Mask)) | PinMode; + } + pGPxCFGR++; + } + + AFIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Select the GPIO pin to be used as EXTI channel. + * @param GPIO_PIN_NUM_n: Specify the GPIO pin number to be configured. + * @param GPIO_Px: GPIO_PA ~ GPIO_PF. + * @retval None + ************************************************************************************************************/ +void AFIO_EXTISourceConfig(u32 GPIO_PIN_NUM_n, u32 GPIO_Px) +{ + u8 index = 0; + u32 tmp = 0; + AFIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO_PORT(GPIO_Px)); + Assert_Param(IS_GPIO_PIN_NUM(GPIO_PIN_NUM_n)); + + AFIO_CK_ON(); + + if (GPIO_PIN_NUM_n > 7) + { + index = 1; + GPIO_PIN_NUM_n -= 8; + } + + tmp = HT_AFIO->ESSR[index]; + tmp &= ~((u32)0x0F << (GPIO_PIN_NUM_n * 4)); + tmp |= (u32)GPIO_Px << (GPIO_PIN_NUM_n * 4); + HT_AFIO->ESSR[index] = tmp; + AFIO_CK_OFF(); +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Private_Functions GPIO private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Turn on/Turn off specify GPIO clock. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval TRUE or FALSE (TRUE: already turn on, FALSE, Turn on by this call) + ***********************************************************************************************************/ +u32 _GPIO_ClockControl(HT_GPIO_TypeDef* HT_GPIOx, ControlStatus Cmd) +{ + u32 PxENStatus; + /*--------------------------------------------------------------------------------------------------------*/ + /* ((0x400Bx000 & 0x0000F000) >> 12 ) / 2 + 16 = */ + /* (0x0 ~ 0x4) + 16 = 16 ~ 20 for AHBCCR PAEN ~ PEEN bit offset */ + /*--------------------------------------------------------------------------------------------------------*/ + u32 offset = ((((u32)HT_GPIOx) & 0x0000F000) >> 12) / 2 + 16; + + PxENStatus = HT_CKCU->AHBCCR & (1 << offset); + + if (PxENStatus != 0) + { + if (Cmd == DISABLE) + { + HT_CKCU->AHBCCR &= (~(1 << offset)); + } + return TRUE; + } + + HT_CKCU->AHBCCR |= (1 << offset); + return FALSE; +} + +/*********************************************************************************************************//** + * @brief Turn on/Turn off AFIO clock. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval TRUE or FALSE (TRUE: already turn on, FALSE, Turn on by this call) + ***********************************************************************************************************/ +u32 _AFIO_ClockControl(ControlStatus Cmd) +{ + u32 AFIOENStatus; + + AFIOENStatus = HT_CKCU->APBCCR0 & (1 << 14); + + if (AFIOENStatus != 0) + { + if (Cmd == DISABLE) + { + HT_CKCU->APBCCR0 &= (~(1 << 14)); + } + return TRUE; + } + + HT_CKCU->APBCCR0 |= (1 << 14); + return FALSE; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gptm.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gptm.c new file mode 100644 index 0000000000..b824c72b16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_gptm.c @@ -0,0 +1,2 @@ +The SCTM, PWM, GPTM, and MCTM timer have similar architecture. They use the same driver, +"ht32fxxxxx_tm.c/.h" to save the code size. For those timers, please refet to the TM driver/example. diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2c.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2c.c new file mode 100644 index 0000000000..81ea72bc65 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2c.c @@ -0,0 +1,773 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_i2c.c + * @version $Rev:: 2787 $ + * @date $Date:: 2022-11-23 #$ + * @brief This file provides all the I2C firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_i2c.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup I2C I2C + * @brief I2C driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Private_Define I2C private definitions + * @{ + */ +/* I2C ENI2C mask */ +#define CR_ENI2C_SET ((u32)0x00000008) +#define CR_ENI2C_RESET ((u32)0xFFFFFFF7) + +/* I2C ENGC mask */ +#define CR_ENGC_SET ((u32)0x00000004) +#define CR_ENGC_RESET ((u32)0xFFFFFFFB) + +/* I2C AA mask */ +#define CR_ACK_SET ((u32)0x00000001) +#define CR_ACK_RESET ((u32)0xFFFFFFFE) + +/* I2C PDMANACK mask */ +#define CR_PDMANACK_SET ((u32)0x00000400) +#define CR_PDMANACK_RESET ((u32)0xFFFFFBFF) + +/* I2C ENTOUT mask */ +#define CR_ENTOUT_SET ((u32)0x00001000) +#define CR_ENTOUT_RESET ((u32)0xFFFFEFFF) + +/* I2C COMBFILT mask */ +#define CR_COMBFILTER_SET ((u32)0x00002000) +#define CR_COMBFILTER_RESET ((u32)0xFFFFDFFF) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Functions I2C exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the I2C peripheral registers to their default reset values. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval None + ************************************************************************************************************/ +void I2C_DeInit(HT_I2C_TypeDef* I2Cx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + if (I2Cx == HT_I2C0) + { + RSTCUReset.Bit.I2C0 = 1; + } + else if (I2Cx == HT_I2C1) + { + RSTCUReset.Bit.I2C1 = 1; + } + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the I2Cx peripheral according to the specified parameters in the I2C_InitStruct. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void I2C_Init(HT_I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct) +{ + u32 PCLK_Freq = 0; + s32 sTmp = 0; + s32 SHPGR = 0; + s32 SLPGR = 0; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_GENERAL_CALL(I2C_InitStruct->I2C_GeneralCall)); + Assert_Param(IS_I2C_ACKNOWLEDGE_ADDRESS(I2C_InitStruct->I2C_AddressingMode)); + Assert_Param(IS_I2C_ACKNOWLEDGE(I2C_InitStruct->I2C_Acknowledge)); + Assert_Param(IS_I2C_ADDRESS(I2C_InitStruct->I2C_OwnAddress)); + Assert_Param(IS_I2C_SPEED(I2C_InitStruct->I2C_Speed)); + + I2Cx->CR = (I2Cx->CR & 0xFFFFFF7A) | I2C_InitStruct->I2C_GeneralCall | + I2C_InitStruct->I2C_AddressingMode | I2C_InitStruct->I2C_Acknowledge; + + I2Cx->ADDR = I2C_InitStruct->I2C_OwnAddress; + + if (I2Cx == HT_I2C0) + PCLK_Freq = CKCU_GetPeripFrequency(CKCU_PCLK_I2C0); + else if (I2Cx == HT_I2C1) + PCLK_Freq = CKCU_GetPeripFrequency(CKCU_PCLK_I2C1); + + switch (I2Cx->CR & 0xC000) + { + case 0: + { + sTmp = 6; + break; + } + case 0x4000: + { + sTmp = 8; + break; + } + case 0x8000: + { + sTmp = 9; + break; + } + } + + SHPGR = (PCLK_Freq * 9)/(I2C_InitStruct->I2C_Speed * 20) - sTmp - I2C_InitStruct->I2C_SpeedOffset; + SLPGR = (PCLK_Freq * 11)/(I2C_InitStruct->I2C_Speed * 20) - sTmp - I2C_InitStruct->I2C_SpeedOffset; + + SHPGR = (SHPGR < 0) ? 0 : SHPGR; + SLPGR = (SLPGR < 0) ? 0 : SLPGR; + + I2Cx->SHPGR = SHPGR; + I2Cx->SLPGR = SLPGR; +} + +/*********************************************************************************************************//** + * @brief Fill each I2C_InitStruct member with its default value. + * @param I2C_InitStruct: pointer to an I2C_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct) +{ + I2C_InitStruct->I2C_GeneralCall = I2C_GENERALCALL_DISABLE; + I2C_InitStruct->I2C_AddressingMode = I2C_ADDRESSING_7BIT; + I2C_InitStruct->I2C_Acknowledge = I2C_ACK_DISABLE; + I2C_InitStruct->I2C_OwnAddress = 0; + I2C_InitStruct->I2C_Speed = 1000000; + I2C_InitStruct->I2C_SpeedOffset = 0; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified I2C peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_Cmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ENI2C_SET; + } + else + { + I2Cx->CR &= CR_ENI2C_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Generate STOP condition of I2C communication. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval None + ************************************************************************************************************/ +void I2C_GenerateSTOP(HT_I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + I2Cx->CR |= 0x2; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable I2C interrupts. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Int: specify if the I2C interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2C_INT_STA + * @arg I2C_INT_STO + * @arg I2C_INT_ADRS + * @arg I2C_INT_GCS + * @arg I2C_INT_ARBLOS + * @arg I2C_INT_RXNACK + * @arg I2C_INT_BUSERR + * @arg I2C_INT_TOUT + * @arg I2C_INT_RXDNE + * @arg I2C_INT_TXDE + * @arg I2C_INT_RXBF + * @arg I2C_INT_ALL + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_IntConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_INT(I2C_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->IER |= I2C_Int; + } + else + { + I2Cx->IER &= (u32)~I2C_Int; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable I2C General Call. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_GeneralCallCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ENGC_SET; + } + else + { + I2Cx->CR &= CR_ENGC_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable I2C sending acknowledgement. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_AckCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ACK_SET; + } + else + { + I2Cx->CR &= CR_ACK_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Configure own address of the specified I2C. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Address: specify own address of I2C. + * @retval None + ************************************************************************************************************/ +void I2C_SetOwnAddress(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDRESS(I2C_Address)); + + I2Cx->ADDR = I2C_Address; +} + +/*********************************************************************************************************//** + * @brief Start transmitting to target slave address. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Address: specify the slave address which will be transmitted. + * @param I2C_Direction: This parameter can be I2C_MASTER_READ or I2C_MASTER_WRITE. + * @retval None + ************************************************************************************************************/ +void I2C_TargetAddressConfig(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address, u32 I2C_Direction) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDRESS(I2C_Address)); + Assert_Param(IS_I2C_DIRECTION(I2C_Direction)); + + /* Make sure the prior stop command has been finished */ + while (I2Cx->CR & 0x2); + + if (I2C_Direction != I2C_MASTER_WRITE) + { + I2Cx->TAR = I2C_Address | I2C_MASTER_READ; + } + else + { + I2Cx->TAR = I2C_Address | I2C_MASTER_WRITE; + } +} + +/*********************************************************************************************************//** + * @brief Send a data word through the I2Cx peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Data: Byte to be transmitted. + * @retval None + ************************************************************************************************************/ +void I2C_SendData(HT_I2C_TypeDef* I2Cx, u8 I2C_Data) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + I2Cx->DR = I2C_Data; +} + +/*********************************************************************************************************//** + * @brief Return the received data by the I2Cx peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval The value of the received data. + ************************************************************************************************************/ +u8 I2C_ReceiveData(HT_I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + return (u8)I2Cx->DR; +} + +/*********************************************************************************************************//** + * @brief Read the specified I2C register and returns its value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Register: specify the register to read. + * This parameter can be one of the following values: + * @arg I2C_REGISTER_CR : Control Register + * @arg I2C_REGISTER_IER : Interrupt Enable Register + * @arg I2C_REGISTER_ADDR : Address Register + * @arg I2C_REGISTER_SR : Status Register + * @arg I2C_REGISTER_SHPGR : SCL High Period Generation Register + * @arg I2C_REGISTER_SLPGR : SCL Low Period Generation Register + * @arg I2C_REGISTER_DR : Data Register + * @arg I2C_REGISTER_TAR : Target Register + * @retval None + ************************************************************************************************************/ +u32 I2C_ReadRegister(HT_I2C_TypeDef* I2Cx, u8 I2C_Register) +{ + vu32 tmp = 0; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_REGISTER(I2C_Register)); + + tmp = (u32)I2Cx; + tmp += I2C_Register; + return (*(u32 *)tmp); +} + +/*********************************************************************************************************//** + * @brief Check whether the specified I2C flag has been set. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Flag: specify the flag to be check. + * This parameter can be one of the following values: + * @arg I2C_FLAG_STA : I2C start condition transmitted flag (Master mode) + * @arg I2C_FLAG_STO : I2C stop condition detected flag (Slave flag) + * @arg I2C_FLAG_ADRS : I2C address flag + * @arg I2C_FLAG_GCS : I2C general call flag (Slave mode) + * @arg I2C_FLAG_ARBLOS : I2C arbitration loss flag (Master mode) + * @arg I2C_FLAG_RXNACK : I2C received not acknowledge flag + * @arg I2C_FLAG_BUSERR : I2C bus error flag + * @arg I2C_FLAG_RXDNE : I2C Rx data not empty flag + * @arg I2C_FLAG_TXDE : I2C Tx data empty flag + * @arg I2C_FLAG_RXBF : I2C RX buffer full flag + * @arg I2C_FLAG_BUSBUSY : I2C bus busy flag + * @arg I2C_FLAG_MASTER : I2C master mode flag (Master flag) + * @arg I2C_FLAG_TXNRX : I2C transmitter mode flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus I2C_GetFlagStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_FLAG(I2C_Flag)); + + if ((I2Cx->SR & I2C_Flag) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified I2C status has been active. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Status: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg I2C_MASTER_SEND_START + * @arg I2C_MASTER_RECEIVER_MODE + * @arg I2C_MASTER_TRANSMITTER_MODE + * @arg I2C_MASTER_RX_NOT_EMPTY + * @arg I2C_MASTER_RX_NOT_EMPTY_NOBUSY + * @arg I2C_MASTER_TX_EMPTY + * @arg I2C_MASTER_RX_BUFFER_FULL + * @arg I2C_SLAVE_ACK_TRANSMITTER_ADDRESS + * @arg I2C_SLAVE_ACK_RECEIVER_ADDRESS + * @arg I2C_SLAVE_ACK_GCALL_ADDRESS + * @arg I2C_SLAVE_RX_NOT_EMPTY + * @arg I2C_SLAVE_RX_NOT_EMPTY_STOP + * @arg I2C_SLAVE_TX_EMPTY + * @arg I2C_SLAVE_RX_BUFFER_FULL + * @arg I2C_SLAVE_RECEIVED_NACK + * @arg I2C_SLAVE_RECEIVED_NACK_STOP + * @arg I2C_SLAVE_STOP_DETECTED + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus I2C_CheckStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Status) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_STATUS(I2C_Status)); + + if (I2Cx->SR == I2C_Status) + { + return (SUCCESS); + } + else + { + return (ERROR); + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified I2C flag. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Flag: specify the flag that is to be cleared. + * This parameter can be one of the following values: + * @arg I2C_FLAG_ARBLOS : I2C arbitration flag + * @arg I2C_FLAG_RXNACK : I2C receive not acknowledge flag + * @arg I2C_FLAG_BUSERR : I2C Bus error flag + * @retval None + ************************************************************************************************************/ +void I2C_ClearFlag(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_CLEAR_FLAG(I2C_Flag)); + + I2Cx->SR = I2C_Flag; +} + +/*********************************************************************************************************//** + * @brief Set the interval timing of the high period of the I2C clock. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_HighPeriod: specify the high period that is to be set. + * This parameter must be a number between 0 and 0xFFFF. + * @retval None + ************************************************************************************************************/ +void I2C_SetSCLHighPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_HighPeriod) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_SCL_HIGH(I2C_HighPeriod)); + + I2Cx->SHPGR = I2C_HighPeriod; +} + +/*********************************************************************************************************//** + * @brief Set the interval timing of low period of the I2C clock. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_LowPeriod: specify the low period that is to be set. + * This parameter must be a number between 0 and 0xFFFF. + * @retval None + ************************************************************************************************************/ +void I2C_SetSCLLowPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_LowPeriod) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_SCL_LOW(I2C_LowPeriod)); + + I2Cx->SLPGR = I2C_LowPeriod; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the I2Cx PDMA interface. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_PDMAREQ: specify the I2C PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2C_PDMAREQ_TX: Tx PDMA transfer request + * @arg I2C_PDMAREQ_RX: Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_PDMACmd(HT_I2C_TypeDef* I2Cx, u32 I2C_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_PDMA_REQ(I2C_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= I2C_PDMAREQ; + } + else + { + I2Cx->CR &= ~I2C_PDMAREQ; + } +} + +/*********************************************************************************************************//** + * @brief Specify that the next PDMA transfer is the last one. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_PDMANACKCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_PDMANACK_SET; + } + else + { + I2Cx->CR &= CR_PDMANACK_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified I2C time out function. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_TimeOutCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ENTOUT_SET; + } + else + { + I2Cx->CR &= CR_ENTOUT_RESET; + } +} + +/*********************************************************************************************************//** + * @brief This function is used to set the I2C timeout value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Timeout: specify the timeout value. + * @retval None + ************************************************************************************************************/ +void I2C_SetTimeOutValue(HT_I2C_TypeDef* I2Cx, u32 I2C_Timeout) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_TIMEOUT(I2C_Timeout)); + + I2Cx->TOUT = (I2C_Timeout | (I2Cx->TOUT & 0xFFFF0000)); +} + +/*********************************************************************************************************//** + * @brief This function is used to set the prescaler of I2C timeout value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Prescaler: specify the I2C time out prescaler value. + * This parameter can be one of the following values: + * @arg I2C_PRESCALER_1 : I2C prescaler set to 1 + * @arg I2C_PRESCALER_2 : I2C prescaler set to 2 + * @arg I2C_PRESCALER_4 : I2C prescaler set to 4 + * @arg I2C_PRESCALER_16 : I2C prescaler set to 16 + * @arg I2C_PRESCALER_32 : I2C prescaler set to 32 + * @arg I2C_PRESCALER_64 : I2C prescaler set to 64 + * @arg I2C_PRESCALER_128 : I2C prescaler set to 128 + * @retval None + ************************************************************************************************************/ +void I2C_SetTimeOutPrescaler(HT_I2C_TypeDef* I2Cx, u32 I2C_Prescaler) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_PRESCALER(I2C_Prescaler)); + + I2Cx->TOUT = (I2C_Prescaler | (I2Cx->TOUT & 0x0000FFFF)); +} + +/*********************************************************************************************************//** + * @brief This function is used to determine the prescaler of I2C timeout value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Mask: specify the bit position of I2C slave address to be masked. + * This parameter can be any combination of the following values: + * @arg I2C_MASKBIT_0 : Bit 0 of I2C slave address is masked + * @arg I2C_MASKBIT_1 : Bit 1 of I2C slave address is masked + * @arg I2C_MASKBIT_2 : Bit 2 of I2C slave address is masked + * @arg I2C_MASKBIT_3 : Bit 3 of I2C slave address is masked + * @arg I2C_MASKBIT_4 : Bit 4 of I2C slave address is masked + * @arg I2C_MASKBIT_5 : Bit 5 of I2C slave address is masked + * @arg I2C_MASKBIT_6 : Bit 6 of I2C slave address is masked + * @arg I2C_MASKBIT_7 : Bit 7 of I2C slave address is masked + * @arg I2C_MASKBIT_8 : Bit 8 of I2C slave address is masked + * @arg I2C_MASKBIT_9 : Bit 9 of I2C slave address is masked + * @retval None + ************************************************************************************************************/ +void I2C_AddressMaskConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Mask) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDRESS_MASK(I2C_Mask)); + + I2Cx->ADDMR = I2C_Mask; +} + +/*********************************************************************************************************//** + * @brief Return the received address by the I2Cx peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval The value of the received address. + ************************************************************************************************************/ +u16 I2C_GetAddressBuffer(HT_I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + return ((u16)I2Cx->ADDSR); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the combinational filter. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_CombFilterCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_COMBFILTER_SET; + } + else + { + I2Cx->CR &= CR_COMBFILTER_RESET; + } +} + +/*********************************************************************************************************//** + * @brief This function is used to determine the filter glitch width of 0~2 PCLK. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param Seq_Filter_Select: specify the glitch width of 0~2 PCLK. + * This parameter can be any combination of the following values: + * @arg SEQ_FILTER_DISABLE : sequential filter is disabled + * @arg SEQ_FILTER_1_PCLK : filter glitch width of 1 PCLK + * @arg SEQ_FILTER_2_PCLK : filter glitch width of 2 PCLK + * @retval None + ************************************************************************************************************/ +void I2C_SequentialFilterConfig(HT_I2C_TypeDef* I2Cx, u32 Seq_Filter_Select) +{ + u32 SHPGR = I2Cx->SHPGR; + u32 SLPGR = I2Cx->SLPGR; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_SEQ_FILTER_MASK(Seq_Filter_Select)); + + switch (I2Cx->CR & 0xC000) + { + case 0: + if (Seq_Filter_Select == SEQ_FILTER_1_PCLK) + { + if (SHPGR >= 2) + { + SHPGR -= 2; + SLPGR -= 2; + } + } + else if (Seq_Filter_Select == SEQ_FILTER_2_PCLK) + { + if (SHPGR >= 2) + { + SHPGR -= 3; + SLPGR -= 3; + } + } + break; + + case 0x4000: + if (Seq_Filter_Select == SEQ_FILTER_DISABLE) + { + SHPGR += 2; + SLPGR += 2; + } + else if (Seq_Filter_Select == SEQ_FILTER_2_PCLK) + { + if (SHPGR >= 1) + { + SHPGR -= 1; + SLPGR -= 1; + } + } + break; + + case 0x8000: + if (Seq_Filter_Select == SEQ_FILTER_DISABLE) + { + SHPGR += 3; + SLPGR += 3; + } + else if (Seq_Filter_Select == SEQ_FILTER_1_PCLK) + { + SHPGR += 1; + SLPGR += 1; + } + break; + + default: + break; + } + + I2Cx->SHPGR = SHPGR; + I2Cx->SLPGR = SLPGR; + I2Cx->CR = (I2Cx->CR & 0x3FFF) | Seq_Filter_Select; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2s.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2s.c new file mode 100644 index 0000000000..b269844127 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_i2s.c @@ -0,0 +1,336 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_i2s.c + * @version $Rev:: 2140 $ + * @date $Date:: 2020-07-23 #$ + * @brief This file provides all the I2S firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_i2s.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup I2S I2S + * @brief I2S driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Private_Define I2S private definitions + * @{ + */ +#define I2S_EN (1UL) +#define MCLK_OP_EN (1UL << 9) +#define TX_MUTE_EN (1UL << 12) +#define CLK_DIV_EN (1UL << 15) +#define BCLK_INV_EN (1UL << 18) +#define MCLK_INV_EN (1UL << 19) + +#define I2S_SLAVE (1UL << 3) +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Functions I2S exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the I2S peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void I2S_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.I2S = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the I2S peripheral according to the specified parameters in the I2S_InitStruct. + * @param I2S_InitStruct: pointer to a I2S_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void I2S_Init(I2S_InitTypeDef* I2S_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode)); + Assert_Param(IS_I2S_FORMAT(I2S_InitStruct->I2S_Format)); + Assert_Param(IS_I2S_WORD_WIDTH(I2S_InitStruct->I2S_WordWidth)); + Assert_Param(IS_I2S_MCLK_DIV(I2S_InitStruct->I2S_X_Div, I2S_InitStruct->I2S_Y_Div)); + Assert_Param(IS_I2S_BCLK_DIV(I2S_InitStruct->I2S_N_Div)); + + HT_I2S->CR = I2S_InitStruct->I2S_Mode | I2S_InitStruct->I2S_Format | I2S_InitStruct->I2S_WordWidth; + + if (I2S_InitStruct->I2S_BclkInv == ENABLE) + { + HT_I2S->CR |= BCLK_INV_EN; + } + + if (I2S_InitStruct->I2S_MclkInv == ENABLE) + { + HT_I2S->CR |= MCLK_INV_EN; + } + + if ((I2S_InitStruct->I2S_Mode & I2S_SLAVE) == RESET) + { + HT_I2S->CDR = (I2S_InitStruct->I2S_N_Div << 16) | (I2S_InitStruct->I2S_X_Div << 8) | + (I2S_InitStruct->I2S_Y_Div); + HT_I2S->CR |= CLK_DIV_EN; + while (I2S_GetFlagStatus(I2S_FLAG_CLK_RDY) == RESET); + + if (I2S_InitStruct->I2S_MclkOut == ENABLE) + { + HT_I2S->CR |= MCLK_OP_EN; + } + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the I2S peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_Cmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->CR |= I2S_EN; + } + else + { + HT_I2S->CR &= ~I2S_EN; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the Tx mute for the I2S peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_TxMuteCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->CR |= TX_MUTE_EN; + } + else + { + HT_I2S->CR &= ~TX_MUTE_EN; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the I2S PDMA interface. + * @param I2S_PDMAREQ: specify the I2S PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2S_PDMAREQ_TX : Tx PDMA transfer request + * @arg I2S_PDMAREQ_RX : Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_PDMACmd(u32 I2S_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_PDMA_REQ(I2S_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->CR |= I2S_PDMAREQ; + } + else + { + HT_I2S->CR &= I2S_PDMAREQ; + } +} + +/*********************************************************************************************************//** + * @brief Reset the specified I2S FIFO. + * @param I2S_FIFO: specify the FIFO that is to be reset. + * This parameter can be any combination of the following values: + * @arg I2S_TX_FIFO : I2S Tx FIFO + * @arg I2S_RX_FIFO : I2S Rx FIFO + * @retval None + ************************************************************************************************************/ +void I2S_FIFOReset(u32 I2S_FIFO) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_TWO_FIFO(I2S_FIFO)); + + HT_I2S->FCR |= I2S_FIFO; +} + +/*********************************************************************************************************//** + * @brief Set the trigger level of specified I2S FIFO. + * @param I2S_FIFO: specify the FIFO that is to be set. + * This parameter can be any combination of the following values: + * @arg I2S_TX_FIFO : I2S Tx FIFO + * @arg I2S_RX_FIFO : I2S Rx FIFO + * @param I2S_FIFOLevel: Specify the FIFO trigger level. + * @retval None + ************************************************************************************************************/ +void I2S_FIFOTrigLevelConfig(u32 I2S_FIFO, u32 I2S_FIFOLevel) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_TWO_FIFO(I2S_FIFO)); + Assert_Param(IS_I2S_FIFO_LEVEL(I2S_FIFOLevel)); + + if (I2S_FIFO == I2S_TX_FIFO) + { + HT_I2S->FCR = ((HT_I2S->FCR & (~0x0000000F)) | I2S_FIFOLevel); + } + else + { + HT_I2S->FCR = ((HT_I2S->FCR & (~0x000000F0)) | (I2S_FIFOLevel << 4)); + } +} + +/*********************************************************************************************************//** + * @brief Return the status of specified I2S FIFO. + * @param I2S_FIFO: specify the FIFO that is to be checked. + * This parameter can be one of the following values: + * @arg I2S_TX_FIFO : I2S Tx FIFO + * @arg I2S_RX_FIFO : I2S Rx FIFO + * @retval The number of data in specified I2S FIFO. + ************************************************************************************************************/ +u8 I2S_GetFIFOStatus(u32 I2S_FIFO) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_ONE_FIFO(I2S_FIFO)); + + if (I2S_FIFO == I2S_TX_FIFO) + { + return (u8)((HT_I2S->SR >> 24) & 0x0F); + } + else + { + return (u8)(HT_I2S->SR >> 28); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the I2S interrupt. + * @param I2S_Int: specify if the I2S interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2S_INT_TXFIFO_TRI : I2S Tx FIFO trigger level interrupt + * @arg I2S_INT_TXFIFO_UF : I2S Rx FIFO underflow interrupt + * @arg I2S_INT_TXFIFO_OV : I2S Tx FIFO overflow interrupt + * @arg I2S_INT_RXFIFO_TRI : I2S Rx FIFO trigger level interrupt + * @arg I2S_INT_RXFIFO_UV : I2S Rx FIFO underflow interrupt + * @arg I2S_INT_RXFIFO_OV : I2S Rx FIFO overflow interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_IntConfig(u32 I2S_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_INT(I2S_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->IER |= I2S_Int; + } + else + { + HT_I2S->IER &= ~I2S_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified I2S flag has been set or not. + * @param I2S_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg I2S_FLAG_TXFIFO_TRI : I2S Tx FIFO trigger level flag + * @arg I2S_FLAG_TXFIFO_UDF : I2S Tx FIFO underflow flag + * @arg I2S_FLAG_TXFIFO_OVF : I2S Tx FIFO overflow flag + * @arg I2S_FLAG_TXFIFO_EMP : I2S Tx FIFO empty flag + * @arg I2S_FLAG_TXFIFO_FUL : I2S Tx FIFO full flag + * @arg I2S_FLAG_RXFIFO_TRI : I2S Rx FIFO trigger level flag + * @arg I2S_FLAG_RXFIFO_UDF : I2S Rx FIFO underflow flag + * @arg I2S_FLAG_RXFIFO_OVF : I2S Rx FIFO overflow flag + * @arg I2S_FLAG_RXFIFO_EMP : I2S Rx FIFO empty flag + * @arg I2S_FLAG_RXFIFO_FUL : I2S Rx FIFO full flag + * @arg I2S_FLAG_RIGHT_CH : I2S right channel flag + * @arg I2S_FLAG_TX_BUSY : I2S Tx busy flag + * @arg I2S_FLAG_CLK_RDY : I2S clock ready flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus I2S_GetFlagStatus(u32 I2S_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_FLAG(I2S_Flag)); + + if (HT_I2S->SR & I2S_Flag) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified I2S flag. + * @param I2S_Flag: specify the flag that is to be cleared. + * This parameter can be any combination of the following values: + * @arg I2S_FLAG_TXFIFO_TRI : I2S Tx FIFO trigger level flag + * @arg I2S_FLAG_TXFIFO_UV : I2S Tx FIFO underflow flag + * @arg I2S_FLAG_TXFIFO_OV : I2S Tx FIFO overflow flag + * @arg I2S_FLAG_RXFIFO_TRI : I2S Rx FIFO trigger level flag + * @arg I2S_FLAG_RXFIFO_UV : I2S Rx FIFO underflow flag + * @arg I2S_FLAG_RXFIFO_OV : I2S Rx FIFO overflow flag + * @retval None + ************************************************************************************************************/ +void I2S_ClearFlag(u32 I2S_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_FLAG_CLEAR(I2S_Flag)); + + HT_I2S->SR = I2S_Flag; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_mctm.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_mctm.c new file mode 100644 index 0000000000..a77c3858b2 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_mctm.c @@ -0,0 +1,253 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_mctm.c + * @version $Rev:: 2797 $ + * @date $Date:: 2022-11-28 #$ + * @brief This file provides all the MCTM firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_mctm.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup MCTM MCTM + * @brief MCTM driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Private_Define MCTM private definitions + * @{ + */ +#define CTR_COMPRE 0x00000100ul +#define CTR_COMUS 0x00000200ul + +#define CHBRKCTR_CHMOE 0x00000010ul +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Functions MCTM exported functions + * @{ + */ + +/*********************************************************************************************************//** + * @brief Configure polarity of the MCTMx channel N. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripheral. + * @param Channel: Specify the MCTM channel. + * This parameter can be one of the following values: + * @arg MCTM_CH_0 : MCTM channel 0 + * @arg MCTM_CH_1 : MCTM channel 1 + * @arg MCTM_CH_2 : MCTM channel 2 + * @arg MCTM_CH_3 : MCTM channel 3 + * @param Pol: Specify the polarity of channel N. + * This parameter can be one of the following values: + * @arg MCTM_CHP_NONINVERTED : active high + * @arg MCTM_CHP_INVERTED : active low + * @retval None + ************************************************************************************************************/ +void MCTM_ChNPolarityConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHP_Enum Pol) +{ + u32 wChpolr; + + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_COMPLEMENTARY_CH(Channel)); + Assert_Param(IS_TM_CHP(Pol)); + + /* Set or reset the CHxN polarity */ + wChpolr = MCTMx->CHPOLR & (~(u32)(0x2 << (Channel << 1))); + MCTMx->CHPOLR = wChpolr | ((Pol << 1) << (Channel << 1)); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the MCTMx channel N. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripheral. + * @param Channel: Specify the MCTM channel. + * This parameter can be one of the following values: + * @arg MCTM_CH_0 : MCTM channel 0 + * @arg MCTM_CH_1 : MCTM channel 1 + * @arg MCTM_CH_2 : MCTM channel 2 + * @arg MCTM_CH_3 : MCTM channel 3 + * @param Control: This parameter can be TM_CHCTL_ENABLE or TM_CHCTL_DISABLE. + * @retval None + ************************************************************************************************************/ +void MCTM_ChannelNConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_COMPLEMENTARY_CH(Channel)); + Assert_Param(IS_TM_CHCTL(Control)); + + /* Reset the CHxNE Bit */ + MCTMx->CHCTR &= ~(u32)(0x2 << (Channel << 1)); + + /* Set or reset the CHxNE Bit */ + MCTMx->CHCTR |= (u32)(Control << 1) << (Channel << 1); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the channels main output of the MCTMx. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void MCTM_CHMOECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the MCTM Main Output */ + MCTMx->CHBRKCTR |= CHBRKCTR_CHMOE; + } + else + { + /* Disable the MCTM Main Output */ + MCTMx->CHBRKCTR &= ~CHBRKCTR_CHMOE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the break feature, dead time, Lock level, the OSSI, the OSSR State + * and the CHAOE(automatic output enable). + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param CHBRKCTRInit: Point to a MCTM_CHBRKCTRInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void MCTM_CHBRKCTRConfig(HT_TM_TypeDef* MCTMx, MCTM_CHBRKCTRInitTypeDef *CHBRKCTRInit) +{ + u32 wTmpReg; + + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_OSSR_STATE(CHBRKCTRInit->OSSRState)); + Assert_Param(IS_MCTM_OSSI_STATE(CHBRKCTRInit->OSSIState)); + Assert_Param(IS_MCTM_LOCK_LEVEL(CHBRKCTRInit->LockLevel)); + Assert_Param(IS_MCTM_BREAK_STATE(CHBRKCTRInit->Break0)); + Assert_Param(IS_MCTM_BREAK_POLARITY(CHBRKCTRInit->Break0Polarity)); + Assert_Param(IS_MCTM_BREAK_STATE(CHBRKCTRInit->Break1)); + Assert_Param(IS_MCTM_BREAK_POLARITY(CHBRKCTRInit->Break1Polarity)); + Assert_Param(IS_MCTM_CHAOE_STATE(CHBRKCTRInit->AutomaticOutput)); + Assert_Param(IS_TM_FILTER(CHBRKCTRInit->BreakFilter)); + + wTmpReg = MCTMx->CHBRKCTR & 0x00000010; // Keep CHMOE + wTmpReg |= (u32)CHBRKCTRInit->BreakFilter << 8; + wTmpReg |= (u32)CHBRKCTRInit->DeadTime << 24; + wTmpReg |= CHBRKCTRInit->LockLevel | CHBRKCTRInit->OSSRState | CHBRKCTRInit->OSSIState; + wTmpReg |= CHBRKCTRInit->Break0 | CHBRKCTRInit->Break0Polarity | CHBRKCTRInit->AutomaticOutput; + wTmpReg |= (CHBRKCTRInit->Break1 << 2) | (CHBRKCTRInit->Break1Polarity << 2); + + MCTMx->CHBRKCTR = wTmpReg; +} + +/*********************************************************************************************************//** + * @brief Fill each CHBRKCTRInitStruct member with its default value. + * @param CHBRKCTRInitStruct: Point to a MCTM_CHBRKCTRInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void MCTM_CHBRKCTRStructInit(MCTM_CHBRKCTRInitTypeDef* CHBRKCTRInitStruct) +{ + /* Set the default configuration */ + CHBRKCTRInitStruct->OSSRState = MCTM_OSSR_STATE_DISABLE; + CHBRKCTRInitStruct->OSSIState = MCTM_OSSI_STATE_DISABLE; + CHBRKCTRInitStruct->LockLevel = MCTM_LOCK_LEVEL_OFF; + CHBRKCTRInitStruct->DeadTime = 0x00; + CHBRKCTRInitStruct->Break0 = MCTM_BREAK_DISABLE; + CHBRKCTRInitStruct->Break0Polarity = MCTM_BREAK_POLARITY_LOW; + CHBRKCTRInitStruct->Break1 = MCTM_BREAK_DISABLE; + CHBRKCTRInitStruct->Break1Polarity = MCTM_BREAK_POLARITY_LOW; + CHBRKCTRInitStruct->BreakFilter = 0; + CHBRKCTRInitStruct->AutomaticOutput = MCTM_CHAOE_DISABLE; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable MCTMx COMPRE function. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void MCTM_COMPRECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the MCTM COMPRE */ + MCTMx->CTR |= CTR_COMPRE; + } + else + { + /* Disable the MCTM COMPRE */ + MCTMx->CTR &= ~CTR_COMPRE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the MCTMx COMUS function. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param Sel: Specify the COMUS value. + * This parameter can be one of the following values: + * @arg MCTM_COMUS_STIOFF : MCTM capture/compare control bits are updated by setting the UEV2G bit only + * @arg MCTM_COMUS_STION : MCTM capture/compare control bits are updated by both setting the UEV2G bit + * or when a rising edge occurs on STI + * @retval None + ************************************************************************************************************/ +void MCTM_COMUSConfig(HT_TM_TypeDef* MCTMx, MCTM_COMUS_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_COMUS(Sel)); + + if (Sel != MCTM_COMUS_STIOFF) + { + /* Set the MCTM COMUS bit */ + MCTMx->CTR |= CTR_COMUS; + } + else + { + /* Clear the MCTM COMUS bit */ + MCTMx->CTR &= ~CTR_COMUS; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pdma.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pdma.c new file mode 100644 index 0000000000..8a816d946f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pdma.c @@ -0,0 +1,341 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_pdma.c + * @version $Rev:: 2717 $ + * @date $Date:: 2022-08-20 #$ + * @brief This file provides all the PDMA firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_pdma.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup PDMA PDMA + * @brief PDMA driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Functions PDMA exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the PDMA peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void PDMA_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.PDMA = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure specific PDMA channel + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * PDMA_CH0 ~ PDMA_CH7 + * PDMA_CH8 ~ PDMA_CH11 (For specific models only) + * @param PDMACH_InitStruct: pointer to a PDMACH_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void PDMA_Config(u32 PDMA_CHn, PDMACH_InitTypeDef *PDMACH_InitStruct) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_WIDTH(PDMACH_InitStruct->PDMACH_DataSize)); + Assert_Param(IS_PDMA_PRIO(PDMACH_InitStruct->PDMACH_Priority)); + Assert_Param(IS_PDMA_ADR_MOD(PDMACH_InitStruct->PDMACH_AdrMod)); + Assert_Param(IS_PDMA_BLK_CNT(PDMACH_InitStruct->PDMACH_BlkCnt)); + Assert_Param(IS_PDMA_BLK_LEN(PDMACH_InitStruct->PDMACH_BlkLen)); + + /* PDMA channel x configuration */ + PDMACHx->CR = (PDMACH_InitStruct->PDMACH_DataSize | PDMACH_InitStruct->PDMACH_Priority | PDMACH_InitStruct->PDMACH_AdrMod); + + PDMACHx->SADR = PDMACH_InitStruct->PDMACH_SrcAddr; + + PDMACHx->DADR = PDMACH_InitStruct->PDMACH_DstAddr; + + PDMACHx->TSR = (PDMACH_InitStruct->PDMACH_BlkCnt << 16) | PDMACH_InitStruct->PDMACH_BlkLen; +} + +/*********************************************************************************************************//** + * @brief PDMA_AddrConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param SrcAddr: Source address + * @param DstAddr: Destination address + * @retval None + ************************************************************************************************************/ +void PDMA_AddrConfig(u32 PDMA_CHn, u32 SrcAddr, u32 DstAddr) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + /* transfer address configuration */ + PDMACHx->SADR = SrcAddr; + PDMACHx->DADR = DstAddr; +} + +/*********************************************************************************************************//** + * @brief PDMA_SrcAddrConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param SrcAddr: Source address + * @retval None + ************************************************************************************************************/ +void PDMA_SrcAddrConfig(u32 PDMA_CHn, u32 SrcAddr) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + /* transfer address configuration */ + PDMACHx->SADR = SrcAddr; +} + +/*********************************************************************************************************//** + * @brief PDMA_DstAddrConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param DstAddr: Destination address + * @retval None + ************************************************************************************************************/ +void PDMA_DstAddrConfig(u32 PDMA_CHn, u32 DstAddr) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + /* transfer address configuration */ + PDMACHx->DADR = DstAddr; +} + +/*********************************************************************************************************//** + * @brief PDMA_TranSizeConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * PDMA_CH0 ~ PDMA_CH7 + * PDMA_CH8 ~ PDMA_CH11 (For specific models only) + * @param BlkCnt: Number of blocks for a transfer + * @param BlkLen: Number of data for a block + * @retval None + ************************************************************************************************************/ +void PDMA_TranSizeConfig(u32 PDMA_CHn, u16 BlkCnt, u16 BlkLen) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_BLK_CNT(BlkCnt)); + Assert_Param(IS_PDMA_BLK_LEN(BlkLen)); + + /* transfer size configuration */ + PDMACHx->TSR = ((BlkCnt << 16) | BlkLen); +} + +/*********************************************************************************************************//** + * @brief Enable the specific PDMA channel interrupts + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * PDMA_CH0 ~ PDMA_CH7 + * PDMA_CH8 ~ PDMA_CH11 (For specific models only) + * @param PDMA_INT_x: PDMA_INT_GE, PDMA_INT_BE, PDMA_INT_HT, PDMA_INT_TC, PDMA_INT_TE + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PDMA_IntConfig(u32 PDMA_CHn, u32 PDMA_INT_x, ControlStatus NewState) +{ + #if (LIBCFG_PDMA_V01) + u32 *PdmaIntEnReg = ((u32 *)(&HT_PDMA->IER0)); + #else + u32 *PdmaIntEnReg = (PDMA_CHn < 6) ? ((u32 *)(&HT_PDMA->IER0)) : ((u32 *)(&HT_PDMA->IER1)); + #endif + u32 BitShift = (PDMA_CHn < 6) ? (PDMA_CHn * 5) : ((PDMA_CHn - 6) * 5); + u32 uRegTmp = 0; + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_INT(PDMA_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_PDMA_CH3FIX) + if (PDMA_CHn == PDMA_CH3) + { + if (PDMA_INT_x & PDMA_INT_BE) + { + uRegTmp |= (PDMA_INT_BE << (PDMA_CH2 * 5)); + } + if (PDMA_INT_x & PDMA_INT_HT) + { + uRegTmp |= (PDMA_INT_HT << (PDMA_CH2 * 5)); + } + } + #endif + + if (NewState != DISABLE) + { + *PdmaIntEnReg |= ((PDMA_INT_x << BitShift) | uRegTmp); + } + else + { + *PdmaIntEnReg &= ~(PDMA_INT_x << BitShift); + } +} + +/*********************************************************************************************************//** + * @brief Enable a specific PDMA channel + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * PDMA_CH0 ~ PDMA_CH7 + * PDMA_CH8 ~ PDMA_CH11 (For specific models only) + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PDMA_EnaCmd(u32 PDMA_CHn, ControlStatus NewState) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SetBit_BB((u32)(&PDMACHx->CR), 0); + } + else + { + ResetBit_BB((u32)(&PDMACHx->CR), 0); + } +} + +/*********************************************************************************************************//** + * @brief Software trigger a specific PDMA channel + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * PDMA_CH0 ~ PDMA_CH7 + * PDMA_CH8 ~ PDMA_CH11 (For specific models only) + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PDMA_SwTrigCmd(u32 PDMA_CHn, ControlStatus NewState) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SetBit_BB((u32)(&PDMACHx->CR), 1); + } + else + { + ResetBit_BB((u32)(&PDMACHx->CR), 1); + } +} + +/*********************************************************************************************************//** + * @brief Get the specific PDMA channel interrupt flag + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * PDMA_CH0 ~ PDMA_CH7 + * PDMA_CH8 ~ PDMA_CH11 (For specific models only) + * @param PDMA_FLAG_x: PDMA_FLAG_GE, PDMA_FLAG_BE, PDMA_FLAG_HT, PDMA_FLAG_TC, PDMA_FLAG_TE + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus PDMA_GetFlagStatus(u32 PDMA_CHn, u32 PDMA_FLAG_x) +{ + #if (LIBCFG_PDMA_V01) + u32 *PdmaIntStatReg = ((u32 *)(&HT_PDMA->ISR0)); + #else + u32 *PdmaIntStatReg = (PDMA_CHn < 6) ? ((u32 *)(&HT_PDMA->ISR0)) : ((u32 *)(&HT_PDMA->ISR1)); + #endif + u32 BitShift = (PDMA_CHn < 6) ? (PDMA_CHn * 5) : ((PDMA_CHn - 6) * 5); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_FLAG(PDMA_FLAG_x)); + + if ((*PdmaIntStatReg & (PDMA_FLAG_x << BitShift)) != RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specific PDMA channel interrupt flags + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * PDMA_CH0 ~ PDMA_CH7 + * PDMA_CH8 ~ PDMA_CH11 (For specific models only) + * @param PDMA_FLAG_x: PDMA_FLAG_GE, PDMA_FLAG_BE, PDMA_FLAG_HT, PDMA_FLAG_TC, PDMA_FLAG_TE + * @retval None + ************************************************************************************************************/ +void PDMA_ClearFlag(u32 PDMA_CHn, u32 PDMA_FLAG_x) +{ + #if (LIBCFG_PDMA_V01) + u32 *PdmaIntStatClrReg = ((u32 *)(&HT_PDMA->ISCR0)); + #else + u32 *PdmaIntStatClrReg = (PDMA_CHn < 6) ? ((u32 *)(&HT_PDMA->ISCR0)) : ((u32 *)(&HT_PDMA->ISCR1)); + #endif + u32 BitShift = (PDMA_CHn < 6) ? (PDMA_CHn * 5) : ((PDMA_CHn - 6) * 5); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_CLEAR_FLAG(PDMA_FLAG_x)); + + *PdmaIntStatClrReg |= (PDMA_FLAG_x << BitShift); +} + +/*********************************************************************************************************//** + * @brief Get remain block count of the specific PDMA channel + * @retval CBLKCNT + ************************************************************************************************************/ +u16 PDMA_GetRemainBlkCnt(u32 PDMA_CHn) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + return ((PDMACHx->CTSR) >> 16); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwm.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwm.c new file mode 100644 index 0000000000..b824c72b16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwm.c @@ -0,0 +1,2 @@ +The SCTM, PWM, GPTM, and MCTM timer have similar architecture. They use the same driver, +"ht32fxxxxx_tm.c/.h" to save the code size. For those timers, please refet to the TM driver/example. diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwrcu.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwrcu.c new file mode 100644 index 0000000000..82f0fdb62a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_pwrcu.c @@ -0,0 +1,665 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_pwrcu.c + * @version $Rev:: 2970 $ + * @date $Date:: 2023-10-25 #$ + * @brief This file provides all the Power Control Unit firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_pwrcu.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup PWRCU PWRCU + * @brief PWRCU driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Private_Define PWRCU private definitions + * @{ + */ +#define APBCCR1_ADDR (HT_CKCU_BASE + 0x30) +#define BAKCR_ADDR (HT_PWRCU_BASE + 0x04) +#define LVDCSR_ADDR (HT_PWRCU_BASE + 0x10) + +#define BB_ADCEN BitBand(APBCCR1_ADDR, 24) +#define BB_RTCEN BitBand(APBCCR1_ADDR, 6) + +#define BB_LDOLCM BitBand(BAKCR_ADDR, 2) +#define BB_LDOOFF BitBand(BAKCR_ADDR, 3) +#define BB_DMOSON BitBand(BAKCR_ADDR, 7) +#define BB_WUPEN BitBand(BAKCR_ADDR, 8) +#define BB_WUPIEN BitBand(BAKCR_ADDR, 9) +#define BB_VRDYSC BitBand(BAKCR_ADDR, 12) +#define BB_DMOSSTS BitBand(BAKCR_ADDR, 15) + +#define BB_BODEN BitBand(LVDCSR_ADDR, 0) +#define BB_BODRIS BitBand(LVDCSR_ADDR, 1) +#define BB_BODF BitBand(LVDCSR_ADDR, 3) +#define BB_LVDEN BitBand(LVDCSR_ADDR, 16) +#define BB_LVDF BitBand(LVDCSR_ADDR, 19) +#define BB_LVDIWEN BitBand(LVDCSR_ADDR, 20) +#define BB_LVDEWEN BitBand(LVDCSR_ADDR, 21) + +#define LDOFTRM_MASK 0xFFFFFFCF +#define LVDS_MASK 0xFFB9FFFF +#define BAKRST_SET 0x1 +#define BAKTEST_READY 0x27 +#define TIME_OUT 48000000 + +#define SLEEPDEEP_SET 0x04 /*!< Cortex SLEEPDEEP bit */ +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Functions PWRCU exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize Backup domain which contains PWRCU and RTC units. + * @retval None + ************************************************************************************************************/ +void PWRCU_DeInit(void) +{ + HT_PWRCU->CR = BAKRST_SET; + while(HT_PWRCU->CR & 0xFFFFEFFF); /* Skip Bit 12 when wait RESET finish. */ + while (HT_PWRCU->SR); /* Waits until the BAKPORF be cleared by read */ +} + +/*********************************************************************************************************//** + * @brief Waits, until the PWRCU can be accessed. + * @retval PWRCU_TIMEOUT or PWRCU_OK + ************************************************************************************************************/ +PWRCU_Status PWRCU_CheckReadyAccessed(void) +{ + u32 wTimeOutCnt = TIME_OUT; + +#if (!LIBCFG_NO_BACK_DOMAIN) + /* Set the ISO control bit */ + HT_CKCU->LPCR = 0x1; +#endif + + while (--wTimeOutCnt) + { + if (HT_PWRCU->TEST == BAKTEST_READY) + { + #if (!LIBCFG_NO_BACK_DOMAIN) + u32 write = ~HT_PWRCU->BAKREG[9]; + u32 backup = HT_PWRCU->BAKREG[9]; + while (1) + { + HT_PWRCU->BAKREG[9] = write; + if (HT_PWRCU->BAKREG[9] == write) break; + } + HT_PWRCU->BAKREG[9] = backup; + #endif + return PWRCU_OK; + } + } + return PWRCU_TIMEOUT; +} + +/*********************************************************************************************************//** + * @brief Return the flags of PWRCU. + * @retval This function will return one of the following: + * - 0x0000 : There is no flag is set. + * - 0x0001 (PWRCU_FLAG_PWRPOR) : Backup domain power-on reset flag has been set. + * - 0x0002 (PWRCU_FLAG_PD) : Power-Down flag has been set. + * - 0x0100 (PWRCU_FLAG_WUP) : External WAKEUP pin flag has been set. + * - 0x0102 (PWRCU_FLAG_PD | PWRCU_FLAG_WUP) : Both PDF and WUPF flags have been set. + ************************************************************************************************************/ +u16 PWRCU_GetFlagStatus(void) +{ + u32 uRTCStatus = 0; + u32 uStatus; + uRTCStatus = BB_RTCEN; + + BB_RTCEN = 1; + + uStatus = HT_PWRCU->SR; + BB_RTCEN = uRTCStatus; + + return uStatus; +} + +#if (!LIBCFG_NO_BACK_DOMAIN) +/*********************************************************************************************************//** + * @brief Return the value of specified backup register. + * @param BAKREGx: Number of backup register. Where x can be 0 ~ 9. + * @return Between 0x0 ~ 0xFFFFFFFF. + ************************************************************************************************************/ +u32 PWRCU_ReadBackupRegister(PWRCU_BAKREG_Enum BAKREGx) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_BAKREG(BAKREGx)); + + return HT_PWRCU->BAKREG[BAKREGx]; +} + +/*********************************************************************************************************//** + * @brief Write the DATA to specified backup register. + * @param BAKREGx : Number of backup registers. Where x can be 0 ~ 9. + * @param DATA : Must between 0x0 ~ 0xFFFFFFFF. + * @retval None + ************************************************************************************************************/ +void PWRCU_WriteBackupRegister(PWRCU_BAKREG_Enum BAKREGx, u32 DATA) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_BAKREG(BAKREGx)); + + HT_PWRCU->BAKREG[BAKREGx] = DATA; +} +#endif + +/*********************************************************************************************************//** + * @brief Enter SLEEP mode. + * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE. + * This parameter can be one of the following values: + * @arg PWRCU_SLEEP_ENTRY_WFE : Enters SLEEP mode via WFE instruction + * @arg PWRCU_SLEEP_ENTRY_WFI : Enters SLEEP mode via WFI instruction + * @retval None + ************************************************************************************************************/ +void PWRCU_Sleep(PWRCU_SLEEP_ENTRY_Enum SleepEntry) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry)); + + /* Clear SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR &= ~(u32)SLEEPDEEP_SET; + + if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE) + { + /* Wait for event */ + __WFE(); + } + else + { + /* Wait for interrupt */ + __WFI(); + } +} + +/*********************************************************************************************************//** + * @brief Enter DEEP-SLEEP Mode 1. + * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE. + * This parameter can be one of the following values: + * @arg PWRCU_SLEEP_ENTRY_WFE : Enters SLEEP mode via WFE instruction + * @arg PWRCU_SLEEP_ENTRY_WFI : Enters SLEEP mode via WFI instruction + * @retval None + ************************************************************************************************************/ +void PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_Enum SleepEntry) +{ + u32 uRTCStatus = 0; + u32 uADCStatus = 0; + + /* Check the parameters */ + Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry)); + + uRTCStatus = BB_RTCEN; + uADCStatus = BB_ADCEN; + + BB_RTCEN = 1; + BB_ADCEN = 0; + + BB_DMOSON = 0; + BB_LDOOFF = 0; + + BB_RTCEN = uRTCStatus; + /* Sets SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SLEEPDEEP_SET; + + if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE) + { + /* Wait for event */ + __WFE(); + } + else + { + /* Wait for interrupt */ + __WFI(); + } + BB_ADCEN = uADCStatus; +} + +/*********************************************************************************************************//** + * @brief Enter DEEP-SLEEP Mode 2. + * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE. + * This parameter can be one of the following values: + * @arg PWRCU_SLEEP_ENTRY_WFE : Enters SLEEP mode via WFE instruction + * @arg PWRCU_SLEEP_ENTRY_WFI : Enters SLEEP mode via WFI instruction + * @retval None + ************************************************************************************************************/ +void PWRCU_DeepSleep2(PWRCU_SLEEP_ENTRY_Enum SleepEntry) +{ + u32 uRTCStatus = 0; + u32 uADCStatus = 0; + #if (!LIBCFG_PWRCU_LDO_LEGACY) + u32 uLDOStatus = 0; + #endif + + /* Check the parameters */ + Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry)); + + uRTCStatus = BB_RTCEN; + uADCStatus = BB_ADCEN; + + BB_RTCEN = 1; + BB_ADCEN = 0; + + if (BB_DMOSSTS == 0) + { + BB_DMOSON = 0; + BB_DMOSON = 1; + } + BB_LDOOFF = 0; + + BB_RTCEN = uRTCStatus; + + #if (!LIBCFG_PWRCU_LDO_LEGACY) + uLDOStatus = HT_PWRCU->CR & ~LDOFTRM_MASK; + if (uLDOStatus >= PWRCU_LDO_OFFSET_ADD3P) + { + CKCU_PSRCWKUPCmd(ENABLE); + } + #endif + + /* Sets SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SLEEPDEEP_SET; + + if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE) + { + /* Wait for event */ + __WFE(); + } + else + { + /* Wait for interrupt */ + __WFI(); + } + + #if (!LIBCFG_PWRCU_LDO_LEGACY) + if (uLDOStatus >= PWRCU_LDO_OFFSET_ADD3P) + { + PWRCU_SetLDOFTRM((PWRCU_LDOFTRM_Enum)uLDOStatus); + CKCU_PSRCWKUPCmd(DISABLE); + + if ((HT_CKCU->GCCR >> 9) & 1) + { + while (CKCU_GetClockReadyStatus(CKCU_FLAG_PLLRDY) != SET); + } + } + #endif + + BB_ADCEN = uADCStatus; +} + +/*********************************************************************************************************//** + * @brief Enter POWER-DOWN Mode. + * @retval None + ************************************************************************************************************/ +void PWRCU_PowerDown(void) +{ + u32 uRTCStatus = 0; + u32 uADCStatus = 0; + + uRTCStatus = BB_RTCEN; + uADCStatus = BB_ADCEN; + + BB_RTCEN = 1; + BB_ADCEN = 0; + + #if (LIBCFG_RTC_LSI_LOAD_TRIM) + { + static u8 isLSITrimLoaded = FALSE; + if (isLSITrimLoaded == FALSE) + { + u32 i = 9600; + isLSITrimLoaded = TRUE; + HT_RTC->CR &= ~(1UL << 2); + /* Insert a delay must > 1 CK_RTC */ + while (i--); + HT_RTC->CR |= (1UL << 2); + while ((HT_CKCU->GCSR & 0x20) == 0); + } + } + #endif + + BB_DMOSON = 0; + BB_LDOOFF = 1; + + BB_RTCEN = uRTCStatus; + + /* Sets SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SLEEPDEEP_SET; + + /* Enters power-down mode */ + __WFE(); + + BB_ADCEN = uADCStatus; +} + +#if (LIBCFG_PWRCU_LDO_LEGACY) +#else +/*********************************************************************************************************//** + * @brief Configure LDO output voltage fine trim. + * @param VolOffset: LDO default output voltage offset. + * This parameter can be one of following: + * @arg PWRCU_LDO_DEFAULT : default output voltage + * @arg PWRCU_LDO_OFFSET_DEC5P : default output voltage offset -5% + * @arg PWRCU_LDO_OFFSET_ADD3P : default output voltage offset +3% + * @arg PWRCU_LDO_OFFSET_ADD7P : default output voltage offset +7% + * @retval None + ************************************************************************************************************/ +void PWRCU_SetLDOFTRM(PWRCU_LDOFTRM_Enum VolOffset) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_LDOFTRM(VolOffset)); + + do { + HT_PWRCU->CR = (HT_PWRCU->CR & LDOFTRM_MASK) | VolOffset; + } while ((HT_PWRCU->CR & ~LDOFTRM_MASK) != VolOffset); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure LVD voltage level. + * @param Level: Low voltage detect level. + * This parameter can be one of the following: + * HT32F165x: + * @arg PWRCU_LVDS_2V7 : 2.7 V + * @arg PWRCU_LVDS_2V8 : 2.9 V + * @arg PWRCU_LVDS_2V9 : 2.9 V + * @arg PWRCU_LVDS_3V : 3.0 V + * @arg PWRCU_LVDS_3V1 : 3.1 V + * @arg PWRCU_LVDS_3V2 : 3.2 V + * @arg PWRCU_LVDS_3V4 : 3.4 V + * @arg PWRCU_LVDS_3V5 : 3.5 V + * HT32F123xx: + * @arg PWRCU_LVDS_2V25 : 2.25 V + * @arg PWRCU_LVDS_2V4 : 2.40 V + * @arg PWRCU_LVDS_2V55 : 2.55 V + * @arg PWRCU_LVDS_2V7 : 2.70 V + * @arg PWRCU_LVDS_2V85 : 2.85 V + * @arg PWRCU_LVDS_3V : 3.00 V + * @arg PWRCU_LVDS_3V15 : 3.15 V + * @arg PWRCU_LVDS_3V3 : 3.30 V + * HT32F12364: + * @arg PWRCU_LVDS_1V75 : 1.75 V + * @arg PWRCU_LVDS_1V95 : 1.95 V + * @arg PWRCU_LVDS_2V15 : 2.15 V + * @arg PWRCU_LVDS_2V35 : 2.35 V + * @arg PWRCU_LVDS_2V55 : 2.55 V + * @arg PWRCU_LVDS_2V75 : 2.75 V + * @arg PWRCU_LVDS_2V95 : 2.95 V + * @arg PWRCU_LVDS_3V15 : 3.15 V + * @retval None + ************************************************************************************************************/ +void PWRCU_SetLVDS(PWRCU_LVDS_Enum Level) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_LVDS(Level)); + + HT_PWRCU->LVDCSR = (HT_PWRCU->LVDCSR & LVDS_MASK) | Level; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable LVD function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_LVDCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + BB_LVDEN = NewState; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable BOD reset function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_BODCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + BB_BODEN = NewState; +} + +/*********************************************************************************************************//** + * @brief Select when the BOD occurs, the action for the cause Reset or Interrupt. + * @param Selection: BOD reset or interrupt selection. + * This parameter can be one of the following values: + * @arg PWRCU_BODRIS_RESET : Reset the whole chip + * @arg PWRCU_BODRIS_INT : Assert interrupt + * @retval None + ************************************************************************************************************/ +void PWRCU_BODRISConfig(PWRCU_BODRIS_Enum Selection) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_BODRIS(Selection)); + + BB_BODRIS = Selection; +} + +/*********************************************************************************************************//** + * @brief Return the flag status of LVD. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus PWRCU_GetLVDFlagStatus(void) +{ + return (FlagStatus)BB_LVDF; +} + +/*********************************************************************************************************//** + * @brief Return the flag status of BOD. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus PWRCU_GetBODFlagStatus(void) +{ + return (FlagStatus)BB_BODF; +} + +/*********************************************************************************************************//** + * @brief Return the DMOS status. + * @retval This function will return one of the following values: + * - PWRCU_DMOS_STS_ON : DMOS on + * - PWRCU_DMOS_STS_OFF : DMOS off + * - PWRCU_DMOS_STS_OFF_BY_BODRESET : DMOS off caused by brow out reset + ************************************************************************************************************/ +PWRCU_DMOSStatus PWRCU_GetDMOSStatus(void) +{ + u32 wDmosStatus = HT_PWRCU->CR & 0x8080; + + if (wDmosStatus == 0x0) + { + return PWRCU_DMOS_STS_OFF; + } + else if (wDmosStatus == 0x8080) + { + return PWRCU_DMOS_STS_ON; + } + else + { + return PWRCU_DMOS_STS_OFF_BY_BODRESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable DMOS function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_DMOSCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (BB_DMOSSTS == 0) + { + BB_DMOSON = 0; + } + + BB_DMOSON = NewState; +} + +#if (LIBCFG_PWRCU_LDO_LEGACY) +#else +/*********************************************************************************************************//** + * @brief Configure the LDO operation mode. + * @param Sel: Specify the LDO mode. + * This parameter can be one of the following values: + * @arg PWRCU_LDO_NORMAL : The LDO is operated in normal current mode + * @arg PWRCU_LDO_LOWCURRENT : The LDO is operated in low current mode + * @retval None + ************************************************************************************************************/ +void PWRCU_LDOConfig(PWRCU_LDOMODE_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_LDOMODE(Sel)); + + if (Sel == PWRCU_LDO_NORMAL) + { + BB_LDOLCM = 0; + } + else + { + BB_LDOLCM = 1; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Configure VDD18/VDD15 power good source. + * @param Sel: Specify VDD18/VDD15 power good source. + * This parameter can be one of the following values: + * @arg PWRCU_VRDYSC_BKISO : Vdd18/Vdd15 power good source come from BK_ISO bit in CKCU unit + * @arg PWRCU_VRDYSC_VPOR : Vdd18/Vdd15 power good source come from Vdd18/Vdd15 power on reset + * @retval None + ************************************************************************************************************/ +void PWRCU_VRDYSourceConfig(PWRCU_VRDYSC_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_VRDYSC(Sel)); + + BB_VRDYSC = Sel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the LVD interrupt wakeup function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_LVDIntWakeupConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + BB_LVDIWEN = NewState; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the LVD event wakeup function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_LVDEventWakeupConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + BB_LVDEWEN = NewState; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the external WAKEUP pin function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_WakeupPinCmd(ControlStatus NewState) +{ + u32 uRTCStatus = 0; + + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + uRTCStatus = BB_RTCEN; + + BB_RTCEN = 1; + + BB_WUPEN = NewState; + + BB_RTCEN = uRTCStatus; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the external WAKEUP pin interrupt function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_WakeupPinIntConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + BB_WUPIEN = NewState; +} + +#if (LIBCFG_PWRCU_HSI_READY_COUNTER) +/*********************************************************************************************************//** + * @brief Configure HSI ready counter bit length. + * @param BitLength: HSI ready counter bit length. + * This parameter can be one of following: + * @arg PWRCU_HSIRCBL_4 : 4 bits + * @arg PWRCU_HSIRCBL_5 : 5 bits + * @arg PWRCU_HSIRCBL_6 : 6 bits + * @arg PWRCU_HSIRCBL_7 : 7 bits (Default) + * @retval None + ************************************************************************************************************/ +void PWRCU_HSIReadyCounterBitLengthConfig(PWRCU_HSIRCBL_Enum BitLength) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_HSIRCBL(BitLength)); + + HT_PWRCU->HSIRCR = BitLength; +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rstcu.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rstcu.c new file mode 100644 index 0000000000..e4ac9f5b9d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rstcu.c @@ -0,0 +1,142 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_rstcu.c + * @version $Rev:: 2787 $ + * @date $Date:: 2022-11-23 #$ + * @brief This file provides all the Reset Control Unit firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_rstcu.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup RSTCU RSTCU + * @brief RSTCU driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Functions RSTCU exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Check whether the specific global reset flag is set or not. + * @param RSTCU_RSTF: specify the reset flag. + * This parameter can be one of the following values: + * @arg RSTCU_FLAG_SYSRST : Get system reset flag + * @arg RSTCU_FLAG_EXTRST : Get external pin reset flag + * @arg RSTCU_FLAG_WDTRST : Get WDT reset flag + * @arg RSTCU_FLAG_PORST : Get power on reset flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus RSTCU_GetResetFlagStatus(RSTCU_RSTF_TypeDef RSTCU_RSTF) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_RSTCU_FLAG(RSTCU_RSTF)); + + tmp = (HT_RSTCU->GRSR & ((u32)0x1 << RSTCU_RSTF)); + if (tmp != RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specific global reset flag. + * @param RSTCU_RSTF: specify the reset flag. + * This parameter can be one of the following values: + * @arg RSTCU_FLAG_SYSRST : Clear system reset flag + * @arg RSTCU_FLAG_EXTRST : Clear external pin reset flag + * @arg RSTCU_FLAG_WDTRST : Clear WDT reset flag + * @arg RSTCU_FLAG_PORST : Clear power on reset flag + * @retval None + ************************************************************************************************************/ +void RSTCU_ClearResetFlag(RSTCU_RSTF_TypeDef RSTCU_RSTF) +{ + /* Check the parameters */ + Assert_Param(IS_RSTCU_FLAG(RSTCU_RSTF)); + + HT_RSTCU->GRSR = (u32)0x1 << RSTCU_RSTF; /* Write 1 to clear */ +} + +/*********************************************************************************************************//** + * @brief Clear all of the global reset flag. + * @retval None + ************************************************************************************************************/ +void RSTCU_ClearAllResetFlag(void) +{ + HT_RSTCU->GRSR = (u32)0xF; /* Write 1 to clear */ +} + +/*********************************************************************************************************//** + * @brief Peripheral reset function. + * @param Reset: specify the peripheral clock enable bits. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RSTCU_PeripReset(RSTCU_PeripReset_TypeDef Reset, ControlStatus Cmd) +{ + u32 uAHBPRST; + u32 uAPBPRST0; + u32 uAPBPRST1; + + uAHBPRST = HT_RSTCU->AHBPRST; + uAPBPRST0 = HT_RSTCU->APBPRST0; + uAPBPRST1 = HT_RSTCU->APBPRST1; + + uAHBPRST &= ~(Reset.Reg[0]); + uAPBPRST0 &= ~(Reset.Reg[1]); + uAPBPRST1 &= ~(Reset.Reg[2]); + + if (Cmd != DISABLE) + { + uAHBPRST |= Reset.Reg[0]; + uAPBPRST0 |= Reset.Reg[1]; + uAPBPRST1 |= Reset.Reg[2]; + } + + HT_RSTCU->AHBPRST = uAHBPRST; + HT_RSTCU->APBPRST0 = uAPBPRST0; + HT_RSTCU->APBPRST1 = uAPBPRST1; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rtc.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rtc.c new file mode 100644 index 0000000000..6c8a2638a7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_rtc.c @@ -0,0 +1,372 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_rtc.c + * @version $Rev:: 2233 $ + * @date $Date:: 2020-10-13 #$ + * @brief This file provides all the RTC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_rtc.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup RTC RTC + * @brief RTC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Private_Define RTC private definitions + * @{ + */ +#define RTC_CR_ADDR (HT_RTC_BASE + 0x008) +#define BB_RTCEN BitBand(RTC_CR_ADDR, 0) +#define BB_RTCSRC BitBand(RTC_CR_ADDR, 1) +#define BB_LSI_EN BitBand(RTC_CR_ADDR, 2) +#define BB_LSE_EN BitBand(RTC_CR_ADDR, 3) +#define BB_CMPCLR BitBand(RTC_CR_ADDR, 4) +#define BB_SOP BitBand(RTC_CR_ADDR, 5) +#define BB_ROEN BitBand(RTC_CR_ADDR, 16) +#define BB_ROES BitBand(RTC_CR_ADDR, 17) +#define BB_ROWM BitBand(RTC_CR_ADDR, 18) +#define BB_ROAP BitBand(RTC_CR_ADDR, 19) +#define BB_ROLF BitBand(RTC_CR_ADDR, 20) +#define RPRE_MASK (0xFFFFF0FF) + +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Functions RTC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the RTC peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void RTC_DeInit(void) +{ + HT_RTC->CR = 0x00000004; + HT_RTC->CMP = 0x0; + HT_RTC->IWEN = 0x0; + HT_RTC->CR |= 0x00000005; + while (HT_RTC->CNT); + HT_RTC->CR = 0x00000F04; + /* Read the RTC_SR register to clear it */ + HT_RTC->SR; +} + +/*********************************************************************************************************//** + * @brief Select the RTC timer clock source. + * @param Source: specify the clock source of RTC and backup domain. + * @arg RTC_SRC_LSI : Low speed internal clock. + * @arg RTC_SRC_LSE : Low speed external clock. + * @retval None + ************************************************************************************************************/ +void RTC_ClockSourceConfig(RTC_SRC_Enum Source) +{ + Assert_Param(IS_RTC_SRC(Source)); + + BB_RTCSRC = Source; +} + +#if (LIBCFG_RTC_LSI_LOAD_TRIM) +/*********************************************************************************************************//** + * @brief Loads the LSI trim data. + * @retval None + ************************************************************************************************************/ +void RTC_LSILoadTrimData(void) +{ + u32 i = 9600; + + HT_RTC->CR &= ~(1UL << 2); + /* Insert a delay must > 1 CK_RTC */ + while (i--); + HT_RTC->CR |= (1UL << 2); + while ((HT_CKCU->GCSR & 0x20) == 0); +} +#endif + +/*********************************************************************************************************//** + * @brief Select the LSE startup mode. + * @param Mode: specify the LSE startup mode. + * This parameter can be one of the following values: + * @arg RTC_LSESM_NORMAL : Little power consumption but longer startup time. + * @arg RTC_LSESM_FAST : Shortly startup time but higher power consumption. + * @retval None + ************************************************************************************************************/ +void RTC_LSESMConfig(RTC_LSESM_Enum Mode) +{ + Assert_Param(IS_RTC_LSESM(Mode)); + + BB_SOP = Mode; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the LSE clock. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_LSECmd(ControlStatus NewState) +{ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == DISABLE) + { + BB_LSE_EN = 0; + while (HT_CKCU->GCSR & 0x10); + } + else + { + BB_LSE_EN = 1; + while ((HT_CKCU->GCSR & 0x10) == 0); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the compare match function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_CMPCLRCmd(ControlStatus NewState) +{ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + BB_CMPCLR = NewState; +} + +/*********************************************************************************************************//** + * @brief Configure the RTC prescaler. + * @param Psc: Value of RTC prescaler. + * This parameter can be one of following values: + * @arg RTC_RPRE_1 + * @arg RTC_RPRE_2 + * @arg RTC_RPRE_4 + * @arg RTC_RPRE_8 + * @arg RTC_RPRE_16 + * @arg RTC_RPRE_32 + * @arg RTC_RPRE_64 + * @arg RTC_RPRE_128 + * @arg RTC_RPRE_256 + * @arg RTC_RPRE_512 + * @arg RTC_RPRE_1024 + * @arg RTC_RPRE_2048 + * @arg RTC_RPRE_4096 + * @arg RTC_RPRE_8192 + * @arg RTC_RPRE_16384 + * @arg RTC_RPRE_32768 + * @retval None + ************************************************************************************************************/ +void RTC_SetPrescaler(RTC_RPRE_Enum Psc) +{ + Assert_Param(IS_RTC_PSC(Psc)); + + HT_RTC->CR = (HT_RTC->CR & RPRE_MASK) | Psc; +} + +/*********************************************************************************************************//** + * @brief Return the RTC prescaler setting. + * @retval The prescaler value. It is powered by 2 and max.is 32768. + ************************************************************************************************************/ +u16 RTC_GetPrescaler(void) +{ + u32 prescaler; + + prescaler = HT_RTC->CR >> 8; + + return ((u16)0x1 << prescaler); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the RTC timer. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_Cmd(ControlStatus NewState) +{ + BB_RTCEN = NewState; +} + +/*********************************************************************************************************//** + * @brief Return the counter value. + * @retval Between 0x0 ~ 0xFFFFFFFF. + ************************************************************************************************************/ +u32 RTC_GetCounter(void) +{ + /* !!! NOTICE !!! + A 1/CK_RTC delay time is required if you read the RTC CNT count immediately when the RTC compare match + occurred (in the RTC ISR or the system is wakeup from the DeepSleep1/2). + The CK_RTC can be configured from the LSI or LSE. + */ + return (HT_RTC->CNT); +} + +/*********************************************************************************************************//** + * @brief Configure the compare match value. + * @param Compare: Between 0x0 ~ 0xFFFFFFFF + * @retval None + ************************************************************************************************************/ +void RTC_SetCompare(u32 Compare) +{ + HT_RTC->CMP = Compare; +} + +/*********************************************************************************************************//** + * @brief Return the compare match value. + * @retval Between 0x0 ~ 0xFFFFFFFF. + ************************************************************************************************************/ +u32 RTC_GetCompare(void) +{ + return (HT_RTC->CMP); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified wakeup source. + * @param RTC_WAKEUP Selection of Wakeup source. + * This parameter can be any combination of the following values: + * @arg RTC_WAKEUP_CSEC : Waken up by counter counting. + * @arg RTC_WAKEUP_CM : Waken up by counter compare match with CMP register. + * @arg RTC_WAKEUP_OV : Waken up by counter overflow. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_WakeupConfig(u32 RTC_WAKEUP, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_RTC_WAKEUP(RTC_WAKEUP)); + + if (NewState != DISABLE) + { + HT_RTC->IWEN |= RTC_WAKEUP; + } + else + { + HT_RTC->IWEN &= ~RTC_WAKEUP; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified interrupt source. + * @param RTC_INT: Selection of Wakeup source. + * This parameter can be any combination of the following values: + * @arg RTC_INT_CSEC : Assert interrupt at counter counting + * @arg RTC_INT_CM : Assert interrupt at counter compare match with CMP register + * @arg RTC_INT_OV : Assert interrupt at counter overflow + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_IntConfig(u32 RTC_INT, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_RTC_INT(RTC_INT)); + + if (NewState != DISABLE) + { + HT_RTC->IWEN |= RTC_INT; + } + else + { + HT_RTC->IWEN &= ~RTC_INT; + } +} + +/*********************************************************************************************************//** + * @brief Return the RTC flags. + * @retval RTC_STS register value. + * This parameter can be any combination of following: + * - 0x0 : No flag set + * - 0x1 : Count flag + * - 0x2 : Match flag + * - 0x4 : Overflow flag + * @note RTC_SR is read clear. + ************************************************************************************************************/ +u8 RTC_GetFlagStatus(void) +{ + return ((u8)HT_RTC->SR); +} + +/*********************************************************************************************************//** + * @brief Configure the RTC output function. + * @param WMode: specify the RTC output waveform mode + * This parameter can be one of the following values: + * @arg RTC_ROWM_PULSE : Pulse mode + * @arg RTC_ROWM_LEVEL : Level mode + * @param EventSel: specify the RTC output event selection + * This parameter can be one of the following values: + * @arg RTC_ROES_MATCH : Compare match selected + * @arg RTC_ROES_SECOND : Second clock selected + * @param Pol: specify the RTC output active polarity + * This parameter can be one of the following values: + * @arg RTC_ROAP_HIGH : Active level is high + * @arg RTC_ROAP_LOW : Active level is low + * @note This function will disable RTC output first. + ************************************************************************************************************/ +void RTC_OutConfig(RTC_ROWM_Enum WMode, RTC_ROES_Enum EventSel, RTC_ROAP_Enum Pol) +{ + Assert_Param(IS_RTC_ROWM(WMode)); + Assert_Param(IS_RTC_ROES(EventSel)); + Assert_Param(IS_RTC_ROAP(Pol)); + + BB_ROEN = 0; + BB_ROWM = WMode; + BB_ROES = EventSel; + BB_ROAP = Pol; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the RTC output. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_OutCmd(ControlStatus NewState) +{ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + BB_ROEN = NewState; +} + +/*********************************************************************************************************//** + * @brief Return the RTCOUT level mode flag. + * @retval SET or RESET + * @note Reads RTC_CR action will clear ROLF flag. + ************************************************************************************************************/ +FlagStatus RTC_GetOutStatus(void) +{ + return (FlagStatus)BB_ROLF; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sci.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sci.c new file mode 100644 index 0000000000..f3c826ae15 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sci.c @@ -0,0 +1,444 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_sci.c + * @version $Rev:: 2797 $ + * @date $Date:: 2022-11-28 #$ + * @brief This file provides all the SCI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_sci.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup SCI SCI + * @brief SCI driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Private_Define SCI private definitions + * @{ + */ +/* SCI ENSCI mask */ +#define CR_ENSCI_SET ((u32)0x00000020) +#define CR_ENSCI_RESET ((u32)0xFFFFFFDF) + +/* SCI WTEN mask */ +#define CR_WTEN_SET ((u32)0x00000004) +#define CR_WTEN_RESET ((u32)0xFFFFFFFB) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Functions SCI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the SCI peripheral registers to their default reset values. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @retval None + ************************************************************************************************************/ +void SCI_DeInit(HT_SCI_TypeDef* SCIx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + if (SCIx == HT_SCI0) + { + RSTCUReset.Bit.SCI0 = 1; + } + #if (LIBCFG_SCI1) + else + { + RSTCUReset.Bit.SCI1 = 1; + } + #endif + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the SCI peripheral according to the specified parameters in the SCI_InitStruct. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_InitStruct: pointer to a SCI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SCI_Init(HT_SCI_TypeDef* SCIx, SCI_InitTypeDef* SCI_InitStruct) +{ + u32 tmpreg; + + /* Check the parameters */ + Assert_Param(IS_SCI_MODE(SCI_InitStruct->SCI_Mode)); + Assert_Param(IS_SCI_RETRY(SCI_InitStruct->SCI_Retry)); + Assert_Param(IS_SCI_CONVENTION(SCI_InitStruct->SCI_Convention)); + Assert_Param(IS_SCI_CARD_POLARITY(SCI_InitStruct->SCI_CardPolarity)); + Assert_Param(IS_SCI_CLOCK_PRESCALER(SCI_InitStruct->SCI_ClockPrescale)); + + + /*------------------------- SCI Control Register Configuration -------------------------------------------*/ + tmpreg = SCIx->CR; + tmpreg &= 0xFFFFFFA4; + + tmpreg |= SCI_InitStruct->SCI_Mode | SCI_InitStruct->SCI_Retry | SCI_InitStruct->SCI_Convention | + SCI_InitStruct->SCI_CardPolarity; + + SCIx->CR = tmpreg; + + /*------------------------- SCI Prescaler Register Configuration -----------------------------------------*/ + SCIx->PSC = SCI_InitStruct->SCI_ClockPrescale; +} + +/*********************************************************************************************************//** + * @brief Initialize the SCI peripheral according to the specified parameters in the SCI_InitStruct. + * @param SCI_InitStruct: pointer to a SCI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SCI_StructInit(SCI_InitTypeDef* SCI_InitStruct) +{ + /* Initialize the SCI_Mode member */ + SCI_InitStruct->SCI_Mode = SCI_MODE_MANUAL; + + /* Initialize the SCI_Retry member */ + SCI_InitStruct->SCI_Retry = SCI_RETRY_NO; + + /* Initialize the SCI_Convention member */ + SCI_InitStruct->SCI_Convention = SCI_CONVENTION_DIRECT; + + /* Initialize the SCI_CardPolarity member */ + SCI_InitStruct->SCI_CardPolarity = SCI_CARDPOLARITY_LOW; + + /* Initialize the SCI_ClockPrescale member */ + SCI_InitStruct->SCI_ClockPrescale = SCI_CLKPRESCALER_1; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SCI peripheral. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_Cmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->CR |= CR_ENSCI_SET; + } + else + { + SCIx->CR &= CR_ENSCI_RESET; + } +} + +/*********************************************************************************************************//** + * @brief This function is used to configure the Elementary Time Unit. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_ETU: specify the SCI Elementary Time Unit. + * @param SCI_Compensation: Enable or Disable the Compensation mode. + * This parameter can be one of the following values: + * @arg SCI_COMPENSATION_ENABLE : Compensation mode enabled + * @arg SCI_COMPENSATION_DISABLE : Compensation mode disabled + * @retval None + ************************************************************************************************************/ +void SCI_ETUConfig(HT_SCI_TypeDef* SCIx, u32 SCI_ETU, u32 SCI_Compensation) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_ETU(SCI_ETU)); + Assert_Param(IS_SCI_ETU_COMPENSATION(SCI_Compensation)); + + SCIx->ETU = SCI_ETU | SCI_Compensation; +} + +/*********************************************************************************************************//** + * @brief This function is used to set the value of SCI GuardTime. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_GuardTime: specify the value of SCI GuardTime value. + * @retval None + ************************************************************************************************************/ +void SCI_SetGuardTimeValue(HT_SCI_TypeDef* SCIx, u16 SCI_GuardTime) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_GUARDTIME(SCI_GuardTime)); + + SCIx->GT = SCI_GuardTime; +} + +/*********************************************************************************************************//** + * @brief This function is used to set the value of SCI Waiting Time. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_WaitingTime: specify the value of SCI Waiting Time value. + * @retval None + ************************************************************************************************************/ +void SCI_SetWaitingTimeValue(HT_SCI_TypeDef* SCIx, u32 SCI_WaitingTime) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_WAITING_TIME(SCI_WaitingTime)); + + SCIx->WT = SCI_WaitingTime; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the Waiting Time Counter. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_WaitingTimeCounterCmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->CR |= CR_WTEN_SET; + } + else + { + SCIx->CR &= CR_WTEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Sends a data byte through the SCI peripheral. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Data: byte to be transmitted. + * @retval None + ************************************************************************************************************/ +void SCI_SendData(HT_SCI_TypeDef* SCIx, u8 SCI_Data) +{ + SCIx->TXB = SCI_Data; +} + +/*********************************************************************************************************//** + * @brief Returns the received data through the SCI peripheral. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @retval The value of the received data. + ************************************************************************************************************/ +u8 SCI_ReceiveData(HT_SCI_TypeDef* SCIx) +{ + return ((u8)SCIx->RXB); +} + +/*********************************************************************************************************//** + * @brief Determines the SCI output clock signal is driven by hardware or software. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_CLKMode: specify the SCI clock pin mode. + * This parameter can be one of the following values: + * @arg SCI_CLK_SOFTWARE : SCI output clock is controlled by software + * @arg SCI_CLK_HARDWARE : SCI output clock is controlled by hardware + * @retval None + ************************************************************************************************************/ +void SCI_ClockModeConfig(HT_SCI_TypeDef* SCIx, u32 SCI_CLKMode) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_CLK_MODE(SCI_CLKMode)); + + if (SCI_CLKMode != SCI_CLK_SOFTWARE) + { + SCIx->CCR |= SCI_CLK_HARDWARE; + } + else + { + SCIx->CCR &= SCI_CLK_SOFTWARE; + } +} + +/*********************************************************************************************************//** + * @brief Output the SCI clock pin low or high by software. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_CLK: specify if the SCI clock pin to be high or low. + * This parameter can be one of the following values: + * @arg SCI_CLK_HIGH : Software drive SCI output clock high + * @arg SCI_CLK_LOW : Software drive SCI output clock low + * @retval None + ************************************************************************************************************/ +void SCI_SoftwareClockCmd(HT_SCI_TypeDef* SCIx, u32 SCI_CLK) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_CLK(SCI_CLK)); + + if (SCI_CLK != SCI_CLK_LOW) + { + SCIx->CCR |= SCI_CLK_HIGH; + } + else + { + SCIx->CCR &= SCI_CLK_LOW; + } +} + +/*********************************************************************************************************//** + * @brief Output the SCI DIO pin low or high by software. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_DIO: specify if the SCI DIO pin to be high or low. + * This parameter can be one of the following values: + * @arg SCI_DIO_HIGH : Drive SCI DIO signal high + * @arg SCI_DIO_LOW : Drive SCI DIO signal low + * @retval None + ************************************************************************************************************/ +void SCI_OutputDIO(HT_SCI_TypeDef* SCIx, u32 SCI_DIO) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_DIO(SCI_DIO)); + + if (SCI_DIO != SCI_DIO_LOW) + { + SCIx->CCR |= SCI_DIO_HIGH; + } + else + { + SCIx->CCR &= SCI_DIO_LOW; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SCI interrupt. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Int: specify the SCI interrupt source to be enabled or disable. + * This parameter can be any combination of the following values: + * @arg SCI_INT_PAR : SCI parity error interrupt + * @arg SCI_INT_RXC : SCI received character interrupt + * @arg SCI_INT_TXC : SCI transmitted character interrupt + * @arg SCI_INT_WT : SCI waiting timer interrupt + * @arg SCI_INT_CARD : SCI card insert/remove interrupt + * @arg SCI_INT_TXBE : SCI transmit buffer empty interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_IntConfig(HT_SCI_TypeDef* SCIx, u32 SCI_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_INT(SCI_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->IER |= SCI_Int; + } + else + { + SCIx->IER &= ~SCI_Int; + } +} + +/*********************************************************************************************************//** + * @brief Get the status of specified SCI flag. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg SCI_FLAG_PAR : SCI parity error flag + * @arg SCI_FLAG_RXC : SCI received character flag + * @arg SCI_FLAG_TXC : SCI transmitted character flag + * @arg SCI_FLAG_WT : SCI waiting timer flag + * @arg SCI_FLAG_CARD : SCI card insert/remove flag + * @arg SCI_FLAG_TXBE : SCI transmit buffer empty flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus SCI_GetFlagStatus(HT_SCI_TypeDef* SCIx, u32 SCI_Flag) +{ + u32 statusreg = 0; + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + Assert_Param(IS_SCI_FLAG(SCI_Flag)); + + statusreg = SCIx->SR; + + if ((statusreg & SCI_Flag) != (u32)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Clears the flag status of specified SCI flag. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Flag: specify the flag to be cleared. + * This parameter can be one of the following values: + * @arg SCI_FLAG_PAR : SCI parity error flag + * @arg SCI_FLAG_TXC : SCI transmitted character flag + * @arg SCI_FLAG_WT : SCI waiting timer flag + * @retval None + ************************************************************************************************************/ +void SCI_ClearFlag(HT_SCI_TypeDef* SCIx, u32 SCI_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_CLEAR_FLAG(SCI_Flag)); + + if (SCI_Flag != SCI_FLAG_WT) + { + SCIx->SR &= ~SCI_Flag; + } + else + { + SCIx->CR &= CR_WTEN_RESET; + SCIx->CR |= CR_WTEN_SET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or disables the SCI PDMA interface. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_PDMAREQ: specify the SCI PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg SCI_PDMAREQ_TX : Tx PDMA transfer request + * @arg SCI_PDMAREQ_RX : Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_PDMACmd(HT_SCI_TypeDef* SCIx, u32 SCI_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_PDMA_REQ(SCI_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->CR |= SCI_PDMAREQ; + } + else + { + SCIx->CR &= ~SCI_PDMAREQ; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sctm.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sctm.c new file mode 100644 index 0000000000..b824c72b16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sctm.c @@ -0,0 +1,2 @@ +The SCTM, PWM, GPTM, and MCTM timer have similar architecture. They use the same driver, +"ht32fxxxxx_tm.c/.h" to save the code size. For those timers, please refet to the TM driver/example. diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sdio.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sdio.c new file mode 100644 index 0000000000..f596560451 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_sdio.c @@ -0,0 +1,355 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_sdio.c + * @version $Rev:: 2459 $ + * @date $Date:: 2021-08-13 #$ + * @brief This file provides all the SDIO firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_sdio.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup SDIO SDIO + * @brief SDIO driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SDIO_Exported_Functions SDIO exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the SDIO peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void SDIO_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.SDIO = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the SDIO peripheral according to the specified parameters in the SDIO_InitStruct. + * @param SDIO_InitStruct: pointer to a SDIO_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct) +{ + u32 t; + + /* Check the parameters */ + Assert_Param(IS_SDIO_CLOC_DIV(SDIO_InitStruct->SDIO_ClockDiv)); + Assert_Param(IS_SDIO_CLOCK_PERIOD(SDIO_InitStruct->SDIO_ClockPeriod)); + Assert_Param(IS_SDIO_CLOCK_POWER_SAVE(SDIO_InitStruct->SDIO_ClockPowerSave)); + Assert_Param(IS_SDIO_BUS_WIDE(SDIO_InitStruct->SDIO_BusWide)); + Assert_Param(IS_SDIO_BUS_MODE(SDIO_InitStruct->SDIO_BusMode)); + + /* Disable the SDIO clock and wait for a while */ + SDIO_ClockCmd(DISABLE); + for (t = 500; t > 0; t--); + + /* Configure SDIO bus and clock */ + HT_SDIO->CR = SDIO_InitStruct->SDIO_BusWide | SDIO_InitStruct->SDIO_BusMode; + + HT_SDIO->CLKCR = SDIO_InitStruct->SDIO_ClockPeriod | SDIO_InitStruct->SDIO_ClockPowerSave | + ((SDIO_InitStruct->SDIO_ClockDiv - 1) << 8); + + /* Enable SDIO bus clock */ + SDIO_ClockCmd(ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or disable the SDIO Clock. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SDIO_ClockCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + BitBand((u32)&HT_SDIO->CLKCR, 2) = Cmd; + } + else + { + BitBand((u32)&HT_SDIO->CLKCR, 2) = Cmd; + } +} + +/*********************************************************************************************************//** + * @brief Initialize the SDIO command according to the specified parameters in the SDIO_CmdInitStruct. + * @param SDIO_CmdInitStruct: pointer to a SDIO_CmdInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_SDIO_CMD_INDEX(SDIO_CmdInitStruct->SDIO_CmdIndex)); + Assert_Param(IS_SDIO_RESPONSE(SDIO_CmdInitStruct->SDIO_Response)); + Assert_Param(IS_SDIO_DATA_PRESENT(SDIO_CmdInitStruct->SDIO_DatPresent)); + Assert_Param(IS_SDIO_CMD_IDX_CHK(SDIO_CmdInitStruct->SDIO_CmdIdxChk)); + Assert_Param(IS_SDIO_CMD_CRC_CHK(SDIO_CmdInitStruct->SDIO_CmdCrcChk)); + + HT_SDIO->ARG = SDIO_CmdInitStruct->SDIO_Argument; + + HT_SDIO->CMD = SDIO_CmdInitStruct->SDIO_CmdIndex | SDIO_CmdInitStruct->SDIO_Response | + SDIO_CmdInitStruct->SDIO_DatPresent | SDIO_CmdInitStruct->SDIO_CmdIdxChk | + SDIO_CmdInitStruct->SDIO_CmdCrcChk; +} + +/*********************************************************************************************************//** + * @brief Return response received from the card for the last command. + * @param SDIO_RESP: Specify the SDIO response register. + * This parameter can be one of the following values: + * @arg SDIO_RESP1 : Response Register 1 + * @arg SDIO_RESP2 : Response Register 2 + * @arg SDIO_RESP3 : Response Register 3 + * @arg SDIO_RESP4 : Response Register 4 + * @retval The Corresponding response register value. + ************************************************************************************************************/ +u32 SDIO_GetResponse(u32 SDIO_RESP) +{ + /* Check the parameters */ + Assert_Param(IS_SDIO_RESP(SDIO_RESP)); + + return(rw((u32)&HT_SDIO->RESP0 + SDIO_RESP)); +} + +/*********************************************************************************************************//** + * @brief Initialize the SDIO data path according to the specified parameters in the SDIO_DataInitStruct. + * @param SDIO_DataInitStruct: pointer to a SDIO_DataInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_SDIO_DATA_BLOCK_COUNT(SDIO_DataInitStruct->SDIO_DataBlockCount)); + Assert_Param(IS_SDIO_DATA_BLOCK_SIZE(SDIO_DataInitStruct->SDIO_DataBlockSize)); + Assert_Param(IS_SDIO_TRANSFER_MODE(SDIO_DataInitStruct->SDIO_TransferMode)); + Assert_Param(IS_SDIO_TRANSFER_DIR(SDIO_DataInitStruct->SDIO_TransferDir)); + Assert_Param(IS_SDIO_DATA_TIMEOUT(SDIO_DataInitStruct->SDIO_DataTimeOut)); + + /* configure DPSM */ + RESET_DPSM(); + HT_SDIO->BLKCNT = SDIO_DataInitStruct->SDIO_DataBlockCount; + HT_SDIO->BLKSIZE = SDIO_DataInitStruct->SDIO_DataBlockSize; + HT_SDIO->TMR = SDIO_DataInitStruct->SDIO_TransferMode | SDIO_DataInitStruct->SDIO_TransferDir; + HT_SDIO->TMOCR = SDIO_DataInitStruct->SDIO_DataTimeOut; +} + +/*********************************************************************************************************//** + * @brief Read one data word from FIFO. + * @return Data received + ************************************************************************************************************/ +u32 SDIO_ReadData(void) +{ + return HT_SDIO->DR; +} + +/*********************************************************************************************************//** + * @brief Write one data word to FIFO. + * @param Data: 32-bit data word to write. + * @retval None + ************************************************************************************************************/ +void SDIO_WriteData(u32 Data) +{ + HT_SDIO->DR = Data; +} + +/*********************************************************************************************************//** + * @brief Return the number of words left to be written to or read from FIFO. + * @return Remaining number of words. + ************************************************************************************************************/ +u32 SDIO_GetFIFOCount(void) +{ + return (HT_SDIO->PSR >> 20); +} + +/*********************************************************************************************************//** + * @brief Enable the SDIO's flag. + * @param SDIO_FLAG: specify the flag to enable. + * This parameter can be one of the following values: + * @arg SDIO_FLAG_CMD_SEND : + * @arg SDIO_FLAG_TRANS_END : + * @arg SDIO_FLAG_BUF_OVERFLOW : + * @arg SDIO_FLAG_BUF_UNDERFLOW : + * @arg SDIO_FLAG_BUF_HALF : + * @arg SDIO_FLAG_BUF_FULL : + * @arg SDIO_FLAG_BUF_EMPTY : + * @arg SDIO_FLAG_CMD_TIMEOUT : + * @arg SDIO_FLAG_CMD_CRCERR : + * @arg SDIO_FLAG_CMD_IDXERR : + * @arg SDIO_FLAG_DATA_TIMEOUT : + * @arg SDIO_FLAG_DATA_CRCERR : + * @arg SDIO_FLAG_CARD_INT : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SDIO_FlagConfig(u32 SDIO_FLAG, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SDIO_FLAG(SDIO_FLAG)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_SDIO->SER |= (SDIO_FLAG); + } + else + { + HT_SDIO->SER &= ~(SDIO_FLAG); + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified SDIO flag is set or not. + * @param SDIO_FLAG: specify the flag to check. + * This parameter can be one of the following values: + * @arg SDIO_FLAG_CMD_SEND : + * @arg SDIO_FLAG_TRANS_END : + * @arg SDIO_FLAG_BUF_OVERFLOW : + * @arg SDIO_FLAG_BUF_UNDERFLOW : + * @arg SDIO_FLAG_BUF_HALF : + * @arg SDIO_FLAG_BUF_FULL : + * @arg SDIO_FLAG_BUF_EMPTY : + * @arg SDIO_FLAG_CMD_TIMEOUT : + * @arg SDIO_FLAG_CMD_CRCERR : + * @arg SDIO_FLAG_CMD_IDXERR : + * @arg SDIO_FLAG_DATA_TIMEOUT : + * @arg SDIO_FLAG_DATA_CRCERR : + * @arg SDIO_FLAG_CARD_INT : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus SDIO_GetFlagStatus(u32 SDIO_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_SDIO_FLAG(SDIO_FLAG)); + + if (HT_SDIO->SR & (SDIO_FLAG)) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the SDIO's pending flags. + * @param SDIO_FLAG: specify the flag to clear. + * This parameter can be one of the following values: + * @arg SDIO_FLAG_CMD_SEND : + * @arg SDIO_FLAG_TRANS_END : + * @arg SDIO_FLAG_BUF_OVERFLOW : + * @arg SDIO_FLAG_BUF_UNDERFLOW : + * @arg SDIO_FLAG_BUF_HALF : + * @arg SDIO_FLAG_BUF_FULL : + * @arg SDIO_FLAG_BUF_EMPTY : + * @arg SDIO_FLAG_ERR : + * @arg SDIO_FLAG_CMD_TIMEOUT : + * @arg SDIO_FLAG_CMD_CRCERR : + * @arg SDIO_FLAG_CMD_ENDERR : + * @arg SDIO_FLAG_CMD_IDXERR : + * @arg SDIO_FLAG_DATA_TIMEOUT : + * @arg SDIO_FLAG_DATA_CRCERR : + * @arg SDIO_FLAG_DATA_ENDERR : + * @arg SDIO_FLAG_CARD_INT : + * @arg SDIO_FLAG_DAT_ERR : + * @arg SDIO_FLAG_CMD_ERR : + * @retval SET or RESET + ************************************************************************************************************/ +void SDIO_ClearFlag(u32 SDIO_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_SDIO_FLAG(SDIO_FLAG)); + + HT_SDIO->SR = (SDIO_FLAG); + + if (SDIO_FLAG & SDIO_FLAG_BUF_OVERFLOW) + { + HT_SDIO->SER &= ~(SDIO_FLAG_BUF_OVERFLOW); + HT_SDIO->SER |= (SDIO_FLAG_BUF_OVERFLOW); + } + if (SDIO_FLAG & SDIO_FLAG_BUF_UNDERFLOW) + { + HT_SDIO->SER &= ~(SDIO_FLAG_BUF_UNDERFLOW); + HT_SDIO->SER |= (SDIO_FLAG_BUF_UNDERFLOW); + } +} + +/*********************************************************************************************************//** + * @brief Clear the SDIO's pending flags. + * @param SDIO_INT: specify the flag to clear. + * This parameter can be one of the following values: + * @arg SDIO_INT_CMD_SEND : + * @arg SDIO_INT_TRANS_END : + * @arg SDIO_INT_BUF_OVERFLOW : + * @arg SDIO_INT_BUF_UNDERFLOW : + * @arg SDIO_INT_BUF_HALF : + * @arg SDIO_INT_BUF_FULL : + * @arg SDIO_INT_BUF_EMPTY : + * @arg SDIO_INT_CMD_TIMEOUT : + * @arg SDIO_INT_CMD_CRCERR : + * @arg SDIO_INT_CMD_IDXERR : + * @arg SDIO_INT_DATA_TIMEOUT : + * @arg SDIO_INT_DATA_CRCERR : + * @arg SDIO_INT_CARD_INT : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval SET or RESET + ************************************************************************************************************/ +void SDIO_IntConfig(u32 SDIO_INT, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SDIO_INT(SDIO_INT)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_SDIO->IER |= (SDIO_INT); + } + else + { + HT_SDIO->IER &= ~(SDIO_INT); + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_spi.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_spi.c new file mode 100644 index 0000000000..c0e8face8c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_spi.c @@ -0,0 +1,623 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_spi.c + * @version $Rev:: 2797 $ + * @date $Date:: 2022-11-28 #$ + * @brief This file provides all the SPI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_spi.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup SPI SPI + * @brief SPI driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Private_Define SPI private definitions + * @{ + */ +/* SPI SPIEN Mask */ +#define CR0_SPIEN_SET (u32)0x00000001 +#define CR0_SPIEN_RESET (u32)0xFFFFFFFE + +/* SPI SELOEN Mask */ +#define CR0_SELOEN_SET (u32)0x00000008 +#define CR0_SELOEN_RESET (u32)0xFFFFFFF7 + +/* SPI SPI DUALEN Mask */ +#define CR0_DUALEN_SET (u32)0x00000040 +#define CR0_DUALEN_RESET (u32)0xFFFFFFBF + +/* SPI SPI GUADTEN Mask */ +#define CR0_GUADTEN_SET (u32)0x00000080 +#define CR0_GUADTEN_RESET (u32)0xFFFFFF7F + +/* SPI FIFOEN Mask */ +#define FCR_FIFOEN_SET (u32)0x00000400 +#define FCR_FIFOEN_RESET (u32)0xFFFFFBFF + +/* SPI DFL Mask */ +#define CR1_DFL_MASK (u32)0x0000000F + +/* SPI FIFO Mask */ +#define FCR_FIFO_MASK (u32)0x0000000F +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Functions SPI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the SPI peripheral registers to their default reset values. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @retval None + ************************************************************************************************************/ +void SPI_DeInit(HT_SPI_TypeDef* SPIx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + + if (SPIx == HT_SPI0) + { + RSTCUReset.Bit.SPI0 = 1; + } + else if (SPIx == HT_SPI1) + { + RSTCUReset.Bit.SPI1 = 1; + } + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the SPIx peripheral according to the specified parameters in the SPI_InitStruct. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SPI_Init(HT_SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode)); + Assert_Param(IS_SPI_FIFO_SET(SPI_InitStruct->SPI_FIFO)); + Assert_Param(IS_SPI_DATALENGTH(SPI_InitStruct->SPI_DataLength)); + Assert_Param(IS_SPI_SEL_MODE(SPI_InitStruct->SPI_SELMode)); + Assert_Param(IS_SPI_SEL_POLARITY(SPI_InitStruct->SPI_SELPolarity)); + Assert_Param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL)); + Assert_Param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA)); + Assert_Param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit)); + Assert_Param(IS_SPI_FIFO_LEVEL(SPI_InitStruct->SPI_RxFIFOTriggerLevel)); + Assert_Param(IS_SPI_FIFO_LEVEL(SPI_InitStruct->SPI_TxFIFOTriggerLevel)); + Assert_Param(IS_SPI_CLOCK_PRESCALER(SPI_InitStruct->SPI_ClockPrescaler)); + + /*---------------------------- SPIx Control Register 2 Configuration -------------------------------------*/ + tmp = SPI_InitStruct->SPI_CPOL; + if (tmp == SPI_CPOL_LOW) + { + tmp |= (0x100 << SPI_InitStruct->SPI_CPHA); + } + else + { + tmp |= (0x200 >> SPI_InitStruct->SPI_CPHA); + } + + SPIx->CR1 = SPI_InitStruct->SPI_Mode | SPI_InitStruct->SPI_DataLength | + SPI_InitStruct->SPI_SELMode | SPI_InitStruct->SPI_SELPolarity | + SPI_InitStruct->SPI_FirstBit | tmp; + + /*---------------------------- SPIx FIFO Control Register Configuration ----------------------------------*/ + SPIx->FCR = SPI_InitStruct->SPI_FIFO | SPI_InitStruct->SPI_TxFIFOTriggerLevel | + (SPI_InitStruct->SPI_RxFIFOTriggerLevel << 4); + + /*---------------------------- SPIx Clock Prescaler Register Configuration -------------------------------*/ + #if (LIBCFG_SPI_CLK_PRE_V01) + SPIx->CPR = (SPI_InitStruct->SPI_ClockPrescaler - 1); + #else + SPIx->CPR = (SPI_InitStruct->SPI_ClockPrescaler / 2) - 1; + #endif +} + +/*********************************************************************************************************//** + * @brief Fill each SPI_InitStruct member with its default value. + * @param SPI_InitStruct: pointer to an SPI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct) +{ + /* Initialize the SPI_Mode member */ + SPI_InitStruct->SPI_Mode = SPI_SLAVE; + + /* Initialize the SPI_FIFO member */ + SPI_InitStruct->SPI_FIFO = SPI_FIFO_DISABLE; + + /* Initialize the SPI_DataLength member */ + SPI_InitStruct->SPI_DataLength = SPI_DATALENGTH_16; + + /* Initialize the SPI_SELMode member */ + SPI_InitStruct->SPI_SELMode = SPI_SEL_SOFTWARE; + + /* Initialize the SPI_SELPolarity member */ + SPI_InitStruct->SPI_SELPolarity = SPI_SELPOLARITY_LOW; + + /* Initialize the SPI_CPOL member */ + SPI_InitStruct->SPI_CPOL = SPI_CPOL_LOW; + + /* Initialize the SPI_CPHA member */ + SPI_InitStruct->SPI_CPHA = SPI_CPHA_FIRST; + + /* Initialize the SPI_FirstBit member */ + SPI_InitStruct->SPI_FirstBit = SPI_FIRSTBIT_MSB; + + /* Initialize the SPI_RxFIFOTriggerLevel member */ + SPI_InitStruct->SPI_RxFIFOTriggerLevel = 0; + + /* Initialize the SPI_TxFIFOTriggerLevel member */ + SPI_InitStruct->SPI_TxFIFOTriggerLevel = 0; + + /* Initialize the SPI_ClockPrescaler member */ + SPI_InitStruct->SPI_ClockPrescaler = 2; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SPI peripheral. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_Cmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected SPI peripheral */ + SPIx->CR0 |= CR0_SPIEN_SET; + } + else + { + /* Disable the selected SPI peripheral */ + SPIx->CR0 &= CR0_SPIEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SEL output for the specified SPI peripheral. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_SELOutputCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->CR0 |= CR0_SELOEN_SET; + } + else + { + SPIx->CR0 &= CR0_SELOEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable SPI FIFO. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_FIFOCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->FCR |= FCR_FIFOEN_SET; + } + else + { + SPIx->FCR &= FCR_FIFOEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Configure the data length for the selected SPI. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_DataLength: specify data length of the SPI. + * @retval None + ************************************************************************************************************/ +void SPI_SetDataLength(HT_SPI_TypeDef* SPIx, u16 SPI_DataLength) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_DATALENGTH(SPI_DataLength)); + + /* Clear DFL[3:0] in CR1 */ + SPIx->CR1 &= (u32)~CR1_DFL_MASK; + + /* Set new DFL[3:0] in CR1 */ + SPIx->CR1 |= SPI_DataLength; +} + +/*********************************************************************************************************//** + * @brief SEL pin is configured to be driven by hardware or software. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_SEL: specify the SPI SEL pin mode. + * This parameter can be one of the following values: + * @arg SPI_SEL_HARDWARE : SEL is driven by hardware + * @arg SPI_SEL_SOFTWARE : SEL is driven by software + * @retval None + ************************************************************************************************************/ +void SPI_SELModeConfig(HT_SPI_TypeDef* SPIx, u32 SPI_SEL) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_SEL_MODE(SPI_SEL)); + + if (SPI_SEL != SPI_SEL_SOFTWARE) + { + SPIx->CR1 |= SPI_SEL_HARDWARE; + } + else + { + SPIx->CR1 &= ~SPI_SEL_HARDWARE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the SEL state by software. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_SoftwareSEL: specify if the SPI SEL to be active or inactive. + * This parameter can be one of the following values: + * @arg SPI_SEL_ACTIVE : activate SEL signal + * @arg SPI_SEL_INACTIVE : deactivate SEL signal + * @retval None + ************************************************************************************************************/ +void SPI_SoftwareSELCmd(HT_SPI_TypeDef* SPIx, u32 SPI_SoftwareSEL) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_SOFTWARE_SEL(SPI_SoftwareSEL)); + + if (SPI_SoftwareSEL != SPI_SEL_INACTIVE) + { + SPIx->CR0 |= SPI_SEL_ACTIVE; + } + else + { + SPIx->CR0 &= SPI_SEL_INACTIVE; + } +} + +/*********************************************************************************************************//** + * @brief Send a data through the SPIx peripheral. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Data: the data to be transmitted. + * @retval None + ************************************************************************************************************/ +void SPI_SendData(HT_SPI_TypeDef* SPIx, SPI_DataTypeDef SPI_Data) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_DATA(SPI_Data)); + + SPIx->DR = SPI_Data; +} + +/*********************************************************************************************************//** + * @brief Return the received data through the SPIx peripheral + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @retval The value of the received data. + ************************************************************************************************************/ +SPI_DataTypeDef SPI_ReceiveData(HT_SPI_TypeDef* SPIx) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + + return (SPI_DataTypeDef)SPIx->DR; +} + +/*********************************************************************************************************//** + * @brief Set the value of SPI FIFO Time Out. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Timeout: specify the value of Time Out. + * @retval None + ************************************************************************************************************/ +void SPI_SetTimeOutValue(HT_SPI_TypeDef* SPIx, SPI_TimeoutTypeDef SPI_Timeout) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + + SPIx->FTOCR = SPI_Timeout; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SPI interrupt. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Int: specify if the SPI interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg SPI_INT_TXBE : SPI Tx buffer empty interrupt + * @arg SPI_INT_TXE : SPI Tx empty interrupt + * @arg SPI_INT_RXBNE : SPI Rx buffer not empty interrupt + * @arg SPI_INT_WC : SPI write collision interrupt + * @arg SPI_INT_RO : SPI read overrun interrupt + * @arg SPI_INT_MF : SPI mode fault interrupt + * @arg SPI_INT_SA : SPI slave abort interrupt + * @arg SPI_INT_TO : SPI time out interrupt + * @arg SPI_INT_ALL : All SPI interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_IntConfig(HT_SPI_TypeDef* SPIx, u32 SPI_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_INT(SPI_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->IER |= SPI_Int; + } + else + { + SPIx->IER &= (u32)~SPI_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified SPI flag has been set or not. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg SPI_FLAG_TXBE : SPI Tx buffer empty flag + * @arg SPI_FLAG_TXE : SPI Tx empty flag + * @arg SPI_FLAG_RXBNE : SPI Rx buffer not empty flag + * @arg SPI_FLAG_WC : SPI write collision flag + * @arg SPI_FLAG_RO : SPI read overrun flag + * @arg SPI_FLAG_MF : SPI mode fault flag + * @arg SPI_FLAG_SA : SPI slave abort flag + * @arg SPI_FLAG_TOUT : SPI time out flag + * @arg SPI_FLAG_BUSY : SPI busy flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus SPI_GetFlagStatus(HT_SPI_TypeDef* SPIx, u32 SPI_Flag) +{ + FlagStatus bitstatus = RESET; + u32 statusreg = 0; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FLAG(SPI_Flag)); + + statusreg = SPIx->SR; + + if ((statusreg & SPI_Flag) != (u32)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Return the status of specified SPI FIFO. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_FIFODirection: specify the FIFO that is to be checked. + * This parameter can be one of the following values: + * @arg SPI_FIFO_TX : + * @arg SPI_FIFO_RX : + * @retval The number of data in Tx FIFO or Rx FIFO. + ************************************************************************************************************/ +u8 SPI_GetFIFOStatus(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection) +{ + u32 tmpreg; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FIFO_DIRECTION(SPI_FIFODirection)); + + if (SPI_FIFODirection == SPI_FIFO_TX) + { + tmpreg = SPIx->FSR & FCR_FIFO_MASK; + } + else + { + tmpreg = (SPIx->FSR & (FCR_FIFO_MASK << 4)) >> 4; + } + + return (u8)tmpreg; +} + +/*********************************************************************************************************//** + * @brief Clear the specified SPI flag. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Flag: specify the flag that is to be cleared. + * This parameter can be one of the following values: + * @arg SPI_FLAG_WC : SPI write collision flag + * @arg SPI_FLAG_RO : SPI read overrun flag + * @arg SPI_FLAG_MF : SPI mode fault flag + * @arg SPI_FLAG_SA : SPI slave abort flag + * @arg SPI_FLAG_TOUT : SPI time out flag + * @retval None + ************************************************************************************************************/ +void SPI_ClearFlag(HT_SPI_TypeDef* SPIx, u32 SPI_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FLAG_CLEAR(SPI_Flag)); + + SPIx->SR = SPI_Flag; +} + +/*********************************************************************************************************//** + * @brief Set the trigger level of SPI FIFO. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_FIFODirection: specify the FIFO that is to be set. + * This parameter can be one of the following values: + * @arg SPI_FIFO_TX : + * @arg SPI_FIFO_RX : + * @param SPI_FIFOLevel: Specify the FIFO trigger level. + * @retval None + ************************************************************************************************************/ +void SPI_FIFOTriggerLevelConfig(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection, u8 SPI_FIFOLevel) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FIFO_DIRECTION(SPI_FIFODirection)); + Assert_Param(IS_SPI_FIFO_LEVEL(SPI_FIFOLevel)); + + if (SPI_FIFODirection == SPI_FIFO_TX) + { + SPIx->FCR = ((SPIx->FCR & (0x00000400 | (FCR_FIFO_MASK << 4))) | SPI_FIFOLevel); + } + else + { + SPIx->FCR = ((SPIx->FCR & (0x00000400 | FCR_FIFO_MASK)) | (SPI_FIFOLevel << 4)); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SPIx PDMA interface. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_PDMAREQ: specify the SPI PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg SPI_PDMAREQ_TX : Tx PDMA transfer request + * @arg SPI_PDMAREQ_RX : Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_PDMACmd(HT_SPI_TypeDef* SPIx, u32 SPI_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_PDMA_REQ(SPI_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->CR0 |= SPI_PDMAREQ; + } + else + { + SPIx->CR0 &= ~SPI_PDMAREQ; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SPIx dual port read interface. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_DUALCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + (NewState == ENABLE)?(SPIx->CR0 |= CR0_DUALEN_SET):(SPIx->CR0 &= CR0_DUALEN_RESET); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SPIx guard time selection function. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_GUARDTCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + (NewState == ENABLE) ? (SPIx->CR0 |= CR0_GUADTEN_SET) : (SPIx->CR0 &= CR0_GUADTEN_RESET); +} + +/*********************************************************************************************************//** + * @brief Set the SPIx guard time length. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param Guard_Time: number of SCK to be the guard time length. + * This parameter can be: SPI_GUADTIME_1_SCK to SPI_GUADTIME_16_SCK. + * @retval None + ************************************************************************************************************/ +void SPI_GUARDTConfig(HT_SPI_TypeDef* SPIx, u32 Guard_Time) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_GUADTIME(Guard_Time)); + + SPIx->CR0 = (SPIx->CR0 & 0xF0FF) | (Guard_Time << 8); +} + +/*********************************************************************************************************//** + * @brief Set the SPIx chip select hold time. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param CS_Hold_Time: number of SCK to be the hold time length. + * This parameter can be: 0 ~ 15 + * @retval None + ************************************************************************************************************/ +void SPI_SELHTConfig(HT_SPI_TypeDef* SPIx, u32 CS_Hold_Time) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_SELHOLDTIME(CS_Hold_Time)); + + SPIx->CR0 = (SPIx->CR0 & 0x0FFF) | (CS_Hold_Time << 12); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_tm.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_tm.c new file mode 100644 index 0000000000..df486b5523 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_tm.c @@ -0,0 +1,1656 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_tm.c + * @version $Rev:: 2973 $ + * @date $Date:: 2023-10-30 #$ + * @brief This file provides all the TM firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_tm.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup TM TM + * @brief TM driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup TM_Private_Define TM private definitions + * @{ + */ +#define CNTCFR_UEVDIS 0x00000001ul +#define CNTCFR_UGDIS 0x00000002ul +#define CNTCFR_DIR 0x01000000ul +#define CNTCFR_CMSEL_MASK ~0x00030000ul +#define CNTCFR_CKDIV_MASK ~0x00000300ul + +#define MDCFR_SPMSET 0x01000000ul +#define MDCFR_TSE 0x00000001ul +#define MDCFR_SMSEL_MASK ~0x00000700ul +#define MDCFR_MMSEL_MASK ~0x00070000ul + +#define TRCFR_ECME 0x01000000ul +#define TRCFR_ETI_POL 0x00010000ul +#define TRCFR_ETI_PSC_MASK ~0x00003000ul +#define TRCFR_ETIF_MASK ~0x00000F00ul +#define TRCFR_TRSEL_MASK ~0x0000000Ful +#define TRCFR_ETI_CONF_MASK ~0x00013F00ul + +#define CTR_TME 0x00000001ul +#define CTR_CRBE 0x00000002ul +#define CTR_CHCCDS 0x00010000ul + +#define CH0ICFR_CH0SRC 0x80000000ul +#define CHICFR_CHF_MASK ~0x0000000Ful +#define CHICFR_CHCCS_MASK ~0x00030000ul +#define CHICFR_CHPSC_MASK ~0x000C0000ul + +#define CHOCFR_REFCE 0x00000008ul +#define CHOCFR_CHPRE 0x00000010ul +#define CHOCFR_IMAE 0x00000020ul +#define CHOCFR_CHOM_MASK ~0x00000107ul + +#define CHPOLR_CH0P 0x00000001ul +#define CHPOLR_CH1P 0x00000004ul +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void _TM_CHx_Config(HT_TM_TypeDef* TMx, TM_CH_Enum Ch, TM_CHP_Enum Pol, TM_CHCCS_Enum Sel, u8 Filter); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Functions TM exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the TMx peripheral registers to their default reset values. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval None + ************************************************************************************************************/ +void TM_DeInit(HT_TM_TypeDef* TMx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + if (TMx == HT_GPTM0) + { + RSTCUReset.Bit.GPTM0 = 1; + } + #if (!LIBCFG_NO_GPTM1) + else if (TMx == HT_GPTM1) + { + RSTCUReset.Bit.GPTM1 = 1; + } + #endif + #if (!LIBCFG_NO_MCTM0) + else if (TMx == HT_MCTM0) + { + RSTCUReset.Bit.MCTM0 = 1; + } + #endif + #if (!LIBCFG_NO_MCTM1) + else if (TMx == HT_MCTM1) + { + RSTCUReset.Bit.MCTM1 = 1; + } + #endif + #if (LIBCFG_PWM0) + else if (TMx == HT_PWM0) + { + RSTCUReset.Bit.PWM0 = 1; + } + #endif + #if (LIBCFG_SCTM0) + else if (TMx == HT_SCTM0) + { + RSTCUReset.Bit.SCTM0 = 1; + } + #endif + #if (LIBCFG_SCTM1) + else if (TMx == HT_SCTM1) + { + RSTCUReset.Bit.SCTM1 = 1; + } + #endif + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the TMx counter to reload, prescaler, counter mode and repetition counter. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param TimeBaseInit: Point to a \ref TM_TimeBaseInitTypeDef that contains the configuration information. + * @retval None + ************************************************************************************************************/ +void TM_TimeBaseInit(HT_TM_TypeDef* TMx, TM_TimeBaseInitTypeDef* TimeBaseInit) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CNT_MODE(TimeBaseInit->CounterMode)); + Assert_Param(IS_TM_PSC_RLD(TimeBaseInit->PSCReloadTime)); + + /* Set the counter reload value */ + TMx->CRR = TimeBaseInit->CounterReload; + + /* Set the Prescaler value */ + TMx->PSCR = TimeBaseInit->Prescaler; + + /* Select the Counter Mode */ + TMx->CNTCFR &= CNTCFR_CMSEL_MASK; /* CNTCFR_DIR is read only when the timer configured as */ + TMx->CNTCFR &= ~(u32)CNTCFR_DIR; /* Center-aligned mode. Reset mode first and then reset the */ + /* CNTCFR_DIR bit (separate as two steps). */ + + TMx->CNTCFR |= TimeBaseInit->CounterMode; + + #if (!LIBCFG_NO_MCTM0) + if ((TMx == HT_MCTM0) || (TMx == HT_MCTM1)) + { + /* Set the Repetition value */ + TMx->REPR = TimeBaseInit->RepetitionCounter; + } + #endif + + /* To reload the Prescaler value immediatly or next update event */ + TMx->EVGR = TimeBaseInit->PSCReloadTime; +} + +/*********************************************************************************************************//** + * @brief Initialize the TMx channel N output. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param OutInit: Point to a \ref TM_OutputInitTypeDef structure that contains + the configuration information. + * @retval None + ************************************************************************************************************/ +void TM_OutputInit(HT_TM_TypeDef* TMx, TM_OutputInitTypeDef* OutInit) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + OutInit->Channel; + vu32 *pCcr = (vu32*)&TMx->CH0CCR + OutInit->Channel; + vu32 *pAcr = (vu32*)&TMx->CH0ACR + OutInit->Channel; + u8 bChPos = OutInit->Channel << 1; + u32 wTmpMask; + u32 wTmpReg; + u32 uIsMCTM = 0; + + #if (!LIBCFG_NO_MCTM0) + if ((TMx == HT_MCTM0) || (TMx == HT_MCTM1)) + { + uIsMCTM = 1; + } + #endif + if (uIsMCTM) + { + wTmpMask = ~(0x3ul << bChPos); + } + else + { + wTmpMask = ~(0x1ul << bChPos); + } + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(OutInit->Channel)); + Assert_Param(IS_TM_OM(OutInit->OutputMode)); + Assert_Param(IS_TM_CHCTL(OutInit->Control)); + Assert_Param(IS_TM_CHP(OutInit->Polarity)); + + #if (!LIBCFG_NO_MCTM0) + if (uIsMCTM) + { + Assert_Param(IS_TM_CHCTL(OutInit->ControlN)); + Assert_Param(IS_TM_CHP(OutInit->PolarityN)); + Assert_Param(IS_MCTM_OIS(OutInit->IdleState)); + Assert_Param(IS_MCTM_OIS(OutInit->IdleStateN)); + } + #endif + + + /* Disable the Channel */ + TMx->CHCTR &= wTmpMask; + + /* Set the Output Compare Polarity */ + wTmpReg = TMx->CHPOLR & wTmpMask; + + if (uIsMCTM) + { + wTmpReg |= (u32)(OutInit->Polarity | (OutInit->PolarityN << 1)) << bChPos; + } + else + { + wTmpReg |= (u32)(OutInit->Polarity) << bChPos; + } + + TMx->CHPOLR = wTmpReg; + + /* Set the Output Idle State */ + if (uIsMCTM) + { + wTmpReg = TMx->CHBRKCFR & wTmpMask; + wTmpReg |= (u32)(OutInit->IdleState | (OutInit->IdleStateN << 1)) << bChPos; + TMx->CHBRKCFR = wTmpReg; + } + + /* Select the Output Compare Mode */ + *pOcfr &= CHOCFR_CHOM_MASK; + *pOcfr |= OutInit->OutputMode; + + /* Set the Capture Compare Register value */ + *pCcr = OutInit->Compare; + + /* Set the Asymmetric Compare Register value */ + *pAcr = OutInit->AsymmetricCompare; + + /* Set the channel state */ + if (uIsMCTM) + { + TMx->CHCTR |= (u32)(OutInit->Control | (OutInit->ControlN << 1)) << bChPos; + } + else + { + TMx->CHCTR |= (u32)(OutInit->Control) << bChPos; + } +} + +/*********************************************************************************************************//** + * @brief Initialize input capture of the TMx channel. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param CapInit: Point to a \ref TM_CaptureInitTypeDef structure that contains the configuration + * information. + * @retval None + ************************************************************************************************************/ +void TM_CaptureInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(CapInit->Channel)); + Assert_Param(IS_TM_CHP(CapInit->Polarity)); + Assert_Param(IS_TM_CHCCS(CapInit->Selection)); + Assert_Param(IS_TM_CHPSC(CapInit->Prescaler)); + Assert_Param(IS_TM_FILTER(CapInit->Filter)); + + _TM_CHx_Config(TMx, CapInit->Channel, CapInit->Polarity, CapInit->Selection, CapInit->Filter); + + /* Set the Input Capture Prescaler value */ + TM_CHPSCConfig(TMx, CapInit->Channel, CapInit->Prescaler); +} + +/*********************************************************************************************************//** + * @brief Configure the TMx to measure an external PWM signal. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param CapInit: Point to a \ref TM_CaptureInitTypeDef structure that contains the configuration + * information. + * @retval None + ************************************************************************************************************/ +void TM_PwmInputInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit) +{ + TM_CHP_Enum OppositePol; + TM_CHCCS_Enum OppositeSel; + TM_CH_Enum OppositeChannel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH_PWMI(CapInit->Channel)); + Assert_Param(IS_TM_CHP(CapInit->Polarity)); + Assert_Param(IS_TM_CHCCS(CapInit->Selection)); + Assert_Param(IS_TM_CHPSC(CapInit->Prescaler)); + Assert_Param(IS_TM_FILTER(CapInit->Filter)); + + /* Select the Opposite Input Polarity */ + if (CapInit->Polarity == TM_CHP_NONINVERTED) + { + OppositePol = TM_CHP_INVERTED; + } + else + { + OppositePol = TM_CHP_NONINVERTED; + } + + /* Select the Opposite Input */ + if (CapInit->Selection == TM_CHCCS_DIRECT) + { + OppositeSel = TM_CHCCS_INDIRECT; + } + else + { + OppositeSel = TM_CHCCS_DIRECT; + } + + if (CapInit->Channel == TM_CH_0) + { + OppositeChannel = TM_CH_1; + } + else + { + OppositeChannel = TM_CH_0; + } + + /* Capture Channel Configuration */ + _TM_CHx_Config(TMx, CapInit->Channel, CapInit->Polarity, CapInit->Selection, CapInit->Filter); + + /* Set the Input Capture Prescaler value */ + TM_CHPSCConfig(TMx, CapInit->Channel, CapInit->Prescaler); + + /* Opposite Channel Configuration */ + _TM_CHx_Config(TMx, OppositeChannel, OppositePol, OppositeSel, CapInit->Filter); + + /* Set the Input Capture Prescaler value */ + TM_CHPSCConfig(TMx, OppositeChannel, CapInit->Prescaler); +} + +/*********************************************************************************************************//** + * @brief Fill each TimeBaseInit member with its default value. + * @param TimeBaseInit: Point to a \ref TM_TimeBaseInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void TM_TimeBaseStructInit(TM_TimeBaseInitTypeDef* TimeBaseInit) +{ + /* Set the default configuration */ + TimeBaseInit->CounterMode = TM_CNT_MODE_UP; + TimeBaseInit->CounterReload = 0xFFFF; + TimeBaseInit->Prescaler = 0x0000; + TimeBaseInit->PSCReloadTime = TM_PSC_RLD_IMMEDIATE; + TimeBaseInit->RepetitionCounter = 0; +} + +/*********************************************************************************************************//** + * @brief Fill each OutInit member with its default value. + * @param OutInit: Point to a \ref TM_OutputInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void TM_OutputStructInit(TM_OutputInitTypeDef* OutInit) +{ + /* Set the default configuration */ + OutInit->Channel = TM_CH_0; + OutInit->OutputMode = TM_OM_MATCH_NOCHANGE; + OutInit->Control = TM_CHCTL_DISABLE; + OutInit->ControlN = TM_CHCTL_DISABLE; + OutInit->Polarity = TM_CHP_NONINVERTED; + OutInit->PolarityN = TM_CHP_NONINVERTED; + OutInit->IdleState = MCTM_OIS_LOW; + OutInit->IdleStateN = MCTM_OIS_LOW; + OutInit->Compare = 0x0000; + OutInit->AsymmetricCompare = 0x0000; +} + +/*********************************************************************************************************//** + * @brief Fill each CapInit member with its default value. + * @param CapInit: Point to a \ref TM_CaptureInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void TM_CaptureStructInit(TM_CaptureInitTypeDef* CapInit) +{ + /* Set the default configuration */ + CapInit->Channel = TM_CH_0; + CapInit->Polarity = TM_CHP_NONINVERTED; + CapInit->Selection = TM_CHCCS_DIRECT; + CapInit->Prescaler = TM_CHPSC_OFF; + CapInit->Filter = 0x00; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable TMx counter. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_Cmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the TM Counter */ + TMx->CTR |= CTR_TME; + } + else + { + /* Disable the TM Counter */ + TMx->CTR &= ~CTR_TME; + } +} + +/*********************************************************************************************************//** + * @brief Configure external clock mode of the TMx. Used ITIx as the clock source. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Iti: Trigger source. + * This parameter can be one of the following values: + * @arg TM_TRSEL_ITI0: Internal trigger 0 + * @arg TM_TRSEL_ITI1: Internal trigger 1 + * @arg TM_TRSEL_ITI2: Internal trigger 2 + * @retval None + ************************************************************************************************************/ +void TM_ItiExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Iti) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_ITI(Iti)); + + /* Select the Internal Trigger. Slave mode will be disable in this function */ + TM_StiConfig(TMx, Iti); + + /* Select the STIED as external clock source */ + TMx->MDCFR |= TM_SMSEL_STIED; +} + +/*********************************************************************************************************//** + * @brief Configure external clock mode of the TMx. Used CHx as the clock source. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the channel source. + * This parameter can be one of the following values: + * @arg TM_TRSEL_TI0BED : TI0 both edge detector + * @arg TM_TRSEL_TI0S0 : Filtered timer input 0 + * @arg TM_TRSEL_TI1S1 : Filtered timer input 1 + * @param Pol: Specify the CHx Polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : active high. + * @arg TM_CHP_INVERTED : active low. + * @param Filter: Specify the filter value. + * This parameter must be a value between 0x0 and 0xF. + * @retval None + ************************************************************************************************************/ +void TM_ChExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel, TM_CHP_Enum Pol, u8 Filter) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_TRSEL_CH(Sel)); + Assert_Param(IS_TM_CHP(Pol)); + Assert_Param(IS_TM_FILTER(Filter)); + + /* Configure the Timer Input Clock Source */ + if (Sel == TM_TRSEL_TI1S1) + { + _TM_CHx_Config(TMx, TM_CH_1, Pol, TM_CHCCS_DIRECT, Filter); + } + else + { + _TM_CHx_Config(TMx, TM_CH_0, Pol, TM_CHCCS_DIRECT, Filter); + } + + /* Select the external clock source. Slave mode will be disable in this function */ + TM_StiConfig(TMx, Sel); + + /* Select the STIED as external clock source */ + TMx->MDCFR |= TM_SMSEL_STIED; +} + +/*********************************************************************************************************//** + * @brief Configure external clock mode of the TMx. Used ETI as the clock source. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param Psc: The external Trigger Prescaler. + * It can be one of the following values: + * @arg TM_ETIPSC_OFF : ETI prescaler off + * @arg TM_ETIPSC_2 : ETIP frequency divided by 2 + * @arg TM_ETIPSC_4 : ETIP frequency divided by 4 + * @arg TM_ETIPSC_8 : ETIP frequency divided by 8 + * @param Pol: The external trigger input polarity. + * It can be one of the following values: + * @arg TM_ETIPOL_NONINVERTED : Active high level or rising edge + * @arg TM_ETIPOL_INVERTED : Active low level or falling edge + * @param Filter: Filter for ETI input. + * This parameter must be a value between 0x00 and 0x0F + * @retval None + ************************************************************************************************************/ +void TM_EtiExternalClockConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_ETIPSC(Psc)); + Assert_Param(IS_TM_ETIPOL(Pol)); + Assert_Param(IS_TM_FILTER(Filter)); + + /* Configure the ETI Clock source */ + TM_EtiConfig(TMx, Psc, Pol, Filter); + + /* Enable the external clock mode */ + TMx->TRCFR |= TRCFR_ECME; +} + +/*********************************************************************************************************//** + * @brief Configure external trigger input (ETI) of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param Psc: The external Trigger Prescaler. + * It can be one of the following values: + * @arg TM_ETIPSC_OFF : ETI prescaler off + * @arg TM_ETIPSC_2 : ETIP frequency divided by 2 + * @arg TM_ETIPSC_4 : ETIP frequency divided by 4 + * @arg TM_ETIPSC_8 : ETIP frequency divided by 8 + * @param Pol: The external trigger input polarity. + * It can be one of the following values: + * @arg TM_ETIPOL_NONINVERTED : Active high level or rising edge + * @arg TM_ETIPOL_INVERTED : Active low level or falling edge + * @param Filter: Filter for ETI input. + * This parameter must be a value between 0x00 and 0x0F + * @retval None + ************************************************************************************************************/ +void TM_EtiConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter) +{ + u32 wTrcfr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_ETIPSC(Psc)); + Assert_Param(IS_TM_ETIPOL(Pol)); + Assert_Param(IS_TM_FILTER(Filter)); + + /* Get TRCFR value with cleared ETI configuration bits */ + wTrcfr = TMx->TRCFR & TRCFR_ETI_CONF_MASK; + + /* Set the prescaler, filter and polarity for ETI input */ + wTrcfr |= (u32)Psc | Pol | ((u32)Filter << 8); + + /* Write to TMx TRCFR */ + TMx->TRCFR = wTrcfr; +} + +/*********************************************************************************************************//** + * @brief Configure prescaler of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Psc: Specify the prescaler value. + * @param PscReloadTime: Specify the TM prescaler reload time. + * This parameter can be one of the following values: + * @arg TM_PSC_RLD_UPDATE : The prescaler is loaded at the next update event. + * @arg TM_PSC_RLD_IMMEDIATE : The prescaler is loaded immediatly. + * @retval None + ************************************************************************************************************/ +void TM_PrescalerConfig(HT_TM_TypeDef* TMx, u16 Psc, TM_PSC_RLD_Enum PscReloadTime) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_PSC_RLD(PscReloadTime)); + + /* Set the prescaler value */ + TMx->PSCR = Psc; + + /* Set the UEVG bit or not */ + TMx->EVGR = PscReloadTime; +} + +/*********************************************************************************************************//** + * @brief Configure counter mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Mod: Specify the counter mode to be used. + * This parameter can be one of the following values: + * @arg TM_CNT_MODE_UP : TM up counting mode. + * @arg TM_CNT_MODE_DOWN : TM down counting mode. + * @arg TM_CNT_MODE_CA1 : TM center aligned mode 1. + * @arg TM_CNT_MODE_CA2 : TM center aligned mode 2. + * @arg TM_CNT_MODE_CA3 : TM center aligned mode 3. + * @retval None + ************************************************************************************************************/ +void TM_CounterModeConfig(HT_TM_TypeDef* TMx, TM_CNT_MODE_Enum Mod) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CNT_MODE(Mod)); + + /* Reset the CMSEL and DIR Bits */ + TMx->CNTCFR &= CNTCFR_CMSEL_MASK; /* CNTCFR_DIR is read only when the timer configured as */ + TMx->CNTCFR &= ~(u32)CNTCFR_DIR; /* Center-aligned mode. Reset mode first and then reset the */ + /* CNTCFR_DIR bit (separate as two steps). */ + + /* Set the Counter Mode */ + TMx->CNTCFR |= Mod; +} + +/*********************************************************************************************************//** + * @brief Select the STI source. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the STI source. + * This parameter can be one of the following: + * @arg TM_TRSEL_ITI0 : Internal trigger 0. + * @arg TM_TRSEL_ITI1 : Internal trigger 1. + * @arg TM_TRSEL_ITI2 : Internal trigger 2. + * @arg TM_TRSEL_TI0BED : TI0 both edge detector. + * @arg TM_TRSEL_TI0S0 : Filtered channel 0 input. + * @arg TM_TRSEL_TI1S1 : Filtered channel 1 input. + * @arg TM_TRSEL_ETIF : External trigger input. + * @arg TM_TRSEL_UEVG : Trigger by setting UEVG bit. + * @retval None + ************************************************************************************************************/ +void TM_StiConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel) +{ + u32 wTrcfr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_TRSEL(Sel)); + + /* Disable slave mode */ + TMx->MDCFR &= MDCFR_SMSEL_MASK; + + /* Get the TRCFR value with cleared TRSEL */ + wTrcfr = TMx->TRCFR & TRCFR_TRSEL_MASK; + + /* Set the STI source */ + TMx->TRCFR |= wTrcfr | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure encoder interface of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param DecoderMod: Specify the TMx decoder mode. + * This parameter can be one of the following values: + * @arg TM_SMSEL_DECODER1 : Counter counts on CH0 edge depending on CH1 level. + * @arg TM_SMSEL_DECODER2 : Counter counts on CH1 edge depending on CH0 level. + * @arg TM_SMSEL_DECODER3 : Counter counts on both CH0 and CH1 edges depending on + * the level of the other input. + * @param CH0P: Specify the CH0 polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : Active high level or rising edge + * @arg TM_CHP_INVERTED : Active low level or falling edge + * @param CH1P: Specify the CH1 polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : Active high level or rising edge + * @arg TM_CHP_INVERTED : Active low level or falling edge + * @retval None + ************************************************************************************************************/ +void TM_DecoderConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum DecoderMod, TM_CHP_Enum CH0P, TM_CHP_Enum CH1P) +{ + u32 wMdcfr, wCh0Icfr, wCh1Icfr, wChpolr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_SMSEL_DECODER(DecoderMod)); + Assert_Param(IS_TM_CHP(CH0P)); + Assert_Param(IS_TM_CHP(CH1P)); + + /* Get the TMx MDCFR register value */ + wMdcfr = TMx->MDCFR; + + /* Get the TMx CH0ICFR & CH1ICFR register value */ + wCh0Icfr = TMx->CH0ICFR; + wCh1Icfr = TMx->CH1ICFR; + + /* Get the TMx CHPOLR register value */ + wChpolr = TMx->CHPOLR; + + /* Set the decoder mode */ + wMdcfr &= MDCFR_SMSEL_MASK; + wMdcfr |= DecoderMod; + + /* Select the channel 0 and the channel 1 as input and clear CH0SRC */ + wCh0Icfr &= CHICFR_CHCCS_MASK & (~CH0ICFR_CH0SRC); + wCh1Icfr &= CHICFR_CHCCS_MASK; + wCh0Icfr |= TM_CHCCS_DIRECT; + wCh1Icfr |= TM_CHCCS_DIRECT; + + /* Set the CH0 and the CH1 polarities */ + wChpolr &= ~(CHPOLR_CH0P | CHPOLR_CH1P); + wChpolr |= (CH0P | (CH1P << 2)); + + /* Write to TMx MDCFR */ + TMx->MDCFR = wMdcfr; + + /* Write to TMx CH0ICFR & CH1ICFR */ + TMx->CH0ICFR = wCh0Icfr; + TMx->CH1ICFR = wCh1Icfr; + + /* Write to TMx CHPOLR */ + TMx->CHPOLR = wChpolr; +} + +/*********************************************************************************************************//** + * @brief Force the TMx CHnOREF waveform to active or inactive level. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param ForcedAction: Specify the forced action to be set to the output waveform. + * This parameter can be one of the following values: + * @arg TM_OM_FORCED_ACTIVE : Forced active level on CH0OREF + * @arg TM_OM_FORCED_INACTIVE : Forced inactive level on CH0OREF. + * @retval None + ************************************************************************************************************/ +void TM_ForcedOREF(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, TM_OM_Enum ForcedAction) +{ + vu32* pCHnOCFR = ((vu32*)&TMx->CH0OCFR) + (TM_CH_n * 1); + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + Assert_Param(IS_TM_OM_FORCED(ForcedAction)); + + /* Configure The forced output mode */ + *pCHnOCFR = (*pCHnOCFR & CHOCFR_CHOM_MASK) | ForcedAction; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the TMx CRR preload function. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_CRRPreloadCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Set the CRR preload control bit */ + TMx->CTR |= CTR_CRBE; + } + else + { + /* Reset the CRR preload control bit */ + TMx->CTR &= ~CTR_CRBE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the TMx CHxCCR preload function. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param NewState This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_CHCCRPreloadConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Enable or disable the channel N CCR preload feature */ + if (NewState != DISABLE) + { + *pOcfr |= CHOCFR_CHPRE; + } + else + { + *pOcfr &= ~CHOCFR_CHPRE; + } +} + +/*********************************************************************************************************//** + * @brief Clear or Safeguard the CHxOREF signal when ETI is active. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param NewState This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_ClearOREFConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Enable or Disable the channel N clear Oref at ETI active function */ + if (NewState != DISABLE) + { + *pOcfr |= CHOCFR_REFCE; + } + else + { + *pOcfr &= ~CHOCFR_REFCE; + } +} + +/*********************************************************************************************************//** + * @brief Configure polarity of the TMx channel N. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Pol: Specify the polarity of channel N. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : active high + * @arg TM_CHP_INVERTED : active low + * @retval None + ************************************************************************************************************/ +void TM_ChPolarityConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHP_Enum Pol) +{ + u32 wChpolr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_CHP(Pol)); + + /* Set or reset the CHx polarity */ + wChpolr = TMx->CHPOLR & (~(u32)(0x1 << (Channel << 1))); + TMx->CHPOLR = wChpolr | (Pol << (Channel << 1)); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the single pulse immediate active function. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + * @note Must configure output mode to PWM1 or PWM2 before invoke this function. + ************************************************************************************************************/ +void TM_ImmActiveConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Enable or disable the channel N clear CHxOREF at ETI active function */ + if (NewState != DISABLE) + { + *pOcfr |= CHOCFR_IMAE; + } + else + { + *pOcfr &= ~CHOCFR_IMAE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the TMx channel N. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Control: This parameter can be TM_CHCTL_ENABLE or TM_CHCTL_DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_ChannelConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_CHCTL(Control)); + + /* Reset the CHxE Bit */ + TMx->CHCTR &= ~(u32)(0x1 << (Channel << 1)); + + /* Set or reset the CHxE Bit */ + TMx->CHCTR |= (u32)Control << (Channel << 1); +} + +/*********************************************************************************************************//** + * @brief Configure output mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Mod: Specify the TM output mode. + * This parameter can be one of the following values: + * @arg TM_OM_MATCH_NOCHANGE : Output dont change on match + * @arg TM_OM_MATCH_INACTIVE : Output inactive on compare match + * @arg TM_OM_MATCH_ACTIVE : Output active on compare match + * @arg TM_OM_MATCH_TOGGLE : Output toggle on compare match + * @arg TM_OM_FORCED_INACTIVE : Output forced inactive + * @arg TM_OM_FORCED_ACTIVE : Output forced active + * @arg TM_OM_PWM1 : PWM1 mode + * @arg TM_OM_PWM2 : PWM2 mode + * @arg TM_OM_ASYMMETRIC_PWM1 : Asymmetric PWM1 mode + * @arg TM_OM_ASYMMETRIC_PWM2 : Asymmetric PWM2 mode + * @retval None + * @note This function disables the selected channel before changing the output mode. + ************************************************************************************************************/ +void TM_OutputModeConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_OM_Enum Mod) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_OM(Mod)); + + /* Disable the channel: Reset the CHxE Bit */ + TMx->CHCTR &= ~(u32)(0x1 << (Channel << 1)); + + /* Selects the TM output mode */ + *pOcfr = (*pOcfr & CHOCFR_CHOM_MASK) | Mod; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable update event of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE (default) or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_UpdateCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == DISABLE) + { + /* Set the update disable bit */ + TMx->CNTCFR |= CNTCFR_UEVDIS; + } + else + { + /* Reset the update disable bit */ + TMx->CNTCFR &= ~CNTCFR_UEVDIS; + } +} + +/*********************************************************************************************************//** + * @brief Configure UEVG interrupt function of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be one of the following value: + * @arg ENABLE : Default value. Any of the following events will generate an update event interrupt: + * - Counter overflow/underflow + * - Setting the UEVG bit + * - Update generation through the slave restart mode + * @arg DISABLE : Only counter overflow/underflow generations an update event interrupt. + * @retval None + ************************************************************************************************************/ +void TM_UEVG_IntConfig(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == DISABLE) + { + /* Set the UEVG interrupt disable bit */ + TMx->CNTCFR |= CNTCFR_UGDIS; + } + else + { + /* Reset the UEVG interrupt disable bit */ + TMx->CNTCFR &= ~CNTCFR_UGDIS; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable hall sensor interface of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_HallInterfaceCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Set the CH0SRC Bit */ + TMx->CH0ICFR |= CH0ICFR_CH0SRC; + } + else + { + /* Reset the CH0SRC Bit */ + TMx->CH0ICFR &= ~CH0ICFR_CH0SRC; + } +} + +/*********************************************************************************************************//** + * @brief Select single pulse mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_SinglePulseModeCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + TMx->MDCFR |= MDCFR_SPMSET; + } + else + { + TMx->MDCFR &= ~MDCFR_SPMSET; + } +} + +/*********************************************************************************************************//** + * @brief Select master trigger output source of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the master trigger output source. + * This parameter can be as follow: + * @arg TM_MMSEL_RESET : Send trigger signal when S/W setting UEVG or slave restart + * @arg TM_MMSEL_ENABLE : The counter enable signal is used as trigger output. + * @arg TM_MMSEL_UPDATE : The update event is used as trigger output. + * @arg TM_MMSEL_CH0CC : Channel 0 capture or compare match occurred as trigger output. + * @arg TM_MMSEL_CH0OREF : The CH0OREF signal is used as trigger output. + * @arg TM_MMSEL_CH1OREF : The CH1OREF signal is used as trigger output. + * @arg TM_MMSEL_CH2OREF : The CH2OREF signal is used as trigger output. + * @arg TM_MMSEL_CH3OREF : The CH3OREF signal is used as trigger output. + * @retval None + ************************************************************************************************************/ +void TM_MMSELConfig(HT_TM_TypeDef* TMx, TM_MMSEL_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_MMSEL(Sel)); + + /* Select the MTO source */ + TMx->MDCFR = (TMx->MDCFR & MDCFR_MMSEL_MASK) | Sel; +} + +/*********************************************************************************************************//** + * @brief Select slave mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the timer slave mode. + * This parameter can be one of the following values: + * @arg TM_SMSEL_RESTART : Slave restart counter mode. + * @arg TM_SMSEL_PAUSE : Slave pause counter mode. + * @arg TM_SMSEL_TRIGGER : Slave trigger counter start mode. + * @arg TM_SMSEL_STIED : Used rising edge of STI as prescaler clock source. + * @retval None + ************************************************************************************************************/ +void TM_SlaveModeConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_SLAVE_MODE(Sel)); + + /* Select the slave mode */ + TMx->MDCFR = (TMx->MDCFR & MDCFR_SMSEL_MASK) | Sel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the master & slave TMx synchronous function. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_TimSyncCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Set the TSE Bit */ + TMx->MDCFR |= MDCFR_TSE; + } + else + { + /* Reset the TSE Bit */ + TMx->MDCFR &= ~MDCFR_TSE; + } +} + +/*********************************************************************************************************//** + * @brief Set counter register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Counter: Specify the counter register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetCounter(HT_TM_TypeDef* TMx, u16 Counter) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Set the Counter Register value */ + TMx->CNTR = Counter; +} + +/*********************************************************************************************************//** + * @brief Set counter reload register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Reload: Specify the counter reload register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetCounterReload(HT_TM_TypeDef* TMx, u16 Reload) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Set the counter reload register value */ + TMx->CRR = Reload; +} + +/*********************************************************************************************************//** + * @brief Set channel n capture/compare register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Cmp: Specify the CH0CCR register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) +{ + vu32* pCHnCCR = ((vu32*)&TMx->CH0CCR) + (TM_CH_n * 1); + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + + /* Set the CHnCCR register new value */ + *pCHnCCR = Cmp; +} + +/*********************************************************************************************************//** + * @brief Set channel n asymmetric compare register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Cmp: Specify the CH0ACR register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetAsymmetricCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) +{ + vu32* pCHnACR = ((vu32*)&TMx->CH0ACR) + (TM_CH_n * 1); + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + + /* Set the CHnACR register new value */ + *pCHnACR = Cmp; +} + +/*********************************************************************************************************//** + * @brief Configure input capture prescaler. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Psc: Specify the input capture prescaler new value. + * This parameter can be one of the following values: + * @arg TM_CHPSC_OFF : No prescaler + * @arg TM_CHPSC_2 : Capture is done once every 2 events + * @arg TM_CHPSC_4 : Capture is done once every 4 events + * @arg TM_CHPSC_8 : Capture is done once every 8 events + * @retval None + ************************************************************************************************************/ +void TM_CHPSCConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHPSC_Enum Psc) +{ + vu32 *pIcfr = (vu32*)&TMx->CH0ICFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_CHPSC(Psc)); + + /* Reset the CHxPSC bits */ + *pIcfr &= CHICFR_CHPSC_MASK; + + /* Set the capture input prescaler value */ + *pIcfr |= Psc; +} + +/*********************************************************************************************************//** + * @brief Set clock division value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Div: Specify the clock division value. + * This parameter can be one of the following value: + * @arg TM_CKDIV_OFF : fDTS = fCLKIN + * @arg TM_CKDIV_2 : fDTS = fCLKIN / 2 + * @arg TM_CKDIV_4 : fDTS = fCLKIN / 4 + * @retval None + ************************************************************************************************************/ +void TM_CKDIVConfig(HT_TM_TypeDef* TMx, TM_CKDIV_Enum Div) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CKDIV(Div)); + + /* Reset the CKDIV Bits */ + TMx->CNTCFR &= CNTCFR_CKDIV_MASK; + + /* Set the CKDIV value */ + TMx->CNTCFR |= Div; +} + +/*********************************************************************************************************//** + * @brief Get channel n capture/compare register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @retval Value of CH0CCR register + ************************************************************************************************************/ +u32 TM_GetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n) +{ + vu32* pCHnCCR = ((vu32*)&TMx->CH0CCR) + (TM_CH_n * 1); + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + + /* Get the CHnCCR register value */ + return (*pCHnCCR); +} + +/*********************************************************************************************************//** + * @brief Get counter value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval Value of Counter register + ************************************************************************************************************/ +u32 TM_GetCounter(HT_TM_TypeDef* TMx) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Get the Counter Register value */ + return TMx->CNTR; +} + +/*********************************************************************************************************//** + * @brief Get prescaler value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval Value of Prescaler register + ************************************************************************************************************/ +u32 TM_GetPrescaler(HT_TM_TypeDef* TMx) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Get the Prescaler Register value */ + return TMx->PSCR; +} + +/*********************************************************************************************************//** + * @brief Generate TMx events. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_EVENT: Stores the event source. + * This parameter can be any combination of following: + * @arg TM_EVENT_CH0CC : Timer Capture/compare 0 event + * @arg TM_EVENT_CH1CC : Timer Capture/compare 1 event + * @arg TM_EVENT_CH2CC : Timer Capture/compare 2 event + * @arg TM_EVENT_CH3CC : Timer Capture/compare 3 event + * @arg TM_EVENT_UEV : Timer update event + * @arg TM_EVENT_UEV2 : Timer update event 2 + * @arg TM_EVENT_TEV : Timer trigger event + * @arg TM_EVENT_BRKEV : Timer break event + * @retval None + ************************************************************************************************************/ +void TM_GenerateEvent(HT_TM_TypeDef* TMx, u32 TM_EVENT) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_EVENT(TM_EVENT)); + + /* Set the event sources */ + TMx->EVGR = TM_EVENT; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified TMx flag has been set. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_FLAG: Specify the flag to be checked. + * This parameter can be one of the following values: + * @arg TM_FLAG_CH0CC : TM Capture/compare 0 flag + * @arg TM_FLAG_CH1CC : TM Capture/compare 1 flag + * @arg TM_FLAG_CH2CC : TM Capture/compare 2 flag + * @arg TM_FLAG_CH3CC : TM Capture/compare 3 flag + * @arg TM_FLAG_CH0OC : TM channel 0 overcapture flag + * @arg TM_FLAG_CH1OC : TM channel 1 overcapture flag + * @arg TM_FLAG_CH2OC : TM channel 2 overcapture flag + * @arg TM_FLAG_CH3OC : TM channel 3 overcapture flag + * @arg TM_FLAG_UEV : TM update flag + * @arg TM_FLAG_UEV2 : TM update 2 flag + * @arg TM_FLAG_TEV : TM trigger flag + * @arg TM_FLAG_BRK0 : TM break 0 flag + * @arg TM_FLAG_BRK1 : TM break 1 flag + * @retval The new state of TM_FLAG (SET or RESET). + ************************************************************************************************************/ +FlagStatus TM_GetFlagStatus(HT_TM_TypeDef* TMx, u32 TM_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_FLAG(TM_FLAG)); + + if ((TMx->INTSR & TM_FLAG) != 0) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear flags of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_FLAG: Specify the flag to be cleared. + * This parameter can be any combination of the following values: + * @arg TM_FLAG_CH0CC : TM Capture/compare 0 flag + * @arg TM_FLAG_CH1CC : TM Capture/compare 1 flag + * @arg TM_FLAG_CH2CC : TM Capture/compare 2 flag + * @arg TM_FLAG_CH3CC : TM Capture/compare 3 flag + * @arg TM_FLAG_CH0OC : TM channel 0 overcapture flag + * @arg TM_FLAG_CH1OC : TM channel 1 overcapture flag + * @arg TM_FLAG_CH2OC : TM channel 2 overcapture flag + * @arg TM_FLAG_CH3OC : TM channel 3 overcapture flag + * @arg TM_FLAG_UEV : TM update flag + * @arg TM_FLAG_UEV2 : TM update 2 flag + * @arg TM_FLAG_TEV : TM trigger flag + * @arg TM_FLAG_BRK0 : TM break 0 flag + * @arg TM_FLAG_BRK1 : TM break 1 flag + * @retval None + ************************************************************************************************************/ +void TM_ClearFlag(HT_TM_TypeDef* TMx, u32 TM_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_FLAG_CLR(TM_FLAG)); + + /* Clear the flags */ + TMx->INTSR = ~TM_FLAG; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified interrupts of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_INT: Specify the TM interrupts sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg TM_INT_CH0CC : TM Capture/compare 0 interrupt + * @arg TM_INT_CH1CC : TM Capture/compare 1 interrupt + * @arg TM_INT_CH2CC : TM Capture/compare 2 interrupt + * @arg TM_INT_CH3CC : TM Capture/compare 3 interrupt + * @arg TM_INT_UEV : TM update interrupt + * @arg TM_INT_UEV2 : TM update 2 interrupt + * @arg TM_INT_TEV : TM trigger interrupt + * @arg TM_INT_BRKEV : TM break interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_IntConfig(HT_TM_TypeDef* TMx, u32 TM_INT, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_INT(TM_INT)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the interrupt sources */ + TMx->DICTR |= TM_INT; + } + else + { + /* Disable the interrupt sources */ + TMx->DICTR &= ~TM_INT; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the TMx interrupt has occurred. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_INT: Specify the TM interrupt source to be checked. + * This parameter can be one of the following values: + * @arg TM_INT_CH0CC : TM Capture/compare 0 interrupt + * @arg TM_INT_CH1CC : TM Capture/compare 1 interrupt + * @arg TM_INT_CH2CC : TM Capture/compare 2 interrupt + * @arg TM_INT_CH3CC : TM Capture/compare 3 interrupt + * @arg TM_INT_UEV : TM update interrupt + * @arg TM_INT_UEV2 : TM update 2 interrupt + * @arg TM_INT_TEV : TM trigger interrupt + * @arg TM_INT_BRKEV : TM break interrupt + * @retval The new state of the TM_INT(SET or RESET) + ************************************************************************************************************/ +FlagStatus TM_GetIntStatus(HT_TM_TypeDef* TMx, u32 TM_INT) +{ + u32 itstatus, itenable; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_GET_INT(TM_INT)); + + itstatus = TMx->INTSR & TM_INT; + itenable = TMx->DICTR & TM_INT; + + if ((itstatus != 0) && (itenable != 0)) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear interrupt pending bits of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_INT: Specify the TM interrupt to be cleared. + * This parameter can be any combination of the following values: + * @arg TM_INT_CH0CC : TM Capture/compare 0 interrupt + * @arg TM_INT_CH1CC : TM Capture/compare 1 interrupt + * @arg TM_INT_CH2CC : TM Capture/compare 2 interrupt + * @arg TM_INT_CH3CC : TM Capture/compare 3 interrupt + * @arg TM_INT_UEV : TM update interrupt + * @arg TM_INT_UEV2 : TM update 2 interrupt + * @arg TM_INT_TEV : TM trigger interrupt + * @arg TM_INT_BRKEV : TM break interrupt + * @retval None + ************************************************************************************************************/ +void TM_ClearIntPendingBit(HT_TM_TypeDef* TMx, u32 TM_INT) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_INT(TM_INT)); + + /* Clear the interrupt pending Bit */ + TMx->INTSR = ~TM_INT; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Disable slave mode to clock the prescaler directly with the internal clock. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval None + ************************************************************************************************************/ +void TM_InternalClockConfig(HT_TM_TypeDef* TMx) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Disable slave mode to clock the prescaler directly with the internal clock */ + TMx->MDCFR &= MDCFR_SMSEL_MASK; +} + +/*********************************************************************************************************//** + * @brief Select Channel Capture/Compare PDMA event of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Selection: This parameter can be TM_CHCCDS_CHCCEV or TM_CHCCDS_UEV. + * @retval None + ************************************************************************************************************/ +void TM_CHCCDSConfig(HT_TM_TypeDef* TMx, TM_CHCCDS_Enum Selection) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CHCCDS(Selection)); + + if (Selection != TM_CHCCDS_CHCCEV) + { + TMx->CTR |= CTR_CHCCDS; + } + else + { + TMx->CTR &= ~CTR_CHCCDS; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified PDMA requests of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_PDMA: Specify the TM PDMA requests to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg TM_PDMA_CH0CC : TM Capture/compare 0 PDMA request + * @arg TM_PDMA_CH1CC : TM Capture/compare 1 PDMA request + * @arg TM_PDMA_CH2CC : TM Capture/compare 2 PDMA request + * @arg TM_PDMA_CH3CC : TM Capture/compare 3 PDMA request + * @arg TM_PDMA_UEV : TM update PDMA request + * @arg TM_PDMA_UEV2 : TM update 2 PDMA request + * @arg TM_PDMA_TEV : TM trigger PDMA request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_PDMAConfig(HT_TM_TypeDef* TMx, u32 TM_PDMA, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_PDMA(TM_PDMA)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the PDMA request */ + TMx->DICTR |= TM_PDMA; + } + else + { + /* Disable the PDMA request */ + TMx->DICTR &= ~TM_PDMA; + } +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup TM_Private_Functions TM private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Configure the CHx as input. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Ch: Specify the TM Channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Pol: The input polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : Active high level or rising edge + * @arg TM_CHP_INVERTED : Active low level or falling edge + * @param Sel: Specify the input to be used. + * This parameter can be one of the following values: + * @arg TM_CHCCS_DIRECT : TM CHxI is mapped on CHx. + * @arg TM_CHCCS_INDIRECT : TM CH1I is mapped on CH0 (or CH0I->CH1 or CH2I->CH3 or CH3I->CH2). + * @arg TM_CHCCS_TRCED : TM CHx is mapped on TRC. + * @param Filter: Specify the input capture filter. + * This parameter must be a value between 0x00 and 0x0F. + * @retval None + ************************************************************************************************************/ +static void _TM_CHx_Config(HT_TM_TypeDef* TMx, TM_CH_Enum Ch, TM_CHP_Enum Pol, TM_CHCCS_Enum Sel, u8 Filter) +{ + vu32* pIcfr = (vu32*)&TMx->CH0ICFR + Ch; + u32 wIcfr, wChpolr; + + /* Disable the channel N: reset the CHxE bit */ + TMx->CHCTR &= ~((u32)0x1 << (Ch << 1)); + + wIcfr = *pIcfr; + wChpolr = TMx->CHPOLR; + + /* Select the input and set the filter */ + wIcfr &= CHICFR_CHCCS_MASK & CHICFR_CHF_MASK; + wIcfr |= Sel | Filter; + *pIcfr = wIcfr; + + /* Select the polarity bit */ + wChpolr &= ~((u32)0x1 << (Ch << 1)); + wChpolr |= (u32)Pol << (Ch << 1); + TMx->CHPOLR = wChpolr; + + /* Set the CHxE Bit */ + TMx->CHCTR |= (u32)0x1 << (Ch << 1); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usart.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usart.c new file mode 100644 index 0000000000..93ccffa0bf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usart.c @@ -0,0 +1,1105 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_usart.c + * @version $Rev:: 2972 $ + * @date $Date:: 2023-10-28 #$ + * @brief This file provides all the USART firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_usart.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup USART USART + * @brief USART driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup USART_Private_Define USART private definitions + * @{ + */ +#if (LIBCFG_USART_V01) +#define MDR_CLEAR_Mask ((u32)0xFFFFFFFC) +#define LCR_CLEAR_Mask ((u32)0xFFFFFFE0) + +#define USART_TIMEOUT_ON ((u32)0x00000080) +#define USART_TIMEOUT_OFF ((u32)0xFFFFFF7F) + +#define USART_BREAK_ON ((u32)0x00000040) +#define USART_BREAK_OFF ((u32)0xFFFFFFBF) + +#define USART_SPE_ON ((u32)0x00000020) +#define USART_SPE_OFF ((u32)0xFFFFFFDF) + +#define USART_EN_ON ((u32)0x00000100) + +#define USART_HFCEN_ON ((u32)0x00000004) +#define USART_HFCEN_OFF ((u32)0xFFFFFFFB) +#else +#define CR_CLEAR_Mask ((u32)0xFFFFE0FC) + +#define USART_BREAK_ON ((u32)0x00004000) +#define USART_BREAK_OFF ((u32)0xFFFFBFFF) + +#define USART_PBE_ON ((u32)0x00000800) +#define USART_SPE_ON ((u32)0x00002000) +#define USART_SPE_OFF ((u32)0xFFFFDFFF) + +#define USART_EN_ON ((u32)0x00000010) + +#define USART_HFCEN_ON ((u32)0x00000008) +#define USART_HFCEN_OFF ((u32)0xFFFFFFF7) + +#define USART_RXTOEN_ON ((u32)0x00000080) +#endif + +#define FCR_TL_Mask ((u32)0x00000030) + +#define TRSM_CLEAR_Mask ((u32)0xFFFFFFFB) +#define TPR_TG_Mask ((u32)0xFFFF00FF) +#define ICR_IRDAPSC_Mask ((u32)0xFFFF00FF) +#define TPR_RXTOIC_Mask ((u32)0xFFFFFF80) +#define RS485CR_ADDM_Mask ((u32)0xFFFF00FF) + +#define USART_IRDA_ON ((u32)0x00000001) +#define USART_IRDA_OFF ((u32)0xFFFFFFFE) + +#define USART_INV_ON ((u32)0x00000010) + +#define USART_RS485NMM_ON ((u32)0x00000002) +#define USART_RS485NMM_OFF ((u32)0xFFFFFFFD) + +#define USART_RS485AAD_ON ((u32)0x00000004) +#define USART_RS485AAD_OFF ((u32)0xFFFFFFFB) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Functions USART exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the USART/UART peripheral registers to their default reset values. + * @param USARTx: Parameter to select the UxART peripheral. + * @retval None + ************************************************************************************************************/ +void USART_DeInit(HT_USART_TypeDef* USARTx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + u32 uIPAddr = (u32)USARTx; + + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + switch (uIPAddr) + { + case HT_USART0_BASE: + { + RSTCUReset.Bit.USART0 = 1; + break; + } + #if !(LIBCFG_NO_USART1) + case HT_USART1_BASE: + { + RSTCUReset.Bit.USART1 = 1; + break; + } + #endif + case HT_UART0_BASE: + { + RSTCUReset.Bit.UART0 = 1; + break; + } + case HT_UART1_BASE: + { + RSTCUReset.Bit.UART1 = 1; + break; + } + } + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the USART/UART peripheral according to the specified parameters in the USART_InitStruct. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_InitStruct: pointer to a USART_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_Init(HT_USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct) +{ + u32 uIPClock = 0; + u32 uIPAddr = (u32)USARTx; + + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_BAUDRATE(USART_InitStruct->USART_BaudRate)); + Assert_Param(IS_USART_WORD_LENGTH(USART_InitStruct->USART_WordLength)); + Assert_Param(IS_USART_STOPBITS(USART_InitStruct->USART_StopBits)); + Assert_Param(IS_USART_PARITY(USART_InitStruct->USART_Parity)); + Assert_Param(IS_USART_MODE(USART_InitStruct->USART_Mode)); + + #if (LIBCFG_USART_V01) + USARTx->LCR = (USARTx->LCR & LCR_CLEAR_Mask) | USART_InitStruct->USART_StopBits | + USART_InitStruct->USART_WordLength | USART_InitStruct->USART_Parity; + + USARTx->MDR = (USARTx->MDR & MDR_CLEAR_Mask) | USART_InitStruct->USART_Mode; + #else + USARTx->CR = (USARTx->CR & CR_CLEAR_Mask) | USART_InitStruct->USART_StopBits | + USART_InitStruct->USART_WordLength | USART_InitStruct->USART_Parity | + USART_InitStruct->USART_Mode; + #endif + + switch (uIPAddr) + { + case HT_USART0_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_USART0); + break; + } + #if !(LIBCFG_NO_USART1) + case HT_USART1_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_USART1); + break; + } + #endif + case HT_UART0_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_UART0); + break; + } + case HT_UART1_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_UART1); + break; + } + } + + USARTx->DLR = uIPClock / (u32)USART_InitStruct->USART_BaudRate; +} + +/*********************************************************************************************************//** + * @brief Fill each USART_InitStruct member with its default value. + * @param USART_InitStruct: pointer to a USART_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_StructInit(USART_InitTypeDef* USART_InitStruct) +{ + /* USART_InitStruct members default value */ + USART_InitStruct->USART_BaudRate = 9600; + USART_InitStruct->USART_WordLength = USART_WORDLENGTH_8B; + USART_InitStruct->USART_StopBits = USART_STOPBITS_1; + USART_InitStruct->USART_Parity = USART_PARITY_NO; + USART_InitStruct->USART_Mode = USART_MODE_NORMAL; +} + +/*********************************************************************************************************//** + * @brief USART/UART send data to Tx. + * @param USARTx: Parameter to select the UxART peripheral. + * @param Data: the data to be transmitted. + * @retval None + ************************************************************************************************************/ +void USART_SendData(HT_USART_TypeDef* USARTx, u16 Data) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_DATA(Data)); + + USARTx->DR = Data; +} + +/*********************************************************************************************************//** + * @brief USART/UART receive data from Rx. + * @param USARTx: Parameter to select the UxART peripheral. + * @retval The received data. + ************************************************************************************************************/ +u16 USART_ReceiveData(HT_USART_TypeDef* USARTx) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + return (u16)(USARTx->DR); +} + +/*********************************************************************************************************//** + * @brief Get the specified USART/UART status flags. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_FLAG_x: Specify the flag to be check. + * This parameter can be one of the following values: + * LIBCFG_USART_V01 / LIBCFG_USART_V01_LEGACY: + * @arg USART_FLAG_RXDNE / USART_LSR_RFDR + * @arg USART_FLAG_THRE / USART_LSR_THRE + * @arg USART_FLAG_TXC / USART_LSR_TE + * @arg USART_FLAG_ERR / USART_LSR_ERR + * @arg USART_FLAG_MODIS + * @arg USART_FLAG_TXDE + * @arg USART_FLAG_RXDR + * @arg USART_FLAG_RLSI + * @arg USART_FLAG_TOUT + * HT32F1xxxx: + * @arg USART_FLAG_RXDNE : + * @arg USART_FLAG_OE : + * @arg USART_FLAG_PE : + * @arg USART_FLAG_FE : + * @arg USART_FLAG_BI : + * @arg USART_FLAG_RXDR : + * @arg USART_FLAG_TOUT : + * @arg USART_FLAG_TXDE : + * @arg USART_FLAG_TXC : + * @arg USART_FLAG_RSADD : + * @arg USART_FLAG_CTSC : + * @arg USART_FLAG_CTSS : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus USART_GetFlagStatus(HT_USART_TypeDef* USARTx, u32 USART_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_FLAG(USART_FLAG_x)); + + #if (LIBCFG_USART_V01) + if (USART_FLAG_x & USART_FLAG_FROM_IIR) + { + if (USARTx->IIR == (USART_FLAG_x & (~(USART_FLAG_FROM_IIR)))) + { + return (SET); + } + else + { + return (RESET); + } + } + else + { + #endif + + if ((USARTx->SR & USART_FLAG_x) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } + + #if (LIBCFG_USART_V01) + } + #endif +} + +#if (LIBCFG_USART_V01) +#else +/*********************************************************************************************************//** + * @brief Get the specified USART/UART INT status. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_INT_x: Specify if the USART/UART interrupt source. + * This parameter can be one of the following values: + * @arg USART_INT_RXDR : + * @arg USART_INT_TXDE : + * @arg USART_INT_TXC : + * @arg USART_INT_OE : + * @arg USART_INT_PE : + * @arg USART_INT_FE : + * @arg USART_INT_BI : + * @arg USART_INT_RSADD : + * @arg USART_INT_TOUT : + * @arg USART_INT_CTS : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus USART_GetIntStatus(HT_USART_TypeDef* USARTx, u32 USART_INT_x) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_INT(USART_INT_x)); + + if ((USARTx->IER & USART_INT_x) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified USART/UART flags. + * @param USARTx: where USARTx is the selected USART/UART from the USART/UART peripherals. + * @param USART_Flag: Specify the flag to check. + * This parameter can be any combination of the following values: + * @arg USART_FLAG_OE : + * @arg USART_FLAG_PE : + * @arg USART_FLAG_FE : + * @arg USART_FLAG_BI : + * @arg USART_FLAG_TOUT : + * @arg USART_FLAG_RSADD : + * @arg USART_FLAG_CTSC : + * @retval SET or RESET + ************************************************************************************************************/ +void USART_ClearFlag(HT_USART_TypeDef* USARTx, u32 USART_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_CLEAR_FLAG(USART_Flag)); + + USARTx->SR &= USART_Flag; +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART interrupts. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_INT_x: Specify if the USART/UART interrupt source to be enabled or disabled. + * This parameter can be one of the following values: + * LIBCFG_USART_V01 / LIBCFG_USART_V01_LEGACY + * @arg USART_INT_RXDR / USART_IER_RDAIE : + * @arg USART_INT_TXDE / USART_IER_THREIE : + * @arg USART_INT_RLSIE / USART_IER_RLSIE : TXC, OE, PE, FE, BI, RSADD + * @arg USART_INT_MSIE / USART_IER_MSIE : + * HT32F1xxxx: + * @arg USART_INT_RXDR : + * @arg USART_INT_TXDE : + * @arg USART_INT_TXC : + * @arg USART_INT_OE : + * @arg USART_INT_PE : + * @arg USART_INT_FE : + * @arg USART_INT_BI : + * @arg USART_INT_RSADD : + * @arg USART_INT_TOUT : + * @arg USART_INT_CTS : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_IntConfig(HT_USART_TypeDef* USARTx, u32 USART_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_INT(USART_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_USART_V01) + if (USART_INT_x & USART_INT_TOUT) + { + if (NewState != DISABLE) + { + USARTx->TPR |= USART_TIMEOUT_ON; + } + else + { + USARTx->TPR &= USART_TIMEOUT_OFF; + } + } + #endif + + if (NewState != DISABLE) + { + USARTx->IER |= USART_INT_x; + } + else + { + USARTx->IER &= ~USART_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART Tx/Rx. + * @param USARTx: Parameter to select the USART peripheral. + * @param TxRx: This parameter can be USART_CMD_TX or USART_CMD_RX. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_TxRxCmd(HT_USART_TypeDef* USARTx, u32 TxRx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_USART_V01) + if (NewState != DISABLE) + { + USARTx->FCR |= (USART_EN_ON << TxRx); + } + else + { + USARTx->FCR &= ~(USART_EN_ON << TxRx); + } + #else + if (NewState != DISABLE) + { + USARTx->CR |= (USART_EN_ON << TxRx); + } + else + { + USARTx->CR &= ~(USART_EN_ON << TxRx); + } + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART PDMA interface. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_PDMAREQ: specify the USART/UART PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg USART_PDMAREQ_TX + * @arg USART_PDMAREQ_RX + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_PDMACmd(HT_USART_TypeDef* USARTx, u32 USART_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_PDMA_REQ(USART_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_USART_V01) + if (NewState != DISABLE) + { + USARTx->MDR |= USART_PDMAREQ; + } + else + { + USARTx->MDR &= ~USART_PDMAREQ; + } + #else + if (NewState != DISABLE) + { + USARTx->CR |= USART_PDMAREQ; + } + else + { + USARTx->CR &= ~USART_PDMAREQ; + } + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART break control function. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_ForceBreakCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_USART_V01) + if (NewState != DISABLE) + { + USARTx->LCR |= USART_BREAK_ON; + } + else + { + USARTx->LCR &= USART_BREAK_OFF; + } + #else + if (NewState != DISABLE) + { + USARTx->CR |= USART_BREAK_ON; + } + else + { + USARTx->CR &= USART_BREAK_OFF; + } + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART stick parity function. + * @param USARTx: Parameter to select the UxART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_StickParityCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_USART_V01) + if (NewState != DISABLE) + { + USARTx->LCR |= USART_SPE_ON; + } + else + { + USARTx->LCR &= USART_SPE_OFF; + } + #else + if (NewState != DISABLE) + { + USARTx->CR |= USART_SPE_ON | USART_PBE_ON; + } + else + { + USARTx->CR &= USART_SPE_OFF; + } + #endif +} + +/*********************************************************************************************************//** + * @brief Configure the stick parity value of the USART/UART. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_StickParity: Specify the stick parity of the USART/UART. + * This parameter can be one of the following values: + * @arg USART_STICK_LOW + * @arg USART_STICK_HIGH + * @retval None + ************************************************************************************************************/ +void USART_StickParityConfig(HT_USART_TypeDef * USARTx, u32 USART_StickParity) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_STICK_PARITY(USART_StickParity)); + + #if (LIBCFG_USART_V01) + if (USART_StickParity != USART_STICK_HIGH) + { + USARTx->LCR |= USART_STICK_LOW; + } + else + { + USARTx->LCR &= USART_STICK_HIGH; + } + #else + if (USART_StickParity != USART_STICK_HIGH) + { + USARTx->CR |= USART_STICK_LOW; + } + else + { + USARTx->CR &= USART_STICK_HIGH; + } + #endif +} + +/*********************************************************************************************************//** + * @brief Set the specified USART guard time. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_GuardTime: Specify the guard time. + * @retval None + ************************************************************************************************************/ +void USART_SetGuardTime(HT_USART_TypeDef* USARTx, u32 USART_GuardTime) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_GUARD_TIME(USART_GuardTime)); + + USARTx->TPR = (USARTx->TPR & TPR_TG_Mask) | (USART_GuardTime << 0x08); +} + +/*********************************************************************************************************//** + * @brief Configure the Tx/Rx FIFO Interrupt Trigger Level. + * @param USARTx: Parameter to select the USART peripheral. + * @param TxRx: This parameter can be USART_CMD_TX or USART_CMD_RX. + * @param USART_tl: Specify the USART Tx/Rx FIFO interrupt trigger level. + * This parameter can be one of the following values: + * For LIBCFG_USART_V01: + * @arg USART_RXTL_01 + * @arg USART_RXTL_04 + * @arg USART_RXTL_08 + * @arg USART_RXTL_14 + * @arg USART_TXTL_00 + * @arg USART_TXTL_02 + * @arg USART_TXTL_04 + * @arg USART_TXTL_08 + * For HT32F1xxxx: + * @arg USART_RXTL_01 + * @arg USART_RXTL_02 + * @arg USART_RXTL_04 + * @arg USART_RXTL_06 + * @arg USART_TXTL_00 + * @arg USART_TXTL_02 + * @arg USART_TXTL_04 + * @arg USART_TXTL_06 + * @retval None + ************************************************************************************************************/ +void USART_TXRXTLConfig(HT_USART_TypeDef* USARTx, u32 TxRx, u32 USART_tl) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_TL(USART_tl)); + + USARTx->FCR = (USARTx->FCR & ~(FCR_TL_Mask << (TxRx * 2))) | (USART_tl << (TxRx * 2)); +} + +/*********************************************************************************************************//** + * @brief Set the USART FIFO time-out value. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_TimeOut: Specify the time-out value. + * @retval None + ************************************************************************************************************/ +void USART_SetTimeOutValue(HT_USART_TypeDef* USARTx, u32 USART_TimeOut) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_TIMEOUT(USART_TimeOut)); + + #if (LIBCFG_USART_V01) + USARTx->TPR = (USARTx->TPR & TPR_RXTOIC_Mask) | USART_TimeOut; + #else + USARTx->TPR = (USARTx->TPR & TPR_RXTOIC_Mask) | USART_TimeOut | USART_RXTOEN_ON; + #endif +} + +/*********************************************************************************************************//** + * @brief Clear both the write and read point in USART Tx FIFO or Rx FIFO. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_FIFODirection: Determine TX FIFO or Rx FIFO that is to be reset. + * This parameter can be any combination of the following values: + * @arg USART_FIFO_TX + * @arg USART_FIFO_RX + * @retval None + ************************************************************************************************************/ +void USART_FIFOReset(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_FIFO_DIRECTION(USART_FIFODirection)); + + USARTx->FCR |= USART_FIFODirection; +} + +/*********************************************************************************************************//** + * @brief Return the status of specified USART FIFO. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_FIFODirection: specify the FIFO that is to be check. + * This parameter can be one of the following values: + * @arg USART_FIFO_TX + * @arg USART_FIFO_RX + * @retval The number of data in Tx FIFO or Rx FIFO. + ************************************************************************************************************/ +u8 USART_GetFIFOStatus(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_FIFO_DIRECTION(USART_FIFODirection)); + + #if (LIBCFG_USART_V01) + if (USART_FIFODirection == USART_FIFO_TX) + { + return (u8)(USARTx->FSR & 0x1F); + } + else + { + return (u8)((USARTx->FSR & 0x1F00) >> 8); + } + #else + if (USART_FIFODirection == USART_FIFO_TX) + { + return (u8)((USARTx->FCR & 0xF0000) >> 16); + } + else + { + return (u8)((USARTx->FCR & 0xF000000) >> 24); + } + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART hardware flow control. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_HardwareFlowControlCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_USART_V01) + if (NewState != DISABLE) + { + USARTx->MCR |= USART_HFCEN_ON; + } + else + { + USARTx->MCR &= USART_HFCEN_OFF; + } + #else + if (NewState != DISABLE) + { + USARTx->CR |= USART_HFCEN_ON; + } + else + { + USARTx->CR &= USART_HFCEN_OFF; + } + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART IrDA interface. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_IrDACmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->ICR |= USART_IRDA_ON; + } + else + { + USARTx->ICR &= USART_IRDA_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Configure the USART IrDA interface. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_IrDAMode: Specify the USART IrDA mode. + * This parameter can be one of the following values: + * @arg USART_IRDA_LOWPOWER + * @arg USART_IRDA_NORMAL + * @retval None + ************************************************************************************************************/ +void USART_IrDAConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDAMode) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_IRDA_MODE(USART_IrDAMode)); + + if (USART_IrDAMode != USART_IRDA_NORMAL) + { + USARTx->ICR |= USART_IRDA_LOWPOWER; + } + else + { + USARTx->ICR &= USART_IRDA_NORMAL; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified USART IrDA prescaler. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_IrDAPrescaler: Specify the USART IrDA prescaler. + * @retval None + ************************************************************************************************************/ +void USART_SetIrDAPrescaler(HT_USART_TypeDef* USARTx, u32 USART_IrDAPrescaler) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_IRDA_PRESCALER(USART_IrDAPrescaler)); + + USARTx->ICR = (USARTx->ICR & ICR_IRDAPSC_Mask) | (USART_IrDAPrescaler << 0x08); +} + +/*********************************************************************************************************//** + * @brief Enable the IrDA transmitter or receiver. + * @param USARTx: Parameter to select the USART peripheral, x can be 0 or 1. + * @param USART_IrDADirection: Specify the USART IrDA direction select. + * This parameter can be one of the following values: + * @arg USART_IRDA_TX + * @arg USART_IRDA_RX + * @retval None + ************************************************************************************************************/ +void USART_IrDADirectionConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDADirection) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_IRDA_DIRECTION(USART_IrDADirection)); + + if (USART_IrDADirection != USART_IRDA_RX) + { + USARTx->ICR |= USART_IRDA_TX; + } + else + { + USARTx->ICR &= USART_IRDA_RX; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable inverting serial output/input function of IrDA on the specified USART. + * @param USARTx: Parameter to select the USART peripheral. + * @param inout: This parameter can be USART_CMD_OUT or USART_CMD_IN. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_IrDAInvtCmd(HT_USART_TypeDef* USARTx, u32 inout, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->ICR |= (USART_INV_ON << inout); + } + else + { + USARTx->ICR &= ~(USART_INV_ON << inout); + } +} + +/*********************************************************************************************************//** + * @brief Configure the polarity of USART RS485 transmitter enable signal. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_RS485Polarity: Specify the polarity of USART RS485 Tx enable signal. + * This parameter can be one of the following values: + * @arg USART_RS485POL_LOW + * @arg USART_RS485POL_HIGH + * @retval None + ************************************************************************************************************/ +void USART_RS485TxEnablePolarityConfig(HT_USART_TypeDef* USARTx, u32 USART_RS485Polarity) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_RS485_POLARITY(USART_RS485Polarity)); + + if (USART_RS485Polarity != USART_RS485POLARITY_HIGH) + { + USARTx->RCR |= USART_RS485POLARITY_LOW; + } + else + { + USARTx->RCR &= USART_RS485POLARITY_HIGH; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART RS485 normal multi-drop operation mode. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_RS485NMMCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->RCR |= USART_RS485NMM_ON; + } + else + { + USARTx->RCR &= USART_RS485NMM_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART RS485 normal multi-drop operation mode. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_RS485AADCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->RCR |= USART_RS485AAD_ON; + } + else + { + USARTx->RCR &= USART_RS485AAD_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified USART RS485 address match value. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_AddressMatchValue: specify the USART RS485 address match value. + * @retval None + ************************************************************************************************************/ +void USART_SetAddressMatchValue(HT_USART_TypeDef* USARTx, u32 USART_AddressMatchValue) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_ADDRESS_MATCH_VALUE(USART_AddressMatchValue)); + + USARTx->RCR = (USARTx->RCR & RS485CR_ADDM_Mask) | (u32)(USART_AddressMatchValue << 0x08); +} + +/*********************************************************************************************************//** + * @brief Initialize the clock of the USART peripheral according to the specified parameters + * in the USART_ClockInitStruct. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_SynClock_InitStruct: pointer to a USART_SynClock_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_SynClockInit(HT_USART_TypeDef* USARTx, USART_SynClock_InitTypeDef* USART_SynClock_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_SYNCHRONOUS_CLOCK(USART_SynClock_InitStruct->USART_ClockEnable)); + Assert_Param(IS_USART_SYNCHRONOUS_PHASE(USART_SynClock_InitStruct->USART_ClockPhase)); + Assert_Param(IS_USART_SYNCHRONOUS_POLARITY(USART_SynClock_InitStruct->USART_ClockPolarity)); + Assert_Param(IS_USART_TRANSFER_MODE(USART_SynClock_InitStruct->USART_TransferSelectMode)); + + USARTx->SCR = USART_SynClock_InitStruct->USART_ClockEnable | USART_SynClock_InitStruct->USART_ClockPhase | + USART_SynClock_InitStruct->USART_ClockPolarity; + + #if (LIBCFG_USART_V01) + USARTx->MDR = (USARTx->MDR & TRSM_CLEAR_Mask) | USART_SynClock_InitStruct->USART_TransferSelectMode; + #else + USARTx->CR = (USARTx->CR & TRSM_CLEAR_Mask) | USART_SynClock_InitStruct->USART_TransferSelectMode; + #endif +} + +/*********************************************************************************************************//** + * @brief Fill each USART_SynClockInitStruct member with its default value. + * @param USART_SynClock_InitStruct: pointer to a USART_SynClock_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_SynClockStructInit(USART_SynClock_InitTypeDef* USART_SynClock_InitStruct) +{ + /* USART_ClockInitStruct members default value */ + USART_SynClock_InitStruct->USART_ClockEnable = USART_SYN_CLOCK_DISABLE; + USART_SynClock_InitStruct->USART_ClockPhase = USART_SYN_CLOCK_PHASE_FIRST; + USART_SynClock_InitStruct->USART_ClockPolarity = USART_SYN_CLOCK_POLARITY_LOW; + USART_SynClock_InitStruct->USART_TransferSelectMode = USART_LSB_FIRST; +} + +#if (LIBCFG_USART_V01) +/*********************************************************************************************************//** + * @brief Force pin DTR/RTS to low or high state. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_ModemPin: Specify the USART modem pin to be forced. + * This parameter can be one of the following values: + * @arg USART_MODEM_DTR + * @arg USART_MODEM_RTS + * @param USART_ModemState: the USART modem pin state. + * This parameter can be one of the following values: + * @arg USART_MODEMSTATE_HIGH + * @arg USART_MODEMSTATE_LOW + * @retval None + ************************************************************************************************************/ +void USART_ForceModemPinState(HT_USART_TypeDef* USARTx, u32 USART_ModemPin, u32 USART_ModemState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_MODEM_PIN(USART_ModemPin)); + Assert_Param(IS_USART_MODEM_STATE(USART_ModemState)); + + if (USART_ModemState != USART_MODEMSTATE_HIGH) + { + USARTx->MCR |= USART_MODEMSTATE_LOW << USART_ModemPin; + } + else + { + USARTx->MCR &= ~(USART_MODEMSTATE_HIGH << USART_ModemPin); + } +} + +/*********************************************************************************************************//** + * @brief Get Modem status. + * @param USARTx: Parameter to select the USART peripheral. + * @retval The current status of Modem Status Register. + ************************************************************************************************************/ +u8 USART_GetModemStatus(HT_USART_TypeDef* USARTx) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + return (u8)(USARTx->MSR); +} + +#if 0 +/*********************************************************************************************************//** + * @brief Enable or Disable time out interrupt of the USART. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_TimeOutIntConfig(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->TPR |= USART_TIMEOUT_ON; + } + else + { + USARTx->TPR &= USART_TIMEOUT_OFF; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Get Interrupt ID value. + * @param USARTx: Parameter to select the USART peripheral. + * @retval The interrupt ID of USART. + * @arg USART_IID_RLS + * @arg USART_IID_RDA + * @arg USART_IID_CTI + * @arg USART_IID_THRE + * @arg USART_IID_MS + * @arg USART_IID_NON + ************************************************************************************************************/ +u8 USART_GetIntID(HT_USART_TypeDef* USARTx) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + return (u8)(USARTx->IIR); +} + +/*********************************************************************************************************//** + * @brief Get Line Status Value. + * @param USARTx: Parameter to select the USART peripheral. + * @retval The vlaue of LSR. + ************************************************************************************************************/ +u32 USART_GetLineStatusValue(HT_USART_TypeDef* USARTx) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + return (u8)(USARTx->LSR); +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usbd.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usbd.c new file mode 100644 index 0000000000..307c5f3d2c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_usbd.c @@ -0,0 +1,796 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_usbd.c + * @version $Rev:: 1670 $ + * @date $Date:: 2019-04-09 #$ + * @brief The USB Device Peripheral Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32f1xxxx_usbdchk.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup USBDevice USB Device + * @brief USB Device driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Constant USB Device private constants + * @{ + */ +#define TCR_MASK (0x1FF) +#define EPLEN_MASK ((u32)0x000FFC00) +#define EPBUFA_MASK ((u32)0x000003FF) +#define ISR_EPn_OFFSET (8) + +/* USB Control and Status Register (USBCSR) */ +#define FRES ((u32)0x00000002) /* Force USB Reset */ +#define PDWN ((u32)0x00000004) /* Power Down */ +#define LPMODE ((u32)0x00000008) /* Low-power Mode */ +#define GENRSM ((u32)0x00000020) /* Generate Resume */ +#define ADRSET ((u32)0x00000100) /* Device Address Setting */ +#define SRAMRSTC ((u32)0x00000200) /* USB SRAM reset condition */ +#define DPPUEN ((u32)0x00000400) /* DP Pull Up Enable */ +#define DPWKEN ((u32)0x00000800) /* DP Wake Up Enable */ + +#define EPDIR_IN (1) +#define EPDIR_OUT (0) +/** + * @} + */ + +/* Private variables ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Variable USB Device private variables + * @{ + */ +static u32 gIsFirstPowered = TRUE; +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Macro USB Device private macros + * @{ + */ +#ifndef USBDCore_LowPower + #define USBDCore_LowPower() PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_WFE) +#endif +/** + * @brief Convert Byte length to Word length + */ +#define ByteLen2WordLen(n) ((n + 3) >> 2) +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void _USBD_CopyMemory(u32 *pFrom, u32 *pTo, u32 len); +static HT_USBEP_TypeDef * _USBD_GetEPTnAddr(USBD_EPTn_Enum USBD_EPTn); +static void _delay(u32 nCount); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Functions USB Device exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Pre initialization for USBD_Init function. + * @param pDriver: USB initialization structure + * @retval None + ***********************************************************************************************************/ +void USBD_PreInit(USBD_Driver_TypeDef *pDriver) +{ + pDriver->uInterruptMask = _UIER_ALL; + + pDriver->ept[USBD_EPT0].CFGR.word = _EP0_CFG; + pDriver->ept[USBD_EPT0].IER = _EP0_IER; + + #if (_EP1_ENABLE == 1) + pDriver->ept[USBD_EPT1].CFGR.word = _EP1_CFG; + pDriver->ept[USBD_EPT1].IER = _EP1_IER; + #endif + + #if (_EP2_ENABLE == 1) + pDriver->ept[USBD_EPT2].CFGR.word = _EP2_CFG; + pDriver->ept[USBD_EPT2].IER = _EP2_IER; + #endif + + #if (_EP3_ENABLE == 1) + pDriver->ept[USBD_EPT3].CFGR.word = _EP3_CFG; + pDriver->ept[USBD_EPT3].IER = _EP3_IER; + #endif + + #if (_EP4_ENABLE == 1) + pDriver->ept[USBD_EPT4].CFGR.word = _EP4_CFG; + pDriver->ept[USBD_EPT4].IER = _EP4_IER; + #endif + + #if (_EP5_ENABLE == 1) + pDriver->ept[USBD_EPT5].CFGR.word = _EP5_CFG; + pDriver->ept[USBD_EPT5].IER = _EP5_IER; + #endif + + #if (_EP6_ENABLE == 1) + pDriver->ept[USBD_EPT6].CFGR.word = _EP6_CFG; + pDriver->ept[USBD_EPT6].IER = _EP6_IER; + #endif + + #if (_EP7_ENABLE == 1) + pDriver->ept[USBD_EPT7].CFGR.word = _EP7_CFG; + pDriver->ept[USBD_EPT7].IER = _EP7_IER; + #endif + + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Peripheral initialization. + * @param pDriver: USB initialization structure + * @retval None + ***********************************************************************************************************/ +void USBD_Init(u32 *pDriver) +{ + USBD_Driver_TypeDef *pDrv = (USBD_Driver_TypeDef *)pDriver; + + /* Init USB Device Driver struct */ + USBD_PreInit(pDrv); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Internal DP pull up. + * @param NewState: ENABLE or DISABLE + * @retval None + ***********************************************************************************************************/ +void USBD_DPpullupCmd(ControlStatus NewState) +{ + (NewState == ENABLE)?(HT_USB->CSR |= DPPUEN):(HT_USB->CSR &= ~DPPUEN); +} + +/*********************************************************************************************************//** + * @brief USB Device Wake Up when DP is high level. + * @param NewState: ENABLE or DISABLE + * @retval None + ***********************************************************************************************************/ +void USBD_DPWakeUpCmd(ControlStatus NewState) +{ + (NewState == ENABLE)?(HT_USB->CSR |= DPWKEN):(HT_USB->CSR &= ~DPWKEN); +} + +/*********************************************************************************************************//** + * @brief USB Device Peripheral deinitialization. + * @retval None + ***********************************************************************************************************/ +void USBD_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.USBD = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); + + return; +} + +/*********************************************************************************************************//** + * @brief USB power up procedure. + * @retval None + ***********************************************************************************************************/ +void USBD_PowerUp(u32 *pDriver, u32 uIsSelfPowered) +{ + USBD_Driver_TypeDef *pDrv = (USBD_Driver_TypeDef *)pDriver; + + if (gIsFirstPowered == TRUE) + { + gIsFirstPowered = FALSE; + + if (HT_USB->CSR & 0x40) + { + HT_USB->CSR = (DPPUEN | LPMODE | PDWN); + while((HT_USB->ISR & URSTIE) == 0); + HT_USB->ISR = 0xFFFFFFFF; + if (uIsSelfPowered == FALSE) + { + USBDCore_LowPower(); + } + USBD_EnableINT(pDrv->uInterruptMask); + } + else + { + HT_USB->CSR = (DPWKEN | DPPUEN | LPMODE | PDWN); + while((HT_USB->ISR & URSTIE) == 0); + HT_USB->ISR = 0xFFFFFFFF; + if (uIsSelfPowered == FALSE) + { + USBDCore_LowPower(); + } + USBD_DPWakeUpCmd(DISABLE); + USBD_EnableINT(pDrv->uInterruptMask); + USBD_DPpullupCmd(DISABLE); + _delay(200); + USBD_DPpullupCmd(ENABLE); + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief Enter USB Device Power Down mode. + * @retval None + ***********************************************************************************************************/ +void USBD_PowerOff(void) +{ + HT_USB->CSR |= (LPMODE | PDWN); + return; +} + +/*********************************************************************************************************//** + * @brief Exit USB Device Power Down mode. + * @retval None + ***********************************************************************************************************/ +void USBD_PowerOn(void) +{ + HT_USB->CSR |= 0x00001000; + HT_USB->CSR &= 0x00001400; + return; +} + +/*********************************************************************************************************//** + * @brief USB SRAM reset condition. + * @param NewState: ENABLE or DISABLE + * @retval None + ***********************************************************************************************************/ +void USBD_SRAMResetConditionCmd(ControlStatus NewState) +{ + (NewState == ENABLE)?(HT_USB->CSR |= SRAMRSTC):(HT_USB->CSR &= ~SRAMRSTC); +} + +/*********************************************************************************************************//** + * @brief Disable Default pull resistance of D+ and D-. + * @retval None + ***********************************************************************************************************/ +void USBD_DisableDefaultPull(void) +{ + HT_USB->CSR = FRES; // Clear PDWN and keep FRES = 1 +} + +/*********************************************************************************************************//** + * @brief Generate a resume request to USB Host for Remote Wakeup function. + * @retval None + ***********************************************************************************************************/ +void USBD_RemoteWakeup(void) +{ + HT_USB->CSR |= GENRSM; + return; +} + +/*********************************************************************************************************//** + * @brief Read Endpoint0 SETUP data from USB Buffer. + * @param pBuffer: Buffer for save SETUP data + * @retval None + ***********************************************************************************************************/ +void USBD_ReadSETUPData(u32 *pBuffer) +{ + u32 *pSrc = (u32 *)HT_USB_SRAM_BASE; + + *pBuffer = *pSrc; + *(pBuffer + 1) = *(pSrc + 1); + return; +} + +/*********************************************************************************************************//** + * @brief Set USB Device address. + * @param address: USB address which specified by Host + * @retval None + ***********************************************************************************************************/ +void USBD_SetAddress(u32 address) +{ + HT_USB->CSR |= ADRSET; + HT_USB->DEVAR = address; + return; +} + +/*********************************************************************************************************//** + * @brief Enable USB Device interrupt. + * @param INTFlag: USB Device global interrupt flag + * @arg UGIE | SOFIE | URSTIE | RSMIE | SUSPIE | ESOFIE + * EP0IE | EP1IE | EP2IE | EP3IE | EP4IE | EP5IE | EP6IE | EP7IE + * @retval None + ***********************************************************************************************************/ +void USBD_EnableINT(u32 INTFlag) +{ + HT_USB->IER |= INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Disable USB Device interrupt. + * @param INTFlag: USB Device global interrupt flag + * @arg UGIE | SOFIE | URSTIE | RSMIE | SUSPIE | ESOFIE + * EP0IE | EP1IE | EP2IE | EP3IE | EP4IE | EP5IE | EP6IE | EP7IE + * @retval None + ***********************************************************************************************************/ +void USBD_DisableINT(u32 INTFlag) +{ + HT_USB->IER &= (~INTFlag); + return; +} + +/*********************************************************************************************************//** + * @brief Get active USB Device interrupt flag. + * @retval USB ISR Flag + ***********************************************************************************************************/ +u32 USBD_GetINT(void) +{ + u32 IER = HT_USB->IER | FRESIE; + return (HT_USB->ISR & IER); +} + +/*********************************************************************************************************//** + * @brief Clear USB Device interrupt flag. + * @param INTFlag: USB Device global interrupt flag + * @arg SOFIF | URSTIF | RSMIF | SUSPIF | ESOFIF + * EP0IF | EP1IF | EP2IF | EP3IF | EP4IF | EP5IF | EP6IF | EP7IF + * @retval None + ***********************************************************************************************************/ +void USBD_ClearINT(u32 INTFlag) +{ + HT_USB->ISR = INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Get USB Endpoint number by interrupt flag. + * @param INTFlag: USB Device global interrupt flag + * @arg SOFIF | URSTIF | RSMIF | SUSPIF | ESOFIF + * EP0IF | EP1IF | EP2IF | EP3IF | EP4IF | EP5IF | EP6IF | EP7IF + * @retval USB Endpoint number from USBD_EPT1 ~ USBD_EPT7 + ***********************************************************************************************************/ +USBD_EPTn_Enum USBD_GetEPTnINTNumber(u32 INTFlag) +{ + s32 i; + for (i = MAX_EP_NUM - 1; i > 0; i--) + { + if ((INTFlag >> (i + ISR_EPn_OFFSET)) & SET) + { + return (USBD_EPTn_Enum)i; + } + } + + return USBD_NOEPT; +} + +/*********************************************************************************************************//** + * @brief USB Device Peripheral initialization for Endpoint. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @param pDriver: USB initialization structure + * @retval None + ***********************************************************************************************************/ +void USBD_EPTInit(USBD_EPTn_Enum USBD_EPTn, u32 *pDriver) +{ + USBD_Driver_TypeDef *pDrv = (USBD_Driver_TypeDef *)pDriver; + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + + USBEPn->CFGR = pDrv->ept[USBD_EPTn].CFGR.word; + USBEPn->IER = pDrv->ept[USBD_EPTn].IER; + + USBEPn->ISR = 0xFFFFFFFF; + + USBD_EPTReset(USBD_EPTn); + + return; +} + +/*********************************************************************************************************//** + * @brief Reset Endpoint Status. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTReset(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + USBEPn->CSR = (USBEPn->CSR) & (DTGTX | DTGRX | NAKRX); + return; +} + +/*********************************************************************************************************//** + * @brief Enable Interrupt for Endpoint. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @param INTFlag: Interrupt flag + * @arg OTRXIE | ODRXIE | ODOVIE | ITRXIE | IDTXIE | NAKIE | STLIE | UERIE | + * STRXIE | SDRXIE | SDERIE | ZLRXIE + * @retval None + ***********************************************************************************************************/ +void USBD_EPTEnableINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag) +{ + _USBD_GetEPTnAddr(USBD_EPTn)->IER = INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Get active USB Device Endpoint interrupt. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval USB Endpoint ISR Flag + ***********************************************************************************************************/ +u32 USBD_EPTGetINT(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + u32 IER = USBEPn->IER; + return (USBEPn->ISR & IER); +} + +/*********************************************************************************************************//** + * @brief Clear Interrupt for Endpoint. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @param INTFlag: Interrupt flag + * @arg OTRXIF | ODRXIF | ODOVIF | ITRXIF | IDTXIF | NAKIF | STLIF | UERIF | + * STRXIF | SDRXIF | SDERIF | ZLRXIF + * @retval None + ***********************************************************************************************************/ +void USBD_EPTClearINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag) +{ + _USBD_GetEPTnAddr(USBD_EPTn)->ISR = INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n Halt status (STLTX or STLRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval Endpoint Halt Status (1: Endpoint is Halt, 0: Endpoint is not Halt) + ***********************************************************************************************************/ +u32 USBD_EPTGetHalt(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + return (((USBEPn->CSR) & STLTX) ? 1 : 0); + } + else + { + return (((USBEPn->CSR) & STLRX) ? 1 : 0); + } +} + +/*********************************************************************************************************//** + * @brief Send STALL on Endpoint n. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTSendSTALL(USBD_EPTn_Enum USBD_EPTn) +{ + _USBD_GetEPTnAddr(USBD_EPTn)->CSR = STLTX; + return; +} + +/*********************************************************************************************************//** + * @brief Set Endpoint n Halt status (STLTX or STLRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTSetHalt(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + +#if 1 + /* Clean STLIF flag, for USBD_EPTWaitSTALLSent function */ + USBEPn->ISR = STLIF; + USBEPn->CSR = (~(USBEPn->CSR)) & (STLTX | STLRX); +#else + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + /* Clean STLIF flag, for USBD_EPTWaitSTALLSent function */ + USBEPn->ISR = STLIF; + /* Set only when STLTX = 0 */ + USBEPn->CSR = (~(USBEPn->CSR)) & STLTX; + } + else + { + /* Set only when STLRX = 0 */ + USBEPn->CSR = (~(USBEPn->CSR)) & STLRX; + } +#endif + + return; +} + +/*********************************************************************************************************//** + * @brief Clear Endpoint n Halt status (STLTX or STLRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTClearHalt(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + +#if 1 + USBEPn->CSR = (USBEPn->CSR) & (STLTX | STLRX); +#else + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + /* Clear only when STLTX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & STLTX; + } + else + { + /* Clear only when STLRX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & STLRX; + } +#endif + + return; +} + +/*********************************************************************************************************//** + * @brief Wait until STALL transmission is finished + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTWaitSTALLSent(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + u32 uSTALLState = (CFGR->EPDIR == EPDIR_IN) ? ((USBEPn->CSR) & STLTX) : ((USBEPn->CSR) & STLRX); + + if (uSTALLState) + { + while ((USBEPn->ISR & STLIF) == 0); + } + + return; +} + +/*********************************************************************************************************//** + * @brief Clear Endpoint n Data toggle bit (DTGTX or DTGRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTClearDTG(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + +#if 1 + USBEPn->CSR = (USBEPn->CSR) & (DTGTX | DTGRX); +#else + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + /* Clear only when DTGTX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & DTGTX; + } + else + { + /* Clear only when DTGRX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & DTGRX; + } +#endif + return; +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n buffer 0 address. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval USB Endpoint buffer 0 address + ***********************************************************************************************************/ +u32 USBD_EPTGetBuffer0Addr(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + return (HT_USB_SRAM_BASE + (USBEPn->CFGR & EPBUFA_MASK)); +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n buffer 1 address. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval USB Endpoint buffer 1 address + ***********************************************************************************************************/ +u32 USBD_EPTGetBuffer1Addr(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + return (HT_USB_SRAM_BASE + (USBEPn->CFGR & EPBUFA_MASK) + USBD_EPTGetBufferLen(USBD_EPTn)); +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n buffer length. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval USB Endpoint buffer length + ***********************************************************************************************************/ +u32 USBD_EPTGetBufferLen(USBD_EPTn_Enum USBD_EPTn) +{ + return ((_USBD_GetEPTnAddr(USBD_EPTn)->CFGR & EPLEN_MASK) >> 10); +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n Transfer Count. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @param USBD_TCR_n: USBD_TCR_0 or USBD_TCR_1 + * @retval Endpoint Transfer Count + ***********************************************************************************************************/ +u32 USBD_EPTGetTransferCount(USBD_EPTn_Enum USBD_EPTn, USBD_TCR_Enum USBD_TCR_n) +{ + return (((_USBD_GetEPTnAddr(USBD_EPTn)->TCR) >> USBD_TCR_n) & TCR_MASK); +} + +/*********************************************************************************************************//** + * @brief Write IN Data from User buffer to USB buffer. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @param pFrom: Source buffer + * @param len: Length for write IN data + * @retval Total length written by this function + ***********************************************************************************************************/ +u32 USBD_EPTWriteINData(USBD_EPTn_Enum USBD_EPTn, u32 *pFrom, u32 len) +{ + u32 bufferlen = USBD_EPTGetBufferLen(USBD_EPTn); + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + u32 EPTnLen; + u32 *pTo; + + EPTnLen = (USBD_EPTn == USBD_EPT0) ? USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTIN):USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTB0); + + if (len <= bufferlen && EPTnLen == 0) + { + pTo = (u32 *)USBD_EPTGetBuffer0Addr(USBD_EPTn); + _USBD_CopyMemory(pFrom, pTo, ByteLen2WordLen(len)); + USBEPn->TCR = len; + USBEPn->CSR = NAKTX; + return len; + } + else + { + return 0; + } +} + +/*********************************************************************************************************//** + * @brief Read OUT Data from USB buffer to User buffer. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @param pTo: Destination memory + * @param len: Length for read OUT data, set as 0 for discard current OUT data in the USB buffer + * @retval Total length read by this function + ***********************************************************************************************************/ +u32 USBD_EPTReadOUTData(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + u32 EPTnLen = 0; + + if (len != 0) + { + EPTnLen = USBD_EPTReadMemory(USBD_EPTn, pTo, len); + } + + if (EPTnLen != 0 || len == 0) + { + USBEPn->CSR = (USBEPn->CSR & NAKRX); + } + + return EPTnLen; +} + +/*********************************************************************************************************//** + * @brief Read memory from endpoint buffer. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @param pTo: Destination buffer + * @param len: Length for read OUT data + * @retval Total length read by this function + ***********************************************************************************************************/ +u32 USBD_EPTReadMemory(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len) +{ + u32 EPTnLen = 0; + u32 *pFrom; + + EPTnLen = (USBD_EPTn == USBD_EPT0) ? USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTOUT):USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTB0); + + if (EPTnLen <= len) + { + pFrom = (USBD_EPTn == USBD_EPT0) ? (u32 *)USBD_EPTGetBuffer1Addr(USBD_EPTn):(u32 *)USBD_EPTGetBuffer0Addr(USBD_EPTn); + _USBD_CopyMemory(pFrom, pTo, ByteLen2WordLen(EPTnLen)); + } + + return EPTnLen; +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Function USB Device private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Copy 32 bits memory from pFrom to pTo. + * @param pFrom: Source buffer + * @param pTo: Destination buffer + * @param len: Copy length + * @retval None + ***********************************************************************************************************/ +static void _USBD_CopyMemory(u32 *pFrom, u32 *pTo, u32 len) +{ + s32 i; + for (i = len - 1; i >= 0; i--) + { + pTo[i] = pFrom[i]; + } + + return; +} + +/*********************************************************************************************************//** + * @brief Convent USBD_EPTn_Enum to USBEP_TypeDef. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval USBEP0 ~ USBEP7 + ***********************************************************************************************************/ +static HT_USBEP_TypeDef * _USBD_GetEPTnAddr(USBD_EPTn_Enum USBD_EPTn) +{ + return ((HT_USBEP_TypeDef *)(HT_USBEP0 + USBD_EPTn)); +} + +/*********************************************************************************************************//** + * @brief Inserts a delay time. + * @param nCount: specifies the delay time length. + * @retval None + ***********************************************************************************************************/ +static void _delay(u32 nCount) +{ + u32 i; + + for (i = 0; i < nCount; i++) + { + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_wdt.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_wdt.c new file mode 100644 index 0000000000..5bd9a98e77 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f1xxxx_wdt.c @@ -0,0 +1,363 @@ +/*********************************************************************************************************//** + * @file ht32f1xxxx_wdt.c + * @version $Rev:: 2797 $ + * @date $Date:: 2022-11-28 #$ + * @brief This file provides all the WDT firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f1xxxx_wdt.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup WDT WDT + * @brief WDT driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Private_Define WDT private definitions + * @{ + */ + +/* WDT Restart Key */ +#define RESTART_KEY ((u32)0x5FA00000) + +/* WDT Protect mask */ +#define PRCT_SET ((u32)0x0000CA35) +#define PRCT_RESET ((u32)0x000035CA) + +/* WDT WDTFIEN mask */ +#define MODE0_WDTFIEN_SET ((u32)0x00001000) +#define MODE0_WDTFIEN_RESET ((u32)0xFFFFEFFF) + +/* WDT WDTRSTEN mask */ +#define MODE0_WDTRETEN_SET ((u32)0x00002000) +#define MODE0_WDTRETEN_RESET ((u32)0xFFFFDFFF) + +/* WDT WDTEN mask */ +#define MODE0_WDTEN_SET ((u32)0x00010000) +#define MODE0_WDTEN_RESET ((u32)0xFFFEFFFF) + +/* WDT WDTLOCK mask */ +#define MODE0_WDTLOCK_SET ((u32)0x00000010) +#define MODE0_WDTLOCK_RESET ((u32)0x00000000) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Exported_Functions WDT exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the WDT peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void WDT_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.WDT = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the WDT. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_Cmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_WDT->MR0 |= MODE0_WDTEN_SET; + } + else + { + HT_WDT->MR0 &= MODE0_WDTEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Configure the WDT to run or halt in sleep and deep sleep1 mode. + * @param WDT_Mode: + * This parameter can be one of the following values: + * @arg MODE0_WDTSHLT_BOTH : WDT runs in sleep and deep sleep1 mode + * @arg MODE0_WDTSHLT_SLEEP : WDT runs in sleep mode + * @arg MODE0_WDTSHLT_HALT : WDT halts in sleep and deep sleep1 mode + * @retval None + ************************************************************************************************************/ +void WDT_HaltConfig(u32 WDT_Mode) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_WDTSHLT_MODE(WDT_Mode)); + + HT_WDT->MR0 = ((WDT_Mode) | (HT_WDT->MR0 & 0x00013FFF)); +} + +#if (LIBCFG_WDT_INT) +/*********************************************************************************************************//** + * @brief Enable or Disable the WDT interrupt when WDT meets underflow or error. + * @param NewState: This parameter can be: ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_IntConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_WDT->MR0 |= MODE0_WDTFIEN_SET; + } + else + { + HT_WDT->MR0 &= MODE0_WDTFIEN_RESET; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the WDT Reset when WDT meets underflow or error. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_ResetCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_WDT->MR0 |= MODE0_WDTRETEN_SET; + } + else + { + HT_WDT->MR0 &= MODE0_WDTRETEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable protection mechanism of the WDT. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_ProtectCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_WDT->PR = PRCT_SET; + } + else + { + HT_WDT->PR = PRCT_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Set reload value of the WDT. + * @param WDT_WDTV : specify the WDT Reload value. + * This parameter must be a number between 0 and 0x0FFF + * @retval None + ************************************************************************************************************/ +void WDT_SetReloadValue(u16 WDT_WDTV) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_RELOAD(WDT_WDTV)); + + HT_WDT->MR0 = WDT_WDTV | (HT_WDT->MR0 & 0x0000F000); +} + +/*********************************************************************************************************//** + * @brief Get the current reload value of the WDT. + * @retval WDT reload value between 0 and 0x0FFF + ************************************************************************************************************/ +u16 WDT_GetReloadValue(void) +{ + return ((u16)(HT_WDT->MR0 & 0xFFF)); +} + +/*********************************************************************************************************//** + * @brief Set delta value of the WDT. + * @param WDT_WDTD : specify the WDT Delta value. + * This parameter must be a number between 0 and 0x0FFF + * @retval None + ************************************************************************************************************/ +void WDT_SetDeltaValue(u16 WDT_WDTD) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_DELTA(WDT_WDTD)); + + HT_WDT->MR1 = (WDT_WDTD | (HT_WDT->MR1 & 0x00007000)); +} + +/*********************************************************************************************************//** + * @brief Get current delta value of the WDT. + * @retval WDT delta value between 0 and 0x0FFF + ************************************************************************************************************/ +u16 WDT_GetDeltaValue(void) +{ + return ((u16)(HT_WDT->MR1 & 0xFFF)); +} + +/*********************************************************************************************************//** + * @brief Set prescaler value of the WDT. + * @param WDT_PRESCALER: specify the WDT Prescaler value. + * This parameter can be one of the following values: + * @arg WDT_PRESCALER_1 : WDT prescaler set to 1 + * @arg WDT_PRESCALER_2 : WDT prescaler set to 2 + * @arg WDT_PRESCALER_4 : WDT prescaler set to 4 + * @arg WDT_PRESCALER_8 : WDT prescaler set to 8 + * @arg WDT_PRESCALER_16 : WDT prescaler set to 16 + * @arg WDT_PRESCALER_32 : WDT prescaler set to 32 + * @arg WDT_PRESCALER_64 : WDT prescaler set to 64 + * @arg WDT_PRESCALER_128 : WDT prescaler set to 128 + * @retval None + ************************************************************************************************************/ +void WDT_SetPrescaler(u16 WDT_PRESCALER) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_PRESCALER(WDT_PRESCALER)); + + HT_WDT->MR1 = (WDT_PRESCALER | (HT_WDT->MR1 & 0x00000FFF)); +} + +/*********************************************************************************************************//** + * @brief Get the current prescaler value of the WDT. + * @retval WDT prescaler value + ************************************************************************************************************/ +u8 WDT_GetPrescaler(void) +{ + u32 tmp; + + tmp = HT_WDT->MR1 & 0x7000; + tmp >>= 12; + return ((u8)0x1 << tmp); +} + +/*********************************************************************************************************//** + * @brief WDT Restart (Reload WDT Counter) + * @retval None + ************************************************************************************************************/ +void WDT_Restart(void) +{ + HT_WDT->CR = RESTART_KEY | 0x1; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified WDT flag has been set. + * @param WDT_FLAG: specify the flag to be check. + * This parameter can be one of the following values: + * @arg WDT_FLAG_UNDERFLOW : WDT underflow active + * @arg WDT_FLAG_ERROR : WDT error active + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus WDT_GetFlagStatus(u32 WDT_FLAG) +{ + u32 statusreg = 0; + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + Assert_Param(IS_WDT_FLAG(WDT_FLAG)); + + statusreg = HT_WDT->SR; + + if (statusreg != WDT_FLAG) + { + bitstatus = RESET; + } + else + { + bitstatus = SET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the WDTLOCK. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_LockCmd(ControlStatus NewState) +{ + u32 uRegVale; + + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + uRegVale = HT_WDT->CSR; + if (NewState != DISABLE) + { + HT_WDT->CSR |= (MODE0_WDTLOCK_SET | (uRegVale & 0x00000001)); + } + else + { + HT_WDT->CSR &= (MODE0_WDTLOCK_RESET | (uRegVale & 0x00000001)); + } +} + +/*********************************************************************************************************//** + * @brief WDT source select. + * @param WDT_SOURCE: LSI or LSE of the WDT source. + * This parameter can be one of the following values: + * @arg WDT_SOURCE_LSI : + * @arg WDT_SOURCE_LSE : + * @retval None + ************************************************************************************************************/ +void WDT_SourceConfig(u32 WDT_SOURCE) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_SOURCE_SELECT(WDT_SOURCE)); + + if (WDT_SOURCE != WDT_SOURCE_LSE) + { + HT_WDT->CSR = WDT_SOURCE_LSI; + } + else + { + HT_WDT->CSR = WDT_SOURCE_LSE; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f2xxxx_csif.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f2xxxx_csif.c new file mode 100644 index 0000000000..fed68afd33 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/ht32f2xxxx_csif.c @@ -0,0 +1,386 @@ +/*********************************************************************************************************//** + * @file ht32f2xxxx_csif.c + * @version $Rev:: 118 $ + * @date $Date:: 2017-06-02 #$ + * @brief This file provides all the CSIF firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f2xxxx_csif.h" + +/** @addtogroup HT32F1xxxx_Peripheral_Driver HT32F1xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CSIF CSIF + * @brief CSIF driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup CSIF_Private_Define CSIF private definitions + * @{ + */ +/* CSIF CSIFEN mask */ +#define ENR_CSIFEN_SET ((u32)0x80000000) +#define ENR_CSIFEN_RESET ((u32)0x00000000) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CSIF_Exported_Functions CSIF exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CSIF peripheral registers to their default reset values. + * @retval None + ***********************************************************************************************************/ +void CSIF_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.CSIF = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initializes the CSIF peripheral according to the specified parameters in the CSIF_BasicInitStruct. + * @param CSIF_BasicInitStruct: pointer to a CSIF_BasicInitTypeDef structure that contains the configuration + * information for the specified CSIF peripheral. + * @retval None + ***********************************************************************************************************/ +void CSIF_BasicInit(CSIF_BasicInitTypeDef* CSIF_BasicInitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_CSIF_FORMAT(CSIF_BasicInitStruct->CSIF_Format)); + Assert_Param(IS_CSIF_VSYNC_TYPE(CSIF_BasicInitStruct->CSIF_VSYNCType)); + Assert_Param(IS_CSIF_HSYNC_TYPE(CSIF_BasicInitStruct->CSIF_HSYNCType)); + Assert_Param(IS_CSIF_SAMPLE_EDGE(CSIF_BasicInitStruct->CSIF_SampleEdge)); + Assert_Param(IS_CSIF_VSYNC_POLARITY(CSIF_BasicInitStruct->CSIF_VSYNCPolarity)); + Assert_Param(IS_CSIF_HSYNC_POLARITY(CSIF_BasicInitStruct->CSIF_HSYNCPolarity)); + Assert_Param(IS_CSIF_LINE_DELAY(CSIF_BasicInitStruct->CSIF_LineDelay)); + Assert_Param(IS_CSIF_FRAME_DELAY(CSIF_BasicInitStruct->CSIF_FrameDelay)); + Assert_Param(IS_CSIF_IMAGE_WIDTH(CSIF_BasicInitStruct->CSIF_ImageWidth)); + Assert_Param(IS_CSIF_IMAGE_HEIGHT(CSIF_BasicInitStruct->CSIF_ImageHeight)); + + /*------------------------ CSIF Control Register Configuration -------------------------------------------*/ + HT_CSIF->CR = CSIF_BasicInitStruct->CSIF_Format | CSIF_BasicInitStruct->CSIF_VSYNCType | CSIF_BasicInitStruct->CSIF_HSYNCType | + CSIF_BasicInitStruct->CSIF_SampleEdge | CSIF_BasicInitStruct->CSIF_VSYNCPolarity | + CSIF_BasicInitStruct->CSIF_HSYNCPolarity | (CSIF_BasicInitStruct->CSIF_LineDelay << 8) | + (CSIF_BasicInitStruct->CSIF_FrameDelay << 16); + + /*------------------------ CSIF Image Width/Height Register Configuration --------------------------------*/ + HT_CSIF->IMGWH = (CSIF_BasicInitStruct->CSIF_ImageWidth-1) | ((CSIF_BasicInitStruct->CSIF_ImageHeight-1) << 16); +} + +/*********************************************************************************************************//** + * @brief Fills each CSIF_BasicInitStruct member with its default value. + * @param CSIF_BasicInitStruct: pointer to an CSIF_BasicInitTypeDef structure which will be initialized. + * @retval None + ***********************************************************************************************************/ +void CSIF_BasicStructInit(CSIF_BasicInitTypeDef* CSIF_BasicInitStruct) +{ + /* Initialize the CSIF_Format member */ + CSIF_BasicInitStruct->CSIF_Format = CSIF_FORMAT_RAWRGB; + + /* Initialize the CSIF_VSYNCType member */ + CSIF_BasicInitStruct->CSIF_VSYNCType = CSIF_VSYNCTYPE_PULSE; + + /* Initialize the CSIF_HSYNCType member */ + CSIF_BasicInitStruct->CSIF_HSYNCType = CSIF_HSYNCTYPE_CONTINUOUS; + + /* Initialize the CSIF_SampleEdge member */ + CSIF_BasicInitStruct->CSIF_SampleEdge = CSIF_SAMPLEEDGE_FALLING; + + /* Initialize the CSIF_VSYNCPolarity member */ + CSIF_BasicInitStruct->CSIF_VSYNCPolarity = CSIF_VSYNCPOLARITY_HIGH; + + /* Initialize the CSIF_HSYNCPolarity member */ + CSIF_BasicInitStruct->CSIF_HSYNCPolarity = CSIF_HSYNCPOLARITY_HIGH; + + /* Initialize the CSIF_LineDelay member */ + CSIF_BasicInitStruct->CSIF_LineDelay = 0; + + /* Initialize the CSIF_FrameDelay member */ + CSIF_BasicInitStruct->CSIF_FrameDelay = 0; + + /* Initialize the CSIF_ImageWidth member */ + CSIF_BasicInitStruct->CSIF_ImageWidth = 0; + + /* Initialize the CSIF_ImageHeight member */ + CSIF_BasicInitStruct->CSIF_ImageHeight = 0; + +} + +/*********************************************************************************************************//** + * @brief Initializes the CSIF peripheral according to the specified parameters in the CSIF_WindowInitStruct. + * @param CSIF_WindowInitStruct: pointer to a CSIF_WindowInitTypeDef structure that contains the configuration + * information for the specified CSIF peripheral. + * @retval None + ***********************************************************************************************************/ +void CSIF_WindowInit(CSIF_WindowInitTypeDef* CSIF_WindowInitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_CSIF_WINDOW(CSIF_WindowInitStruct->CSIF_Window)); + Assert_Param(IS_CSIF_HORSTART_POINT(CSIF_WindowInitStruct->CSIF_HorizontalStartPoint)); + Assert_Param(IS_CSIF_VERSTART_POINT(CSIF_WindowInitStruct->CSIF_VerticalStartPoint)); + Assert_Param(IS_CSIF_WINDOW_WIDTH(CSIF_WindowInitStruct->CSIF_WindowWidth)); + Assert_Param(IS_CSIF_WINDOW_HEIGHT(CSIF_WindowInitStruct->CSIF_WindowHeight)); + + /*------------------------ CSIF Window Capture Register 0 Configuration ----------------------------------*/ + HT_CSIF->WCR0 = CSIF_WindowInitStruct->CSIF_Window | CSIF_WindowInitStruct->CSIF_HorizontalStartPoint | + (CSIF_WindowInitStruct->CSIF_VerticalStartPoint << 16); + + /*------------------------ CSIF Window Capture Register 1 Configuration ----------------------------------*/ + HT_CSIF->WCR1 = (CSIF_WindowInitStruct->CSIF_WindowWidth-1) | ((CSIF_WindowInitStruct->CSIF_WindowHeight-1) << 16); +} + +/*********************************************************************************************************//** + * @brief Fills each CSIF_WindowStructInit member with its default value. + * @param CSIF_WindowInitStruct: pointer to an CSIF_WindowInitTypeDef structure which will be initialized. + * @retval None + ***********************************************************************************************************/ +void CSIF_WindowStructInit(CSIF_WindowInitTypeDef* CSIF_WindowInitStruct) +{ + /* Initialize the CSIF_Window member */ + CSIF_WindowInitStruct->CSIF_Window = CSIF_WINDOW_DISABLE; + + /* Initialize the CSIF_HorizontalStartPoint member */ + CSIF_WindowInitStruct->CSIF_HorizontalStartPoint = 0; + + /* Initialize the CSIF_VerticalStartPoint member */ + CSIF_WindowInitStruct->CSIF_VerticalStartPoint = 0; + + /* Initialize the CSIF_WindowWidth member */ + CSIF_WindowInitStruct->CSIF_WindowWidth = 0; + + /* Initialize the CSIF_WindowHeight member */ + CSIF_WindowInitStruct->CSIF_WindowHeight = 0; +} + +/*********************************************************************************************************//** + * @brief Initializes the CSIF peripheral according to the specified parameters in the CSIF_SubSampleInitStruct. + * @param CSIF_SubSampleInitStruct: pointer to a CSIF_SubSampleInitTypeDef structure that contains the configuration + * information for the specified CSIF peripheral. + * @retval None + ***********************************************************************************************************/ +void CSIF_SubSampleInit(CSIF_SubSampleInitTypeDef* CSIF_SubSampleInitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_CSIF_SUB_SAMPLE(CSIF_SubSampleInitStruct->CSIF_SubSample)); + Assert_Param(IS_CSIF_MASK_LENGTH(CSIF_SubSampleInitStruct->CSIF_ColumnSkipMaskLength)); + Assert_Param(IS_CSIF_MASK_LENGTH(CSIF_SubSampleInitStruct->CSIF_RowSkipMaskLength)); + + /*------------------------ CSIF Row & Column Sub-Sample RegisterConfiguration ----------------------------*/ + HT_CSIF->SMP = CSIF_SubSampleInitStruct->CSIF_SubSample | (CSIF_SubSampleInitStruct->CSIF_ColumnSkipMaskLength << 8) | + (CSIF_SubSampleInitStruct->CSIF_RowSkipMaskLength << 16); + + /*------------------------ CSIF Column Sub-Sample Register Configuration ---------------------------------*/ + HT_CSIF->SMPCOL = CSIF_SubSampleInitStruct->CSIF_ColumnSkipMask; + + /*------------------------ CSIF Row Sub-Sample Register Configuration ------------------------------------*/ + HT_CSIF->SMPROW = CSIF_SubSampleInitStruct->CSIF_RowSkipMask; +} + +/*********************************************************************************************************//** + * @brief Fills each CSIF_SubSampleInitStruct member with its default value + * @param CSIF_SubSampleInitStruct: pointer to an CSIF_SubSampleInitTypeDef structurewhich will be initialized. + * @retval None + ***********************************************************************************************************/ +void CSIF_SunSampleStructInit(CSIF_SubSampleInitTypeDef* CSIF_SubSampleInitStruct) +{ + /* Initialize the CSIF_SubSample member */ + CSIF_SubSampleInitStruct->CSIF_SubSample = CSIF_SUBSAMPLE_DISABLE; + + /* Initialize the CSIF_ColumnSkipMaskLength member */ + CSIF_SubSampleInitStruct->CSIF_ColumnSkipMaskLength = CSIF_MASKLENGTH_32B; + + /* Initialize the CSIF_RowSkipMaskLength member */ + CSIF_SubSampleInitStruct->CSIF_RowSkipMaskLength = CSIF_MASKLENGTH_32B; + + /* Initialize the CSIF_ColumnSkipMask member */ + CSIF_SubSampleInitStruct->CSIF_ColumnSkipMask = 0; + + /* Initialize the CSIF_RowSkipMask member */ + CSIF_SubSampleInitStruct->CSIF_RowSkipMask = 0; +} + +/*********************************************************************************************************//** + * @brief Enables or Disables the CSIF peripheral. + * @param NewState: new state of the CSIF peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void CSIF_Cmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable CSIF peripheral */ + HT_CSIF->ENR = ENR_CSIFEN_SET; + } + else + { + /* Disable CSIF peripheral */ + HT_CSIF->ENR = ENR_CSIFEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enables or Disables the specified CSIF interrupt. + * @param CSIF_Int: specifies if the CSIF interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CSIF_INT_SOFFLG : CSIF start of frame interrupt + * @arg CSIF_INT_EOFFLG : CSIF end of frame interrupt + * @arg CSIF_INT_CAPSTA : CSIF cpature start interrupt + * @arg CSIF_INT_CAPSTS : CSIF capture status interrupt + * @arg CSIF_INT_BADFRAME : CSIF bad frame interrupt + * @arg CSIF_INT_FIFOOVR : CSIF FIFO overrun interrupt + * @arg CSIF_INT_FIFOEMP : CSIF FIFO empty interrupt + * @arg CSIF_INT_FIFOFUL : CSIF FIFO full interrupt + * @arg CSIF_INT_ALL : All CSIF interrupt + * @param NewState: new state of the CSIF interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void CSIF_IntConfig(u32 CSIF_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CSIF_INT(CSIF_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CSIF->IER |= CSIF_Int; + } + else + { + HT_CSIF->IER &= (u32)~CSIF_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified CSIF flag has been set. + * @param CSIF_Flag: specifies the flag that is to be check. + * This parameter can be one of the following values: + * @arg CSIF_FLAG_SOFFLG : CSIF start of frame flag + * @arg CSIF_FLAG_EOFFLG : CSIF end of frame flag + * @arg CSIF_FLAG_CAPSTA : CSIF cpature start flag + * @arg CSIF_FLAG_CAPSTS : CSIF capture status flag + * @arg CSIF_FLAG_BADFRAME : CSIF bad frame fla + * @arg CSIF_FLAG_FIFOOVR : CSIF FIFO overrun flag + * @arg CSIF_FLAG_FIFOEMP : CSIF FIFO empty flag + * @arg CSIF_FLAG_FIFOFUL : CSIF FIFO full flag + * @retval The new state of CSIF_Flag (SET or RESET). + ***********************************************************************************************************/ +FlagStatus CSIF_GetFlagStatus(u32 CSIF_Flag) +{ + u32 statusreg = 0; + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + Assert_Param(IS_CSIF_FLAG(CSIF_Flag)); + + statusreg = HT_CSIF->SR; + + if ((statusreg & CSIF_Flag) != (u32)RESET ) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Clear the specified CSIF flag. + * @param CSIF_Flag: specifies the flag to be cleared. + * This parameter can be one of the following values: + * @arg CSIF_FLAG_SOFFLG : CSIF start of frame flag + * @arg CSIF_FLAG_EOFFLG : CSIF end of frame flag + * @arg CSIF_FLAGT_CAPSTA : CSIF cpature start flag + * @arg CSIF_FLAG_CAPSTS : CSIF capture status flag + * @arg CSIF_FLAG_BADFRAME : CSIF bad frame flag + * @retval None + ***********************************************************************************************************/ +void CSIF_ClearFlag(u32 CSIF_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_CSIF_CLEAR_FLAG(CSIF_Flag)); + + HT_CSIF->SR = CSIF_Flag; +} + +/*********************************************************************************************************//** + * @brief Enables or Disables the CSIF Master Clock. + * @param NewState: new state of the CSIF Master Clock. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void CSIF_MasterClockCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CKCU->AHBCCR |= 0x00000200; + } + else + { + HT_CKCU->AHBCCR &= 0xFFFFFDFF; + } +} + +/*********************************************************************************************************//** + * @brief Sets the CSIF Master Clock Prescaler. + * @param CSIF_Prescaler: specifies the CSIF Master Clock Prescaler value. + * This parameter must be even. + * @retval None + ***********************************************************************************************************/ +void CSIF_SetMasterClockPrescaler(u8 CSIF_Prescaler) +{ + /* Check the parameters */ + Assert_Param(IS_CSIF_PRESCALER(CSIF_Prescaler)); + + HT_CKCU->GCFGR |= (CSIF_Prescaler/2-1) << 24; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/printf.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/printf.c new file mode 100644 index 0000000000..7b4f905013 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/printf.c @@ -0,0 +1,390 @@ +/*********************************************************************************************************//** + * @file printf.c + * @version $Rev:: 5 $ + * @date $Date:: 2017-05-11 #$ + * @brief Print functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup PRINTF printf re-implementation + * @brief printf related functions + * @{ + */ + + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup PRINTF_Private_Macro printf private macros + * @{ + */ +#define vaStart(list, param) list = (char*)((int)¶m + sizeof(param)) +#define vaArg(list, type) ((type *)(list += sizeof(type)))[-1] +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static const char *FormatItem(const char *f, int a); +static void PutRepChar(const char c, int count); +static int PutString(const char *pString); +static int PutStringReverse(const char *pString, int index); +static void PutNumber(int value, int radix, int width, char fill); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup PRINTF_Exported_Functions printf exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Print function. + * @param f: Format string. + * @retval String length. + ************************************************************************************************************/ +signed int printf(const char *f, ...) +{ + char *argP; + int i = 0; + + vaStart(argP, f); + while (*f) + { + if (*f == '%') + { + f = FormatItem(f + 1, vaArg(argP, int)); + } + else + { + fputc(*f++, (FILE *)1); + } + i++; + } + return i; +} + +/*********************************************************************************************************//** + * @brief Put string. + * @param pString: String. + * @retval String length. + ************************************************************************************************************/ +signed int puts(const char *pString) +{ + int i; + i = PutString(pString); + fputc('\n', (FILE *)1); + return i; +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup PRINTF_Private_Function printf private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Format item for print function. + * @param f: Format string. + * @param a: Length of format string. + * @retval Point of string. + ************************************************************************************************************/ +static const char *FormatItem(const char *f, int a) +{ + char c; + int fieldwidth = 0; + int leftjust = FALSE; + int radix = 0; + char fill = ' '; + int i; + + if (*f == '0') + { + fill = '0'; + } + + while ((c = *f++) != 0) + { + if (c >= '0' && c <= '9') + { + fieldwidth = (fieldwidth * 10) + (c - '0'); + } + else + { + switch (c) + { + case '\000': + { + return (--f); + } + case '%': + { + fputc('%', (FILE *)1); + return (f); + } + case '-': + { + leftjust = TRUE; + break; + } + case 'c': + { + if (leftjust) + { + fputc(a & 0x7f, (FILE *)f); + } + if (fieldwidth > 0) + { + PutRepChar(fill, fieldwidth - 1); + } + if (!leftjust) + { + fputc(a & 0x7f, (FILE *)f); + return (f); + } + } + case 's': + { + i = 0; + while (*((char *)(a + i)) !='\0' ) + { + i++; + } + + if (leftjust) + { + PutString((char *)a); + } + + if (fieldwidth > i ) + { + PutRepChar(fill, fieldwidth - i); + } + + if (!leftjust) + { + PutString((char *)a); + } + return (f); + } + case 'l': + { + radix = -10; + f++; + break; + } + case 'd': + case 'i': + { + radix = -10; + break; + } + case 'u': + { + radix = 10; + break; + } + case 'x': + case 'X': + { + radix = 16; + break; + } + case 'o': + { + radix = 8; + break; + } + default: + { + radix = 3; + break; + } + } + } + if (radix) + { + break; + } + } + + if (leftjust) + { + fieldwidth = -fieldwidth; + } + + PutNumber(a, radix, fieldwidth, fill); + + return (f); +} + +/*********************************************************************************************************//** + * @brief Put repeat character. + * @param c: Character. + * @param count: Repeat count + ************************************************************************************************************/ +static void PutRepChar(const char c, int count) +{ + while (count--) + { + fputc(c, (FILE *)1); + } +} + +/*********************************************************************************************************//** + * @brief Put string. + * @param pString: String. + * @retval String length. + ************************************************************************************************************/ +static int PutString(const char *pString) +{ + int i = 0; + while (*pString != '\0') + { + fputc(*pString, (FILE *)1); + pString++; + i++; + } + + return i; +} + +/*********************************************************************************************************//** + * @brief Put string in reversed order. + * @param pString: String. + * @param index: String length + * @retval String length. + ************************************************************************************************************/ +static int PutStringReverse(const char *pString, int index) +{ + int i = 0; + while ((index--) > 0) + { + fputc(pString[index], (FILE *)1); + i++; + } + return i; +} + +/*********************************************************************************************************//** + * @brief Put number. + * @param value: Value of number. + * @param radix: Radix of number. + * @param width: Width of number. + * @param fill: fill character. + ************************************************************************************************************/ +static void PutNumber(int value, int radix, int width, char fill) +{ + char buffer[8]; + int bi = 0; + unsigned int uvalue; + unsigned short digit; + unsigned short left = FALSE; + unsigned short negative = FALSE; + + if (fill == 0) + { + fill = ' '; + } + + if (width < 0) + { + width = -width; + left = TRUE; + } + + if (width < 0 || width > 80) + { + width = 0; + } + + if (radix < 0) + { + radix = -radix; + if (value < 0) + { + negative = TRUE; + value = -value; + } + } + + uvalue = value; + + do + { + if (radix != 16) + { + digit = uvalue % radix; + uvalue = uvalue / radix; + } + else + { + digit = uvalue & 0xf; + uvalue = uvalue >> 4; + } + buffer[bi] = digit + ((digit <= 9) ? '0' : ('A' - 10)); + bi++; + } + while (uvalue != 0); + + if (negative) + { + buffer[bi] = '-'; + bi += 1; + } + + if (width <= bi) + { + PutStringReverse(buffer, bi); + } + else + { + width -= bi; + if (!left) + { + PutRepChar(fill, width); + } + + PutStringReverse(buffer, bi); + + if (left) + { + PutRepChar(fill, width); + } + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/syscalls.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/syscalls.c new file mode 100644 index 0000000000..b78500264e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32F1xxxx_Driver/src/syscalls.c @@ -0,0 +1,127 @@ +/*********************************************************************************************************//** + * @file syscalls.c + * @version $Rev:: 2904 $ + * @date $Date:: 2023-03-27 #$ + * @brief Implementation of system call related functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include +#include +#include +#include + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup SYSCALLS System call functions + * @brief System call functions for GNU toolchain + * @{ + */ + + +/* Global variables ----------------------------------------------------------------------------------------*/ +/** @defgroup SYSCALLS_Global_Variable System call global variables + * @{ + */ +#undef errno +extern int errno; +extern int _end; +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SYSCALLS_Exported_Functions System call exported functions + * @{ + */ +caddr_t _sbrk(int incr) +{ + static unsigned char *heap = NULL; + unsigned char *prev_heap; + + if (heap == NULL) + { + heap = (unsigned char *)&_end; + } + prev_heap = heap; + + heap += incr; + + return (caddr_t) prev_heap; +} + +int link(char *old, char *new) { +return -1; +} + +int _close(int fd) +{ + return -1; +} + +int _fstat(int fd, struct stat *st) +{ + st->st_mode = S_IFCHR; + return 0; +} + +int _isatty(int fd) +{ + return 1; +} + +int _lseek(int fd, int ptr, int dir) +{ + return 0; +} + +int _read(int fd, char *ptr, int len) +{ + return 0; +} + +int _write(int fd, char *ptr, int len) +{ + return len; +} + +void abort(void) +{ + /* Abort called */ + while (1); +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c new file mode 100644 index 0000000000..a90caeb986 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c @@ -0,0 +1,426 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_class.c + * @version $Rev:: 11 $ + * @date $Date:: 2017-05-15 #$ + * @brief The USB Device Class. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_usbd_core.h" +#include "ht32_usbd_class.h" + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDClass USB Device Class + * @brief USB Device Class + * @{ + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Private_Define USB Device Class private definitions + * @{ + */ +#define CLASS_REQ_01_CMD1 (u16)(0x1 << 8) +#define CLASS_REQ_02_CMD2 (u16)(0x2 << 8) +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void USBDClass_MainRoutine(u32 uPara); +static void USBDClass_ClassProcess(void); +static void USBDClass_EPT1Process(void); +static void USBDClass_EPT2Process(void); + +static void USBDClass_Reset(u32 uPara); +static void USBDClass_StartOfFrame(u32 uPara); + +static void USBDClass_Standard_GetDescriptor(USBDCore_Device_TypeDef *pDev); +static void USBDClass_Standard_SetInterface(USBDCore_Device_TypeDef *pDev); +static void USBDClass_Standard_GetInterface(USBDCore_Device_TypeDef *pDev); + +static void USBDClass_Request(USBDCore_Device_TypeDef *pDev); + +static void USBDClass_CMD1(USBDCore_Device_TypeDef *pDev); +static void USBDClass_CMD2(USBDCore_Device_TypeDef *pDev); + +static void USBDClass_Endpoint1(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint2(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint3(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint4(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint5(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint6(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint7(USBD_EPTn_Enum EPTn); + +/* Global Function -----------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Exported_Functions USB Device Class exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Class initialization. + * @param pClass: pointer of USBDCore_Class_TypeDef + * @retval None + ***********************************************************************************************************/ +void USBDClass_Init(USBDCore_Class_TypeDef *pClass) +{ + pClass->CallBack_MainRoutine.func = USBDClass_MainRoutine; + //pClass->CallBack_MainRoutine.uPara = (u32)NULL; + + pClass->CallBack_Reset.func = USBDClass_Reset; + pClass->CallBack_Reset.uPara = (u32)NULL; + + pClass->CallBack_StartOfFrame.func = USBDClass_StartOfFrame; + pClass->CallBack_StartOfFrame.uPara = (u32)NULL; + + pClass->CallBack_ClassGetDescriptor = USBDClass_Standard_GetDescriptor; + pClass->CallBack_ClassSetInterface = USBDClass_Standard_SetInterface; + pClass->CallBack_ClassGetInterface = USBDClass_Standard_GetInterface; + + pClass->CallBack_ClassRequest = USBDClass_Request; + pClass->CallBack_EPTn[1] = USBDClass_Endpoint1; + pClass->CallBack_EPTn[2] = USBDClass_Endpoint2; + pClass->CallBack_EPTn[3] = USBDClass_Endpoint3; + pClass->CallBack_EPTn[4] = USBDClass_Endpoint4; + pClass->CallBack_EPTn[5] = USBDClass_Endpoint5; + pClass->CallBack_EPTn[6] = USBDClass_Endpoint6; + pClass->CallBack_EPTn[7] = USBDClass_Endpoint7; + + #ifdef RETARGET_IS_USB + pClass->CallBack_EPTn[RETARGET_RX_EPT] = SERIAL_USBDClass_RXHandler; + #endif + + return; +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Private_Functions USB Device Class private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Class main routine. + * @param uPara: Parameter for Class main routine + * @retval None + ***********************************************************************************************************/ +static void USBDClass_MainRoutine(u32 uPara) +{ + USBDClass_ClassProcess(); + USBDClass_EPT1INProcess(); + USBDClass_EPT2OUTProcess(); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Process for application. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_ClassProcess(void) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint 1 Process for application. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_EPT1Process(void) +{ + if (gIsEP1 == TRUE) + { + gIsEP1 = FALSE; + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint 2 Process for application. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_EPT2Process(void) +{ + if (gIsEP2 == TRUE) + { + gIsEP2 = FALSE; + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Reset. + * @param uPara: Parameter for Class Reset. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Reset(u32 uPara) +{ + +} + +/*********************************************************************************************************//** + * @brief USB Class Start of Frame. + * @param uPara: Parameter for Class Start of Frame. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_StartOfFrame(u32 uPara) +{ + +} + +/*********************************************************************************************************//** + * @brief USB Device Class Request + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Request(USBDCore_Device_TypeDef *pDev) +{ + u16 uUSBCmd = *((u16 *)(&(pDev->Request))); + +#ifdef RETARGET_IS_USB + SERIAL_USBDClass_Request(pDev); +#endif + + switch (uUSBCmd) + { + /*------------------------------------------------------------------------------------------------------*/ + /* | bRequest | Data transfer direction | Type | Recipient | Data */ + /*------------------------------------------------------------------------------------------------------*/ + + /*------------------------------------------------------------------------------------------------------*/ + /* | 01_CMD1 | 80_Device-to-Host | 20_Class Request | 1_Interface | 01A1h */ + /*------------------------------------------------------------------------------------------------------*/ + case (CLASS_REQ_01_CMDID0 | REQ_DIR_01_D2H | REQ_TYPE_01_CLS | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld CMD0\t[%02d][%02d]\r\n", __DBG_USBCount, pDev->Request.wValueH, pDev->Request.wLength ); + USBDClass_RequestCMD1(pDev); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 02_CMD2 | 00_Host-to-Device | 20_Class Request | 1_Interface | 0221h */ + /*------------------------------------------------------------------------------------------------------*/ + case (CLASS_REQ_02_GET_IDLE | REQ_DIR_00_H2D | REQ_TYPE_01_CLS | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld CMD1\t[%02d][%02d]\r\n", __DBG_USBCount, pDev->Request.wValueH, pDev->Request.wLength ); + USBDClass_RequestCMD2(pDev); + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Class Standard Request - GET_DESCRIPTOR + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Standard_GetDescriptor(USBDCore_Device_TypeDef *pDev) +{ + u32 type = pDev->Request.wValueH; + + switch (type) + { + case DESC_TYPE_01_XXX + { + pDev->Transfer.pData = (uc8 *)(__BUFFER_POINTER__); + pDev->Transfer.sByteLength = DESC_LEN_XXX; + pDev->Transfer.Action = USB_ACTION_DATAIN; + break; + } + case DESC_TYPE_02_XXX: + { + pDev->Transfer.pData = (uc8 *)(__BUFFER_POINTER__); + pDev->Transfer.sByteLength = DESC_LEN_XXX; + pDev->Transfer.Action = USB_ACTION_DATAIN; + break; + } + } /* switch (type) */ + + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Class Standard Request - SET_INTERFACE + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Standard_SetInterface(USBDCore_Device_TypeDef *pDev) +{ + +} + +/*********************************************************************************************************//** + * @brief USB Device Class Standard Request - GET_INTERFACE + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Standard_GetInterface(USBDCore_Device_TypeDef *pDev) +{ + +} + + + +/*********************************************************************************************************//** + * @brief USB Device Class Request - CMD1 + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_CMD1(USBDCore_Device_TypeDef *pDev) +{ + /* Add your own Class request function here.... + For example.... + + u32 uReportID = pDev->Request.wValueL; + u32 uInterface = pDev->Request.wIndex; + + pDev->Transfer.pData = (uc8 *)&(__IDLE_DURATION_BUFFER[uReportID]); + pDev->Transfer.sByteLength = 1; + pDev->Transfer.Action= USB_ACTION_DATAIN; + + */ + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Class Request - CMD2 + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_CMD2(USBDCore_Device_TypeDef *pDev) +{ + /* Add your own Class request function here.... + For example.... + + u32 uReportID = pDev->Request.wValueL; + u32 uInterface = pDev->Request.wIndex; + + pDev->Transfer.pData = (uc8 *)&(__IDLE_DURATION_BUFFER[uReportID]); + pDev->Transfer.sByteLength = 1; + pDev->Transfer.Action= USB_ACTION_DATAIN; + + */ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint1(USBD_EPTn_Enum EPTn) +{ + gIsEP1 = TRUE; + + __DBG_USBPrintf("%06ld EP1\t[%02d]", ++__DBG_USBCount, (int)USBDCore_EPTGetBufferLen(EPTn)); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint2(USBD_EPTn_Enum EPTn) +{ + gIsEP2 = TRUE; + __DBG_USBPrintf("%06ld EP2\t[%02d]", ++__DBG_USBCount, (int)USBDCore_EPTGetBufferLen(EPTn)); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint3(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint4(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint5(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint6(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint7(USBD_EPTn_Enum EPTn) +{ + return; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h new file mode 100644 index 0000000000..c674de9ce6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h @@ -0,0 +1,87 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_class.h + * @version $Rev:: 5 $ + * @date $Date:: 2017-05-11 #$ + * @brief The header file of USB Device Class. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_USBD_CLASS_H +#define __HT32_USBD_CLASS_H + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDClass USB Device Class + * @brief USB Device Class + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Private_Define USB Device Class private definitions + * @{ + */ +/* For ht32_usbd_descriptor.c */ +#define CLASS_INF_CLASS (DESC_CLASS_03_XXX) +#define CLASS_INF_SUBCLASS (HID_SUBCLASS_00_NONE) +#define CLASS_INF_PTCO (HID_PROTOCOL_00_NONE) + +/* HID related definition */ +#define DESC_LEN_XXX ((u32)(9)) +#define DESC_LEN_XXX ((u16)(47)) + +#define DESC_TYPE_01_XXX (0x01) +#define DESC_TYPE_02_XXX (0x02) + +#define HID_SUBCLASS_00_NONE (0x00) +#define HID_SUBCLASS_01_BOOT (0x01) + +#define HID_PROTOCOL_00_NONE (0x00) +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Exported_Functions USB Device Class exported functions + * @{ + */ +void USBDClass_Init(USBDCore_Class_TypeDef *pClass); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#endif /* __HT32_USBD_CLASS_H ------------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c new file mode 100644 index 0000000000..a4432bf192 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c @@ -0,0 +1,368 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_descriptor.c + * @version $Rev:: 5 $ + * @date $Date:: 2017-05-11 #$ + * @brief The USB Descriptor. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_usbd_core.h" +#include "ht32_usbd_class.h" +#include "ht32_usbd_descriptor.h" + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDDescriptor USB Descriptor + * @brief USB descriptor + * @{ + */ + + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Device descriptor setting +// USB Specification Release number (bcdUSB) +// <0x0200=> USB 2.0 +// <0x0110=> USB 1.1 +// <0x0100=> USB 1.0 +// USB Class code (assigned by the USB-IF) +// <0x00=> Use class information in the Interface Descriptors (0x00) +// <0x02=> Communications and CDC Control (CDC, 0x02) +// <0xDC=> Diagnostic Device (0xDC) +// <0xEF=> Miscellaneous (0xEF) +// <0xFF=> Vendor Specific (0xFF) +// USB Subclass code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Protocol code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Vendor ID <0x0-0xFFFF:1> +// USB Product ID <0x0-0xFFFF:1> +// USB Device Version <0x0-0xFFFF:1> +// USB String descriptor - Manufacturer +// USB String descriptor - Product +// USB String descriptor - Device serial number +// USB Number of possible configurations <0-255:1> +#define DESC_BCDUSB (0x0110) +#define DESC_BDEVCLASS (0x00) +#define DESC_BDEVSUBCLASS (0x00) +#define DESC_BDEVPROTOCOL (0x00) +#define DESC_IDVENDOR (0x04D9) +#define DESC_IDPRODUCT (0x8008) +#define DESC_BCDDEVICE (0x0100) +#define DESC_IMANUFACTURE (1) +#define DESC_IPRODUCT (1) +#define DESC_ISERIALNUM (1) +#define DESC_INUMCONFN (1) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (DESC_BDEVCLASS == 0x0 & DESC_BDEVSUBCLASS != 0x0) +#error "DESC_BDEVSUBCLASS must be reset to zero when the DESC_BDEVCLASS is equal to zero." +#endif +#define DESC_WMAXPACKETSIZE0 (_EP0LEN) +#define DESC_STR_MAN (1 * DESC_IMANUFACTURE) +#define DESC_STR_PRD (2 * DESC_IPRODUCT) +#define DESC_STR_SER (3 * DESC_ISERIALNUM) +#define DESC_NUM_STRING (1 + 3) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_DeviceDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Device descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_DEV, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_01_DEV, // bDescriptorType 1 DEVICE Descriptor Type + DESC_H2B(DESC_BCDUSB), // bcdUSB 2 USB Specification Release Number + DESC_BDEVCLASS, // bDeviceClass 1 Class code (assigned by the USB-IF) + DESC_BDEVSUBCLASS, // bDeviceSubClass 1 Subclass code (assigned by the USB-IF) + DESC_BDEVPROTOCOL, // bDeviceProtocol 1 Protocol code (assigned by the USB-IF) + DESC_WMAXPACKETSIZE0, // wMaxPacketSize0 1 Maximum packet size for endpoint zero + DESC_H2B(DESC_IDVENDOR), // idVendor 2 Vendor ID (assigned by USB-IF) + DESC_H2B(DESC_IDPRODUCT), // idProduct 2 Product ID (assigned by manufacturer) + DESC_H2B(DESC_BCDDEVICE), // bcdDevice 2 Device release number + DESC_STR_MAN, // iManufacturer 1 Index of string descriptor (Manufacturer) + DESC_STR_PRD, // iProduct 1 Index of string descriptor (Product) + DESC_STR_SER, // iSerialNumber 1 Index of string descriptor (Serial Number) + DESC_INUMCONFN, // iNumConfigurations 1 Number of possible configuration +}; + + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Configuration descriptor setting +// Self-powered +// Bit 6 of bmAttributes +// Remote Wakeup +// Bit 5 of bmAttributes +// USB Device maximum power (mA) < 2-512:2> +#define DESC_BMATTR_SELF_POWER (0) +#define DESC_BMATTR_REMOTE_WAKEUP (1) +#define DESC_BMAXPOWER (100) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#define DESC_BMATTRIBUTES (0x80 | (DESC_BMATTR_SELF_POWER << 6) | (DESC_BMATTR_REMOTE_WAKEUP << 5)) +#define DESC_TOTAL_LEN DESC_H2B((DESC_LEN_CONFN_T + RETARGET_DLEN)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_ConfnDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Configuration descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_CONFN, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_02_CONFN, // bDescriptorType 1 CONFIGURATION Descriptor Type + DESC_TOTAL_LEN, // wTotalLength 2 Total length of data returned for this configuration + 0x01 + RETARGET_INF, // bNumberInterface 1 Number of interfaces supported by this configuration + 0x01, // bConfigurationValue 1 Value to use as an argument to the SetConfiguration() + 0x00, // iConfiguration 1 Index of string descriptor describing this configuration + DESC_BMATTRIBUTES, // bmAttributes 1 Configuration characteristics + // D6: Self-powered, D5: RemoteWakeup + DESC_POWER(DESC_BMAXPOWER), // bMaxPower 1 Maximum power consumption of the USB device (2 mA units) + + /*--------------------------------------------------------------------------------------------------------*/ + /* Interface descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_INF, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_04_INF, // bDescriptorType 1 INTERFACE Descriptor Type + 0x00, // bInterfaceNumber 1 Number of this interface (Zero-based 0) + 0x00, // bAlternateSetting 1 Value used to select this alternate setting + 2, // bNumEndpoints 1 Number of endpoints used by this interface + CLASS_INF_CLASS, // bInterfaceClass 1 Class code (assigned by USB-IF) + CLASS_INF_SUBCLASS, // bInterfaceSubClass 1 Subclass code (assigned by USB-IF) + CLASS_INF_PTCO, // bInterfaceProtocol 1 Protocol code (assigned by USB) + 0x00, // iInterface 1 Index of string descriptor describing this interface + + /*--------------------------------------------------------------------------------------------------------*/ + /* XXX descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_XXX, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_01_XXX, // bDescriptorType 1 XXX Descriptor type + DESC_H2B(0x0110), // bcdXXX 2 XXX Specification Release Number + 0x21, // bCountryCode 1 Country code of the localized hardware + 0x01, // bNumDescriptors 1 Number of class descriptors (at least 1) + DESC_TYPE_02_XXX, // bDescriptorType 1 REPORT Descriptor Type + DESC_H2B(DESC_LEN_XXXX), // bDescriptorLength 2 Total size of the Report descriptor + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + 0x81, // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x03, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(_EP1LEN), // wMaxPacketSize 2 Maximum packet size + 0x01, // bInterval 1 Interval for polling endpoint + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + 0x02, // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x03, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(_EP2LEN), // wMaxPacketSize 2 Maximum packet size + 0x01, // bInterval 1 Interval for polling endpoint + + #ifdef RETARGET_IS_USB + #include "ht32_retarget_desc.h" + #endif + +}; + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB String Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_StringDescLANGID[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* LANGID (Index = 0) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(1), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_H2B(0x0409), // wLANGID[0] 2 LANGID code zero +}; + +#if (DESC_IMANUFACTURE == 1) +__ALIGN4 static uc8 guUSB_StringDescManufacture[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Manufacture (Index = 1) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(6), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('H'), // bString N UNICODE encoded string + DESC_CHAR('O'), + DESC_CHAR('L'), + DESC_CHAR('T'), + DESC_CHAR('E'), + DESC_CHAR('K'), +}; +#endif + +#if (DESC_IPRODUCT == 1) +__ALIGN4 static uc8 guUSB_StringDescProduct[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Product (Index = 2) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(12), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('U'), // bString N UNICODE encoded string + DESC_CHAR('S'), + DESC_CHAR('B'), + DESC_CHAR('-'), + DESC_CHAR('X'), + DESC_CHAR('X'), + DESC_CHAR('X'), + DESC_CHAR(' '), + DESC_CHAR('D'), + DESC_CHAR('E'), + DESC_CHAR('M'), + DESC_CHAR('O'), +}; +#endif + + +#if (DESC_ISERIALNUM == 1) +__ALIGN4 static u8 guUSB_StringDescSerialNum[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Serial Number (Index = 3) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(12), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('S'), // bString N UNICODE encoded string + DESC_CHAR('N'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), +}; +#endif + +uc8 *gpStringDesc[DESC_NUM_STRING] = +{ + + guUSB_StringDescLANGID, + + #if (DESC_IMANUFACTURE == 1) + guUSB_StringDescManufacture, + #else + NULL, + #endif + + #if (DESC_IPRODUCT == 1) + guUSB_StringDescProduct, + #else + NULL, + #endif + + #if (DESC_ISERIALNUM == 1) + guUSB_StringDescSerialNum + #else + NULL, + #endif + +}; + +/*********************************************************************************************************//** + * @brief USB Descriptor pointer initialization. + * @param pDesc: pointer of USBDCore_Desc_TypeDef + * @retval None + ***********************************************************************************************************/ +void USBDDesc_Init(USBDCore_Desc_TypeDef *pDesc) +{ + pDesc->pDeviceDesc = guUSB_DeviceDesc; + pDesc->pConfnDesc = guUSB_ConfnDesc; + pDesc->ppStringDesc = gpStringDesc; + pDesc->uStringDescNumber = DESC_NUM_STRING; + + return; +} + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h new file mode 100644 index 0000000000..1f0dee2e81 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h @@ -0,0 +1,59 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_descriptor.h + * @version $Rev:: 5 $ + * @date $Date:: 2017-05-11 #$ + * @brief The USB descriptor. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_USBD_DESCRIPTOR_H +#define __HT32_USBD_DESCRIPTOR_H + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDDescriptor USB Descriptor + * @brief USB descriptor + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +#define DESC_LEN_CONFN_T (u16)(DESC_LEN_CONFN + DESC_LEN_INF + DESC_LEN_XXX + DESC_LEN_EPT * 2) + +/* Exported functions --------------------------------------------------------------------------------------*/ +void USBDDesc_Init(USBDCore_Desc_TypeDef *pDesc); + + +/** + * @} + */ + +/** + * @} + */ + +#endif /* __HT32_USBD_DESCRIPTOR_H -------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h new file mode 100644 index 0000000000..73cdd54b0a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h @@ -0,0 +1,453 @@ +/*********************************************************************************************************//** + * @file example/ht32fxxxxx_usbdconf.h + * @version $Rev:: 5 $ + * @date $Date:: 2017-05-11 #$ + * @brief The configuration file of USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32FXXXX_USBDCONF_H +#define __HT32FXXXX_USBDCONF_H + +// Enter Low Power mode when Suspended +#define USBDCORE_ENABLE_LOW_POWER (0) +// + +#if (USBDCORE_ENABLE_LOW_POWER == 1) + #define USBDCore_LowPower() PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_WFE) +#else + #define USBDCore_LowPower(...) +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Interrupt Enable */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Interrupt Setting (UIER) +// USB Global Interrupt Enable (UGIE) (Default) +// Start Of Frame Interrupt Enable (SOFIE) +// USB Reset Interrupt Enable (URSTIE) (Default) +// Resume Interrupt Enable (RSMIE) (Default) +// Suspend Interrupt Enable (SUSPIE) (Default) +// Expected Start of Frame Interrupt Enable (ESOFE) +// Control Endpoint Interrupt Enable (EP0IE) (Default) +// Endpoint1 Interrupt Enable (EP1IE) +// Endpoint2 Interrupt Enable (EP2IE) +// Endpoint3 Interrupt Enable (EP3IE) +// Endpoint4 Interrupt Enable (EP4IE) +// Endpoint5 Interrupt Enable (EP5IE) +// Endpoint6 Interrupt Enable (EP6IE) +// Endpoint7 Interrupt Enable (EP7IE) +#define _UIER (0x071D) +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Control Endpoint0 Configuration +// Endpoint Buffer Length (EPLEN) +// <8=> 8 bytes +// <16=> 16 bytes +// <32=> 32 bytes +// <64=> 64 bytes + /* Maximum: 64 Bytes */ +#define _EP0LEN (64) + + +// Control Endpoint0 Interrupt Enable Settings (EP0IER) +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) (Default) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) (Default) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +// SETUP Token Packet Received Interrupt Enable (STRXIE) +// SETUP Data Packet Received Interrupt Enable (SDRXIE) (Default) +// SETUP Data Error Interrupt Enable (SDERIE) +// Zero Length Data Packet Received Interrupt Enable (ZLRXIE) +#define _EP0_IER (0x212) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint1 Configuration +#define _EP1_ENABLE (1) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP1_CFG_EPADR (1) + +// Endpoint Enable (EPEN) +#define _EP1_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP1_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP1_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP1LEN_TMP (64) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP1_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint2 Configuration +#define _EP2_ENABLE (1) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP2_CFG_EPADR (2) + +// Endpoint Enable (EPEN) +#define _EP2_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP2_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP2_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP2LEN_TMP (64) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP2_IER (0x002) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint3 Configuration +#define _EP3_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP3_CFG_EPADR (3) + +// Endpoint Enable (EPEN) +#define _EP3_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP3_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP3_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP3LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP3_IER (0x10) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint4 Configuration +#define _EP4_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP4_CFG_EPADR (4) + +// Endpoint Enable (EPEN) +#define _EP4_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP4_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP4_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP4LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP4_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP4_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint5 Configuration +#define _EP5_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP5_CFG_EPADR (5) + +// Endpoint Enable (EPEN) +#define _EP5_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP5_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP5_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP5LEN_TMP (8) + + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP5_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP5_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint6 Configuration +#define _EP6_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP6_CFG_EPADR (6) + +// Endpoint Enable (EPEN) +#define _EP6_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP6_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP6_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP6LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP6_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP6_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint7 Configuration +#define _EP7_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP7_CFG_EPADR (7) + +// Endpoint Enable (EPEN) +#define _EP7_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP7_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP7_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP7LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP7_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP7_IER (0x10) +// +// + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h new file mode 100644 index 0000000000..a30f749d10 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h @@ -0,0 +1,435 @@ +/*********************************************************************************************************//** + * @file ht32_usbd_core.h + * @version $Rev:: 2555 $ + * @date $Date:: 2022-03-15 #$ + * @brief The header file of standard protocol related function for HT32 USB Device Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_USBD_CORE_H +#define __HT32_USBD_CORE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32_USBD_Library + * @{ + */ + +/** @addtogroup USBDCore + * @{ + */ + + +/* Settings ------------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Settings USB Device Core settings + * @{ + */ +/* USBD Debug mode */ +// Enable USB Debug mode +// Dump USB Debug data +#ifndef USBDCORE_DEBUG + #define USBDCORE_DEBUG (0) /*!< Enable USB Debug mode */ + #define USBDCORE_DEBUG_DATA (0) /*!< Dump USB Debug data */ +#endif +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Type USB Device Core exported types + * @{ + */ +/** + * @brief USB Device Request. + */ +typedef __PACKED_H struct +{ + uc8 bmRequestType; + uc8 bRequest; + uc8 wValueL; + uc8 wValueH; + uc16 wIndex; + uc16 wLength; +} __PACKED_F USBDCore_Request_TypeDef; + +/** + * @brief USB Descriptor. + */ +typedef struct +{ + uc8 *pDeviceDesc; /*!< Device Descriptor */ + uc8 *pConfnDesc; /*!< Configuration Descriptor */ + uc8 **ppStringDesc; /*!< String Descriptor */ + u32 uStringDescNumber; /*!< Count of String Descriptor */ +} USBDCore_Desc_TypeDef; + +/** + * @brief STALL, control IN or control OUT. + */ +typedef enum +{ + USB_ACTION_STALL = 0, + USB_ACTION_DATAIN = 1, + USB_ACTION_DATAOUT = 2, +} USBDCore_Action_Enum; + +/** + * @brief Call back function. + */ +typedef struct +{ + void (*func) (u32 uPara); /*!< Call back function pointer */ + u32 uPara; /*!< Parameter of call back function */ +} USBDCore_CallBack_TypeDef; + +/** + * @brief Parameter for control IN/OUT Transfer. + */ +typedef struct +{ + u8 uBuffer[2]; /*!< Temporary buffer */ + uc8 *pData; /*!< Pointer of control IN/OUT Data */ + s32 sByteLength; /*!< Total length for control IN/OUT Transfer */ + USBDCore_Action_Enum Action; /*!< STALL, control IN or control OUT */ + USBDCore_CallBack_TypeDef CallBack_OUT; /*!< Call back function pointer for Control OUT */ +} USBDCore_Transfer_TypeDef; + +/** + * @brief USB Device. + */ +typedef struct +{ + USBDCore_Request_TypeDef Request; /*!< USB Device Request */ + USBDCore_Desc_TypeDef Desc; /*!< USB Descriptor */ + USBDCore_Transfer_TypeDef Transfer; /*!< Parameter for control IN/OUT Transfer */ +} USBDCore_Device_TypeDef; + +/** + * @brief Bit access for CurrentFeature. + */ +typedef __PACKED_H struct _FEATURE_TYPEBIT +{ + unsigned bSelfPowered :1; /*!< Remote Wakeup feature */ + unsigned bRemoteWakeup :1; /*!< Self Powered */ +} __PACKED_F USBDCore_Feature_TypeBit; + +/** + * @brief For Set/ClearFeature and GetStatus request. + */ +typedef __PACKED_H union _FEATURE_TYPEDEF +{ + u8 uByte; /*!< Byte access for CurrentFeature */ + USBDCore_Feature_TypeBit Bits; /*!< Bit access for CurrentFeature */ +} __PACKED_F USBDCore_Feature_TypeDef; + +/** + * @brief Device State. + */ +typedef enum +{ + USB_STATE_UNCONNECTED = 0, + USB_STATE_ATTACHED = 1, + USB_STATE_POWERED = 2, + USB_STATE_SUSPENDED = 3, + USB_STATE_DEFAULT = 4, + USB_STATE_ADDRESS = 5, + USB_STATE_CONFIGURED = 6, +} USBDCore_Status_Enum; + +/** + * @brief USB Device information. + */ +typedef struct +{ + u8 uCurrentConfiguration; /*!< For Set/GetConfiguration request */ + u8 uCurrentInterface; /*!< For Set/GetInterface request */ + volatile USBDCore_Status_Enum CurrentStatus; /*!< Device State */ + USBDCore_Status_Enum LastStatus; /*!< Device State before SUSPEND */ + USBDCore_Feature_TypeDef CurrentFeature; /*!< For Set/ClearFeature and GetStatus request */ + u32 uIsDiscardClearFeature; /*!< Discard ClearFeature flag for Mass Storage */ +} USBDCore_Info_TypeDef; + +typedef void (*USBDCore_CallBackClass_Typedef) (USBDCore_Device_TypeDef *pDev); +typedef void (*USBDCore_CallBackVendor_Typedef) (USBDCore_Device_TypeDef *pDev); +typedef void (*USBDCore_CallBackEPTn_Typedef) (USBD_EPTn_Enum EPTn); + +/** + * @brief USB Class call back function. + */ +typedef struct +{ + USBDCore_CallBack_TypeDef CallBack_MainRoutine; /*!< Class main routine call back function */ + USBDCore_CallBack_TypeDef CallBack_Reset; /*!< Class RESET call back function */ + USBDCore_CallBack_TypeDef CallBack_StartOfFrame; /*!< Class SOF call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassGetDescriptor; /*!< Class Get Descriptor call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassSetInterface; /*!< Set Interface call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassGetInterface; /*!< Get Interface call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassRequest; /*!< Class Request call back function */ + USBDCore_CallBackVendor_Typedef CallBack_VendorRequest; /*!< Vendor Request call back function */ + USBDCore_CallBackEPTn_Typedef CallBack_EPTn[MAX_EP_NUM]; /*!< Endpoint n call back function */ +} USBDCore_Class_TypeDef; + +/** + * @brief USB Device Power related call back function. + */ +typedef struct +{ + USBDCore_CallBack_TypeDef CallBack_Suspend; +} USBDCore_Power_TypeDef; + +/** + * @brief Major structure of USB Library. + */ +typedef struct +{ + USBDCore_Device_TypeDef Device; /*!< USB Device */ + USBDCore_Info_TypeDef Info; /*!< USB Device information */ + USBDCore_Class_TypeDef Class; /*!< USB Class call back function */ + u32 *pDriver; /*!< USB Device Driver initialization structure */ + USBDCore_Power_TypeDef Power; /*!< USB Device Power related call back function */ +} USBDCore_TypeDef; + +/*----------------------------------------------------------------------------------------------------------*/ +/* Variable architecture of USB Library */ +/*----------------------------------------------------------------------------------------------------------*/ +/* USBCore - USBDCore_TypeDef Major structure of USB Library */ +/* USBCore.Device - USBDCore_Device_TypeDef USB Device */ +/* USBCore.Device.Request - USBDCore_Request_TypeDef USB Device Request */ +/* USBCore.Device.Request.bmRequestType */ +/* USBCore.Device.Request.bRequest */ +/* USBCore.Device.Request.wValueL */ +/* USBCore.Device.Request.wValueH */ +/* USBCore.Device.Request.wIndex */ +/* USBCore.Device.Request.wLength */ +/* USBCore.Device.Desc - USBDCore_Desc_TypeDef USB Descriptor */ +/* USBCore.Device.Desc.pDeviceDesc Device Descriptor */ +/* USBCore.Device.Desc.pConfnDesc Configuration Descriptor */ +/* USBCore.Device.Desc.pStringDesc[DESC_NUM_STRING] String Descriptor */ +/* USBCore.Device.Desc.uStringDescNumber Count of String Descriptor */ +/* USBCore.Device.Transfer - USBDCore_Transfer_TypeDef Parameter for control IN/OUT Transfer */ +/* USBCore.Device.Transfer.uBuffer[2] Temporary buffer */ +/* USBCore.Device.Transfer.pData Pointer of control IN/OUT Data */ +/* USBCore.Device.Transfer.sByteLength Total length for control IN/OUT Transfer */ +/* USBCore.Device.Transfer.Action - USBDCore_Action_Enum STALL, control IN or control OUT */ +/* USBCore.Device.Transfer.CallBack_OUT.func(uPara) Call back function pointer for Control OUT */ +/* USBCore.Device.Transfer.CallBack_OUT.uPara Parameter of Control OUT call back function */ +/* */ +/* USBCore.Info - USBDCore_Info_TypeDef USB Device information */ +/* USBCore.Info.uCurrentConfiguration For Set/GetConfiguration request */ +/* USBCore.Info.uCurrentInterface For Set/GetInterface request */ +/* USBCore.Info.CurrentStatus - USBDCore_Status_Enum Device State */ +/* USBCore.Info.LastStatus - USBDCore_Status_Enum Device State before SUSPEND */ +/* USBCore.Info.CurrentFeature - USBDCore_Feature_TypeDef For Set/ClearFeature and GetStatus request */ +/* USBCore.Info.CurrentFeature.uByte Byte access for CurrentFeature */ +/* USBCore.Info.CurrentFeature.Bits.bRemoteWakeup Remote Wakeup feature */ +/* USBCore.Info.CurrentFeature.Bits.bSelfPowered Self Powered */ +/* USBCore.Info.uIsDiscardClearFeature Discard ClearFeature flag for Mass Storage */ +/* */ +/* USBCore.Class - USBDCore_Class_TypeDef USB Class call back function */ +/* USBCore.Class.CallBack_MainRoutine.func(uPara) Class main routine call back function */ +/* USBCore.Class.CallBack_MainRoutine.uPara Parameter of class main routine */ +/* USBCore.Class.CallBack_Reset.func(uPara) Class RESET call back function */ +/* USBCore.Class.CallBack_Reset.uPara Parameter of RESET call back function */ +/* USBCore.Class.CallBack_StartOfFrame.func(uPara) Class SOF call back function */ +/* USBCore.Class.CallBack_StartOfFrame.uPara Parameter of SOF call back function */ +/* USBCore.Class.CallBack_ClassGetDescriptor(pDev) Class Get Descriptor call back function */ +/* USBCore.Class.CallBack_ClassSetInterface(pDev) Set Interface call back function */ +/* USBCore.Class.CallBack_ClassGetInterface(pDev) Get Interface call back function */ +/* USBCore.Class.CallBack_ClassRequest(pDev) Class Request call back function */ +/* USBCore.Class.CallBack_EPTn[MAX_EP_NUM](EPTn) Endpoint n call back function */ +/* */ +/* USBCore.pDriver USB Device Driver initialization structure */ +/* */ +/* USBCore.Power - USBDCore_Power_TypeDef USB Device Power related call back function */ +/* USBCore.Power.CallBack_Suspend.func(uPara) System low power function for SUSPEND */ +/* USBCore.Power.CallBack_Suspend.uPara Parameter of system low power function */ +/*----------------------------------------------------------------------------------------------------------*/ + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Constant USB Device Core exported constants + * @{ + */ + +/** @defgroup USBDCore_Descriptor Definitions for USB descriptor + * @{ + */ +#define DESC_TYPE_01_DEV (0x1) +#define DESC_TYPE_02_CONFN (0x2) +#define DESC_TYPE_03_STR (0x3) +#define DESC_TYPE_04_INF (0x4) +#define DESC_TYPE_05_EPT (0x5) +#define DESC_TYPE_06_DEV_QLF (0x6) +#define DESC_TYPE_08_INF_PWR (0x8) + +#define DESC_CLASS_00_BY_INF (0x00) +#define DESC_CLASS_01_AUDIO (0x01) +#define DESC_CLASS_02_CDC_CTRL (0x02) +#define DESC_CLASS_03_HID (0x03) +#define DESC_CLASS_05_PHY (0x05) +#define DESC_CLASS_06_STILL_IMG (0x06) +#define DESC_CLASS_07_PRINTER (0x07) +#define DESC_CLASS_08_MASS_STORAGE (0x08) +#define DESC_CLASS_09_HUB (0x09) +#define DESC_CLASS_0A_CDC_DATA (0x0A) +#define DESC_CLASS_0B_SMART_CARD (0x0B) +#define DESC_CLASS_0E_VIDEO (0x0E) +#define DESC_CLASS_0F_PHD (0x0F) +#define DESC_CLASS_FF_VENDOR (0xFF) + +#define DESC_LEN_DEV ((u32)(18)) +#define DESC_LEN_CONFN ((u32)(9)) +#define DESC_LEN_INF ((u32)(9)) +#define DESC_LEN_EPT ((u32)(7)) +/** + * @} + */ + +/** @defgroup USBDCore_Request Definitions for USB Request + * @{ + */ +#define REQ_DIR_00_H2D (0 << 7) +#define REQ_DIR_01_D2H (1 << 7) + +#define REQ_TYPE_00_STD (0 << 5) +#define REQ_TYPE_01_CLS (1 << 5) +#define REQ_TYPE_02_VND (2 << 5) + +#define REQ_REC_00_DEV (0) +#define REQ_REC_01_INF (1) +#define REQ_REC_02_EPT (2) +/** + * @} + */ + +/** + * @brief For USBDCore_EPTReadOUTData function. + */ +#define USB_DISCARD_OUT_DATA (0) + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Macro USB Device Core exported macros + * @{ + */ +#define __DBG_USBPrintf(...) +#define __DBG_USBDump(a, b) + +#if (USBDCORE_DEBUG == 1) + #ifndef RETARGET_IS_USB + extern u32 __DBG_USBCount; + #undef __DBG_USBPrintf + #define __DBG_USBPrintf printf + #if (USBDCORE_DEBUG_DATA == 1) + #undef __DBG_USBDump + void __DBG_USBDump(uc8 *memory, u32 len); + #endif + #endif +#endif + +/** + * @brief Convert Half-Word to Byte for descriptor. + */ +#define DESC_H2B(Val) ((u8)(Val & 0x00FF)), ((u8)((Val & 0xFF00) >> 8)) + +/** + * @brief Padding 0 automatically for String descriptor. + */ +#define DESC_CHAR(c) (c), (0) + +/** + * @brief Calculate String length for String descriptor. + */ +#define DESC_STRLEN(n) (n * 2 + 2) + +/** + * @brief Calculate power for Configuration descriptor. + */ +#define DESC_POWER(mA) (mA / 2) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Functions USB Device Core exported functions + * @{ + */ +#define USBDCore_DeInit API_USB_DEINIT +#define USBDCore_EPTReset API_USB_EPTn_RESET +#define USBDCore_EPTGetBufferLen API_USB_EPTn_GET_BUFFLEN +#define USBDCore_EPTGetTransferCount API_USB_EPTn_GET_CNT +#define USBDCore_EPTSetSTALL API_USB_EPTn_SET_HALT +#define USBDCore_EPTWaitSTALLSent API_USB_EPTn_WAIT_STALL_SENT +#define USBDCore_EPTClearDataToggle API_USB_EPTn_CLR_DTG + +#define USBDCore_EPTWriteINData API_USB_EPTn_WRITE_IN +#define USBDCore_EPTReadOUTData API_USB_EPTn_READ_OUT +#define USBDCore_EPTReadMemory API_USB_EPTn_READ_MEM + +void USBDCore_Init(USBDCore_TypeDef *pCore); +void USBDCore_IRQHandler(USBDCore_TypeDef *pCore); +void USBDCore_MainRoutine(USBDCore_TypeDef *pCore); +u32 USBDCore_IsSuspend(USBDCore_TypeDef *pCore); +u32 USBDCore_GetRemoteWakeUpFeature(USBDCore_TypeDef *pCore); +void USBDCore_TriggerRemoteWakeup(void); +USBDCore_Status_Enum USBDCore_GetStatus(void); + +void USBDCore_EPTReset(USBD_EPTn_Enum USBD_EPTn); +u32 USBDCore_EPTGetBufferLen(USBD_EPTn_Enum USBD_EPTn); +u32 USBDCore_EPTGetTransferCount(USBD_EPTn_Enum USBD_EPTn, USBD_TCR_Enum type); +void USBDCore_EPTSetSTALL(USBD_EPTn_Enum USBD_EPTn); +void USBDCore_EPTWaitSTALLSent(USBD_EPTn_Enum USBD_EPTn); +void USBDCore_EPTClearDataToggle(USBD_EPTn_Enum USBD_EPTn); + +u32 USBDCore_EPTWriteINData(USBD_EPTn_Enum USBD_EPTn, u32 *pFrom, u32 len); +u32 USBDCore_EPTReadOUTData(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +u32 USBDCore_EPTReadMemory(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __HT32_USBD_CORE_H -------------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c new file mode 100644 index 0000000000..0a7bc4c20c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_1xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c @@ -0,0 +1,1037 @@ +/*********************************************************************************************************//** + * @file ht32_usbd_core.c + * @version $Rev:: 1684 $ + * @date $Date:: 2019-05-07 #$ + * @brief The standard protocol related function of HT32 USB Device Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_usbd_core.h" + +#ifdef USBD_VENDOR_SUPPORT +#include "ht32_usbd_vendor.c" +#endif + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDCore USB Device Core + * @brief USB Device Core standard protocol related function + * @{ + */ + + +/* Private types -------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_TypesDefinitions USB Device Core private types definitions + * @{ + */ +typedef enum +{ + Device = 0, + Interface = 1, + Endpoint = 2, + Other = 3, +} USBDCore_Recipient_Enum; + +typedef enum +{ + ClearFeature = 0, + SetFeature = 1, +} USBDCore_SetClearFeature_Enum; +/** + * @} + */ + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Define USB Device Core private definitions + * @{ + */ +/* USBD Debug mode */ +#if (USBDCORE_DEBUG == 1) + #ifdef RETARGET_IS_USB + #warning "USB debug mode can not work when retaget to USB Virtual COM. Turn off automatically." + #undef USBDCORE_DEBUG + #define USBDCORE_DEBUG 0 + #else + u32 __DBG_USBCount; + #warning "USB debug mode has been enabled which degrade the performance." + #warning "After the debug operation, please remember to turn off USB debug mode." + #endif +#endif + +/** @defgroup USBDCore_STD Definition for standard request + * @{ + */ +#define REQ_00_GET_STAT ((u16)(0 << 8)) +#define REQ_01_CLR_FETU ((u16)(1 << 8)) +#define REQ_03_SET_FETU ((u16)(3 << 8)) +#define REQ_05_SET_ADDR ((u16)(5 << 8)) +#define REQ_06_GET_DESC ((u16)(6 << 8)) +#define REQ_07_SET_DESC ((u16)(7 << 8)) +#define REQ_08_GET_CONF ((u16)(8 << 8)) +#define REQ_09_SET_CONF ((u16)(9 << 8)) +#define REQ_10_GET_INF ((u16)(10 << 8)) +#define REQ_11_SET_INF ((u16)(11 << 8)) +#define REQ_12_SYN_FRME ((u16)(12 << 8)) +/** + * @} + */ + +#define DESC_TYPE_01_DEV (0x1) +#define DESC_TYPE_02_CONFN (0x2) +#define DESC_TYPE_03_STR (0x3) +#define USB_NO_DATA (-1) /*!< For Device.Transfer.sByteLength */ +#define BMREQUEST_TYPE_MASK (0x6 << 4) /*!< bmRequestType[6:5] */ +#define USB_FEATURE_REMOTE_WAKEUP (1) + +#define MAX_CONTROL_OUT_SIZE (64) +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void _USBDCore_PowerHandler(USBDCore_TypeDef *pCore); +static void _USBDCore_Reset(USBDCore_TypeDef *pCore); +static void _USBDCore_Resume(USBDCore_TypeDef *pCore); +static void _USBDCore_Suspend(USBDCore_TypeDef *pCore); +static void _USBDCore_Setup(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_Request(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_GetStatus(USBDCore_TypeDef *pCore, USBDCore_Recipient_Enum recipient); +static void _USBDCore_Standard_SetClearFeature(USBDCore_TypeDef *pCore, USBDCore_Recipient_Enum recipient, USBDCore_SetClearFeature_Enum type); +static void _USBDCore_Standard_SetAddress(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_GetDescriptor(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_GetConfiguration(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_SetConfiguration(USBDCore_TypeDef *pCore); +static void _USBDCore_ControlIN(USBDCore_TypeDef *pCore); +static void _USBDCore_ControlOUT(USBDCore_TypeDef *pCore); + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Macro USB Device Core private macros + * @{ + */ +/** + * @brief Get self powered bit from Device descriptor + */ +#define _GET_SELFPOWERED_FROM_DESC() (((pCore->Device.Desc.pConfnDesc[7]) >> 6) & 0x01) +/** + * @} + */ + +/* Private variables ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Variable USB Device Core private variables + * @{ + */ +USBDCore_TypeDef *pUSBCore; +/** + * @} + */ + + +/* Global Function -----------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Functions USB Device Core exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Core initialization. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +void USBDCore_Init(USBDCore_TypeDef *pCore) +{ + pUSBCore = pCore; + pCore->Info.CurrentStatus = USB_STATE_POWERED; + API_USB_INIT(pCore->pDriver); + __DBG_USBPrintf("\r\n%06ld \r\n", ++__DBG_USBCount); + return; +} + +/*********************************************************************************************************//** + * @brief USB Interrupt Service Routine. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +void USBDCore_IRQHandler(USBDCore_TypeDef *pCore) +{ + u32 USBISRFlag = API_USB_GET_INT(); + u32 USBEPTISRFlag; + USBD_EPTn_Enum EPTn; + + #if (USBDCORE_DEBUG == 1) + u32 USBAddr = HT_USB->DEVAR; + #endif + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB SOF Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_SOF_INT(USBISRFlag)) + { + __DBG_USBPrintf("%06ld SOF[%02d][%02lX]\r\n", ++__DBG_USBCount, pCore->Info.CurrentStatus, USBAddr); + if (pCore->Class.CallBack_StartOfFrame.func != NULL) + { + pCore->Class.CallBack_StartOfFrame.func(pCore->Class.CallBack_StartOfFrame.uPara); + } + API_USB_CLR_SOF_INT(); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB SUSPEND Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_SUSPEND_INT(USBISRFlag)) + { + __DBG_USBPrintf("%06ld SUSPEND[%02d]\r\n", ++__DBG_USBCount, pCore->Info.CurrentStatus); + API_USB_CLR_SUSPEND_INT(); + _USBDCore_Suspend(pCore); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB RESET Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_RESET_INT(USBISRFlag)) + { + if (API_USB_IS_FRES_INT(USBISRFlag)) + { + API_USB_CLR_FRES_INT(); + } + else + { + __DBG_USBPrintf("%06ld RESET[%02d][%02lX]\r\n", ++__DBG_USBCount, pCore->Info.CurrentStatus, USBAddr); + _USBDCore_Reset(pCore); + if (pCore->Class.CallBack_Reset.func != NULL) + { + pCore->Class.CallBack_Reset.func(pCore->Class.CallBack_Reset.uPara); + } + } + API_USB_CLR_RESET_INT(); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB RESUME Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_RESUME_INT(USBISRFlag)) + { + __DBG_USBPrintf("%06ld RESUME\r\n", ++__DBG_USBCount); + _USBDCore_Resume(pCore); + API_USB_CLR_RESUME_INT(); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB Endpoint 0 interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_EPTn_INT(USBISRFlag, USBD_EPT0)) + { + USBEPTISRFlag = API_USB_EPTn_GET_INT(USBD_EPT0); + + /*------------------------------------------------------------------------------------------------------*/ + /* Control SETUP Stage */ + /*------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_SETUP_INT(USBEPTISRFlag)) + { + API_USB_READ_SETUP(&(pCore->Device.Request)); /* Read SETUP Command data from USB Buffer*/ + + __DBG_USBPrintf("%06ld SETUP\t[08]\r\n", ++__DBG_USBCount); + __DBG_USBDump((uc8 *)&(pCore->Device.Request), 8); + + _USBDCore_Setup(pCore); + API_USB_CLR_SETUP_INT(); /* Clear SETUP Interrupt */ + } + + /*------------------------------------------------------------------------------------------------------*/ + /* Control Endpoint 0 IN */ + /*------------------------------------------------------------------------------------------------------*/ + if (API_USB_EPTn_IS_IN_INT(USBEPTISRFlag)) + { + __DBG_USBPrintf("%06ld EP0IN\t[%02ld]", ++__DBG_USBCount, pCore->Device.Transfer.sByteLength); + + _USBDCore_ControlIN(pCore); + API_USB_EPTn_CLR_IN_INT(USBD_EPT0); + } + + /*------------------------------------------------------------------------------------------------------*/ + /* Control Endpoint 0 OUT */ + /*------------------------------------------------------------------------------------------------------*/ + if (API_USB_EPTn_IS_OUT_INT(USBEPTISRFlag)) + { + __DBG_USBPrintf("%06ld EP0OUT\t[%02ld]", ++__DBG_USBCount, pCore->Device.Transfer.sByteLength); + + /*----------------------------------------------------------------------------------------------------*/ + /* Clear interrupt flag before USBDCore_ControlOUT is meaning since USBDCore_ControlOUT clear NAKRX */ + /* bit which will cause another interrupt occur. */ + /*----------------------------------------------------------------------------------------------------*/ + API_USB_EPTn_CLR_OUT_INT(USBD_EPT0); + _USBDCore_ControlOUT(pCore); + } + + /*------------------------------------------------------------------------------------------------------*/ + /* Clear Control Endpoint 0 global interrupt */ + /*------------------------------------------------------------------------------------------------------*/ + API_USB_CLR_EPTn_INT(USBD_EPT0); + + } /* if (API_USB_IS_EP_INT(USBISRFlag, USBD_EPT0)) */ + + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB Endpoint n call back function */ + /*--------------------------------------------------------------------------------------------------------*/ + while ((EPTn = API_USB_GET_EPT_NUM(API_USB_GET_INT())) != USBD_NOEPT) + { + USBEPTISRFlag = API_USB_EPTn_GET_INT((USBD_EPTn_Enum)EPTn); + + if (API_USB_EPTn_IS_INT(USBEPTISRFlag)) + { + API_USB_EPTn_CLR_INT(EPTn); + API_USB_CLR_EPTn_INT(EPTn); + + if (pCore->Class.CallBack_EPTn[EPTn] != NULL) + { + pCore->Class.CallBack_EPTn[EPTn](EPTn); + } + } + } /* while ((EPTn = API_USB_GET_EPTn_NUM(API_USB_GET_INT())) != USBD_NOEPT) */ + + return; +} + +/*********************************************************************************************************//** + * @brief USB Core Main Routine for application. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +void USBDCore_MainRoutine(USBDCore_TypeDef *pCore) +{ + _USBDCore_PowerHandler(pCore); + + /*--------------------------------------------------------------------------------------------------------*/ + /* Class main routine call back function */ + /*--------------------------------------------------------------------------------------------------------*/ + if ((pCore->Class.CallBack_MainRoutine.func != NULL) && (pCore->Info.CurrentStatus == USB_STATE_CONFIGURED)) + { + pCore->Class.CallBack_MainRoutine.func(pCore->Class.CallBack_MainRoutine.uPara); + } + + return; +} + +/*********************************************************************************************************//** + * @brief Return Suspend status + * @param pCore: pointer of USB Device + * @retval TRUE or FALSE + ***********************************************************************************************************/ +u32 USBDCore_IsSuspend(USBDCore_TypeDef *pCore) +{ + return ((pCore->Info.CurrentStatus == USB_STATE_SUSPENDED) ? TRUE : FALSE); +} + +/*********************************************************************************************************//** + * @brief Return remote wake status which set by SET FEATURE standard command + * @param pCore: pointer of USB Device + * @retval TRUE or FALSE + ***********************************************************************************************************/ +u32 USBDCore_GetRemoteWakeUpFeature(USBDCore_TypeDef *pCore) +{ + return (pCore->Info.CurrentFeature.Bits.bRemoteWakeup); +} + +/*********************************************************************************************************//** + * @brief Turn on USB power and remote wakeup the Host + * @retval None + ***********************************************************************************************************/ +void USBDCore_TriggerRemoteWakeup(void) +{ + API_USB_POWER_ON(); /* Turn on USB Power */ + API_USB_REMOTE_WAKEUP(); /* Generate Remote Wakeup request to Host (RESUME) */ + return; +} + +/*********************************************************************************************************//** + * @brief Get USB Device status + * @retval USBDCore_Status_Enum + ***********************************************************************************************************/ +USBDCore_Status_Enum USBDCore_GetStatus(void) +{ + return pUSBCore->Info.CurrentStatus; +} + +/*********************************************************************************************************//** + * @brief Dump memory data for debug purpose. + * @param memory: buffer pointer to dump + * @param len: dump length + * @retval None + ***********************************************************************************************************/ +#if (USBDCORE_DEBUG == 1 && USBDCORE_DEBUG_DATA == 1) +void __DBG_USBDump(uc8 *memory, u32 len) +{ + u32 i; + for (i = 0; i < len; i++) + { + if (i % 8 == 0) + { + if (i != 0) + { + __DBG_USBPrintf("\r\n"); + } + __DBG_USBPrintf("\t\t"); + } + __DBG_USBPrintf("%02X ", *((u8 *)(memory + i))); + } + __DBG_USBPrintf("\r\n"); + + return; +} +#endif +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Function USB Device Core private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Core Power handler for application. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_PowerHandler(USBDCore_TypeDef *pCore) +{ + API_USB_POWER_UP(pCore->pDriver, pCore->Info.CurrentFeature.Bits.bSelfPowered); + + if (pCore->Info.CurrentStatus == USB_STATE_SUSPENDED) + { + /*------------------------------------------------------------------------------------------------------*/ + /* System Low Power call back function */ + /*------------------------------------------------------------------------------------------------------*/ + if (pCore->Power.CallBack_Suspend.func != NULL) + { + __DBG_USBPrintf("%06ld >LOWPOWER\r\n", ++__DBG_USBCount); + + pCore->Power.CallBack_Suspend.func(pCore->Power.CallBack_Suspend.uPara); + + __DBG_USBPrintf("%06ld pDriver; + + pCore->Device.Transfer.sByteLength = USB_NO_DATA; + pCore->Info.uCurrentConfiguration = 0; + pCore->Info.uCurrentInterface = 0; + pCore->Info.CurrentFeature.Bits.bRemoteWakeup = 0; + pCore->Info.CurrentStatus = USB_STATE_DEFAULT; + pCore->Info.uIsDiscardClearFeature = FALSE; + + API_USB_DEINIT(); + + API_USB_POWER_ON(); + + /* Endpoint 0 initialization */ + API_USB_EPTn_INIT(USBD_EPT0, pCore->pDriver); // To be modify, init from desc + + /* Enable USB interrupt */ + API_USB_ENABLE_INT(pDrv->uInterruptMask); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Resume + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Resume(USBDCore_TypeDef *pCore) +{ + API_USB_POWER_ON(); + pCore->Info.CurrentStatus = pCore->Info.LastStatus; + return; +} + +/*********************************************************************************************************//** + * @brief USB Suspend + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Suspend(USBDCore_TypeDef *pCore) +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* When Device has been suspended, Change CurrentStatus as SUSPEND and then USBDCore_PowerHandler will */ + /* turn off chip power. */ + /*--------------------------------------------------------------------------------------------------------*/ + if (pCore->Info.CurrentStatus >= USB_STATE_POWERED) + { + API_USB_POWER_OFF(); + pCore->Info.LastStatus = pCore->Info.CurrentStatus; + pCore->Info.CurrentStatus = USB_STATE_SUSPENDED; + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Setup Stage + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Setup(USBDCore_TypeDef *pCore) +{ + pCore->Device.Transfer.Action = USB_ACTION_STALL; + pCore->Device.Transfer.sByteLength = 0; + + switch (pCore->Device.Request.bmRequestType & BMREQUEST_TYPE_MASK) + { + /*------------------------------------------------------------------------------------------------------*/ + /* Standard requests */ + /*------------------------------------------------------------------------------------------------------*/ + case REQ_TYPE_00_STD: + { + _USBDCore_Standard_Request(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* Class requests */ + /*------------------------------------------------------------------------------------------------------*/ + case REQ_TYPE_01_CLS: + { + if (pCore->Class.CallBack_ClassRequest != NULL) + { + pCore->Class.CallBack_ClassRequest(&(pCore->Device)); + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* Vendor requests */ + /*------------------------------------------------------------------------------------------------------*/ + case REQ_TYPE_02_VND: + { + if (pCore->Class.CallBack_VendorRequest != NULL) + { + pCore->Class.CallBack_VendorRequest(&(pCore->Device)); + } + /* Add Vendor requests handler here.... */ + #ifdef USBD_VENDOR_SUPPORT + USBDVendor_Request(pCore); + #endif + break; + } + } /* switch (gUSBReq.bmRequestType.byte) */ + + switch (pCore->Device.Transfer.Action) + { + /*------------------------------------------------------------------------------------------------------*/ + /* Control IN */ + /*------------------------------------------------------------------------------------------------------*/ + case USB_ACTION_DATAIN: + { + /*----------------------------------------------------------------------------------------------------*/ + /* When the Control IN length is large than the Host required, transfer the length which specified */ + /* by SETUP Data Packet. */ + /*----------------------------------------------------------------------------------------------------*/ + if (pCore->Device.Transfer.sByteLength > pCore->Device.Request.wLength) + { + pCore->Device.Transfer.sByteLength = pCore->Device.Request.wLength; + } + __DBG_USBPrintf("%06ld EP0IN\t[%02ld]", __DBG_USBCount, pCore->Device.Transfer.sByteLength); + + _USBDCore_ControlIN(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* Control OUT */ + /*------------------------------------------------------------------------------------------------------*/ + case USB_ACTION_DATAOUT: + { + if (pCore->Device.Transfer.sByteLength == 0) + { + API_USB_EPTn_WRITE_IN(USBD_EPT0, (u32 *)0, 0); /* Prepare ZLP ack for Control OUT */ + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* STALL */ + /*------------------------------------------------------------------------------------------------------*/ + default: + { + __DBG_USBPrintf("%06ld EP0 STALL\r\n", __DBG_USBCount); + + API_USB_EPTn_SEND_STALL(USBD_EPT0); + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Stand Request. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_Request(USBDCore_TypeDef *pCore) +{ + u16 USBCmd = *((u16 *)(&(pCore->Device.Request))); + + switch (USBCmd) + { + /*------------------------------------------------------------------------------------------------------*/ + /* | bRequest | Data transfer direction | Type | Recipient | Data */ + /*------------------------------------------------------------------------------------------------------*/ + + /*------------------------------------------------------------------------------------------------------*/ + /* | 00_Get Status | 80_Device-to-Host | 00_Standard Request | 0_Device | 0080h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_00_GET_STAT | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld GET DST\t[%02d]\r\n", __DBG_USBCount, pCore->Info.CurrentFeature.uByte); + _USBDCore_Standard_GetStatus(pCore, Device); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 00_Get Status | 80_Device-to-Host | 00_Standard Request | 1_Interface | 0081h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_00_GET_STAT | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld GET IST\t[%02d]\r\n", __DBG_USBCount, 0); + _USBDCore_Standard_GetStatus(pCore, Interface); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 00_Get Status | 80_Device-to-Host | 00_Standard Request | 2_Endpoint | 0082h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_00_GET_STAT | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_02_EPT): + { + __DBG_USBPrintf("%06ld GET EST\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wIndex); + _USBDCore_Standard_GetStatus(pCore, Endpoint); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 01_Clear Feature | 00_Host-to-Device | 00_Standard Request | 0_Device | 0100h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_01_CLR_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld CLR DFEA\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetClearFeature(pCore, Device, ClearFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 01_Clear Feature | 00_Host-to-Device | 00_Standard Request | 2_Endpoint | 0102h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_01_CLR_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_02_EPT): + { + __DBG_USBPrintf("%06ld CLR EFEA\t[0x%02x]\r\n", __DBG_USBCount, pCore->Device.Request.wIndex); + _USBDCore_Standard_SetClearFeature(pCore, Endpoint, ClearFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 03_Set Feature | 00_Host-to-Device | 00_Standard Request | 0_Device | 0300h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_03_SET_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld SET DFEA\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetClearFeature(pCore, Device, SetFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 03_Set Feature | 00_Host-to-Device | 00_Standard Request | 2_Endpoint | 0302h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_03_SET_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_02_EPT): + { + __DBG_USBPrintf("%06ld SET EFEA\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wIndex); + _USBDCore_Standard_SetClearFeature(pCore, Endpoint, SetFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 05_Set Address | 00_Host-to-Device | 00_Standard Request | 0_Device | 0500h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_05_SET_ADDR | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld SET ADDR\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetAddress(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 06_Get Descriptor | 80_Device-to-Host | 00_Standard Request | 0_Device | 0680h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_06_GET_DESC | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld GET DDESC\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueH); + _USBDCore_Standard_GetDescriptor(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 06_Get Descriptor | 80_Device-to-Host | 00_Standard Request | 1_Interface | 0681h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_06_GET_DESC | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld GET IDESC\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueH); + if (pCore->Class.CallBack_ClassGetDescriptor != NULL) + { + pCore->Class.CallBack_ClassGetDescriptor((USBDCore_Device_TypeDef *)&(pCore->Device)); + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 08_Get Configuration | 80_Host-to-Device | 00_Standard Request | 0_Device | 0880h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_08_GET_CONF | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld GET CONF\t[%02X]\r\n", __DBG_USBCount, pCore->Info.uCurrentConfiguration); + _USBDCore_Standard_GetConfiguration(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 09_Set Configuration | 00_Host-to-Device | 00_Standard Request | 0_Device | 0900h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_09_SET_CONF | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld SET CONF\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetConfiguration(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 11_Set Interface | 00_Host-to-Device | 00_Standard Request | 1_Interface | 0B01h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_11_SET_INF | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld SET INF\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + if (pCore->Class.CallBack_ClassSetInterface != NULL) + { + pCore->Class.CallBack_ClassSetInterface((USBDCore_Device_TypeDef *)&(pCore->Device)); + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 10_Get Interface | 80_Device-to-Host | 00_Standard Request | 1_Interface | 0A81h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_10_GET_INF | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld GET INF\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + if (pCore->Class.CallBack_ClassGetInterface != NULL) + { + pCore->Class.CallBack_ClassGetInterface((USBDCore_Device_TypeDef *)&(pCore->Device)); + } + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - GET_STATUS. + * @param pCore: pointer of USB Device + * @param recipient: Recipient + * @arg Device: 0 + * @arg Interface: 1 + * @arg Endpoint: 2 + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_GetStatus(USBDCore_TypeDef *pCore, USBDCore_Recipient_Enum recipient) +{ + pCore->Device.Transfer.uBuffer[1] = 0; + switch (recipient) + { + case Device: + { + pCore->Device.Transfer.uBuffer[0] = pCore->Info.CurrentFeature.uByte; + break; + } + case Interface: + { + pCore->Device.Transfer.uBuffer[0] = 0; + break; + } + case Endpoint: + { + pCore->Device.Transfer.uBuffer[0] = API_USB_EPTn_GET_HALT((USBD_EPTn_Enum)(pCore->Device.Request.wIndex & 0xF)); + break; + } + default: + { + return; + } + } + + pCore->Device.Transfer.pData = (uc8 *)&(pCore->Device.Transfer.uBuffer); + pCore->Device.Transfer.sByteLength = 2; + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - SET_FEATURE / CLEAR_FEATURE. + * @param pCore: pointer of USB Device + * @param recipient: Recipient + * @arg Device: 0 + * @arg Interface: 1 + * @arg Endpoint: 2 + * @param type: + * @arg ClearFeature: 0 + @arg SerFeature: 1 + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_SetClearFeature(USBDCore_TypeDef *pCore, + USBDCore_Recipient_Enum recipient, + USBDCore_SetClearFeature_Enum type) +{ + u32 i; + switch (recipient) + { + case Device: + { + if (pCore->Device.Request.wValueL == USB_FEATURE_REMOTE_WAKEUP) + { + pCore->Info.CurrentFeature.Bits.bRemoteWakeup = type; + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + } + break; + } + case Endpoint: + { + i = pCore->Device.Request.wIndex & 0xF; + if (i != 0) + { + if (type == ClearFeature) + { + if (pCore->Info.uIsDiscardClearFeature == FALSE) + { + API_USB_EPTn_CLR_HALT((USBD_EPTn_Enum)i); + API_USB_EPTn_CLR_DTG((USBD_EPTn_Enum)i); + } + } + else + { + API_USB_EPTn_SET_HALT((USBD_EPTn_Enum)i); + } + } + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + break; + } + default: + { + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - SET_ADDRESS. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_SetAddress(USBDCore_TypeDef *pCore) +{ + API_USB_SET_ADDR(pCore->Device.Request.wValueL); + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + pCore->Info.CurrentStatus = USB_STATE_ADDRESS; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - GET_DESCRIPTOR. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_GetDescriptor(USBDCore_TypeDef *pCore) +{ + u32 value = pCore->Device.Request.wValueH; + uc8 *pTemp; + + switch (value) + { + case DESC_TYPE_01_DEV: + { + pCore->Device.Transfer.pData = pCore->Device.Desc.pDeviceDesc; + pCore->Device.Transfer.sByteLength = *(pCore->Device.Desc.pDeviceDesc); + pCore->Device.Transfer.Action= USB_ACTION_DATAIN; + break; + } + case DESC_TYPE_02_CONFN: + { + pCore->Device.Transfer.pData = pCore->Device.Desc.pConfnDesc; + pCore->Device.Transfer.sByteLength = *(u16 *)((pCore->Device.Desc.pConfnDesc) + 2); + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + break; + } + case DESC_TYPE_03_STR: + { + value = pCore->Device.Request.wValueL; + if (value < pCore->Device.Desc.uStringDescNumber) + { + if (*(pCore->Device.Desc.ppStringDesc + value) != NULL) + { + pTemp = *(pCore->Device.Desc.ppStringDesc + value); + pCore->Device.Transfer.pData = (uc8 *)(pTemp); + pCore->Device.Transfer.sByteLength = *(pTemp); + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + } + } + break; + } + } + + #ifdef USBD_VENDOR_SUPPORT + USBDVendor_StandardGetDescriptor(pCore); + #endif + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - GET_CONFIGURATION. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_GetConfiguration(USBDCore_TypeDef *pCore) +{ + pCore->Device.Transfer.pData = &(pCore->Info.uCurrentConfiguration); + pCore->Device.Transfer.sByteLength = 1; + pCore->Device.Transfer.Action= USB_ACTION_DATAIN; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - SET_CONFIGURATION. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_SetConfiguration(USBDCore_TypeDef *pCore) +{ + u32 i; + + pCore->Info.uCurrentConfiguration = pCore->Device.Request.wValueL; + pCore->Device.Transfer.Action= USB_ACTION_DATAIN; + + /* Endpoint n settings */ + for (i = 1; i < MAX_EP_NUM; i++) + { + API_USB_EPTn_INIT((USBD_EPTn_Enum)i, pCore->pDriver); // To be modify, init from desc + } + + pCore->Info.CurrentStatus = USB_STATE_CONFIGURED; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Control IN transfer. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_ControlIN(USBDCore_TypeDef *pCore) +{ + s32 EP0INLen = API_USB_GET_CTRL_IN_LEN(); + u32 len; + + if (pCore->Device.Transfer.sByteLength != USB_NO_DATA && pCore->Device.Transfer.Action == USB_ACTION_DATAIN) + { + if (pCore->Device.Transfer.sByteLength >= EP0INLen) + { + len = EP0INLen; + pCore->Device.Transfer.sByteLength -= len; + } + else + { + len = pCore->Device.Transfer.sByteLength; + pCore->Device.Transfer.sByteLength = USB_NO_DATA; + pCore->Device.Transfer.Action = USB_ACTION_DATAOUT; + } + + __DBG_USBPrintf("[%02ld]\r\n", len); + __DBG_USBDump((uc8 *)pCore->Device.Transfer.pData, len); + + API_USB_EPTn_WRITE_IN(USBD_EPT0, (u32 *)pCore->Device.Transfer.pData, len); + pCore->Device.Transfer.pData = pCore->Device.Transfer.pData + len; + } + else + { + __DBG_USBPrintf("[-1]\r\n"); + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Control OUT transfer. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_ControlOUT(USBDCore_TypeDef *pCore) +{ + u32 len; + + if (pCore->Device.Transfer.sByteLength != USB_NO_DATA && pCore->Device.Transfer.Action == USB_ACTION_DATAOUT) + { + len = API_USB_EPTn_READ_OUT(USBD_EPT0, (u32 *)pCore->Device.Transfer.pData, MAX_CONTROL_OUT_SIZE); + + __DBG_USBPrintf("[%02ld]\r\n", len); + __DBG_USBDump((uc8 *)pCore->Device.Transfer.pData, len); + + pCore->Device.Transfer.pData = pCore->Device.Transfer.pData + len; + pCore->Device.Transfer.sByteLength -= len; + + if (pCore->Device.Transfer.sByteLength == 0) + { + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + if (pCore->Device.Transfer.CallBack_OUT.func != NULL) + { + pCore->Device.Transfer.CallBack_OUT.func(pCore->Device.Transfer.CallBack_OUT.uPara); + pCore->Device.Transfer.CallBack_OUT.func = NULL; + } + pCore->Device.Transfer.sByteLength = USB_NO_DATA; + API_USB_EPTn_WRITE_IN(USBD_EPT0, (u32 *)0, 0); + } + } + else + { + __DBG_USBPrintf("[-1]\r\n"); + } + + return; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/Release_Notes.txt b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/Release_Notes.txt new file mode 100644 index 0000000000..948233eafc --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/Release_Notes.txt @@ -0,0 +1,1674 @@ +/*********************************************************************************************************//** + * @file Release_Notes.txt + * @version V1.9.1 + * @date 2023-12-22 + * @brief The Release notes of HT32 Firmware Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +// Supported Device +// ======================================== +// HT32F50020, HT32F50030 +// HT32F50220, HT32F50230 +// HT32F50231, HT32F50241 +// HT32F50343 +// HT32F50431, HT32F50441 +// HT32F50442, HT32F50452 +// HT32F52220, HT32F52230 +// HT32F52231, HT32F52241 +// HT32F52234, HT32F52244 +// HT32F52243, HT32F52253 +// HT32F52331, HT32F52341 +// HT32F52342, HT32F52352 +// HT32F52344, HT32F52354 +// HT32F52357, HT32F52367 +// HT32F53231, HT32F53241 +// HT32F53242, HT32F53252 +// HT32F54231, HT32F54241 +// HT32F54243, HT32F54253 +// HT32F57331, HT32F57341 +// HT32F57342, HT32F57352 +// HT32F59041, HT32F59741 +// HT32F59046, HT32F59746 +// HT32F5826, HT32F5828 +// HT32F0006 +// HT32F0008 +// HT32F52142 +// HT32F61030, HT32F61041 +// HT32F61141 +// HT32F61244, HT32F61245 +// HT32F61352 +// HT32F61355, HT32F61356, HT32F61357 +// HT32F61630, HT32F61641 +// HT32F62030, HT32F62040, HT32F62050 +// HT32F65230, HT32F65240 +// HT32F65232 +// HT32F67041, HT32F67051 +// HT32F67232 +// HT32F67233 +// HT32F67741 +// HT32F67742 +// HT50F32002, HT50F32003 +// HT50F3200S, HT50F3200T +// HF5032 +// MXTX6306 + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.9.1_7446 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-12-22 + Main Changes + + Add example support of BM18B367A DVB. + + Add "system_ht32f5xxxx_18.c" for BM18B367A DVB. + + Update "ht32f5xxxx_aes.c/h", changed API parameter 4 bytes to remove type conversion at driver layer. + + Update example, add "__ALIGN4" to variables and enforced type conversion for 4 bytes read/write API calls. + - "AES/CBC" + - "AES/CTR" + - "AES/ECB" + + Update USB example, add the process of detecting USB bus status before USBDCore_LowPower(). + - "CKCU/HSI_AutoTrim_By_USB" + - "USBD/*" + + Update USART example for BM18B367A DVB, add the HSI auto trim by LSE related flow. + - "USART/Interrupt" + - "USART/Interrupt_FIFO" + - "USART/PDMA" + - "USART/Polling" + - "USART/Retarget" + - "USART/RS485_NMM_Slave" + + Others + + Update comment, format, typing error, and coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.8.1_7371 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-12-06 + Main Changes + + Update "ht32f5xxxx_usbd.c", fix the USB buffer unaligned handling mechanism. + + Update "ht32f5xxxx_rtc.c", modify the RTC_LSECmd() related flow. + + Fix example IO define error of BM53A367A DVB. + - "I2C/PDMA" + + Update example IO define for the latest version of BM53A367A DVB. + - "TM/MatchOutputToggle" + - "TM/PWM" + + Update "ht32f5xxxx_adc.c" and "ht32f65xxx_66xxx_adc.c" to modify the ADC enable related flow. + + Others + + Update comment, format, typing error, and coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.7.1_7327 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-11-01 + Main Changes + + Fix example IO define conflict with LED1 of HT32F57352 Starter Kit. + - "CMP/ComparatorInterrupt" + + Fix example IO define error of HT32F50441. + - "MCTM/ComplementaryOutput" + + Update "ht32f5xxxx_ckcu.c", modify the HSI Auto Trim initial function related flow. + + Update "ht32f5xxxx_adc.c" and "ht32f65xxx_66xxx_adc.c", modify the ADC enable related flow. + + Update "ht32_op.c" and "ht32_op.s" to support new version of bootloader waiting time setting address. + (The setting address is changed from 0x1FF0002C to 0x1FF0004C) + + Add "ht32_op_V107.c" and "ht32_op_V107.s" to support the use of older versions of bootloader. + + Others + + Update comment, format, typing error, and coding style. + + Modify and check the example supportability of each IC. + + Add the below file, for the BMduino shield. + - "ht32_undef_IP.h" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.6.2_7271 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-10-03 + Main Changes + + Add example support. + - HT32F53231/41, HT32F53242/52 + - HT32F50431/41, HT32F50442/52 + - HT32F52234/44 + + Fix example IO define error of HT32F52367. + - "USBD/Mass_Storage" + + Modify the example below, add volatile qualifier on some variables (in the for loop usage) + to fix the Arm Compiler Version 6 optimization issue. + ("u32" to "vu32", unsigned int to volatile unsigned int). + - "FMC/FLASH_Security" + + Modify the example below, change the timer used from GPTM to BFTM to increase support. + - "PDMA/SoftwareTrigger" + + Add the below folder, For the BMduino shield/module Keil Driver. + - "BestModules" + + Others + + Update comment, format, typing error, and coding style. + + Adjust "LIBCFG_xxxxx" definition below. + New: + "LIBCFG_ADC_IVREF_DEFAULT_08V" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.6.1_7190 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-08-31 + Main Changes + + Add new device support. + - HT32F61030, HT32F61041 + - HT32F50431, HT32F50441, HT32F50442, HT32F50452 + - HT32F53231, HT32F53241, HT32F53242, HT32F53252 + + Add Controller Area Network driver, "ht32f5xxxx_can.c/h". + + Add new "CAN/FIFO" example. + + Others + + Update comment, format, typing error, and coding style. + + Update "project_template/Script" for adding project C++ source files and setting the chip model mechanism. + - The updated files are as follows: + "Script/_ProjectSource.bat" + "Script/_ProjectSource.ini" + + Update "project_template/Script" for improving script mechanism. + - The updated files are as follows: + "Script/_CreateProjectConfScript.bat" + "Script/_CreateProjectScript.bat" + "Script/_ht32_ic_name.ini" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.5.1_7084 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-08-01 + Main Changes + + Add new device support. + - HT32F52234, HT32F52244 + + Modify DAC related define (The left side old one is still kept for backward compatible). + - HT_DAC -> HT_DAC0 + - AFIO_FUN_DAC -> AFIO_FUN_DAC0 + - CKCU_PCLK_DAC -> CKCU_PCLK_DAC0 + + Modify API as below, add parameter "HT_DAC_TypeDef* HT_DACn" to select DAC engine from the DAC peripherals. + Old API + - DAC_DeInit(void) + - DAC_ModeConfig(u8 ModeSel) + - DAC_ReferenceConfig(u8 DAC_Ch, u32 RefSel) + - DAC_ResolutionConfig(u8 DAC_Ch, u32 ResoSel) + - DAC_OutBufCmd(u8 DAC_Ch, ControlStatus NewState) + - DAC_Cmd(u8 DAC_Ch, ControlStatus NewState) + - DAC_SetData(u8 DAC_Ch, u32 Data) + - DAC_GetOutData(u8 DAC_Ch) + New API + - DAC_DeInit(HT_DAC_TypeDef* HT_DACn) + - DAC_ModeConfig(HT_DAC_TypeDef* HT_DACn, u8 ModeSel) + - DAC_ReferenceConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 RefSel) + - DAC_ResolutionConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 ResoSel) + - DAC_OutBufCmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState) + - DAC_Cmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState) + - DAC_SetData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 Data) + - DAC_GetOutData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch) + + Add API as below. + - "USART_LIN_SendBreak()" API for the USART/UART LIN mode send break to Tx. + - "USART_LIN_LengthSelect()" API for the USART/UART LIN mode configure the break detection length. + - "CKCU_Set_HSIReadyCounter" API for set HSI ready counter value. + + Others + + Update comment, format, typing error, and coding style. + + Rename "LIBCFG_xxxxx" definition below. + - "LIBCFG_DAC" to "LIBCFG_DAC0" + + Add HT32F61630/HT32F61641 related files for Create Project. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.4.3_7026 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-07-17 + + Main Changes + + Add new device support. + - HT32F59046, HT32F59746 + + Others + + Update comment, format, typing error, and coding style. + + Update and sync startup.s/system.c files. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.4.2_6992 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-06-20 + + Main Changes + + Add new device support. + - HT32F61630, HT32F61641 + - HT32F62030, HT32F62040, HT32F62050 + - HT32F67742 + + Modify "RETARGET_Configuration()", add the operation of UxARTn peripheral clock enable. + + Update and sync "ht32f5xxxx_conf.h", modify related define of UxARTn retarget port. + + Others + + Update comment, format, typing error, and coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.4.1_6948 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-05-19 + + Main Changes + + Add new device support. + - HT50F3200S, HT50F3200T + + Add example support of HT32F67233. + + Add new "GPIO/PinLock" example. + + Add "Project or Target File Clearing" functions ("_ClearProject.bat" and "_ClearTarget.bat"). + + Rename "ht32f652xx_opa.c/h" to "ht32f65xxx_66xxx_opa.c/h". + + Rename "ht32f652xx_adc.c/h" to "ht32f65xxx_66xxx_adc.c/h". + + Add "ht32f652xx_opa.c/h" and "ht32f652xx_adc.c/h" for backward compatible. + + Modify "ht32_time.h", "ht32f5xxxx_conf.h" and "ht32_time_conf.h" for "LIBCFG_CKCU_NO_APB_PRESCALER" series. + - To ensure the correct configuration of the timer clock, the "HTCFG_TIME_PCLK_DIV" is redefined as 0. + + Modify "syscall.c" to prevent redundant initialization of the heap index. + + Modify the examples below, use separate "if" statements instead of "if-else" to avoid double-entry ISR. + - "PWRCU/DeepSleepMode1" + - "PWRCU/DeepSleepMode2" + + Modify "ht32f5xxxx_01.h" below, ensure the defined register naming to be consistent with the document. + Old New + ----- ----- + - HT_OPA_TypeDef + "OFR" to "VOS" + "VALR" to "DAC" + - HT_CMP_TypeDef + "ICR" to "CI" + "OCR" to "CO" + + Others + + Update comment, format, typing error, and coding style. + + Update e-Link32 Pro/Lite Command line tool as "V1.19" ("utilities/elink32pro/eLink32pro.exe"). + + Update the LVDS setting method of "example\PWRCU\BOD_LVD" example ht32_board_config.h file. + + Update "system_ht32f5xxxx_nn.c" and "startup_ht32f5xxxx_nn.s" files. + + Modify "_ProjectConfigScript.bat" to prevent the creation of project that copy unused system/startup files. + + Modify the Sourcery G++ Lite toolchain project. + - Set C99 mode to fix issues after updating CMSIS v5.9.0 ("for" loop initial declarations). + + Modify and check the startup_ht32fxxxxx_nn files, fix _HT32FWID more than one digit problem. + + Adjust "LIBCFG_xxxxx" definition below. + New: + "LIBCFG_ADC_NO_OFFSET_REG" + Rename: + "LIBCFG_CMP_OCR" to "LIBCFG_CMP_CO" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.3.4_6737 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-02-17 + + Main Changes + + Add example support of HT32F61244, HT32F61245. + + Modify the example below, add volatile qualifier on some variables (in the for loop usage) + to fix the Arm Compiler Version 6 optimization issue. + ("u32" to "vu32", unsigned int to volatile unsigned int). + - "PWRCU/PowerDown_WAKEUPPin" + - "PWRCU/PowerDown_RTC" + - "TM/PWM" + + Others + + Update comment, format, typing error, and coding style. + + Change the default RTC clock as LSI for the "PWRCU/PowerDownMode" example. + + Add the pin group of QSPI in "ht32f61245_sk.h". + + Add "ht32_board_config.h" for the "SYSTICK/DelayMicrosecond" example. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.3.3_6685 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2023-01-18 + + Main Changes + + Add new device support. + - HT32F61244, HT32F61245, HT32F67233 + + Add new examples: + - "SRAM_Overwrite/Watchpoint_Heap" + - "SRAM_Overwrite/Watchpoint_Stack" + + Update "ht32f5xxxx_conf.h" for user layer HSE_VALUE setting. + + Update "ht32f5xxxx_midi.c/.h" for HT32F0006/61355/61356/61357/61244/61245. + + Add "PDMA_MIDI_IN", "PDMA_MIDI_OUT" define. + + Fix "MAX_EP_NUM" define error of HT32F61141. + + Update "SPI/PDMA" example, fix the function call order as below. The "SPI_SELOutputCmd()" shall be called + before the "SPI_Cmd()", to prevent SPI Master Mode Fault (MF) error if Chip Select pin did not have + an external pull-up. + "SPI_SELOutputCmd(HTCFG_SPIS_PORT, ENABLE);" + "SPI_Cmd(HTCFG_SPIS_PORT, ENABLE);" + + Others + + Update comment, format, typing error, and coding style. + + Update and sync startup.s/system.c files. + + Modify "system_ht32fxxxxx_nn.c", add HSE_VALUE notice and update PLL Out formula. + + Update EEPROM Emulation middleware, improve efficacy and reduce resource usage. + "utilities/middleware/eeprom_emulation.c" + "utilities/middleware/ht32_eeprom_config_templet.h" + + Update I2C Master middleware, improve setting way and fix minor errors. + "utilities/middleware/i2c_master.c/.h" + "utilities/middleware/i2c_master_config_templet.h" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.3.2_6448 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-11-15 + + Main Changes + + Add new examples: + - "ADC/ADC_InternalReferenceVoltage_SWTriggerr" + + Add "LIBCFG_ADC_TRIG_DELAY" define to support "ADC_TrigDelayConfig" function for HT32F65230/65240. + + Update "ADC_24bit/Convert_Interrupt" example, fix "I2CMaster_Typedef" structure variable error (correct + "uTimeout_ms" to "uTimeout_us") of "ADC24_WriteRegNonBlock()" and "ADC24_ReadRegNonBlock()". + + Update "ht32_time.h", fix a formula error of "TIME_TICK2US()" and "TIME_TICK2MS()" macro. + + Modify "ht32_retarget.c", fix retarget can't work when the MicroLIB is not used in Keil's V6 compiler. + + Others + + Upgrade CMSIS to v5.9.0. + + Update "ht32_op.s/c", allow "Bootloader Waiting Time" function for all series. + + Modify "HT32F5xxxx_01_DebugSupport.ini" content. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.3.1_6405 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-10-28 + + Main Changes + + Add new device support. + - HT32F50020, HT32F50030 + + GPIO + - Add new define "GPIO_PIN_NUM_n" for GPIO pin number (n = 0 ~ 15). + + EXTI + - Add "gEXTIn_IRQn[]" and "EXTI_GetIRQn()"" macro to map GPIO pin number (0 ~ 15) to "EXTIn_IRQn". + - Add "GPIO2EXTI()"" macro to map GPIO pin to EXTI Channel. + - Change "AFIO_EXTISourceConfig()"" API, remove "AFIO_EXTI_CH_Enum" and "AFIO_ESS_Enum". + Old: "void AFIO_EXTISourceConfig(AFIO_EXTI_CH_Enum AFIO_EXTI_CH_n, AFIO_ESS_Enum AFIO_ESS_Px);" + New: "void AFIO_EXTISourceConfig(u32 GPIO_PIN_NUM_n, u32 GPIO_Px);" + + LEDC + - Fix typing error of the following define. + Old New + ------------- ---------------- + LEDC_FLAG_FEAME LEDC_FLAG_FRAME + LEDC_INT_FEAME LEDC_INT_FRAME + + Fix the error that "TM_DeInit(HT_PWM2)" not works. + + Add new examples: + - "ADC/OneShot_SWTrigger" + + Rename examples as below. + IP Old Name New Name + -------- -------- -------- + ADC InternalReferenceVoltage InternalReferenceVoltage_PWMTrigger + + Modify "EXTI/WakeUp_SleepMode" example, fix "EXTIn_IRQHandler()" ISR naming error of "ht32f5xxxx_01_it.c" + (HT32F652xx). + + Others + + Update comment, format, typing error, and coding style. + + Update and sync startup.s/system.c files. + + Modify API parameter check macro of Library Debug Mode, fix parameter check error. + + Modify variable declaration of "PDMACH_InitTypeDef" to reduce memory size. + + Add a setting, "HT32_LIB_ENABLE_GET_CK_ADC" to control "ADC0_Freq/ADC1_Freq" calculation of the + "CKCU_GetClocksFrequency()" function (default off for code size consideration). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.2.1_6192 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-09-30 + + Main Changes + + Add new device support. + - HT32F67232 + - HT32F67041, HT32F67051 + + Add the following API for PDMA. + - "PDMA_DeInit()" + - "PDMA_AddrConfig()" + - "PDMA_SrcAddrConfig()" + - "PDMA_DstAddrConfig()" + - "PDMA_GetRemainBlkCnt()" + + Add the following API for ADC (HT32F652xx only). + - "ADC_ChannelDataAlign()" + - "ADC_ChannelOffsetValue()" + - "ADC_ChannelOffsetCmd()" + + Add the following API for OPA (HT32F652xx only). + - "OPA_SetUnProtectKey()" + - "OPA_ProtectConfig()" + + Update "OPA/OPA_Enable" example, add the un-protect key related functions. + + Update "FLASH_SetWaitState()" function, disable Pre-fetch and Branch Cache function before change + wait state. + + Fix "HT_ADC->OFR" define error of HT32F65232. + + Update "ht32_retarget.c", modify the retarget related functions for SEGGER Embedded Studio. + + Update following middleware. + "utilities/middleware/i2c_master.c/h" + "utilities/middleware/uart_module.c" + + Others + + Update comment, format, typing error, and coding style. + + Update and sync startup.s/system.c files. + + Change "HT_PWRCU->BAKPSR" to "HT_PWRCU->LDOSR" of HT32F57352. + + Fix "HT_AES->KEYR" define error (from KEYR[8] to KEYR[4] for AES128). + + Update "BFTM/OneShot" example, fix the register access sequence and time calculation formula. + + Update "TM/PWM/main.c", add "HTCFG_PWM_TM_RELOAD" check. + + Update "SLED/*" example, for fix error and coding style. + + Update "HT32F_DVB_PBInit()" of "ht32f5xxxx_board_01.c", add "LIBCFG_EXTI_4_7_GROUP" support. + + Update e-Link32 Pro/Lite Command line tool as "V1.18" ("utilities/elink32pro/eLink32pro.exe"). + + Change the project recommended minimum version of SEGGER Embedded Studio from V4.12 to V6.20. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.1.1_5938 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-06-08 + + Main Changes + + Add new "TM/TriggerCounter_FrequencyMeasure" example. + + Add following middleware. + "utilities/middleware/spi_module.c" + "utilities/middleware/spi_module.h" + "utilities/middleware/spi_module_config_templet.h" + + Fixed FW library compatibility with ARM compiler version 6 of MDK-ARM V5.37. + - Add MDK-ARMv537 project template for MDK-ARM V5.37. + - Update "project_template/Script". Those MDK-ARMv537 project templates will be added for use if choose + the target IDE is "Keil MDK-ARMv5". The fixed files are as follows: + "Script/_CreateProjectScript.bat" + "Script/_ProjectConfig.bat" + "Script/_ProjectSource.bat" + - Update "core_cm0plus.h", fix compiler error. + - Update "SLED/ARGB_GetLEDNum", fix compiler warning. + - Update "FMC/FLASH_OperationNoHalt", fix the compiler issue of Arm Compiler Version V6.18 and the + compiler warning of linker script file. The fixed files are as follows: + "FLASH_OperationNoHalt/main.c" + "FLASH_OperationNoHalt/linker.lin" + - Update following middleware, remove STRCAT3 usage to fix compiler error. + "utilities/middleware/uart_module.c" + "utilities/middleware/i2c_master.c" + "utilities/middleware/spi_module.c" + + Update "ht32_retarget.c". Implement __write function to fix compiler error in IAR EWARM Version 9.20 + or later. + + Update GNU Arm makefile in the project_template, fix the compatibility issue that the makefile of GNU Arm + Version 11 cannot be compiled. + + Update EWARM in the project_template, fix the compiler error that header file path doesn't exist in + the file list of Workspace of IAR EWARM Version 7. + + Fix SPI initial PDMA parameter in the "utilities/common/spi_flash.c". + + Others + + Update comment, format, typing error, and coding style. + + Update e-Link32 Pro/Lite Command line tool as "V1.16" ("utilities/elink32pro/eLink32pro.exe"). + + Update the following examples to remove compiler warning of the IAR EWARM. + "BFTM/TimeMeasure" + "TM/PWMOut_PDMA_4CH" + "USBD/HID_Keyboard_Virtual_COM" + "USBD/USB_UAC_Sound" + "USBD/USB_Video" + "USBD/Virtual_COM" + + Update "TM/PWM" example, add the PWM channel initial function to "pwm.c". + + Update "WDT/Period_Reload" example, add WDT_ResetCmd function. + + Update and sync create project related files ("_ProjectConfig.bat", "_ProjectConfig.ini"). + + Update content of "project_template/IP/Example/readme.txt", add MDK-ARM V5.37 related information. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.0.25_5831 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-04-19 + + Main Changes + + Add example support of BM53A367A. + + Add "LIBCFG_ADC_MVDDA" define, fix the issue that "ADC_MVDDACmd()" function is missing of HT32F50343. + + Update EEPROM Basic and EEPROM Emulation middleware, fix the include and define sequence. + "utilities/middleware/eeprom_basic.h" + "utilities/middleware/eeprom_emulation.h" + + Update UART Module middleware, add the "UARTM_IsTxFinished()" API. + "utilities/middleware/uart_module.c" + "utilities/middleware/uart_module.h" + + Others + + Update comment, format, typing error, and coding style. + + Update e-Link32 Pro/Lite Command line tool as "V1.0.15" ("utilities/elink32pro/eLink32pro.exe"). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_V1.0.24_5762 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-03-08 + + Main Changes + + Change to the new Holtek version format (Vm.n.r). + + Add following middleware. + "utilities/middleware/uart_module.c" + "utilities/middleware/uart_module.h" + + Add new "FMC/FLASH_OperationNoHalt" example. + + Modify "utilities/common/ring_buffer.c", fix the thread-safe issue of "Buffer_GetLength()". + + Others + + Update comment, format, typing error, and coding style. + + Update "startup_ht32fxxxxx_nn.s", support "USE_HT32_CHIP" define exist at startup.s and project Asm + setting in the same time (project's Asm Define has the higher priority). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v023_5734 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2022-02-10 + + Main Changes + + Add new device support. + - MXTX6306 + + Rename previously "EXTI/GPIO_Interrupt" example to "EXTI/EXTI_Key_LED". + + Add new "EXTI/GPIO_Interrupt" example. + + Update the internal VREF level driver, add the missing voltage level setting/define for the HT32F542xx + series. + ADC_VREF_2V5 + ADC_VREF_3V0 + ADC_VREF_4V0 + ADC_VREF_4V5 + + Others + + Update comment, format, typing error, and coding style. + + Modify "bool, TRUE, FALSE" define way for C++/.cpp applications. + + Add warning message for the HT32F54241 SK ("ht32f54241_sk.h" and "ht32_board_config.h" of the related + examples). + + Simplify the following examples to use less IO/LED/KEY. + - "GPIO/InputOutput" + - "EXTI/EXTI_Key_LED" + + Update "utilities/common/spi_flash.c and spi_lcd.c", change the SPI Clock prescaler from 2 to 4 when the + Core clock is large than 48 MHz. + + Update "eLink32pro.exe" from v1.1.2 to v1.1.3. + + Update related middleware (eeprom_basic and eeprom_emulation). + + Update "ADC/InternalReferenceVoltage" example, add the voltage level setting of the internal VREF for + the 5V MCU. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v022_5673 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-12-09 + + Main Changes + + Add new device support. + HT32F61141 + + Add new board support. + HT32F54241 DVB + HT32F54253 DVB + + Add new examples: + - "SYSTICK/DelayMicrosecond" + + Update "ht32fxxxxx_sk.h", "spi_lcd.c/.h", fix the GPIO Chip SEL define mistake which cause the H/W SPI SEL + not work of the following SK model. + HT32F50230, HT32F50241, HT32F52241, HT32F52253, HT32F52341, HT32F54241, HT32F65232, HT32F65240 + + Update "ht32f54241_sk.h" and "ht32f54253_sh.h", fix the COM port UART/Pin and SPI LCD BL typing error. + + Update "GNU_ARM/linker.ld", fix the heap/stack area overlap problem. + + Fix the following library configuration error of HT32F54241/54253. + Add: "LIBCFG_CKCU_PLLSRCDIV", "LIBCFG_PWRCU_PORF". + Remove: "LIBCFG_CMP" (HT32F54241 only, not support). + + Update "example/I2C/TouchKey/ht32_board_config.h", fix the typing error of I2C Port. + + Others + + Rename "LIBCFG_NO_PWRCU_PORF" to "LIBCFG_NO_PWRCU_VDDPORF". + + Update comment, format, typing error, and coding style. + + Update "example/LEDC/7-SegmentDigitalDisplay/main.c", change the frame rate from 40 Hz to 50 Hz. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v021_5582 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-08-19 + + Main Changes + + Add example support of HT32F54241/54253. + + Update "SPI/Slave" example of HT32F52253, modify the SPI port and pin assignment from SPI1 to SPI0. + + Update "SPI/SEL_Software" example of HT32F52253, fix the typing error of SEL GPIO clock. + + Update "SPI/Master" example of HT32F52253. + - Fix the configuration typing error of "ht32_board_config.h". + - Modify the SPI port and pin assignment from SPI1 to SPI0. + + Others + + Update comment, format, typing error, and coding style. + + Update "_ProjectConfig*.bat" files. + + Update "RSTCU/Peripheral_Reset_Function" example, modify "HTCFG_LED0_RST" to "HTCFG_LED1_RST". + + Update "SPI/Slave" example, move the IRQHandler define from "ht32f5xxxx_01_it.c" to "ht32_board_config.h" + to reduce maintenance time. + + Add "LCD_SPI_RST_UNUSE" define for "ht32fxxxxx_sk.h" and "spi_lcd.c", to decide the "spi_lcd.c" controls + the LCD_RST pin or not. + + Update e-Link32 Pro Commander to V1.10. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v020_5545 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-07-23 + + Main Changes + + Add new device support. + HT32F54231, HT32F54241 + HT32F54243, HT32F54253 + HT32F67741 + + Add "ht32_time.c/.h" to support following new functions for delay, time measure, and timeout. + "Time_Init()" + "Time_Delay()" + "Time_GetTick()" + + Add new examples: + - "GPIO/Input" + - "GPIO/Output" + - "Time/TimeFun" + - "Time/TimeFun_UserConf" + - "TM/PWMOut_PDMA_4CH" + - "USART/RS485_NMM_Slave" + + Add new definition, "FLASH_WAITSTATE_MAX". + + Fix the problem that "FLASH_BranchCacheCmd()" is not exist of HT32F0006, HT32F61352, and HT32F6135x. + + Fix the problem that "PWRCU_WakeupMultiPinCmd()", "PWRCU_WAKEUP_PIN_1" are not exist of HT32F50343. + + Fix typing error which cause the "I2C2_IRQn" missing (from "USE_HT32F2243_53" to "USE_HT32F52243_53"). + + Modify the following definition (CH4 to CH7 usually have the compare function only but the "TM_FLAG_CHnC" + definition is not compatible with the "TM_FLAG_CHnCC"). + "TM_FLAG_CH4C" to "TM_FLAG_CH4CC" + "TM_FLAG_CH5C" to "TM_FLAG_CH5CC" + "TM_FLAG_CH6C" to "TM_FLAG_CH6CC" + "TM_FLAG_CH7C" to "TM_FLAG_CH7CC" + + Modify "TM_GetCaptureCompare()" to support TM_CH4 ~ TM_CH7 for 8 channel PWM timer. + + Add "TM_GetCaptureCompare4()" ~ "TM_GetCaptureCompare7()" functions. + + Add "USART_PARITY_MARK" and "USART_PARITY_SPACE" for the UART parity mode. + + Update "example/I2C/Interrupt/main.c", fix the configuration error of I2C slave. + + Update following example, modify the default value of "gIsINEmpty" from TRUE to FALSE. The default value + TRUE may cause the F/W to not send CSW after the first Inquiry CBW Command in a specific condition. + "example/USBD/HID_Keyboard_Mass_Storage" + "example/USBD/Mass_Storage" + "example/USBD/Mass_Storage_IAP" + + Others + + Update comment, format, typing error, and coding style. + + Adjust and fix error of "LIBCFG_xxxxx" definition. + New: + "LIBCFG_FMC_PREFETCH", + Rename: + "LIBCFG_SINK_CURRENT_ENHANCED" to "LIBCFG_GPIO_SINK_CURRENT_ENHANCED" + "LIBCFG_WAKEUP_V01" to "LIBCFG_PWRCU_WAKEUP_V01" + "LIBCFG_CACHE" to "LIBCFG_FMC_BRANCHCACHE" + Remove: + "LIBCFG_ADC_INTERNAL_CH_V02", "LIBCFG_NO_FMC_PRE_FETCH", "LIBCFG_NO_FMC_WAIT_STATUS", + "LIBCFG_ADC_INTERNAL_CH_V03", "LIBCFG_ADC_INTERNAL_CH_DAC" + + Remove unnecessary functions, "PWRCU_WakeupPinIntConfig()" and "PWRCU_WakeupMultiPinIntConfig()". + + Remove unuse global variable "DelayTime" of "ebi_lcd.c" and "spi_lcd.c". + + Change the member order of the "I2C_InitTypeDef". + + Modify the "USART_StickParityCmd()" function to set the PBE bit by default when the command is ENABLE. + + Remove compiler warning of GNU by adding the dummy "if" usage of the unused parameter. + + Fix the case error of "HT32_Board" include path. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v019_5358 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-05-11 + + Main Changes + + Add new examples: + - "ADC/OneShot_SWTrigger_ByTM" + - "CKCU/HSI_AutoTrim_By_LSE" + + Update startup/system files supported of specific MCU projects. + Old New + ------------------------- ------------------------- + - HT32F0006/HT32F61352 + system_ht32f0006.c to system_ht32f5xxxx_07.c + startup_ht32f5xxxx_xxx_01.s to startup_ht32f5xxxx_xxx_07.s + - HT32F52344/HT32F52354 + startup_ht32f5xxxx_01.s to startup_ht32f5xxxx_03.s + + Fix the problem of Flash API of HT32F50343 that the AHB clock of the GPIO port was not enable ,but the + drive current of SPI_MOSI is adjusted. The fixed item is as follows: + - The function "SPI_FLASH_Init()", It is in the "utilities/common/spi_flash.c". + - Add new define "#define FLASH_SPI_MOSI_CLK(CK) (CK.Bit.PB)", It is in the + "utilities/HT32_Board/ht32f50343_sk.h". + + Fixed the system was stuck in CKCU_HSIAutoTrimCmd() because of the misjudgment of CKCU_HSIAutoTrimIsReady(). + + Fixed the problem that the example CKCU/HSI_AUTO_Trim_BY_USB uses HSE(CKCU_PLLSRC_HSE) as the USB PLL + clock source. Change the USB PLL Clock source to HSI(CKCU_PLLSRC_HSI). + + Fix the CHIP ID error in all HT32F6135x projects. Fixed "USE_HT32_CHIP=10" to "USE_HT32_CHIP=17". + + Remove the interrupt capability of the DAC. Modify the file as follows: + - "example/DAC/Async_2CH/ht32f5xxxx_01_it.c"" + - "example/DAC/Async_2CH/main.c" + - "example/DAC/Sync_12bit_2CH/ht32f5xxxx_01_it.c" + - "example/DAC/Sync_12bit_2CH/main.c" + - "trunk/library/Device/Holtek/HT32F5xxxx/Include/ht32f5xxxx_01.h" + - "library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac.h" + - "library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac.c" + + Others + + Update comment, format, typing error, and coding style. + + Update LIBCFG of SCTM. + - Add the new definition of LIBCFG for a specific MCU: + "#define LIBCFG_SCTM0 (1)" + "#define LIBCFG_SCTM1 (1)" + - Remove the definition of LIBCFG for a specific MCU: + "#define LIBCFG_NO_SCTM (1)" + - Update ht325xxxx_tm.c to depend on the new definitions LIBCFG_SCTM0 and LIBCFG_SCTM1. + + Update the version of eLink32pro.exe to 1.0.1.1. + + Update the following project setting: + - IAR EWARM v6/v7: Modify "_ht32_project_source.c" to "_ht32_project_source.h". + - SEGGER Embedded Studio: Add the new definition "arm_compiler_variant="SEGGER"". + + Remove redundant SCTM definition of 57331/57341. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v018_5303 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2021-02-26 + + Main Changes + + Add "Create Project Configuration Menu" to choose the target IDE and Device when the first time to do the + create project operation of the example. The configuration file, "_CreateProjectConfig.bat" is saved to + the root path of the HT32 Firmware Library. You can reset the create project IDE/IC configuration anytime + by deleting the configuration file. + Target IDE/Compiler: + - Keil MDK-ARM v5 + - Keil MDK-ARM v4 + - IAR EWARM v8 + - IAR EWARM v6/v7 + - SEGGER Embedded Studio + - GNU [with Keil and GNU make] + - SourceryG++Lite [with Keil] + Target Device: + - xxxxx: Single Device + - xxx*: Series + + Add new examples: + - "ADC_24bit/Convert_Interrupt" + - "NVIC/Disable_Interrupt" + - "TM/InternalTrigger" + - "WDT/Auto_Enable" + + Add Flash programming function of GNU Maker (via e-Link32 Pro/Lite Commander). + "make IC=xxxxx eraseall" + "make IC=xxxxx program" + "make IC=xxxxx run" + + Update "CKCU_HSIAutoTrimCmd()" and "CKCU_HSIAutoTrimIsReady()" function to improve clock stability. + + Fix the cache address problem of "SDDISK_Read()" function. + "USBD/Mass_Storage/sd_disk.c" + + Update GNU project (*.uvprojx), fix the compile error when use new GNU Arm version + ("gcc-arm-none-eabi-10-2020-q2-preview-win32" or above). + + Fix Keil compiling error when disable both retarget and MicroLib. + + Update "ht32f1xxxx_01.h", fix the compatibility issue when user include "stdbool.h". + + Modify GNU compiler settings, output text file (disassembly) after building the code. + + Change the startup/system supporting files of specify MCU device. + Old New + ------------------------- ------------------------- + - HT32F0006/HT32F61352 + system_ht32f0006.c to system_ht32f5xxxx_07.c + startup_ht32f5xxxx_xxx_01.s to startup_ht32f5xxxx_xxx_07.s + - HT32F52344/HT32F52354 + startup_ht32f5xxxx_01.s to startup_ht32f5xxxx_03.s + + Add "HT32_FWLIB_VER" and "HT32_FWLIB_SVN" in "ht32f1xxxx_lib.h" for the version information of + HT32 Firmware Library. + Example: + "#define HT32_FWLIB_VER (018)" + "#define HT32_FWLIB_VER (5303)" + + Add new AFIO define in "ht32f1xxxx_gpio.h". + - "AFIO_FUN_MCTM0", "AFIO_FUN_MCTM1" + - "AFIO_FUN_GPTM0", "AFIO_FUN_GPTM1", "AFIO_FUN_GPTM2", "AFIO_FUN_GPTM3" + - "AFIO_FUN_PWM0", "AFIO_FUN_PWM1", "AFIO_FUN_PWM2", "AFIO_FUN_PWM3" + + Add following alias of MCTM IRQ handler + "#define MCTM0_IRQn MCTM0UP_IRQn" + "#define MCTM0_IRQHandler MCTM0UP_IRQHandler" + "#define MCTM1_IRQn MCTM1UP_IRQn" + "#define MCTM1_IRQHandler MCTM1UP_IRQHandler" + + Others + + Update comment, format, typing error, and coding style. + + Update "TM/PWM_Buzzer" example, move the buzzer function to "buzzer_pwm.c/.h". + + Update "_ProjectConfig*.bat" files. + + Add "Project Source File Setting" functions ("_ProjectSource.ini" and "_ProjectSource.bat"). + + Rename "_CreateProjectUSB.bat" as "_CreateProject.bat". + + Add dummy xxTM C files, to notify the user that SCTM/PWM/GPTM/MCTM timer use the "ht32f5xxxx_tm.c" driver. + "ht32f5xxxx_gptm.c", "ht32f5xxxx_pwm.c", "ht32f5xxxx_sctm.c" + + Add "IS_IPN_MCTM()" and "IS_IPN_GPTM" macro, for use to confirm the xxTMn is GPTM or MCTM. + + Update comment and board/pin configuration of "ADC/OneShot_TMTrigger_PDMA" example. + + Update and sync startup.s/system.c files. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v017_5137 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2020-12-31 + + Main Changes + + Update IAR linker.icf, modify the ROM/RAM size. + + Add "LCDENS" related notice of "ht32f5xxxx_lcd.c/.h". + + Fix Keil compiling error when disable both retarget and MicroLib. + + Update "ht32f5xxxx_flash.c", fix the flash erase/program related flow. + + Others + + Update comment, format, typing error, and coding style. + + Update SPI chip select define and SPI configuration of "utilities/common/spi_lcd.c & spi_lcd.h". + + Add "BOARD_DISABLE_EEPROM" define of "utilities/common/i2c_eeprom.c". + + Add notice of VREF stable time and output function. + + Update create project script. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v017_5074 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2020-11-08 + + Main Changes + + Add new device and example support. + HT32F65232, HT32F5828 + + Add "ADC_DualModeConfig()" API for the dual ADC mode of HT32F65230/65240. + + Add "ADC/OneShot_PWMTrigger_Dual_ADC" example. + + Update "startup_ht32f5xxxx_*_05.s" to support HT32F5828. + + Add "system_ht32f5xxxx_08.c" and "startup_ht32f5xxxx_*_08.s" for HT32F652xx series. + + Fix the FIFF/TIFN(Fsampling/Event) setting error of the following function and typedef of the + HT32F65230/65240. + "TM_CaptureInit()" + "TM_PwmInputInit()" + "TM_CHFDIV_Enum" + + Modify the function "MCTM_UpdateDisable()" to "MCTM_UpdateEventDisable" and add "MCTM_UEV1UD/MCTM_UEV1OD" + enum for HT32F65230/65240. + + Add OCR support and update CMP_INPUT_x define for HT32F65232. + + Rename "startup_ht32f65230_40.s" to "startup_ht32fxxxx_08.s" for HT32F652xx series. + + Rename "ht32f65230_40_opa.c/h" to "ht32f652xx_opa.c/h". + + Rename "ht32f65230_40_adc.c/h" to "ht32f652xx_adc.c/h". + + Add missing define of ADC_TRIG_XXXX and modify "ht32f652xx_adc.c/h" for support HT32F652xx series. + + Modify "ht32f5xxxx_rtc.c/h", use LIBCFG_LSE to disable "RTC_SRC_LSE", "RTC_LSECmd()", and + "RTC_LSESMConfig()". + + Remove un-support functions of HT32F5xxxx series. + "TM_EtiExternalClockConfig()" + "TM_EtiConfig()" + + Add missing enum, "TM_CKDIV_8" for HT32F652xx series. + + Add "MCTM_CHBRKCTRConfig2()" MCTM to support Break2 of HT32F652xx series. + + Add missing MCTM interrupt define of HT32F652xx series. + "MCTM_INT_CH0CD" + "MCTM_INT_CH1CD" + "MCTM_INT_CH2CD" + "MCTM_INT_CH3CD" + "MCTM_INT_OVER" + "MCTM_INT_UNDER" + + Others + + Update "system_ht32f5xxxx_04.c", remove unnecessary define. + + Update comment, format, typing error, and coding style. + + Add below notice of examples to inform the user to check the local structure variable without a + default value. + "Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below this function." + + Add "LIBCFG_EXTI_4_9_GROUP" define for the chip who supported extra EXTI interrupt channel. + + Update "MCTM_CHBRKCTRConfig()" function to keep "CHMOE" value. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v016_4983 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2020-10-16 + + Main Changes + + Add new device and example support. + HT32F61355, HT32F61356, HT32F61357 + + Add new board support. + HT32F65240 Starter Kit + + Add more example support for HT32F65240 DVB. + + Add a new example. + "OPA/OPA_Enable" + + Change the default USB LDO setting from the enable mode to bypass mode. + + Update "SPI/FIFO_SEL_Hardware" example. Use timeout interrupt and RX_FIFO length to read the + corresponding data (Previously, it was fixed to read 4 bytes which may cause the data loss problem in + specific conditions). + + Update "CKCU/Clock_Configuration_LSI" example. Add wait for LSI clock ready before the system clock + source switches to LSI (Otherwise, the switching may fail). + + Update "SPI/Slave" example to fix missing EXTI interrupt service routine of HT32F52354. + + Modify "TM/PWM" example to output the complete PWM signal before stopping it. + + Update CMP driver, "ht32f5xxxx_cmp.c/h" and "ht32f65230_40_libcfg.h". Support new CMP function of + HT32F65230/65240. + + Update CMP example "CMP/ComparatorInterrupt" to support HT32F65230/65240 and improve readability. + + Remove "OFVCR" parameter of "HT_OPA_TypeDef" struct in the "ht32f5xxx_01.h". This register is not + supported by the HT32F65230/65240. + + Remove the following unnecessary API in the "ht32f65230_40_opa.c" and "ht32f65230_40_opa.h". + "void OPA_Config(HT_OPA_TypeDef* HT_OPAn, u32 mode, u32 cancellation)" + "void OPA_CancellationModeConfig(HT_OPA_TypeDef* HT_OPAn, u16 OPA_REF_INPUT)" + "void OPA_SetCancellationVaule(HT_OPA_TypeDef* HT_OPAn, u32 cancellation)" + "u32 OPA_GetCancellationVaule(HT_OPA_TypeDef* HT_OPAn)" + + Others + + Update comment, format, typing error, and coding style. + + Update "I2C/Interrupt/main.c" to improve readability. + + Add below notice into USB examples to inform the user turn on the HSI Auto Trim function when the PLL + clock source is HSI (PLL for USB 48 MHz clock). + "Msut turn on if the USB clock source is from HSI (PLL clock Source)" + + Remove the following unnecessary files. + "WDT/Period_Reload/ht32_board_config.h" + "FMC/FLASH_Write_Protection/ht32_board_config.h" + + Remove the remote wake-up function in the "USB_Video/main.c". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v015_4909 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2020-08-11 + + Main Changes + + Add the following files to use e-Link32 Pro with SEGGER Embedded Studio. Refer to the + "readme e-Link32 Pro.txt" for how to use it. + "emStudiov4/readme e-Link32 Pro.txt" + "emStudiov4/Project_xxxxx.bat" + "emStudiov4/_MassErase.bat" + + Add QSPI support. + "ht32f5xxxx_spi.c". + "QSPI_QuadCmd()" + "QSPI_DirectionConfig()" + "utilities/common/spi_flash.c" + "SPI_FLASH_WriteStatus2()" + "QSPI_FLASH_BufferQuadRead()" + "QSPI_FLASH_BufferQuadReadByDMA()" + "QSPI_FLASH_BufferWrite()" + "QSPI_FLASH_BufferWriteByDMA()" + "utilities/HT32_Board" + "ht32f52367_sk.h" + "ht32f0006_dvb.h" + + Add new examples. + "TM/PWM" + "TM/UpdateEvent" + "QSPI/Flash_Quad_Mode_PDMA" + + Change the USB LDO default state from ON (PWRCU_VREG_ENABLE) to OFF (PWRCU_VREG_BYPASS) and + add below notice description. + "USB LDO Should be enabled (PWRCU_VREG_ENABLE) if the MCU VDD > 3.6 V." + + Change the driving current as 8 mA of LCD/SPI Flash utilities driver SPI pins for HT32F50343 (since the + default operation voltage of Starter Kit is 3.3 V). + + Add "SPI_FLASH_WaitForWriteEnd()" function in the end of the write status operation + ("SPI_FLASH_WriteStatus()"). + + Fix typing error of the define, "LIBCFG_MAX_SPEED" for HT32F52220/52230/52231/52241/52243/52253. + There are a few examples that refer to this value to set the IP-related frequency. + + Fix the I2S clock setting error of the following example. + "I2S/CodecLoopback_PDMA" + "USBD/USB_UAC_Sound" + "USBD/USB_UAC_Sound_RateControl" + + Add below notice of examples to inform the user to check the local structure variable without a + default value. + "Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below this function." + + Fix defined problem of "utilities/common/ebi_lcd.c". Change "EBI_FUN_BYTELAND" / "EBI_FUN_ASYNCREADY" to + "LIBCFG_EBI_BYTELAND_ASYNCREADY". + + Fix the "I2S_FIFOTrigLevelConfig()" error which did not clear the field of I2S FCR correctly. + + Fix "RPRE_MASK" define error for "RTC_SetPrescaler()" function. + + Add utilities drivers into HT32F0006/HT32F61352 project. + "i2c_eeprom.c" + "spi_flash.c" + "spi_lcd.c" + + Others + + Update comment, format, typing error, and coding style. + + Add below notice in the "FMC/FLASH_Security" example. + "The Option Byte will be write protected (cannot be changed again) after the + Security Protection is enabled. Refer to the user manual for details." + + Update and modify naming rule of the "HTCFG_xxxx" configuration define in the "ht32_board_config.h". + "I2S/CodecLoopback_PDMA" + + Update the following examples to remove compiler warning of the GNU compiler. + "SLED/ARGB_GetLEDNum" + "USART/PDMA" + + Add "-Waddress-of-packed-member" #pragma of below examples to remove compiler warning of the + GNU compiler. + "USBD/Mass_Storage" + "USBD/HID_Keyboard_Mass_Storage" + + Add the following notice in the Program/Erase related function. + "HSI must keep turn on when doing the Flash operation (Erase/Program)." + + Remove HSI disable setting of Configuration Wizard and add notice in the "system_xxxxx_nn.c". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v014_4736 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2020-04-08 + + Main Changes - Modification & Improvement + + Add "USBDClass_Reset()" into the "USBD/*" example to reset related flag for the self-power application. + + Modify "ht32f5xxxx_aes.c", fix "AES_SetKeyTable()" and "_AES_CryptData()" functions who did not clear + related fields before set it. + + Update UxART related example, turn on internal pull up to prevent unknown state. + + Remove unnecessary RTC compare match restart setting of the "RTC/Calendar_BackupDomain" example. + (which cause the time not correct after entering the low power mode). + + Make up the init structure member when the XXXXX_InitTypeDef is a local variable (which without the + default value). For example, add the following code. + "MCTM_OutputInitStructure.AsymmetricCompare = 0;" + "OutInit.ControlN = TM_CHCTL_DISABLE;" + + Update "TM/InputCapture" example, fix the Pulse Width Count formula (shall be plus with 1). + + Fix RAM size from 8K to 16K of HT32F0006 (LIBCFG_RAM_SIZE). + + Update the following example to improve readability. + "ADC/AnalogWatchdog" + "ADC/Continuous_Potentiometer" + "ADC/Discontinuous_EXTITrigger" + "ADC/InternalReferenceVoltage" + "ADC/OneShot_PWMTrigger" + "ADC/OneShot_PWMTrigger_with_Delay" + "ADC/OneShot_TMTrigger_PDMA" + "ADC/Two_Group_MaxCH" + "EXTI/GPIO_Interrupt" + "HWDIV/DIV32" + "TM/InputCapture" + "TM/MatchOutputActive" + "TM/MatchOutputToggle" + "TM/PWM_Buzzer" + "TM/PWMInput" + "TM/PWMOut_PDMA" + "TM/SinglePulseMode" + "TM/TriggerCounter" + "USART/Interrupt" + "USART/Interrupt_FIFO" + "USART/PDMA" + "USART/Polling" + "USART/Retarget" + "USBD/HID_Demo" + "USBD/HID_DemoVendorReport" + + Main Changes - API Function & Compatibility + + Add "USART_GetIntStatus()" function to get the both enabled and occurred interrupt source. + + Remove the "I2C_Cmd()" in the "I2C_Init()" function since it shall be called after the I2C related + settings. User shall call the "I2C_Cmd()" by themself after the "I2C_Init()". + + Add "DR_8BIT", "DR_16BIT", and "DR_32BIT" define for the "HT_SLEDn" structure. + + Modify "ADC_RegularChannelConfig()", add the last variable-length argument for the code compatibility + between the general HT32 model and the specific model (with the independent sample & hold function of each + ADC channel). + "ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, ...)" + + Modify the following MCTM IRQ define for compatibility. + Old New + ------------- ---------------- + MCTM_BRK_IRQn MCTM0_BRK_IRQn + MCTM_UP_IRQn MCTM0_UP_IRQn + MCTM_TR_UP2_IRQn MCTM0_TR_UP2_IRQn + MCTM_CC_IRQn MCTM0_CC_IRQn + GPTM_G_IRQn GPTM0_G_IRQn + GPTM_VCLK_IRQn GPTM0_VCLK_IRQn + + Modify "AFIO_FUN_ADC" as AFIO_FUN_ADC0. + + Add the following functions of "ht32f5xxxx_div.c". + "DIV_IsDivByZero()": Return the division by zero flag. + "DIV_uDiv32()": Do the 32-bit unsigned division. + "DIV_uGetLastRemainder()": Get remainder of last 32-bit unsigned division. + + Add "u64" definition. + + Add the following definition for convenience. + PDMACH0_IRQn ~ PDMACH5_IRQn + AFIO_FUN_MCTM0 + AFIO_FUN_GPTM0 ~ AFIO_FUN_GPTM3 + AFIO_FUN_PWM0 ~ AFIO_FUN_PWM3 + AFIO_FUN_SCTM0 ~ AFIO_FUN_SCTM3 + + Add "LIBCFG_MAX_SPEED" in the file "ht32fxxxxx_libcfg.h" which indicate the maximum core speed. + + Main Changes - New Example & Supporting + + Add new examples. + "BFTM/OneShot" + "BFTM/TimeMeasure" + "Mono_LCD/LCD_module" (for ESK32-A3A31 mono LCD module) + "SLED/ARGB_GetLEDNum" + "USBD/HID_DemoVendorReport" + + Add example support of HT32F65230/65240 + ADC, BFTM, CRC, EXTI, FMC, GPIO, HWDIV, NVIC, PDMA, PWRCU, RSTCU, RTC, SWDIV, SYSTICK, TM, WDT + + Rename examples as below. + IP Old Name New Name + -------- -------- -------- + ADC EXTITrigger_DiscontinuousMode Discontinuous_EXTITrigger + ADC PDMA_ADCResult OneShot_TMTrigger_PDMA + ADC Potentiometer_ContinuousMode Continuous_Potentiometer + ADC TM_Trigger OneShot_PWMTrigger + ADC TM_Trigger_with_Delay OneShot_PWMTrigger_with_Delay + QSPI Flash Flash_Quad_Mode + TM PWMOutput PWM_Buzzer + USART HyperTerminal_TxRx Retarget + USART HyperTerminal_TxRx_Interrupt Interrupt + USART HyperTerminal_TxRx_Interrupt_FIFO Interrupt_FIFO + Mono_LCD 8CHAR_14SEG_Demo Demo + + Others + + Update comment, format, typing error, and coding style. + + Update and modify naming rule of the "HTCFG_xxxx" configuration define in the "ht32_board_config.h". + + Update "ht32_series.c/h" and "ht32_retarget_usbdconf.h" to improve the compatibly of the + terminal software. + + Add ring buffer support of the "Virtual_COM" and "HID_Keyboard_Virtual_COM" examples. + + Fix interrupt mode of UxART retarget, remove unnecessary FIFO/interrupt configuration of the + retarget function. + + Update "system_ht32fxxxxx_nn.c" (coding style only). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v013_4429 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-12-05 + + Main Changes + + Update "USBD/Virtual_COM" example, add ZLP process for BULK transfer. + + Fix memory size error of HT32F65230. + + Modify "ht32f65230_40_libcfg.h", fix the "USE_MEM_HT32F65230" define problem of HT32F65230. + + Others + + Fix typing error of ""USBD/HID_Keyboard_Virtual_COM" example. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v013_4425 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-11-29 + + Main Changes + + Add new device support. + HT32F65230 + + Changes for HT32F65230 and HT32F65240 + Change USE_HT32F65240 to USE_HT32F65230_40. + Rename "startup_ht3265240_xxx.s" to "startup_ht3265230_40_xxx.s". + + Update "HID_Demo_UI.exe" to support HID Report ID. + + Add "USBD/HID_DemoVendorReport" example. + + Add UART0_IRQn ~ UART3_IRQn define for HT32F52357/52367 (map to UART0_UART2_IRQn and UART1_UART3_IRQn). + + Add "RETARGET_UxART_BAUDRATE" setting to change the retarget UART baudrate in "ht32f5xxxx_conf.h". + + Add "RETARGET_HSI_ATM" setting to turn on/off the auto-trim function of HSI. + + Add "RETARGET_DEFINE_HANDLER" setting to remove the UxARTn_IRQHandler() define of the retarget. + This setting is used for the model who grouping two UART Interrupt into one vector. + + Add non-block mode of USB Virtual-COM retarget function ((Drop data if USB or terminal software is + not ready). + + Fix EXTI4_IRQn ~ EXTI15_IRQn define error of HT32F65230/65240. + + Add SWCLK toggle of "GPIO_DisableDebugPort()" function. + + Others + + Add "USAGE_PAGE_L" define of "USB/HID_Demo" example. + + Add "UART0_UART2_IRQHandler()" and "UART1_UART3_IRQHandler" example in the file "ht32f5xxxx_01_it.c" for + HT32F52357/52367. + + Update format and coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v012_4285 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-10-18 + + Main Changes + + Add new device support. + HT32F50343, HT32F59041, HT32F59741, HF5032 + + Fix HT32F65240 IRQ number error of "USART0_IRQn" and "UART0_IRQn". + + Fix "ADC_CH_GND_VREF" and "ADC_CH_VDD_VREF" define error of HT32F65240. + + Add "GPIO_GetID()" function to convert the HT_GPIOx to GPIO_Px. + + Add "LIBCFG_PWRCU_NO_PORF" define of HT32F65240 to fix the "PWRCU_DeInit()" function not work. + + Update "system_ht32fxxxxx.c" and "startup_ht32fxxxxx_xx_nn.s". + + Rename "startup_ht32f5xxxx_01/02.s" of IAR as "startup_ht32f5xxxx_iar_01/02.s". + + Move the "common/*.h" include from the begin to the end (after the pin define) in the file + "HT32_Board/ht32fxxxx_sk/dvb.h". The original include way leads to the pin define lost when you + use the EBI_LCD->EBI_LCD_RAM outside the "ebi_lcd.c". + + Update "ebi_lcd.c", fix LCD_SPI_BL_GPIO_XXX define error (shall be LCD_EBI_BL_GPIO_XXX). + + Fix error of "_CreateProjectScript.bat" which cause the stack size and RW base can not be set by the + "_ProjectConfig.bat" of the emStudiov4 project. + + Others + + Remove the wrong define, "LIBCFG_CKCU_USB_PLL_96M" of HT32F52367. + + Add calculation method of PLL clock in the file, "system_ht32f5xxxx_nn.c". + + Add "utilities/common/lcd.h" to put the lcd related register together. + + Update example to improve readability. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v011_4188 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-08-05 + + Main Changes + + Add new device support. + HT32F57331, HT32F57341, HT32F57342, HT32F57352, HT32F52357, HT32F52367, HT32F52142, + HT32F65240, HT32F61352, HT50F32002, HT50F32003 + + Fix define error of "ht32fxxxxx_libcfg.h". + + Update "system_ht32fxxxxx.c" and "startup_ht32fxxxxx_xx_nn.s". + + Rename "startup_ht32f5xxxx_nn.s" of IAR as "startup_ht32f5xxxx_iar_nn.s". + + Modify ADC related define (The left side old one is still kept for backward compatible). + HT_ADC -> HT_ADC0 + ADC -> ADC0 + ADC_IRQn -> ADC0_IRQn + + Fix typing error of the function name below. + SPI_GUARDTCmd(), SPI_GUARDTConfig() + + Others + + Update content of "readme.txt". + + Add s64 ("typedef signed long long s64;"). + + Update comment and coding style. + + Update and sync "ht32f5xxxx_conf.h". + + Update and sync create project related files ("_ProjectConfig.bat", "_CreateProjectScript.bat"). + + Update "HT32F5xxxx_01_DebugSupport.ini". + + Update "ht32_op.s" and "ht32_op.c". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v010_3748 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-04-09 + + Main Changes + + Update functions of "ht32f5xxxx_dac_dual16.c". + + Update Create Project script, add Script folder in project_template. + + Fix VREFCR/VREFVALR register address error of HT_ADC_TypeDef. + + Fix "ADC_VREFConfig()" error (ADC_VREF_x shift error). + + Add "ADC_MVDDACmd()" function. + + Add "PWRCU_DeepSleep2Ex()" function for the case which wakeup by EXTI in the short time or the wakeup + source keeps active. + Notice: PWRCU_DeepSleep2Ex() function will affect the accuracy of RTC for the date/time application. + + Add "TM/TriggerCounter" example. + + Add "ADC/InternalReferenceVoltage" example. + + Update "ADC/Potentiometer_ContinuousMode" example, remove division in the ISR of ADC. + + Others + + Update "ht32f5xxxx_usbd.c" and "ht32_usbd_core.c", add Force USB Reset Control function (apply to specific + model only). + + Update/sync startup.s/system.c files, fix PLL range and content errors. + + Update "BootProcess" function. + + Update/sync "ht32_op.s" and "ht32_op.c". + + Update "PWRCU/DeepSleepMode1" examples, fix compile error when set "DISABLE_DEBUG_PIN" = 1. + + Update "PWRCU/PowerDownMode" examples + - Update EXTI ISR to reduce maintenance time. + - Add "DISABLE_DEBUG_PIN" function. + + Update/sync "FlashMacro.mac". + + Update Keil after build setting + - Add double quotes (") in the command. + - Change filename keyword from "#L" to "!L" (relative path specification to the current folder). + - Update "fromelf.txt" and "objcopy.txt" + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v009_3383 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2019-02-12 + + Main Changes + + Add SEGGER Embedded Studio IDE support (beta version). + + Update "EXTI/WakeUp_DeepSleepMode1" Example, fix channel error of EXTI clear wakeup flag and add LED3 + (for some SK have only LED2 and LED3 on board). + + Others + + Update comment and coding style. + + Add "USBD/USB_UAC_Sound_RateControl" Example. + + Add "USBD/HID_Keyboard_Mass_Storage" Example. + + Update utilities/common/spi_flash.c/h", change the way of HT_PDMA define. + + Update HT32F0006 MDK-ARM project related files (uvproj*). fix SRAM size. + + Update "LIBCFG_DAC" as "LIBCFG_DACDUAL16" for HT32F0006. + + Add "LIBCFG_DACDUAL16" define for "ht32f5xxxx_dac_dual16.h" of "ht32f5xxxx_lib.h". + + Fix missed "I2C2_IRQHandler" and "AES_IRQHandler" in "startup_ht32f5xxxx_01.s" files (both MDK-ARM and + EWARM). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v008_3322 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-12-17 + + Main Changes + + Fix filename error of IAR EWARM and GNU make file ("ht32f5xxxx_dac_dual16.c"). + + Others + + Update "startup_ht32f5xxxx_xxxx.s". + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v008_3314 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-12-12 + + Main Changes + + Add new device support. + HT32F0006 + + Modify Control IN/OUT method of USB Core, to fix USB transfer problem when CPU in the lower speed or late + USB interrupt case. + + Add workaround for PDMA CH3 issue (Interrupt Enable bit of CH3 is not work). + + Modify "CKCU_ATC_EXT_PIN" as "CKCU_ATC_CKIN". + + Others + + Fix typing error of MCTM. + + Add "LIBCFG_ipname" define to the IP channel of "ht32f5xxxx_pdma.h". + + Add "USBD_DisableDefaultPull()" function to disable pull resistance when the USB is not use. + + Update comment and coding style. + + Rename RTC example as below. + "Calendar" -> "Time" + "Calendar_backup_Domain" -> "Time_BackupDomain" + + Add new example, "RTC/Calendar_BackupDomain". + + Update "EXTI/WakeUp_DeepSleepMode1" example. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v007_3076 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-09-30 + + Main Changes + + Update HardFault_Handler of "ht32f5xxxx_01_it.c",add the debug instruction and system reset. + + Update AES examples, add zero init of local Struct (AES_InitTypeDef AES_InitStruct). + + Add "__HT_check_sp" and "__HT_check_heap" symbol into startup.s and watchpoint command into + "HT32F5xxxx_01_DebugSupport.ini" for debug stack/heap underflow, overflow, and overwrite. + + Add GNU Make support of GNU Arm compiler. + + Add 52354 IAR project files into "project_template/IP/Template_USB". + + Add "LIBCFG_ADC_INTERNAL_CH_V02" define to fix the "ADC_CH_GNDREF/ADC_CH_VREF" mismatch of HT32F502xx + Series (The ADC input channel number of analog ground/power is different between HT32F502xx and other + series). + + Update "USBD/HID_Keyboard_Joystick" and "USBD/HID_Mouse" example, change the set flag sequence + (before USBDCore_EPTWriteINData). + + Others + + Add "objcooy.txt" which shows how to use obj tools of GNU Arm compiler. + + Update format and coding style. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v007_2962 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-08-02 + + Main Changes + + Add GNU Arm compiler support. + - Add project_template related files + - "startup_ht32f5xxxx_gcc_nn.s" + - "linker.ld" (link script) + + Fix typing error of "ht32f52230_sk.h" file. + "COM1_IRQHandler" shall be "UART0_IRQHandler". + + Fix startup.s error of IAP example which cause UART not work. + + Rename "CreatProject.bat" to "_CreateProject.bat" and update its content. + + Update "ht32f5xxxx_tm.c/.h", add following functions which have TM_CH_n parameter. + void TM_ForcedOREF(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, TM_OM_Enum ForcedAction) + void TM_SetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) + void TM_SetAsymmetricCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) + u32 TM_GetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n) + + Others + + Fix compile error when turn on Library debug mode (HT32_LIB_DEBUG = 1). + + Fix compile warning/error of GNU Arm compiler. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v006_2891 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-07-14 + + Main Changes + + None + + Others + + Add "USBD/HID_Keyboard_Virtual_COM" example. + + Add "ADC/Two_Group_MaxCH" example. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v006_2863 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-06-11 + + Main Changes + + Add new device support. + HT32F52344, HT32F52354 + + Add DMA support of "utilities/common/spi_flash.c". + + Add missed function prototype declaration of "GPIO_SinkConfig()" in "ht32f5xxxx_gpio.h". + + Add "EXTI_GetEdgeFlag()" function. + + Add LIBCFG_AES_SWAP function to process endian issue of AES. + + Others + + Update project and "ht32f5826_libcfg.h" typing error of HT32F5826. + + Fix "LIBCFC_CKCU_USB_PLL" typing error of ht32fxxxx_libcfg.h and example code (shall be LIBCFG_CKCU_USB_PLL). + + Add LED3 toggle of "//project_template/IP/Example" since HT32F52253 Starter Kit using LED2 and LED3. + + Fix compiler error of "USBD/USB_UAC_Sound" Example. + + Remove unnecessary define "LIBCFG_CKCU_INTERRUPT_FLAG_V01". + + Update ht32_op.s and ht32_op.c (improve readability). + + FIx memory size typing error of HT32F0008 project. + + Add LIBCFG_FMC_CMD_READY_WAIT define to insert NOP after ISP command for specific model. + + Update USB's example, driver, an setting related to the LIBCFG_CKCU_USB_PLL_96M. + + Update comment and coding style. + + Add MDK_ARMv5 project of IAP example. + + Fix HT32F52352 IAP_PPBIT define error of "IAP/IAP_UI" example. + + Change buffer size of "IAP/IAP_UI" example for the MCU runs on the slower speed. + + Update "USBD/Mass_Storage" example. + + Update "ht32f5xxxx_ckcu.c" to remove unnecessary register write of PLL. + + Update "EXTI/GPIO_Interrupt" example to reduce maintenance effort. + + Update "ht32f52352_sk.h", "ht32f52354_sk.h", and "ebi_lcd.h" to support EBI 8-bit mode with SPI dual output. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v006_2687 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-04-12 + + Main Changes + + Add SourceryG++Lite compiler support. + - Add project_template related files + - "startup_ht32f5xxxx_cs3_nn.s" + - "linker.ld" (link script) + + Fix typing error of "Project_50241.uvproj" files. + + Others + + Update "ht32f5xxxx_conf.h" for AUTO_RETURN (\r) option. + + Update "ht32f5xxxx_div.h" to remove compiler error of SourceryG++Lite compiler. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v005_2639 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2018-02-28 + + Main Changes + + Add "I2C_SpeedOffset" parameter of "I2C_InitTypeDef" struct to reach real I2C speed. + + Add "CKCU/HSI_AutoTrim_By_USB" Example. + + Add "USBD/HID_Keyboard_Joystick" Example. + + Update "CKCU_HSIAutoTrimIsReady" function of "ht32f5xxxx_ckcu.c". + + Others + + Update SPI/PDMA example to support HT32F52243/52253. + + Add "I2C_SpeedOffset" parameter of I2C related examples. + + Update "i2c_eeprom.c" to remove warning on specify compiler. + + Modify EXTI related code of "USBD/HID_Keyboard" Example to reduce maintenance effort. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v005_2481 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-12-30 + + Main Changes + + None + + Others + + Update I2S and USB UAC related examples (Coding style and remove unuse define). + + Fix I2S setting of "USB_UAC_Sound" example. + + Fix define error of "PWRCU/DeepSleepMode1" example. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v005_2470 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-12-29 + + Main Changes + + Add new device support. + HT32F50231, HT32F50241 + Note: The examples of HT32F50220, HT32F50230, HT32F50231, HT32F50241 are under test. Please contact us if + any question. Thanks. + + Update boot related functions of "startup_ht32f5xxxx_nn.s" and "system_ht32f5xxxx_nn.c". + + Fix USB example code which forget to turn on USB PLL of HT32F0008. + + Update IAP example to support HT32F0008. + + Add "GPIO_DisableDebugPort()"" function to disable SWD function. + + Add "GPIO_SinkConfig()" function for sink current configuration (Apply to specific model only). + + Update "ht32_op.c" and "ht32_op.s" to support enable WDT function by Flash Option byte (Apply to specific + model only). + + Add "Clock_Configuration_LSI" example to show how to configure the system clock between High Speed + (PLL, HSI, or HSE) and LSI. + + Others + + Fix errors of following examples (related to the MCU we added recently). + "EXTI/GPIO_Interrupt" + "PWRCU/BOD_LVD" + "PWRCU/PowerDownMode" + "RAND/Random_Number" + "SPI/Slave" + "TM/MatchOutputToggle" + "TM/PWMOut_PDMA" + "TM/PWMOutput" + "TM/SinglePulseMode" + "USART/HyperTerminal_TxRx_Interrupt_FIFO" + "USART/PDMA" + + Fix "LIBCFG_CHIPNAME" typing error of HT32F50220/50230. + + Remove useless "RTC_LSICmd()"" function. + + Update "RTC_LSILoadTrimData()" to prevent hardfault if RTC clock is not enabled when calling this function. + + Update typing error and coding style of "ht32f5xxxx_ckcu.h". + + Change pin assignment of HT32F0008's example. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v005_2267 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-11-30 + + Main Changes + + Add new device support. + HT32F0008 + HT32F50220, HT32F50230 + + Others + + Update "ht32_virtual_com.inf" file, add Digital Signature. + + Update "ht32_usbd_core.c/.h", add vendor request call back capability. + + Fix compiler warning when turn on library debug mode. + + Fix IAR project setting of IAP related examples (Output format). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v004_1996 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-10-19 + + Main Changes + + Update "system_ht32F5xxxx_03.c", modify PLL related setting. + + Change "LIBCFG_WP_2PAGE_PER_BIT" to "LIBCFG_FLASH_2PAGE_PER_WPBIT". + + Others + + Update "PWRCU/DeepSleepMode2" example, fix compiler error when DISABLE_DEBUG_PIN = 1. + + Update "WDT/Period_Reload" example, fix comment typing error. + + Add "LIBCFG_CHIPNAME" define. + + Update project setting. + + Update "NVIC/External_Interrupt" example, remove unuse define. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v004_1790 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-09-05 + + Main Changes + + Fix vector table error ("startup_ht32f5xxxx_01.s"). + + Others + + Update "system_ht32f5xxxx_xx.c". + + Update Keil project setting, enable "User->After Build Run #1" as default value to output Binary file. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32_STD_5xxxx_FWLib_v004_1753 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-08-31 + + Main Changes + + Rename "HT32F520xx_FWLib" to "HT32_STD_5xxxx_FWLib" and "520xx" to "5xxxx". + The following files are also renamed. + Old New + ====================================== ====================================== + startup_ht32f520xx_01.s startup_ht32f5xxxx_01.s + system_ht32f520xx_01.c system_ht32f5xxxx_01.c + system_ht32f5xxxx_02.c system_ht32f5xxxx_02.c + ht32f520xx_01_it.c ht32f5xxxx_01_it.c + ht32f523xx_01_usbdconf.h ht32f5xxxx_01_usbdconf.h + ht32f520xx_01_conf.h ht32f5xxxx_conf.h + HT32F520xx_01_DebugSupport.ini HT32F5xxxx_01_DebugSupport.ini + ht32f520xx_sk.c ht32f5xxxx_board_01.c + ht32f520xx_01.h ht32f5xxxx_01.h + + Others + + Update "ht32_usbd_core.c" to support vendor function. + + Add "USE_MEM_HT32F5xxxx" define into project. + + Add "USE_MEM_HT32F5xxxx" default define into "ht32f5xxxx_xx_libcfg.h". + + Update the IAP Example. Change IAP loader size from 3 KBytes to 4 KBytes (Since the code size of IAP + example for IAR EWARM is large than 3 KB). + + Add new device support + HT32F5826 + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F520xx_FWLib_v003_1661 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-07-27 + + Main Changes + + Add hardware divider driver, "ht32f520xx_div.c/h" + + Update following example to support HT32F52243 and HT32F52253. + DIV, IAP, SPI, TM + Note: The code size of IAP example for IAR EWARM is large than 3 KB. It over Reserved size of the IAP + area. We will update it in the next version. + + Others + + Update project related file and setting. + + Modify USB/Mass_Storage example for WIN10 compatibility issue. + + Update "ht32_op.c" and "ht32_op.s", add CK_CODE/CK_DATA/CK_CODEOP in Option Bytes (same format with e-Writer32). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F520xx_FWLib_v003_1566 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-07-17 + + Main Changes + + Fix COM1 & BUZZER setting error of "ht32f52253_sk.h". + + Update following example to support HT32F52243 and HT32F52253. + ADC, I2C + + Others + + Update ht32_op.s and ht32_op.c + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F520xx_FWLib_v003_1534 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-07-03 + + Main Changes + + Add new device support + HT32F52243, HT32F52253 + Note: The following example is not supported yet for the HT32F52243 and HT32F52253. + ADC, DIV, I2C, IAP, SPI, TM + + Add IAR EWARMv8 project template (create by IAR EWARM v8.11). + + Update "system_ht32f520xx_01.c" and "system_ht32f520xx_02.c" to support different setting between + IAP and AP. + + Fix "ht32_retarget.c" error (UxART Rx interrupt is no need to turn on). + + Update UxART driver to sync with HT32_STD_1xxxx FW Library. + + Modify following variable name of "MCTM_CHBRKCTRInitTypeDef". + Break -> Break0 + BreakPolarity -> Break0Polarity + + Others + + Update project related file and setting. + + Upgrade the version of IAR EWARM project template from v6.20 to v6.50. + Note: + 1. Supported CMSIS-DAP: IAR EWARM v6.50 and above. + 2. RDI/e-Link32 is not supported anymore from the v8.xx of IAR EWARM. + 3. For the Cortex-M0+, you must use IAR EWARM v6.40 and above. + + Update file format and coding style. + + Modify "EXTI_DebounceCnt" of "EXTI_InitTypeDef" from u32 to u16, to prevent count setting over range. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F520xx_FWLib_v002_1320 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2017-05-04 + + Main Changes + + Fix IAR compiler failed issue of "ht32_cm0plus_misc.c" (Tool Internal Error with Access violation error). + + Others + + Fix config error of ADC example, "PWMTrigger_OneShotMode". + + Rename ADC example "PWMTrigger_OneShotMode" as "TM_Trigger". + + Add ADC example, "TM_Trigger_with_Delay". + + Fix I2C register naming (ADDBR to ADDSR). + + Fix build error when Library Debug mode enable. + + Fix IAP example, add "USART_ClearFlag(HTCFG_UART_PORT, USART_FLAG_TOUT)" in the UART ISR. + + Fix SPI Flash dual read, enable dual read function (SPI_DUALCmd()) before send dummy bytes. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F520xx_FWLib_v002_1143 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2016-10-11 + + Main Changes + + Fix FLASH_WP_ALLPAGE_SET macro error. + + Add memory footprint information (ht32fxxxxx_xx_libcfg.h). + + Others + + Update typing error and naming rule. + + Update "ht32f520xx_02.h" variable data type define to prevent data type confusion (such as const s32 not + equal to sc32). + + Modify Re-target to USB Tx buffer size from 63 to 1. Add notice message for SERIAL_Flush() when Tx buffer + size is lager than 1. + + Update MDK_ARMv5 project setting. + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F520xx_FWLib_v002_966 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2016-08-17 + + Main Changes + + Add "CKCU_HSIAutoTrimIsReady()" functions. + + Fix Re-target USB virtual bug (Bulk out 64 Bytes without zero length OUT is not allow). + + Add example code. + + Update IAR EWARM project of example codes. + + Add random number function/example. + + Others + + Rename and update "HT32_Virtual_COM.inf". Add VID/PID for e-Link32Pro USB to UART function. + + Update pin assignment of HT32F52341 SPI/Master example. + + Fix "CKCU_GetClocksFrequency()" and "CKCU_GetPLLFrequency()" error. + + Update typing error and naming rule. + + Fix USB descriptor error of "ht32_retarget_desc.h". + + Fix CKCU/Clock_Configuration example error (CKOUT pin). + +/*----------------------------------------------------------------------------------------------------------*/ +/* HT32F520xx_FWLib_v002_820 */ +/*----------------------------------------------------------------------------------------------------------*/ + Release Date: 2016-06-20 + + Main Changes + + Fix IAP_Text_RAM example setting error. + + Fix "_USBD_CopyMemory()" error. + + Fix EXTI init sequence of HT32F_DVB_PBInit() which may cause unexpect EXTI interrupt. + + Fix LIBCFG_WP_2PAGE_PER_BIT define error of HT32F52331/41. + + Add project files of MDK_ARMv5 (*.uvprojx), select CMSIS-DAP debug adapter as default setting. + + Others + + Fix IAR scanf not work issue + + Add UART interrupt mode for Re-target. + + Improve efficiency of USB re-target (USB IN). + + Modify uIsTerminalOpened check method. + + Fix Re-target to USB bug (OUT data overrun the Rx buffer). + + Remove unnecessary divide/mod operation ("ring_buffer.c", "ht32_serial.c"). + + Remove unnecessary code of "ht32f520xx_tm.c". + + Fix Buffer_GetLength error of "ring_buffer.c". + + Modify __RBIT as RBIT of "ht32_cm0plus_misc.c" (__RBIT is keyword of IAR). diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/SConscript b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/SConscript new file mode 100644 index 0000000000..b673b24b8f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/SConscript @@ -0,0 +1,49 @@ +import rtconfig +from building import * +Import('rtconfig') + +cwd = GetCurrentDir() +src = [] + +if GetDepend(['SOC_HT32F52352']): + src = Split(""" + library/HT32F5xxxx_Driver/src/ht32_cm0plus_misc.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_adc.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_bftm.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_ckcu.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_cmp.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_crc.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_ebi.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_exti.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_flash.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_gpio.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2c.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2s.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_mctm.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_pdma.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwrcu.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_rstcu.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_rtc.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_sci.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_tm.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_usart.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_usbd.c + library/HT32F5xxxx_Driver/src/ht32f5xxxx_wdt.c + library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_01.c + """) + + + +path = [ + cwd + '/library/HT32F5xxxx_Driver/inc', + cwd + '/library/CMSIS/Include', + cwd + '/library/Device/Holtek/HT32F5xxxx/Include' +] + +CPPDEFINES = ['USE_HT32_DRIVER'] + +group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) + +Return('group') + diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc new file mode 100644 index 0000000000..96775d502a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/ARM.CMSIS.pdsc @@ -0,0 +1,3271 @@ + + + + CMSIS + CMSIS (Common Microcontroller Software Interface Standard) + ARM + + http://www.keil.com/pack/ + + + + CMSIS-Core(M): 5.6.0 + - Arm Cortex-M85 cpu support + - Arm China STAR-MC1 cpu support + - Updated system_ARMCM55.c + CMSIS-DSP: 1.10.0 (see revision history for details) + CMSIS-NN: 3.1.0 (see revision history for details) + - Support for int16 convolution and fully connected for reference implementation + - Support for DSP extension optimization for int16 convolution and fully connected + - Support dilation for int8 convolution + - Support dilation for int8 depthwise convolution + - Support for int16 depthwise conv for reference implementation including dilation + - Support for int16 average and max pooling for reference implementation + - Support for elementwise add and mul int16 scalar version + - Support for softmax int16 scalar version + - Support for SVDF with 8 bit state tensor + CMSIS-RTOS2: 2.1.3 (unchanged) + - RTX 5.5.4 (see revision history for details) + CMSIS-Pack: deprecated (moved to Open-CMSIS-Pack) + CMSIS-SVD: 1.3.9 (see revision history for details) + CMSIS-DAP: 2.1.1 (see revision history for details) + - Allow default clock frequency to use fast clock mode + Devices + - Support for Cortex-M85 + Utilities + - SVDConv 3.3.42 + - PackChk 1.3.95 + + + CMSIS-Core(M): 5.5.0 (see revision history for details) + - Updated GCC LinkerDescription, GCC Assembler startup + - Added Armv8-M Stack Sealing (to linker, startup) for toolchain ARM, GCC + - Changed C-Startup to default Startup. + - Updated Armv8-M Assembler startup to use GAS syntax + Note: Updating existing projects may need manual user interaction! + CMSIS-Core(A): 1.2.1 (see revision history for details) + - Bugfixes for Cortex-A32 + CMSIS-DAP: 2.1.0 (see revision history for details) + - Enhanced DAP_Info + - Added extra UART support + CMSIS-DSP: 1.9.0 (see revision history for details) + - Purged pre-built libs from Git + - Enhanced support for f16 datatype + - Fixed couple of GCC issues + CMSIS-NN: 3.0.0 (see revision history for details including version 2.0.0) + - Major interface change for functions compatible with TensorFlow Lite for Microcontroller + - Added optimization for SVDF kernel + - Improved MVE performance for fully Connected and max pool operator + - NULL bias support for fully connected operator in non-MVE case(Can affect performance) + - Expanded existing unit test suite along with support for FVP + - Removed Examples folder + CMSIS-RTOS2: + - RTX 5.5.3 (see revision history for details) + - CVE-2021-27431 vulnerability mitigation. + - Enhanced stack overrun checking. + - Various bug fixes and improvements. + CMSIS-Pack: 1.7.2 (see revision history for details) + - Support for Microchip XC32 compiler + - Support for Custom Datapath Extension + + + CMSIS-Build: 0.9.0 (beta) + - Draft for CMSIS Project description (CPRJ) + CMSIS-Core(M): 5.4.0 (see revision history for details) + - Cortex-M55 cpu support + - Enhanced MVE support for Armv8.1-MML + - Fixed device config define checks. + - L1 Cache functions for Armv7-M and later + CMSIS-Core(A): 1.2.0 (see revision history for details) + - Fixed GIC_SetPendingIRQ to use GICD_SGIR + - Added missing DSP intrinsics + - Reworked assembly intrinsics: volatile, barriers and clobber + CMSIS-DSP: 1.8.0 (see revision history for details) + - Added new functions and function groups + - Added MVE support + CMSIS-NN: 1.3.0 (see revision history for details) + - Added MVE support + - Further optimizations for kernels using DSP extension + CMSIS-RTOS2: + - RTX 5.5.2 (see revision history for details) + CMSIS-Driver: 2.8.0 + - Added VIO API 0.1.0 (Preview) + - removed volatile from status related typedefs in APIs + - enhanced WiFi Interface API with support for polling Socket Receive/Send + CMSIS-Pack: 1.6.3 (see revision history for details) + - deprecating all types specific to cpdsc format. Cpdsc is replaced by Cprj with dedicated schema. + Devices: + - ARMCM55 device + - ARMv81MML startup code recognizing __MVE_USED macro + - Refactored vector table references for all Cortex-M devices + - Reworked ARMCM* C-StartUp files. + - Include L1 Cache functions in ARMv8MML/ARMv81MML devices + Utilities: + Attention: Linux binaries moved to Linux64 folder! + - SVDConv 3.3.35 + - PackChk 1.3.89 + + + CMSIS-Core(M): 5.3.0 (see revision history for details) + - Added provisions for compiler-independent C startup code. + CMSIS-Core(A): 1.1.4 (see revision history for details) + - Fixed __FPU_Enable. + CMSIS-DSP: 1.7.0 (see revision history for details) + - New Neon versions of f32 functions + - Python wrapper + - Preliminary cmake build + - Compilation flags for FFTs + - Changes to arm_math.h + CMSIS-NN: 1.2.0 (see revision history for details) + - New function for depthwise convolution with asymmetric quantization. + - New support functions for requantization. + CMSIS-RTOS: + - RTX 4.82.0 (updated provisions for Arm Compiler 6 when using Cortex-M0/M0+) + CMSIS-RTOS2: + - RTX 5.5.1 (see revision history for details) + CMSIS-Driver: 2.7.1 + - WiFi Interface API 1.0.0 + Devices: + - Generalized C startup code for all Cortex-M family devices. + - Updated Cortex-A default memory regions and MMU configurations + - Moved Cortex-A memory and system config files to avoid include path issues + + + The following folders are deprecated + - CMSIS/Include/ (superseded by CMSIS/DSP/Include/ and CMSIS/Core/Include/) + + CMSIS-Core(M): 5.2.1 (see revision history for details) + - Fixed compilation issue in cmsis_armclang_ltm.h + + + The following folders have been removed: + - CMSIS/Lib/ (superseded by CMSIS/DSP/Lib/) + - CMSIS/DSP_Lib/ (superseded by CMSIS/DSP/) + The following folders are deprecated + - CMSIS/Include/ (superseded by CMSIS/DSP/Include/ and CMSIS/Core/Include/) + + CMSIS-Core(M): 5.2.0 (see revision history for details) + - Reworked Stack/Heap configuration for ARM startup files. + - Added Cortex-M35P device support. + - Added generic Armv8.1-M Mainline device support. + CMSIS-Core(A): 1.1.3 (see revision history for details) + CMSIS-DSP: 1.6.0 (see revision history for details) + - reworked DSP library source files + - reworked DSP library documentation + - Changed DSP folder structure + - moved DSP libraries to folder ./DSP/Lib + - ARM DSP Libraries are built with ARMCLANG + - Added DSP Libraries Source variant + CMSIS-RTOS2: + - RTX 5.5.0 (see revision history for details) + CMSIS-Driver: 2.7.0 + - Added WiFi Interface API 1.0.0-beta + - Added components for project specific driver implementations + CMSIS-Pack: 1.6.0 (see revision history for details) + Devices: + - Added Cortex-M35P and ARMv81MML device templates. + - Fixed C-Startup Code for GCC (aligned with other compilers) + Utilities: + - SVDConv 3.3.25 + - PackChk 1.3.82 + + + Aligned pack structure with repository. + The following folders are deprecated: + - CMSIS/Include/ + - CMSIS/DSP_Lib/ + + CMSIS-Core(M): 5.1.2 (see revision history for details) + - Added Cortex-M1 support (beta). + CMSIS-Core(A): 1.1.2 (see revision history for details) + CMSIS-NN: 1.1.0 + - Added new math functions. + CMSIS-RTOS2: + - API 2.1.3 (see revision history for details) + - RTX 5.4.0 (see revision history for details) + * Updated exception handling on Cortex-A + CMSIS-Driver: + - Flash Driver API V2.2.0 + Utilities: + - SVDConv 3.3.21 + - PackChk 1.3.71 + + + Updated Arm company brand. + CMSIS-Core(M): 5.1.1 (see revision history for details) + CMSIS-Core(A): 1.1.1 (see revision history for details) + CMSIS-DAP: 2.0.0 (see revision history for details) + CMSIS-NN: 1.0.0 + - Initial contribution of the bare metal Neural Network Library. + CMSIS-RTOS2: + - RTX 5.3.0 (see revision history for details) + - OS Tick API 1.0.1 + + + CMSIS-Core(M): 5.1.0 (see revision history for details) + - Added MPU Functions for ARMv8-M for Cortex-M23/M33. + - Added compiler_iccarm.h to replace compiler_iar.h shipped with the compiler. + CMSIS-Core(A): 1.1.0 (see revision history for details) + - Added compiler_iccarm.h. + - Added additional access functions for physical timer. + CMSIS-DAP: 1.2.0 (see revision history for details) + CMSIS-DSP: 1.5.2 (see revision history for details) + CMSIS-Driver: 2.6.0 (see revision history for details) + - CAN Driver API V1.2.0 + - NAND Driver API V2.3.0 + CMSIS-RTOS: + - RTX: added variant for Infineon XMC4 series affected by PMU_CM.001 errata. + CMSIS-RTOS2: + - API 2.1.2 (see revision history for details) + - RTX 5.2.3 (see revision history for details) + Devices: + - Added GCC startup and linker script for Cortex-A9. + - Added device ARMCM0plus_MPU for Cortex-M0+ with MPU. + - Added IAR startup code for Cortex-A9 + + + CMSIS-RTOS2: + - RTX 5.2.1 (see revision history for details) + + + CMSIS-Core(M): 5.0.2 (see revision history for details) + - Changed Version Control macros to be core agnostic. + - Added MPU Functions for ARMv7-M for Cortex-M0+/M3/M4/M7. + CMSIS-Core(A): 1.0.0 (see revision history for details) + - Initial release + - IRQ Controller API 1.0.0 + CMSIS-Driver: 2.05 (see revision history for details) + - All typedefs related to status have been made volatile. + CMSIS-RTOS2: + - API 2.1.1 (see revision history for details) + - RTX 5.2.0 (see revision history for details) + - OS Tick API 1.0.0 + CMSIS-DSP: 1.5.2 (see revision history for details) + - Fixed GNU Compiler specific diagnostics. + CMSIS-Pack: 1.5.0 (see revision history for details) + - added System Description File (*.SDF) Format + CMSIS-Zone: 0.0.1 (Preview) + - Initial specification draft + + + Package Description: + - added taxonomy for Cclass RTOS + CMSIS-RTOS2: + - API 2.1 (see revision history for details) + - RTX 5.1.0 (see revision history for details) + CMSIS-Core: 5.0.1 (see revision history for details) + - Added __PACKED_STRUCT macro + - Added uVisior support + - Updated cmsis_armcc.h: corrected macro __ARM_ARCH_6M__ + - Updated template for secure main function (main_s.c) + - Updated template for Context Management for ARMv8-M TrustZone (tz_context.c) + CMSIS-DSP: 1.5.1 (see revision history for details) + - added ARMv8M DSP libraries. + CMSIS-Pack:1.4.9 (see revision history for details) + - added Pack Index File specification and schema file + + + Changed open source license to Apache 2.0 + CMSIS_Core: + - Added support for Cortex-M23 and Cortex-M33. + - Added ARMv8-M device configurations for mainline and baseline. + - Added CMSE support and thread context management for TrustZone for ARMv8-M + - Added cmsis_compiler.h to unify compiler behaviour. + - Updated function SCB_EnableICache (for Cortex-M7). + - Added functions: NVIC_GetEnableIRQ, SCB_GetFPUType + CMSIS-RTOS: + - bug fix in RTX 4.82 (see revision history for details) + CMSIS-RTOS2: + - new API including compatibility layer to CMSIS-RTOS + - reference implementation based on RTX5 + - supports all Cortex-M variants including TrustZone for ARMv8-M + CMSIS-SVD: + - reworked SVD format documentation + - removed SVD file database documentation as SVD files are distributed in packs + - updated SVDConv for Win32 and Linux + CMSIS-DSP: + - Moved DSP libraries from CMSIS/DSP/Lib to CMSIS/Lib. + - Added DSP libraries build projects to CMSIS pack. + + + - CMSIS-Core 4.30.0 (see revision history for details) + - CMSIS-DAP 1.1.0 (unchanged) + - CMSIS-Driver 2.04.0 (see revision history for details) + - CMSIS-DSP 1.4.7 (no source code change [still labeled 1.4.5], see revision history for details) + - CMSIS-Pack 1.4.1 (see revision history for details) + - CMSIS-RTOS 4.80.0 Restored time delay parameter 'millisec' old behavior (prior V4.79) for software compatibility. (see revision history for details) + - CMSIS-SVD 1.3.1 (see revision history for details) + + + - CMSIS-Core 4.20 (see revision history for details) + - CMSIS-DSP 1.4.6 (no source code change [still labeled 1.4.5], see revision history for details) + - CMSIS-Pack 1.4.0 (adding memory attributes, algorithm style) + - CMSIS-Driver 2.03.0 (adding CAN [Controller Area Network] API) + - CMSIS-RTOS + -- API 1.02 (unchanged) + -- RTX 4.79 (see revision history for details) + - CMSIS-SVD 1.3.0 (see revision history for details) + - CMSIS-DAP 1.1.0 (extended with SWO support) + + + - CMSIS-Core 4.10 (Cortex-M7 extended Cache Maintenance functions) + - CMSIS-DSP 1.4.5 (see revision history for details) + - CMSIS-Driver 2.02 (adding SAI (Serial Audio Interface) API) + - CMSIS-Pack 1.3.3 (Semantic Versioning, Generator extensions) + - CMSIS-RTOS + -- API 1.02 (unchanged) + -- RTX 4.78 (see revision history for details) + - CMSIS-SVD 1.2 (unchanged) + + + Adding Cortex-M7 support + - CMSIS-Core 4.00 (Cortex-M7 support, corrected C++ include guards in core header files) + - CMSIS-DSP 1.4.4 (Cortex-M7 support and corrected out of bound issues) + - CMSIS-Pack 1.3.1 (Cortex-M7 updates, clarification, corrected batch files in Tutorial) + - CMSIS-SVD 1.2 (Cortex-M7 extensions) + - CMSIS-RTOS RTX 4.75 (see revision history for details) + + + - fixed conditions preventing the inclusion of the DSP library in projects for Infineon XMC4000 series devices + + + - CMSIS-Driver 2.02 (incompatible update) + - CMSIS-Pack 1.3 (see revision history for details) + - CMSIS-DSP 1.4.2 (unchanged) + - CMSIS-Core 3.30 (unchanged) + - CMSIS-RTOS RTX 4.74 (unchanged) + - CMSIS-RTOS API 1.02 (unchanged) + - CMSIS-SVD 1.10 (unchanged) + PACK: + - removed G++ specific files from PACK + - added Component Startup variant "C Startup" + - added Pack Checking Utility + - updated conditions to reflect tool-chain dependency + - added Taxonomy for Graphics + - updated Taxonomy for unified drivers from "Drivers" to "CMSIS Drivers" + + + + - CMSIS-RTOS 4.74 (see revision history for details) + - PACK Extensions (Boards, Device Features, Flash Programming, Generators, Configuration Wizard). Schema version 1.1. + + + + + + + + + Software components for audio processing + Generic Interfaces for Evaluation and Development Boards + Drivers that support an external component available on an evaluation board + Compiler Software Extensions + Cortex Microcontroller Software Interface Components + Unified Device Drivers compliant to CMSIS-Driver Specifications + Startup, System Setup + Data exchange or data formatter + Drivers that support an extension board or shield + File Drive Support and File System + IoT cloud client connector + IoT specific services + IoT specific software utility + Graphical User Interface + Network Stack using Internet Protocols + Real-time Operating System + Encryption for secure communication or storage + Universal Serial Bus Stack + Generic software utility components + + + + + + + +The Cortex-M0 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + +The Cortex-M0+ processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + + + + + + +The ARM Cortex-M1 FPGA processor is intended for deeply embedded applications that require a small processor integrated into an FPGA. +The ARM Cortex-M1 processor implements the ARMv6-M architecture profile. + + + + + + + + + + + + + + + + +The Cortex-M3 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + +The Cortex-M4 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + + + + + + +The Cortex-M7 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling +- upward compatibility with the rest of the Cortex-M processor family. + + + + + + + + + + + + + + + + + + + + + + + + + + +The Arm Cortex-M23 is based on the Armv8-M baseline architecture. +It is the smallest and most energy efficient Arm processor with Arm TrustZone technology. +Cortex-M23 is the ideal processor for constrained embedded applications requiring efficient security. + + + + + + + + + + + + + + + + + + + + + + + +The Arm Cortex-M33 is the most configurable of all Cortex-M processors. It is a full featured microcontroller +class processor based on the Armv8-M mainline architecture with Arm TrustZone security. + + + + + + + + + + + + no DSP Instructions, no Floating Point Unit, no TrustZone + + + + + + + + no DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, no TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-M35P is the most configurable of all Cortex-M processors. It is a full featured microcontroller +class processor based on the Armv8-M mainline architecture with Arm TrustZone security designed for a broad range of secure embedded applications. + + + + + + + + + + + + + no DSP Instructions, no Floating Point Unit, no TrustZone + + + + + + + + no DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, no TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-M55 processor is a fully synthesizable, mid-range, microcontroller-class processor that implements the Armv8.1-M mainline architecture and includes support for the M-profile Vector Extension (MVE), also known as Arm Helium technology. +It is Arm's most AI-capable Cortex-M processor, delivering enhanced, energy-efficient digital signal processing (DSP) and machine learning (ML) performance. +The Cortex-M55 processor achieves high compute performance across scalar and vector operations, while maintaining low energy consumption. + + + + + + + + + + + + + Floating Point Vector Extensions, DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-M85 processor is a fully synthesizable high-performance microcontroller class processor that implements the Armv8.1-M Mainline architecture which includes support for the M-profile Vector Extension (MVE). +The processor also supports previous Armv8-M architectural features. +The design is focused on compute applications such as Digital Signal Processing (DSP) and machine learning. +The Arm Cortex-M85 processor is energy efficient and achieves high compute performance across scalar and vector operations while maintaining low power consumption. + + + + + + + + + + + + + Floating Point Vector Extensions, DSP Instructions, Double Precision Floating Point Unit, TrustZone, PACBTI + + + + + + + + +The Arm SC000 processor is an entry-level 32-bit Arm Cortex processor designed for a broad range of secure embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling + + + + + + + + + + + + + + + +The ARM SC300 processor is an entry-level 32-bit ARM Cortex processor designed for a broad range of secure embedded applications. It offers significant benefits to developers, including: +- simple, easy-to-use programmers model +- highly efficient ultra-low power operation +- excellent code density +- deterministic, high-performance interrupt handling + + + + + + + + + + + + + + + + +Armv8-M Baseline based device with TrustZone + + + + + + + + + + + + + + + + + + +Armv8-M Mainline based device with TrustZone + + + + + + + + + + + + no DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, no Floating Point Unit, TrustZone + + + + + + + + no DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Single Precision Floating Point Unit, TrustZone + + + + + + + + no DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + + +Armv8.1-M Mainline based device with TrustZone and MVE + + + + + + + + + + + + + Double Precision Vector Extensions, DSP Instructions, Double Precision Floating Point Unit, TrustZone + + + + + + + + + +The Arm Cortex-A5 processor is a high-performance, low-power, Arm macrocell with an L1 cache subsystem that provides full +virtual memory capabilities. The Cortex-A5 processor implements the Armv7-A architecture profile and can execute 32-bit +Arm instructions and 16-bit and 32-bit Thumb instructions. The Cortex-A5 is the smallest member of the Cortex-A processor family. + + + + + + + + + + + + + + + + + +The Cortex-A7 MPCore processor is a high-performance, low-power processor that implements the Armv7-A architecture. +The Cortex-A7 MPCore processor has one to four processors in a single multiprocessor device with a L1 cache subsystem, +an optional integrated GIC, and an optional L2 cache controller. + + + + + + + + + + + + + + + + + +The Cortex-A9 processor is a high-performance, low-power, Arm macrocell with an L1 cache subsystem that provides full virtual memory capabilities. +The Cortex-A9 processor implements the Armv7-A architecture and runs 32-bit Arm instructions, 16-bit and 32-bit Thumb instructions, +and 8-bit Java bytecodes in Jazelle state. + + + + + + + + + + + + + + + + + + + Device interrupt controller interface + + + + + + RTOS Kernel system tick timer interface + + + + + + + CMSIS-RTOS API for Cortex-M, SC000, and SC300 + + + + + + CMSIS-RTOS API for Cortex-M, SC000, and SC300 + + + + + + + + USART Driver API for Cortex-M + + + + + + + SPI Driver API for Cortex-M + + + + + + + SAI Driver API for Cortex-M + + + + + + + I2C Driver API for Cortex-M + + + + + + + CAN Driver API for Cortex-M + + + + + + + Flash Driver API for Cortex-M + + + + + + + MCI Driver API for Cortex-M + + + + + + + NAND Flash Driver API for Cortex-M + + + + + + + Ethernet MAC and PHY Driver API for Cortex-M + + + + + + + + Ethernet MAC Driver API for Cortex-M + + + + + + + Ethernet PHY Driver API for Cortex-M + + + + + + + USB Device Driver API for Cortex-M + + + + + + + USB Host Driver API for Cortex-M + + + + + + + WiFi driver + + + + + + + Virtual I/O + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Armv6-M architecture based device + + + + + + + Armv7-M architecture based device + + + + + + + Armv8-M base line architecture based device + + + + + Armv8-M main line architecture based device + + + + + + + Armv8.1-M main line architecture based device + + + + + + Armv8-M/Armv8.1-M architecture based device + + + + + Armv8-M architecture based device + + + + + + Armv6_7-M architecture based device + + + + + Armv6_7_8-M architecture based device + + + + + + Armv7-A architecture based device + + + + + + + TrustZone + + + + TrustZone (Secure) + + + + + TrustZone (Non-secure) + + + + + + + + Startup files for Arm Compiler 6 targeting TrustZone secure mode + + + + + Startup files for Arm Compiler 6 targeting non-TrustZone or TrustZone non-secure mode + + + + + + + Generic Arm Cortex-M0 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M0+ device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M1 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M3 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M4 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M7 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M23 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M33 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M35P device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M55 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-M85 device startup and depends on CMSIS Core + + + + + + Generic Arm SC000 device startup and depends on CMSIS Core + + + + + + Generic Arm SC300 device startup and depends on CMSIS Core + + + + + + Generic Armv8-M Baseline device startup and depends on CMSIS Core + + + + + + Generic Armv8-M Mainline device startup and depends on CMSIS Core + + + + + + Generic Armv8.1-M Mainline device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-A5 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-A7 device startup and depends on CMSIS Core + + + + + + Generic Arm Cortex-A9 device startup and depends on CMSIS Core + + + + + + + Components required for DSP + + + + + + + + Components required for NN + + + + + + Components required for RTOS RTX + + + + + + + Components required for RTOS RTX IFX + + + + + + + + Components required for RTOS RTX5 + + + + + + Components required for RTOS2 RTX5 + + + + + + + Components required for RTOS2 RTX5 on Armv7-A + + + + + + + + + Components required for RTOS2 RTX5 in Non-Secure Domain + + + + + + + + + Arm Compiler for Armv6-M architecture (little endian) + + + + + + Arm Compiler for Armv6-M architecture (big endian) + + + + + + Arm Compiler for Armv7-M architecture without FPU (little endian) + + + + + + + Arm Compiler for Armv7-M architecture without FPU (big endian) + + + + + + + Arm Compiler for Armv7-M architecture with FPU (little endian) + + + + + + + + Arm Compiler for Armv7-M architecture with FPU (big endian) + + + + + + + + Arm Compiler for Armv8-M base line architecture (little endian) + + + + + + Arm Compiler for Armv8-M/Armv8.1-M main line architecture without FPU/MVE (little endian) + + + + + + + + Arm Compiler for Armv8-M/Armv8.1-M main line architecture with FPU/MVE (little endian) + + + + + + + + + + + GNU Compiler for Armv6-M architecture (little endian) + + + + + + GNU Compiler for Armv6-M architecture (big endian) + + + + + + GNU Compiler for Armv7-M architecture without FPU (little endian) + + + + + + + GNU Compiler for Armv7-M architecture without FPU (big endian) + + + + + + + GNU Compiler for Armv7-M architecture with FPU (little endian) + + + + + + + + GNU Compiler for Armv7-M architecture with FPU (big endian) + + + + + + + + GNU Compiler for Armv8-M base line architecture (little endian) + + + + + + GNU Compiler for Armv8-M/Armv8.1-M main line architecture without FPU/MVE (little endian) + + + + + + + + GNU Compiler for Armv8-M/Armv8.1-M main line architecture with FPU/MVE (little endian) + + + + + + + + + + + IAR Compiler for Armv6-M architecture (little endian) + + + + + + IAR Compiler for Armv6-M architecture (big endian) + + + + + + IAR Compiler for Armv7-M architecture without FPU (little endian) + + + + + + + IAR Compiler for Armv7-M architecture without FPU (big endian) + + + + + + + IAR Compiler for Armv7-M architecture with FPU (little endian) + + + + + + + + IAR Compiler for Armv7-M architecture with FPU (big endian) + + + + + + + + IAR Compiler for Armv8-M base line architecture (little endian) + + + + + + IAR Compiler for Armv8-M main line architecture without FPU (little endian) + + + + + + + IAR Compiler for Armv8-M main line architecture with FPU (little endian) + + + + + + + + IAR Compiler for Armv8.1-M main line architecture without FPU/MVE (little endian) + + + + + + + + IAR Compiler for Armv8.1-M main line architecture with FPU/MVE (little endian) + + + + + + + + + + + Arm Assembler for Armv6-M architecture + + + + + GNU Assembler for Armv6-M architecture + + + + + + IAR Assembler for Armv6-M architecture + + + + + + Arm Assembler for Armv7-M architecture + + + + + GNU Assembler for Armv7-M architecture + + + + + + IAR Assembler for Armv7-M architecture + + + + + + GNU Assembler for Armv8-M base line architecture + + + + + GNU Assembler for Armv8-M/Armv8.1-M main line architecture + + + + + IAR Assembler for Armv8-M base line architecture + + + + + IAR Assembler for Armv8-M main line architecture + + + + + + Arm Assembler for Armv7-A architecture + + + + + GNU Assembler for Armv7-A architecture + + + + + + IAR Assembler for Armv7-A architecture + + + + + + + Components required for OS Tick Private Timer + + + + + + + Components required for OS Tick Generic Physical Timer + + + + + + + + + + CMSIS-CORE for Cortex-M, SC000, SC300, Star-MC1, ARMv8-M, ARMv8.1-M + + + + + + + + + + + + + CMSIS-CORE for Cortex-A + + + + + + + + + + + System and Startup for Generic Arm Cortex-M0 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M0 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M0+ device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M0+ device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M1 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M1 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M3 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M3 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M4 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M4 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M7 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M7 device + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M23 device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M23 device + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M33 device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M33 device + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-M35P device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm Cortex-M35P device + + + + + + + + + + + + + + + + + + + System and Startup for Generic Cortex-M55 device + + + + + + + + + + + + + + + + + System and Startup for Generic Cortex-M85 device + + + + + + + + + + + + + + + + + System and Startup for Generic Arm SC000 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm SC000 device + + + + + + + + + + + + + + + System and Startup for Generic Arm SC300 device + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Arm SC300 device + + + + + + + + + + + + + + + System and Startup for Generic Armv8-M Baseline device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Armv8-M Baseline device + + + + + + + + + + + + + + + + + + System and Startup for Generic Armv8-M Mainline device + + + + + + + + + + + + + + + DEPRECATED: System and Startup for Generic Armv8-M Mainline device + + + + + + + + + + + + + + + + + + System and Startup for Generic Armv8.1-M Mainline device + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-A5 device + + + + + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-A7 device + + + + + + + + + + + + + + + + + + + + + + System and Startup for Generic Arm Cortex-A9 device + + + + + + + + + + + + + + + + + + + + + + IRQ Controller implementation using GIC + + + + + + + + OS Tick implementation using Private Timer + + + + + + + OS Tick implementation using Generic Physical Timer + + + + + + + + CMSIS-DSP Library for Cortex-M, SC000, and SC300 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-NN Neural Network Library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS RTX implementation for Cortex-M, SC000, and SC300 + + + #define RTE_CMSIS_RTOS /* CMSIS-RTOS */ + #define RTE_CMSIS_RTOS_RTX /* CMSIS-RTOS Keil RTX */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS RTX implementation for Infineon XMC4 series affected by PMU_CM.001 errata + + + #define RTE_CMSIS_RTOS /* CMSIS-RTOS */ + #define RTE_CMSIS_RTOS_RTX /* CMSIS-RTOS Keil RTX */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS RTX5 implementation for Cortex-M, SC000, and SC300 + + + #define RTE_CMSIS_RTOS /* CMSIS-RTOS */ + #define RTE_CMSIS_RTOS_RTX5 /* CMSIS-RTOS Keil RTX5 */ + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Cortex-M, SC000, SC300, ARMv8-M, ARMv8.1-M (Library) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Armv8-M/Armv8.1-M Non-Secure Domain (Library) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_ARMV8M_NS /* CMSIS-RTOS2 Keil RTX5 Armv8-M Non-secure domain */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Cortex-M, SC000, SC300, ARMv8-M, ARMv8.1-M (Source) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Armv7-A (Source) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMSIS-RTOS2 RTX5 for Armv8-M/Armv8.1-M Non-Secure Domain (Source) + + + #define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */ + #define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */ + #define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */ + #define RTE_CMSIS_RTOS2_RTX5_ARMV8M_NS /* CMSIS-RTOS2 Keil RTX5 Armv8-M Non-secure domain */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Access to #include Driver_USART.h file and code template for custom implementation + + + + + + + Access to #include Driver_SPI.h file and code template for custom implementation + + + + + + + Access to #include Driver_SAI.h file and code template for custom implementation + + + + + + + Access to #include Driver_I2C.h file and code template for custom implementation + + + + + + + Access to #include Driver_CAN.h file and code template for custom implementation + + + + + + + Access to #include Driver_Flash.h file and code template for custom implementation + + + + + + + Access to #include Driver_MCI.h file and code template for custom implementation + + + + + + + Access to #include Driver_NAND.h file and code template for custom implementation + + + + + + + Access to #include Driver_ETH_PHY/MAC.h files and code templates for custom implementation + + + + + + + + + Access to #include Driver_ETH_MAC.h file and code template for custom implementation + + + + + + + Access to #include Driver_ETH_PHY.h file and code template for custom implementation + + + + + + + Access to #include Driver_USBD.h file and code template for custom implementation + + + + + + + Access to #include Driver_USBH.h file and code template for custom implementation + + + + + + + Access to #include Driver_WiFi.h file + + + + + + + + + Virtual I/O custom implementation template + + + + + + Virtual I/O implementation using memory only + + + + + + + + + + uVision Simulator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EWARM Simulator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DSP_Lib Bayes example + + + + + + + + + Getting Started + + + + + DSP_Lib Class Marks example + + + + + + + + + Getting Started + + + + + DSP_Lib Convolution example + + + + + + + + + Getting Started + + + + + DSP_Lib Dotproduct example + + + + + + + + + Getting Started + + + + + DSP_Lib FFT Bin example + + + + + + + + + Getting Started + + + + + DSP_Lib FIR example + + + + + + + + + Getting Started + + + + + DSP_Lib Graphic Equalizer example + + + + + + + + + Getting Started + + + + + DSP_Lib Linear Interpolation example + + + + + + + + + Getting Started + + + + + DSP_Lib Matrix example + + + + + + + + + Getting Started + + + + + DSP_Lib Signal Convergence example + + + + + + + + + Getting Started + + + + + DSP_Lib Sinus/Cosinus example + + + + + + + + + Getting Started + + + + + DSP_Lib SVM example + + + + + + + + + Getting Started + + + + + DSP_Lib Variance example + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Blinky example + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 mixed API v1 and v2 + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Message Queue Example + + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Memory Pool Example + + + + + + + + + + Getting Started + + + + + Bare-metal secure/non-secure example without RTOS + + + + + + + + + Getting Started + + + + + Secure/non-secure RTOS example with thread context management + + + + + + + + + Getting Started + + + + + Secure/non-secure RTOS example with security test cases and system recovery + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Blinky example + + + + + + + + + Getting Started + + + + + CMSIS-RTOS2 Message Queue Example + + + + + + + + + Getting Started + + + + + + diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h new file mode 100644 index 0000000000..abebc95f94 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cachel1_armv7.h @@ -0,0 +1,411 @@ +/****************************************************************************** + * @file cachel1_armv7.h + * @brief CMSIS Level 1 Cache API for Armv7-M and later + * @version V1.0.1 + * @date 19. April 2021 + ******************************************************************************/ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_CACHEL1_ARMV7_H +#define ARM_CACHEL1_ARMV7_H + +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_CacheFunctions Cache Functions + \brief Functions that configure Instruction and Data cache. + @{ + */ + +/* Cache Size ID Register Macros */ +#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) +#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) + +#ifndef __SCB_DCACHE_LINE_SIZE +#define __SCB_DCACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#endif + +#ifndef __SCB_ICACHE_LINE_SIZE +#define __SCB_ICACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#endif + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */ + + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate I-Cache + \details Invalidates I-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief I-Cache Invalidate by address + \details Invalidates I-Cache for the given address. + I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + I-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] isize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (volatile void *addr, int32_t isize) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if ( isize > 0 ) { + int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_ICACHE_LINE_SIZE; + op_size -= __SCB_ICACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */ + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + __DSB(); + + SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable D-Cache + \details Turns off D-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | + ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address. + D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (volatile void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (volatile void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned and invalidated. + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (volatile void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + +/*@} end of CMSIS_Core_CacheFunctions */ + +#endif /* ARM_CACHEL1_ARMV7_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h new file mode 100644 index 0000000000..a955d47139 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armcc.h @@ -0,0 +1,888 @@ +/**************************************************************************//** + * @file cmsis_armcc.h + * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file + * @version V5.3.2 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_ARMCC_H +#define __CMSIS_ARMCC_H + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) + #error "Please use Arm Compiler Toolchain V4.0.677 or later!" +#endif + +/* CMSIS compiler control architecture macros */ +#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \ + (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) ) + #define __ARM_ARCH_6M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1)) + #define __ARM_ARCH_7M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1)) + #define __ARM_ARCH_7EM__ 1 +#endif + + /* __ARM_ARCH_8M_BASE__ not applicable */ + /* __ARM_ARCH_8M_MAIN__ not applicable */ + /* __ARM_ARCH_8_1M_MAIN__ not applicable */ + +/* CMSIS compiler control DSP macros */ +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __ARM_FEATURE_DSP 1 +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE static __forceinline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __declspec(noreturn) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed)) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT __packed struct +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION __packed union +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x))) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr))) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __memory_changed() +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __nop + + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __dsb(0xF) + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) +{ + rev16 r0, r0 + bx lr +} +#endif + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value) +{ + revsh r0, r0 + bx lr +} +#endif + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +#define __ROR __ror + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __breakpoint(value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __RBIT __rbit +#else +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ + return result; +} +#endif + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __clz + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) +#else + #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) +#else + #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) +#else + #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXB(value, ptr) __strex(value, ptr) +#else + #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXH(value, ptr) __strex(value, ptr) +#else + #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXW(value, ptr) __strex(value, ptr) +#else + #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __clrex + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) +{ + rrx r0, r0 + bx lr +} +#endif + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRBT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRHT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRT(value, ptr) __strt(value, ptr) + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __enable_irq(); */ + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __disable_irq(); */ + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; + __ISB(); +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_INLINE uint32_t __get_IPSR(void) +{ + register uint32_t __regIPSR __ASM("ipsr"); + return(__regIPSR); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_INLINE uint32_t __get_APSR(void) +{ + register uint32_t __regAPSR __ASM("apsr"); + return(__regAPSR); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_INLINE uint32_t __get_xPSR(void) +{ + register uint32_t __regXPSR __ASM("xpsr"); + return(__regXPSR); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + return(__regProcessStackPointer); +} + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + __regProcessStackPointer = topOfProcStack; +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + return(__regMainStackPointer); +} + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + __regMainStackPointer = topOfMainStack; +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xFFU); +} + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + register uint32_t __regBasePriMax __ASM("basepri_max"); + __regBasePriMax = (basePri & 0xFFU); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & (uint32_t)1U); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + return(__regfpscr); +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +#define __SADD8 __sadd8 +#define __QADD8 __qadd8 +#define __SHADD8 __shadd8 +#define __UADD8 __uadd8 +#define __UQADD8 __uqadd8 +#define __UHADD8 __uhadd8 +#define __SSUB8 __ssub8 +#define __QSUB8 __qsub8 +#define __SHSUB8 __shsub8 +#define __USUB8 __usub8 +#define __UQSUB8 __uqsub8 +#define __UHSUB8 __uhsub8 +#define __SADD16 __sadd16 +#define __QADD16 __qadd16 +#define __SHADD16 __shadd16 +#define __UADD16 __uadd16 +#define __UQADD16 __uqadd16 +#define __UHADD16 __uhadd16 +#define __SSUB16 __ssub16 +#define __QSUB16 __qsub16 +#define __SHSUB16 __shsub16 +#define __USUB16 __usub16 +#define __UQSUB16 __uqsub16 +#define __UHSUB16 __uhsub16 +#define __SASX __sasx +#define __QASX __qasx +#define __SHASX __shasx +#define __UASX __uasx +#define __UQASX __uqasx +#define __UHASX __uhasx +#define __SSAX __ssax +#define __QSAX __qsax +#define __SHSAX __shsax +#define __USAX __usax +#define __UQSAX __uqsax +#define __UHSAX __uhsax +#define __USAD8 __usad8 +#define __USADA8 __usada8 +#define __SSAT16 __ssat16 +#define __USAT16 __usat16 +#define __UXTB16 __uxtb16 +#define __UXTAB16 __uxtab16 +#define __SXTB16 __sxtb16 +#define __SXTAB16 __sxtab16 +#define __SMUAD __smuad +#define __SMUADX __smuadx +#define __SMLAD __smlad +#define __SMLADX __smladx +#define __SMLALD __smlald +#define __SMLALDX __smlaldx +#define __SMUSD __smusd +#define __SMUSDX __smusdx +#define __SMLSD __smlsd +#define __SMLSDX __smlsdx +#define __SMLSLD __smlsld +#define __SMLSLDX __smlsldx +#define __SEL __sel +#define __QADD __qadd +#define __QSUB __qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ + ((int64_t)(ARG3) << 32U) ) >> 32U)) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h new file mode 100644 index 0000000000..6911417747 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang.h @@ -0,0 +1,1503 @@ +/**************************************************************************//** + * @file cmsis_armclang.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V5.4.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +#define __SADD8 __builtin_arm_sadd8 +#define __QADD8 __builtin_arm_qadd8 +#define __SHADD8 __builtin_arm_shadd8 +#define __UADD8 __builtin_arm_uadd8 +#define __UQADD8 __builtin_arm_uqadd8 +#define __UHADD8 __builtin_arm_uhadd8 +#define __SSUB8 __builtin_arm_ssub8 +#define __QSUB8 __builtin_arm_qsub8 +#define __SHSUB8 __builtin_arm_shsub8 +#define __USUB8 __builtin_arm_usub8 +#define __UQSUB8 __builtin_arm_uqsub8 +#define __UHSUB8 __builtin_arm_uhsub8 +#define __SADD16 __builtin_arm_sadd16 +#define __QADD16 __builtin_arm_qadd16 +#define __SHADD16 __builtin_arm_shadd16 +#define __UADD16 __builtin_arm_uadd16 +#define __UQADD16 __builtin_arm_uqadd16 +#define __UHADD16 __builtin_arm_uhadd16 +#define __SSUB16 __builtin_arm_ssub16 +#define __QSUB16 __builtin_arm_qsub16 +#define __SHSUB16 __builtin_arm_shsub16 +#define __USUB16 __builtin_arm_usub16 +#define __UQSUB16 __builtin_arm_uqsub16 +#define __UHSUB16 __builtin_arm_uhsub16 +#define __SASX __builtin_arm_sasx +#define __QASX __builtin_arm_qasx +#define __SHASX __builtin_arm_shasx +#define __UASX __builtin_arm_uasx +#define __UQASX __builtin_arm_uqasx +#define __UHASX __builtin_arm_uhasx +#define __SSAX __builtin_arm_ssax +#define __QSAX __builtin_arm_qsax +#define __SHSAX __builtin_arm_shsax +#define __USAX __builtin_arm_usax +#define __UQSAX __builtin_arm_uqsax +#define __UHSAX __builtin_arm_uhsax +#define __USAD8 __builtin_arm_usad8 +#define __USADA8 __builtin_arm_usada8 +#define __SSAT16 __builtin_arm_ssat16 +#define __USAT16 __builtin_arm_usat16 +#define __UXTB16 __builtin_arm_uxtb16 +#define __UXTAB16 __builtin_arm_uxtab16 +#define __SXTB16 __builtin_arm_sxtb16 +#define __SXTAB16 __builtin_arm_sxtab16 +#define __SMUAD __builtin_arm_smuad +#define __SMUADX __builtin_arm_smuadx +#define __SMLAD __builtin_arm_smlad +#define __SMLADX __builtin_arm_smladx +#define __SMLALD __builtin_arm_smlald +#define __SMLALDX __builtin_arm_smlaldx +#define __SMUSD __builtin_arm_smusd +#define __SMUSDX __builtin_arm_smusdx +#define __SMLSD __builtin_arm_smlsd +#define __SMLSDX __builtin_arm_smlsdx +#define __SMLSLD __builtin_arm_smlsld +#define __SMLSLDX __builtin_arm_smlsldx +#define __SEL __builtin_arm_sel +#define __QADD __builtin_arm_qadd +#define __QSUB __builtin_arm_qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h new file mode 100644 index 0000000000..1e255d5907 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_armclang_ltm.h @@ -0,0 +1,1928 @@ +/**************************************************************************//** + * @file cmsis_armclang_ltm.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V1.5.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h new file mode 100644 index 0000000000..adbf296f15 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_compiler.h @@ -0,0 +1,283 @@ +/**************************************************************************//** + * @file cmsis_compiler.h + * @brief CMSIS compiler generic header file + * @version V5.1.0 + * @date 09. October 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_COMPILER_H +#define __CMSIS_COMPILER_H + +#include + +/* + * Arm Compiler 4/5 + */ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + + +/* + * Arm Compiler 6.6 LTM (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) + #include "cmsis_armclang_ltm.h" + + /* + * Arm Compiler above 6.10.1 (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) + #include "cmsis_armclang.h" + + +/* + * GNU Compiler + */ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + + +/* + * IAR Compiler + */ +#elif defined ( __ICCARM__ ) + #include + + +/* + * TI Arm Compiler + */ +#elif defined ( __TI_ARM__ ) + #include + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __attribute__((packed)) + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed)) + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed)) + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) + #endif + #ifndef __RESTRICT + #define __RESTRICT __restrict + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * TASKING Compiler + */ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __packed__ + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __packed__ + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __packed__ + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __packed__ T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __align(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * COSMIC Compiler + */ +#elif defined ( __CSMC__ ) + #include + + #ifndef __ASM + #define __ASM _asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + // NO RETURN is automatically detected hence no warning here + #define __NO_RETURN + #endif + #ifndef __USED + #warning No compiler specific solution for __USED. __USED is ignored. + #define __USED + #endif + #ifndef __WEAK + #define __WEAK __weak + #endif + #ifndef __PACKED + #define __PACKED @packed + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT @packed struct + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION @packed union + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + @packed struct T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. + #define __ALIGNED(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +#else + #error Unknown compiler. +#endif + + +#endif /* __CMSIS_COMPILER_H */ + diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h new file mode 100644 index 0000000000..67bda4ef3c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_gcc.h @@ -0,0 +1,2211 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS compiler GCC header file + * @version V5.4.1 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" + +/* Fallback for __has_builtin */ +#ifndef __has_builtin + #define __has_builtin(x) (0) +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START + +/** + \brief Initializes data and bss sections + \details This default implementations initialized all data and additional bss + sections relying on .copy.table and .zero.table specified properly + in the used linker script. + + */ +__STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) +{ + extern void _start(void) __NO_RETURN; + + typedef struct { + uint32_t const* src; + uint32_t* dest; + uint32_t wlen; + } __copy_table_t; + + typedef struct { + uint32_t* dest; + uint32_t wlen; + } __zero_table_t; + + extern const __copy_table_t __copy_table_start__; + extern const __copy_table_t __copy_table_end__; + extern const __zero_table_t __zero_table_start__; + extern const __zero_table_t __zero_table_end__; + + for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = pTable->src[i]; + } + } + + for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = 0u; + } + } + + _start(); +} + +#define __PROGRAM_START __cmsis_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP __StackTop +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT __StackLimit +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section(".vectors"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL __StackSeal +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP() __ASM volatile ("nop") + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI() __ASM volatile ("wfi":::"memory") + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE() __ASM volatile ("wfe":::"memory") + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV() __ASM volatile ("sev") + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__STATIC_FORCEINLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__STATIC_FORCEINLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__STATIC_FORCEINLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (int16_t)__builtin_bswap16(value); +#else + int16_t result; + + __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + __ASM ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return result; +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__STATIC_FORCEINLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_FORCEINLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_get_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + return __builtin_arm_get_fpscr(); +#else + uint32_t result; + + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + return(result); +#endif +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_set_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + __builtin_arm_set_fpscr(fpscr); +#else + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); +#endif +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +#define __USAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16_RORn(uint32_t op1, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtb16 %0, %1, ROR %2" : "=r" (result) : "r" (op1), "i" (rotate) ); + } else { + result = __SXTB16(__ROR(op1, rotate)) ; + } + return result; +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16_RORn(uint32_t op1, uint32_t op2, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtab16 %0, %1, %2, ROR %3" : "=r" (result) : "r" (op1) , "r" (op2) , "i" (rotate)); + } else { + result = __SXTAB16(op1, __ROR(op2, rotate)); + } + return result; +} + + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +#define __PKHBT(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#pragma GCC diagnostic pop + +#endif /* __CMSIS_GCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h new file mode 100644 index 0000000000..65b824b009 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_iccarm.h @@ -0,0 +1,1002 @@ +/**************************************************************************//** + * @file cmsis_iccarm.h + * @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file + * @version V5.3.0 + * @date 14. April 2021 + ******************************************************************************/ + +//------------------------------------------------------------------------------ +// +// Copyright (c) 2017-2021 IAR Systems +// Copyright (c) 2017-2021 Arm Limited. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//------------------------------------------------------------------------------ + + +#ifndef __CMSIS_ICCARM_H__ +#define __CMSIS_ICCARM_H__ + +#ifndef __ICCARM__ + #error This file should only be compiled by ICCARM +#endif + +#pragma system_include + +#define __IAR_FT _Pragma("inline=forced") __intrinsic + +#if (__VER__ >= 8000000) + #define __ICCARM_V8 1 +#else + #define __ICCARM_V8 0 +#endif + +#ifndef __ALIGNED + #if __ICCARM_V8 + #define __ALIGNED(x) __attribute__((aligned(x))) + #elif (__VER__ >= 7080000) + /* Needs IAR language extensions */ + #define __ALIGNED(x) __attribute__((aligned(x))) + #else + #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored. + #define __ALIGNED(x) + #endif +#endif + + +/* Define compiler macros for CPU architecture, used in CMSIS 5. + */ +#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__ +/* Macros already defined */ +#else + #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M' + #if __ARM_ARCH == 6 + #define __ARM_ARCH_6M__ 1 + #elif __ARM_ARCH == 7 + #if __ARM_FEATURE_DSP + #define __ARM_ARCH_7EM__ 1 + #else + #define __ARM_ARCH_7M__ 1 + #endif + #endif /* __ARM_ARCH */ + #endif /* __ARM_ARCH_PROFILE == 'M' */ +#endif + +/* Alternativ core deduction for older ICCARM's */ +#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \ + !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__) + #if defined(__ARM6M__) && (__CORE__ == __ARM6M__) + #define __ARM_ARCH_6M__ 1 + #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__) + #define __ARM_ARCH_7M__ 1 + #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__) + #define __ARM_ARCH_7EM__ 1 + #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #else + #error "Unknown target." + #endif +#endif + + + +#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1 + #define __IAR_M0_FAMILY 1 +#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1 + #define __IAR_M0_FAMILY 1 +#else + #define __IAR_M0_FAMILY 0 +#endif + + +#ifndef __ASM + #define __ASM __asm +#endif + +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +#ifndef __INLINE + #define __INLINE inline +#endif + +#ifndef __NO_RETURN + #if __ICCARM_V8 + #define __NO_RETURN __attribute__((__noreturn__)) + #else + #define __NO_RETURN _Pragma("object_attribute=__noreturn") + #endif +#endif + +#ifndef __PACKED + #if __ICCARM_V8 + #define __PACKED __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED __packed + #endif +#endif + +#ifndef __PACKED_STRUCT + #if __ICCARM_V8 + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_STRUCT __packed struct + #endif +#endif + +#ifndef __PACKED_UNION + #if __ICCARM_V8 + #define __PACKED_UNION union __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_UNION __packed union + #endif +#endif + +#ifndef __RESTRICT + #if __ICCARM_V8 + #define __RESTRICT __restrict + #else + /* Needs IAR language extensions */ + #define __RESTRICT restrict + #endif +#endif + +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif + +#ifndef __FORCEINLINE + #define __FORCEINLINE _Pragma("inline=forced") +#endif + +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE +#endif + +#ifndef __UNALIGNED_UINT16_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint16_t __iar_uint16_read(void const *ptr) +{ + return *(__packed uint16_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR) +#endif + + +#ifndef __UNALIGNED_UINT16_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val) +{ + *(__packed uint16_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint32_t __iar_uint32_read(void const *ptr) +{ + return *(__packed uint32_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR) +#endif + +#ifndef __UNALIGNED_UINT32_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val) +{ + *(__packed uint32_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32 /* deprecated */ +#pragma language=save +#pragma language=extended +__packed struct __iar_u32 { uint32_t v; }; +#pragma language=restore +#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v) +#endif + +#ifndef __USED + #if __ICCARM_V8 + #define __USED __attribute__((used)) + #else + #define __USED _Pragma("__root") + #endif +#endif + +#undef __WEAK /* undo the definition from DLib_Defaults.h */ +#ifndef __WEAK + #if __ICCARM_V8 + #define __WEAK __attribute__((weak)) + #else + #define __WEAK _Pragma("__weak") + #endif +#endif + +#ifndef __PROGRAM_START +#define __PROGRAM_START __iar_program_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP CSTACK$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT CSTACK$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __vector_table +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE @".intvec" +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL STACKSEAL$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + +#ifndef __ICCARM_INTRINSICS_VERSION__ + #define __ICCARM_INTRINSICS_VERSION__ 0 +#endif + +#if __ICCARM_INTRINSICS_VERSION__ == 2 + + #if defined(__CLZ) + #undef __CLZ + #endif + #if defined(__REVSH) + #undef __REVSH + #endif + #if defined(__RBIT) + #undef __RBIT + #endif + #if defined(__SSAT) + #undef __SSAT + #endif + #if defined(__USAT) + #undef __USAT + #endif + + #include "iccarm_builtin.h" + + #define __disable_fault_irq __iar_builtin_disable_fiq + #define __disable_irq __iar_builtin_disable_interrupt + #define __enable_fault_irq __iar_builtin_enable_fiq + #define __enable_irq __iar_builtin_enable_interrupt + #define __arm_rsr __iar_builtin_rsr + #define __arm_wsr __iar_builtin_wsr + + + #define __get_APSR() (__arm_rsr("APSR")) + #define __get_BASEPRI() (__arm_rsr("BASEPRI")) + #define __get_CONTROL() (__arm_rsr("CONTROL")) + #define __get_FAULTMASK() (__arm_rsr("FAULTMASK")) + + #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + #define __get_FPSCR() (__arm_rsr("FPSCR")) + #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE))) + #else + #define __get_FPSCR() ( 0 ) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #define __get_IPSR() (__arm_rsr("IPSR")) + #define __get_MSP() (__arm_rsr("MSP")) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __get_MSPLIM() (0U) + #else + #define __get_MSPLIM() (__arm_rsr("MSPLIM")) + #endif + #define __get_PRIMASK() (__arm_rsr("PRIMASK")) + #define __get_PSP() (__arm_rsr("PSP")) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __get_PSPLIM() (0U) + #else + #define __get_PSPLIM() (__arm_rsr("PSPLIM")) + #endif + + #define __get_xPSR() (__arm_rsr("xPSR")) + + #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE))) + #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE))) + +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __arm_wsr("CONTROL", control); + __iar_builtin_ISB(); +} + + #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE))) + #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __set_MSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE))) + #endif + #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE))) + #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE))) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __set_PSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE))) + #endif + + #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS")) + +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __arm_wsr("CONTROL_NS", control); + __iar_builtin_ISB(); +} + + #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS")) + #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE))) + #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS")) + #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE))) + #define __TZ_get_SP_NS() (__arm_rsr("SP_NS")) + #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE))) + #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS")) + #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE))) + #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS")) + #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE))) + #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS")) + #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __TZ_get_PSPLIM_NS() (0U) + #define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE)) + #else + #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS")) + #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE))) + #endif + + #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS")) + #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE))) + + #define __NOP __iar_builtin_no_operation + + #define __CLZ __iar_builtin_CLZ + #define __CLREX __iar_builtin_CLREX + + #define __DMB __iar_builtin_DMB + #define __DSB __iar_builtin_DSB + #define __ISB __iar_builtin_ISB + + #define __LDREXB __iar_builtin_LDREXB + #define __LDREXH __iar_builtin_LDREXH + #define __LDREXW __iar_builtin_LDREX + + #define __RBIT __iar_builtin_RBIT + #define __REV __iar_builtin_REV + #define __REV16 __iar_builtin_REV16 + + __IAR_FT int16_t __REVSH(int16_t val) + { + return (int16_t) __iar_builtin_REVSH(val); + } + + #define __ROR __iar_builtin_ROR + #define __RRX __iar_builtin_RRX + + #define __SEV __iar_builtin_SEV + + #if !__IAR_M0_FAMILY + #define __SSAT __iar_builtin_SSAT + #endif + + #define __STREXB __iar_builtin_STREXB + #define __STREXH __iar_builtin_STREXH + #define __STREXW __iar_builtin_STREX + + #if !__IAR_M0_FAMILY + #define __USAT __iar_builtin_USAT + #endif + + #define __WFE __iar_builtin_WFE + #define __WFI __iar_builtin_WFI + + #if __ARM_MEDIA__ + #define __SADD8 __iar_builtin_SADD8 + #define __QADD8 __iar_builtin_QADD8 + #define __SHADD8 __iar_builtin_SHADD8 + #define __UADD8 __iar_builtin_UADD8 + #define __UQADD8 __iar_builtin_UQADD8 + #define __UHADD8 __iar_builtin_UHADD8 + #define __SSUB8 __iar_builtin_SSUB8 + #define __QSUB8 __iar_builtin_QSUB8 + #define __SHSUB8 __iar_builtin_SHSUB8 + #define __USUB8 __iar_builtin_USUB8 + #define __UQSUB8 __iar_builtin_UQSUB8 + #define __UHSUB8 __iar_builtin_UHSUB8 + #define __SADD16 __iar_builtin_SADD16 + #define __QADD16 __iar_builtin_QADD16 + #define __SHADD16 __iar_builtin_SHADD16 + #define __UADD16 __iar_builtin_UADD16 + #define __UQADD16 __iar_builtin_UQADD16 + #define __UHADD16 __iar_builtin_UHADD16 + #define __SSUB16 __iar_builtin_SSUB16 + #define __QSUB16 __iar_builtin_QSUB16 + #define __SHSUB16 __iar_builtin_SHSUB16 + #define __USUB16 __iar_builtin_USUB16 + #define __UQSUB16 __iar_builtin_UQSUB16 + #define __UHSUB16 __iar_builtin_UHSUB16 + #define __SASX __iar_builtin_SASX + #define __QASX __iar_builtin_QASX + #define __SHASX __iar_builtin_SHASX + #define __UASX __iar_builtin_UASX + #define __UQASX __iar_builtin_UQASX + #define __UHASX __iar_builtin_UHASX + #define __SSAX __iar_builtin_SSAX + #define __QSAX __iar_builtin_QSAX + #define __SHSAX __iar_builtin_SHSAX + #define __USAX __iar_builtin_USAX + #define __UQSAX __iar_builtin_UQSAX + #define __UHSAX __iar_builtin_UHSAX + #define __USAD8 __iar_builtin_USAD8 + #define __USADA8 __iar_builtin_USADA8 + #define __SSAT16 __iar_builtin_SSAT16 + #define __USAT16 __iar_builtin_USAT16 + #define __UXTB16 __iar_builtin_UXTB16 + #define __UXTAB16 __iar_builtin_UXTAB16 + #define __SXTB16 __iar_builtin_SXTB16 + #define __SXTAB16 __iar_builtin_SXTAB16 + #define __SMUAD __iar_builtin_SMUAD + #define __SMUADX __iar_builtin_SMUADX + #define __SMMLA __iar_builtin_SMMLA + #define __SMLAD __iar_builtin_SMLAD + #define __SMLADX __iar_builtin_SMLADX + #define __SMLALD __iar_builtin_SMLALD + #define __SMLALDX __iar_builtin_SMLALDX + #define __SMUSD __iar_builtin_SMUSD + #define __SMUSDX __iar_builtin_SMUSDX + #define __SMLSD __iar_builtin_SMLSD + #define __SMLSDX __iar_builtin_SMLSDX + #define __SMLSLD __iar_builtin_SMLSLD + #define __SMLSLDX __iar_builtin_SMLSLDX + #define __SEL __iar_builtin_SEL + #define __QADD __iar_builtin_QADD + #define __QSUB __iar_builtin_QSUB + #define __PKHBT __iar_builtin_PKHBT + #define __PKHTB __iar_builtin_PKHTB + #endif + +#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #define __CLZ __cmsis_iar_clz_not_active + #define __SSAT __cmsis_iar_ssat_not_active + #define __USAT __cmsis_iar_usat_not_active + #define __RBIT __cmsis_iar_rbit_not_active + #define __get_APSR __cmsis_iar_get_APSR_not_active + #endif + + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #define __get_FPSCR __cmsis_iar_get_FPSR_not_active + #define __set_FPSCR __cmsis_iar_set_FPSR_not_active + #endif + + #ifdef __INTRINSICS_INCLUDED + #error intrinsics.h is already included previously! + #endif + + #include + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #undef __CLZ + #undef __SSAT + #undef __USAT + #undef __RBIT + #undef __get_APSR + + __STATIC_INLINE uint8_t __CLZ(uint32_t data) + { + if (data == 0U) { return 32U; } + + uint32_t count = 0U; + uint32_t mask = 0x80000000U; + + while ((data & mask) == 0U) + { + count += 1U; + mask = mask >> 1U; + } + return count; + } + + __STATIC_INLINE uint32_t __RBIT(uint32_t v) + { + uint8_t sc = 31U; + uint32_t r = v; + for (v >>= 1U; v; v >>= 1U) + { + r <<= 1U; + r |= v & 1U; + sc--; + } + return (r << sc); + } + + __STATIC_INLINE uint32_t __get_APSR(void) + { + uint32_t res; + __asm("MRS %0,APSR" : "=r" (res)); + return res; + } + + #endif + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #undef __get_FPSCR + #undef __set_FPSCR + #define __get_FPSCR() (0) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #pragma diag_suppress=Pe940 + #pragma diag_suppress=Pe177 + + #define __enable_irq __enable_interrupt + #define __disable_irq __disable_interrupt + #define __NOP __no_operation + + #define __get_xPSR __get_PSR + + #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0) + + __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr) + { + return __LDREX((unsigned long *)ptr); + } + + __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr) + { + return __STREX(value, (unsigned long *)ptr); + } + #endif + + + /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + #if (__CORTEX_M >= 0x03) + + __IAR_FT uint32_t __RRX(uint32_t value) + { + uint32_t result; + __ASM volatile("RRX %0, %1" : "=r"(result) : "r" (value)); + return(result); + } + + __IAR_FT void __set_BASEPRI_MAX(uint32_t value) + { + __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value)); + } + + + #define __enable_fault_irq __enable_fiq + #define __disable_fault_irq __disable_fiq + + + #endif /* (__CORTEX_M >= 0x03) */ + + __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2) + { + return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2)); + } + + #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + __IAR_FT uint32_t __get_MSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,MSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_MSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR MSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __get_PSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_PSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_CONTROL_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,CONTROL_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value) + { + __asm volatile("MSR CONTROL_NS,%0" :: "r" (value)); + __iar_builtin_ISB(); + } + + __IAR_FT uint32_t __TZ_get_PSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PSP_NS(uint32_t value) + { + __asm volatile("MSR PSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_MSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSP_NS(uint32_t value) + { + __asm volatile("MSR MSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_SP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,SP_NS" : "=r" (res)); + return res; + } + __IAR_FT void __TZ_set_SP_NS(uint32_t value) + { + __asm volatile("MSR SP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value) + { + __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value) + { + __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value) + { + __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value) + { + __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value)); + } + + #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + +#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value)) + +#if __IAR_M0_FAMILY + __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) + { + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; + } + + __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) + { + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; + } +#endif + +#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + + __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr) + { + uint32_t res; + __ASM volatile ("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr) + { + uint32_t res; + __ASM volatile ("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDRT(volatile uint32_t *addr) + { + uint32_t res; + __ASM volatile ("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return res; + } + + __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr) + { + __ASM volatile ("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr) + { + __ASM volatile ("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr) + { + __ASM volatile ("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory"); + } + +#endif /* (__CORTEX_M >= 0x03) */ + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + + __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDA(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr) + { + __ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr) + { + __ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr) + { + __ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + +#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#undef __IAR_FT +#undef __IAR_M0_FAMILY +#undef __ICCARM_V8 + +#pragma diag_default=Pe940 +#pragma diag_default=Pe177 + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* __CMSIS_ICCARM_H__ */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h new file mode 100644 index 0000000000..8b4765f186 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/cmsis_version.h @@ -0,0 +1,39 @@ +/**************************************************************************//** + * @file cmsis_version.h + * @brief CMSIS Core(M) Version definitions + * @version V5.0.5 + * @date 02. February 2022 + ******************************************************************************/ +/* + * Copyright (c) 2009-2022 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CMSIS_VERSION_H +#define __CMSIS_VERSION_H + +/* CMSIS Version definitions */ +#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ +#define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */ +#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ + __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h new file mode 100644 index 0000000000..94128a1a70 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv81mml.h @@ -0,0 +1,4228 @@ +/**************************************************************************//** + * @file core_armv81mml.h + * @brief CMSIS Armv8.1-M Mainline Core Peripheral Access Layer Header File + * @version V1.4.2 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV81MML_H_GENERIC +#define __CORE_ARMV81MML_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMV81MML + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS ARMV81MML definitions */ +#define __ARMv81MML_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv81MML_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv81MML_CMSIS_VERSION ((__ARMv81MML_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv81MML_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (81U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV81MML_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV81MML_H_DEPENDANT +#define __CORE_ARMV81MML_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv81MML_REV + #define __ARMv81MML_REV 0x0000U + #warning "__ARMv81MML_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 2U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 31 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv81MML */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[3]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE4 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE8 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFEC (R/W) PMU Peripheral Identification Register 3 */ + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (0xFFFFUL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (0xFFFFUL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (0xFFUL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (0x3FUL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/** \brief PMU Authentication Status Register Definitions */ + +#define PMU_AUTHSTATUS_NSID_Pos 0U /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSID_Msk (0x3UL /*<< PMU_AUTHSTATUS_NSID_Pos*/) /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSNID_Pos 2U /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSNID_Msk (0x3UL << PMU_AUTHSTATUS_NSNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SID_Pos 4U /*!< PMU AUTHSTATUS: Secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_SID_Msk (0x3UL << PMU_AUTHSTATUS_SID_Pos) /*!< PMU AUTHSTATUS: Secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SNID_Pos 6U /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SNID_Msk (0x3UL << PMU_AUTHSTATUS_SNID_Pos) /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUID_Pos 16U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUID_Msk (0x3UL << PMU_AUTHSTATUS_NSUID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUNID_Pos 18U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUNID_Msk (0x3UL << PMU_AUTHSTATUS_NSUNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUID_Pos 20U /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_SUID_Msk (0x3UL << PMU_AUTHSTATUS_SUID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUNID_Pos 22U /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SUNID_Msk (0x3UL << PMU_AUTHSTATUS_SUNID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Mask */ + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV81MML_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h new file mode 100644 index 0000000000..e9c9b5bf59 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mbl.h @@ -0,0 +1,2222 @@ +/**************************************************************************//** + * @file core_armv8mbl.h + * @brief CMSIS Armv8-M Baseline Core Peripheral Access Layer Header File + * @version V5.1.0 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV8MBL_H_GENERIC +#define __CORE_ARMV8MBL_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMv8MBL + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS definitions */ +#define __ARMv8MBL_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv8MBL_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv8MBL_CMSIS_VERSION ((__ARMv8MBL_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv8MBL_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (2U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MBL_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV8MBL_H_DEPENDANT +#define __CORE_ARMV8MBL_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv8MBL_REV + #define __ARMv8MBL_REV 0x0000U + #warning "__ARMv8MBL_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif + + #ifndef __ETM_PRESENT + #define __ETM_PRESENT 0U + #warning "__ETM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MTB_PRESENT + #define __MTB_PRESENT 0U + #warning "__MTB_PRESENT not defined in device header file; using default!" + #endif + +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv8MBL */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint32_t IPR[124U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHPR[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t RESERVED0[6U]; + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x3UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + uint32_t RESERVED0[7U]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: EN Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: EN Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#endif +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_DWTENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: DWTENA Position */ +#define CoreDebug_DEMCR_DWTENA_Msk (1UL << CoreDebug_DEMCR_DWTENA_Pos) /*!< \deprecated CoreDebug DEMCR: DWTENA Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MBL_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h new file mode 100644 index 0000000000..c119fbf242 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_armv8mml.h @@ -0,0 +1,3209 @@ +/**************************************************************************//** + * @file core_armv8mml.h + * @brief CMSIS Armv8-M Mainline Core Peripheral Access Layer Header File + * @version V5.2.3 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV8MML_H_GENERIC +#define __CORE_ARMV8MML_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMv8MML + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS Armv8MML definitions */ +#define __ARMv8MML_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv8MML_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv8MML_CMSIS_VERSION ((__ARMv8MML_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv8MML_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (80U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MML_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV8MML_H_DEPENDANT +#define __CORE_ARMV8MML_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv8MML_REV + #define __ARMv8MML_REV 0x0000U + #warning "__ARMv8MML_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv8MML */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MML_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h new file mode 100644 index 0000000000..0a0ba223e1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0.h @@ -0,0 +1,952 @@ +/**************************************************************************//** + * @file core_cm0.h + * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File + * @version V5.0.8 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0_H_GENERIC +#define __CORE_CM0_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M0 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0 definitions */ +#define __CM0_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ + __CM0_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0_H_DEPENDANT +#define __CORE_CM0_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0_REV + #define __CM0_REV 0x0000U + #warning "__CM0_REV not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M0 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + uint32_t RESERVED0; + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + Address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ + /* ARM Application Note 321 states that the M0 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h new file mode 100644 index 0000000000..879a384124 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm0plus.h @@ -0,0 +1,1087 @@ +/**************************************************************************//** + * @file core_cm0plus.h + * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File + * @version V5.0.9 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0PLUS_H_GENERIC +#define __CORE_CM0PLUS_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex-M0+ + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0+ definitions */ +#define __CM0PLUS_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0PLUS_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ + __CM0PLUS_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0PLUS_H_DEPENDANT +#define __CORE_CM0PLUS_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0PLUS_REV + #define __CM0PLUS_REV 0x0000U + #warning "__CM0PLUS_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex-M0+ */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0+ header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0+ */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ +#endif + /* ARM Application Note 321 states that the M0+ does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +#endif +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h new file mode 100644 index 0000000000..83b8fc6a0d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm1.h @@ -0,0 +1,979 @@ +/**************************************************************************//** + * @file core_cm1.h + * @brief CMSIS Cortex-M1 Core Peripheral Access Layer Header File + * @version V1.0.1 + * @date 12. November 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM1_H_GENERIC +#define __CORE_CM1_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M1 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM1 definitions */ +#define __CM1_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM1_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM1_CMSIS_VERSION ((__CM1_CMSIS_VERSION_MAIN << 16U) | \ + __CM1_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (1U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM1_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM1_H_DEPENDANT +#define __CORE_CM1_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM1_REV + #define __CM1_REV 0x0100U + #warning "__CM1_REV not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M1 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + uint32_t RESERVED0; + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_ITCMUAEN_Pos 4U /*!< ACTLR: Instruction TCM Upper Alias Enable Position */ +#define SCnSCB_ACTLR_ITCMUAEN_Msk (1UL << SCnSCB_ACTLR_ITCMUAEN_Pos) /*!< ACTLR: Instruction TCM Upper Alias Enable Mask */ + +#define SCnSCB_ACTLR_ITCMLAEN_Pos 3U /*!< ACTLR: Instruction TCM Lower Alias Enable Position */ +#define SCnSCB_ACTLR_ITCMLAEN_Msk (1UL << SCnSCB_ACTLR_ITCMLAEN_Pos) /*!< ACTLR: Instruction TCM Lower Alias Enable Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M1 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M1 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M1 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + Address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)0x0U; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M1 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)0x0U; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM1_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h new file mode 100644 index 0000000000..f2cf49fb16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm23.h @@ -0,0 +1,2297 @@ +/**************************************************************************//** + * @file core_cm23.h + * @brief CMSIS Cortex-M23 Core Peripheral Access Layer Header File + * @version V5.1.0 + * @date 11. February 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM23_H_GENERIC +#define __CORE_CM23_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M23 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS definitions */ +#define __CM23_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM23_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM23_CMSIS_VERSION ((__CM23_CMSIS_VERSION_MAIN << 16U) | \ + __CM23_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (23U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM23_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM23_H_DEPENDANT +#define __CORE_CM23_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM23_REV + #define __CM23_REV 0x0000U + #warning "__CM23_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif + + #ifndef __ETM_PRESENT + #define __ETM_PRESENT 0U + #warning "__ETM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MTB_PRESENT + #define __MTB_PRESENT 0U + #warning "__MTB_PRESENT not defined in device header file; using default!" + #endif + +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M23 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint32_t IPR[124U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHPR[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t RESERVED0[6U]; + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x3UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + uint32_t RESERVED0[7U]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: EN Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: EN Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#endif +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register */ +#define CoreDebug_DEMCR_DWTENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: DWTENA Position */ +#define CoreDebug_DEMCR_DWTENA_Msk (1UL << CoreDebug_DEMCR_DWTENA_Pos) /*!< \deprecated CoreDebug DEMCR: DWTENA Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else +/*#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping not available for Cortex-M23 */ +/*#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping not available for Cortex-M23 */ + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM23_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h new file mode 100644 index 0000000000..74fb87e5c5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm3.h @@ -0,0 +1,1943 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V5.1.2 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM3_H_GENERIC +#define __CORE_CM3_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M3 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (3U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM3_H_DEPENDANT +#define __CORE_CM3_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM3_REV + #define __CM3_REV 0x0200U + #warning "__CM3_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M3 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV < 0x0201U) /* core r2p1 */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#else +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +#else + uint32_t RESERVED1[1U]; +#endif +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ +#endif + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h new file mode 100644 index 0000000000..18a2e6fb03 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm33.h @@ -0,0 +1,3277 @@ +/**************************************************************************//** + * @file core_cm33.h + * @brief CMSIS Cortex-M33 Core Peripheral Access Layer Header File + * @version V5.2.3 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM33_H_GENERIC +#define __CORE_CM33_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M33 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM33 definitions */ +#define __CM33_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM33_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM33_CMSIS_VERSION ((__CM33_CMSIS_VERSION_MAIN << 16U) | \ + __CM33_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (33U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM33_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM33_H_DEPENDANT +#define __CORE_CM33_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM33_REV + #define __CM33_REV 0x0000U + #warning "__CM33_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M33 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM33_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h new file mode 100644 index 0000000000..3843d9542c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm35p.h @@ -0,0 +1,3277 @@ +/**************************************************************************//** + * @file core_cm35p.h + * @brief CMSIS Cortex-M35P Core Peripheral Access Layer Header File + * @version V1.1.3 + * @date 13. October 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM35P_H_GENERIC +#define __CORE_CM35P_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M35P + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM35P definitions */ +#define __CM35P_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM35P_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM35P_CMSIS_VERSION ((__CM35P_CMSIS_VERSION_MAIN << 16U) | \ + __CM35P_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (35U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM35P_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM35P_H_DEPENDANT +#define __CORE_CM35P_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM35P_REV + #define __CM35P_REV 0x0000U + #warning "__CM35P_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M35P */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM35P_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h new file mode 100644 index 0000000000..e21cd14925 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm4.h @@ -0,0 +1,2129 @@ +/**************************************************************************//** + * @file core_cm4.h + * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File + * @version V5.1.2 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM4_H_GENERIC +#define __CORE_CM4_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M4 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM4 definitions */ +#define __CM4_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM4_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ + __CM4_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (4U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM4_H_DEPENDANT +#define __CORE_CM4_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM4_REV + #define __CM4_REV 0x0000U + #warning "__CM4_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M4 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and FP Feature Register 2 Definitions */ + +#define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ +#define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ +#define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M4 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h new file mode 100644 index 0000000000..faa30ce36a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm55.h @@ -0,0 +1,4817 @@ +/**************************************************************************//** + * @file core_cm55.h + * @brief CMSIS Cortex-M55 Core Peripheral Access Layer Header File + * @version V1.2.4 + * @date 21. April 2022 + ******************************************************************************/ +/* + * Copyright (c) 2018-2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM55_H_GENERIC +#define __CORE_CM55_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M55 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM55 definitions */ +#define __CM55_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM55_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM55_CMSIS_VERSION ((__CM55_CMSIS_VERSION_MAIN << 16U) | \ + __CM55_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (55U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM55_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM55_H_DEPENDANT +#define __CORE_CM55_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM55_REV + #define __CM55_REV 0x0000U + #warning "__CM55_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 8U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 8 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M55 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core EWIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core PMU Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ICB Implementation Control Block register (ICB) + \brief Type definitions for the Implementation Control Block Register + @{ + */ + +/** + \brief Structure type to access the Implementation Control Block (ICB). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} ICB_Type; + +/* Auxiliary Control Register Definitions */ +#define ICB_ACTLR_DISCRITAXIRUW_Pos 27U /*!< ACTLR: DISCRITAXIRUW Position */ +#define ICB_ACTLR_DISCRITAXIRUW_Msk (1UL << ICB_ACTLR_DISCRITAXIRUW_Pos) /*!< ACTLR: DISCRITAXIRUW Mask */ + +#define ICB_ACTLR_DISDI_Pos 16U /*!< ACTLR: DISDI Position */ +#define ICB_ACTLR_DISDI_Msk (3UL << ICB_ACTLR_DISDI_Pos) /*!< ACTLR: DISDI Mask */ + +#define ICB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define ICB_ACTLR_DISCRITAXIRUR_Msk (1UL << ICB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define ICB_ACTLR_EVENTBUSEN_Pos 14U /*!< ACTLR: EVENTBUSEN Position */ +#define ICB_ACTLR_EVENTBUSEN_Msk (1UL << ICB_ACTLR_EVENTBUSEN_Pos) /*!< ACTLR: EVENTBUSEN Mask */ + +#define ICB_ACTLR_EVENTBUSEN_S_Pos 13U /*!< ACTLR: EVENTBUSEN_S Position */ +#define ICB_ACTLR_EVENTBUSEN_S_Msk (1UL << ICB_ACTLR_EVENTBUSEN_S_Pos) /*!< ACTLR: EVENTBUSEN_S Mask */ + +#define ICB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define ICB_ACTLR_DISITMATBFLUSH_Msk (1UL << ICB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define ICB_ACTLR_DISNWAMODE_Pos 11U /*!< ACTLR: DISNWAMODE Position */ +#define ICB_ACTLR_DISNWAMODE_Msk (1UL << ICB_ACTLR_DISNWAMODE_Pos) /*!< ACTLR: DISNWAMODE Mask */ + +#define ICB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define ICB_ACTLR_FPEXCODIS_Msk (1UL << ICB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +#define ICB_ACTLR_DISOLAP_Pos 7U /*!< ACTLR: DISOLAP Position */ +#define ICB_ACTLR_DISOLAP_Msk (1UL << ICB_ACTLR_DISOLAP_Pos) /*!< ACTLR: DISOLAP Mask */ + +#define ICB_ACTLR_DISOLAPS_Pos 6U /*!< ACTLR: DISOLAPS Position */ +#define ICB_ACTLR_DISOLAPS_Msk (1UL << ICB_ACTLR_DISOLAPS_Pos) /*!< ACTLR: DISOLAPS Mask */ + +#define ICB_ACTLR_DISLOBR_Pos 5U /*!< ACTLR: DISLOBR Position */ +#define ICB_ACTLR_DISLOBR_Msk (1UL << ICB_ACTLR_DISLOBR_Pos) /*!< ACTLR: DISLOBR Mask */ + +#define ICB_ACTLR_DISLO_Pos 4U /*!< ACTLR: DISLO Position */ +#define ICB_ACTLR_DISLO_Msk (1UL << ICB_ACTLR_DISLO_Pos) /*!< ACTLR: DISLO Mask */ + +#define ICB_ACTLR_DISLOLEP_Pos 3U /*!< ACTLR: DISLOLEP Position */ +#define ICB_ACTLR_DISLOLEP_Msk (1UL << ICB_ACTLR_DISLOLEP_Pos) /*!< ACTLR: DISLOLEP Mask */ + +#define ICB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define ICB_ACTLR_DISFOLD_Msk (1UL << ICB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +/* Interrupt Controller Type Register Definitions */ +#define ICB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define ICB_ICTR_INTLINESNUM_Msk (0xFUL /*<< ICB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_ICB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup MemSysCtl_Type Memory System Control Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Memory System Control Registers (MEMSYSCTL) + @{ + */ + +/** + \brief Structure type to access the Memory System Control Registers (MEMSYSCTL). + */ +typedef struct +{ + __IOM uint32_t MSCR; /*!< Offset: 0x000 (R/W) Memory System Control Register */ + __IOM uint32_t PFCR; /*!< Offset: 0x004 (R/W) Prefetcher Control Register */ + uint32_t RESERVED1[2U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x010 (R/W) ITCM Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x014 (R/W) DTCM Control Register */ + __IOM uint32_t PAHBCR; /*!< Offset: 0x018 (R/W) P-AHB Control Register */ + uint32_t RESERVED2[313U]; + __IOM uint32_t ITGU_CTRL; /*!< Offset: 0x500 (R/W) ITGU Control Register */ + __IOM uint32_t ITGU_CFG; /*!< Offset: 0x504 (R/W) ITGU Configuration Register */ + uint32_t RESERVED3[2U]; + __IOM uint32_t ITGU_LUT[16U]; /*!< Offset: 0x510 (R/W) ITGU Look Up Table Register */ + uint32_t RESERVED4[44U]; + __IOM uint32_t DTGU_CTRL; /*!< Offset: 0x600 (R/W) DTGU Control Registers */ + __IOM uint32_t DTGU_CFG; /*!< Offset: 0x604 (R/W) DTGU Configuration Register */ + uint32_t RESERVED5[2U]; + __IOM uint32_t DTGU_LUT[16U]; /*!< Offset: 0x610 (R/W) DTGU Look Up Table Register */ +} MemSysCtl_Type; + +/* MEMSYSCTL Memory System Control Register (MSCR) Register Definitions */ +#define MEMSYSCTL_MSCR_CPWRDN_Pos 17U /*!< MEMSYSCTL MSCR: CPWRDN Position */ +#define MEMSYSCTL_MSCR_CPWRDN_Msk (0x1UL << MEMSYSCTL_MSCR_CPWRDN_Pos) /*!< MEMSYSCTL MSCR: CPWRDN Mask */ + +#define MEMSYSCTL_MSCR_DCCLEAN_Pos 16U /*!< MEMSYSCTL MSCR: DCCLEAN Position */ +#define MEMSYSCTL_MSCR_DCCLEAN_Msk (0x1UL << MEMSYSCTL_MSCR_DCCLEAN_Pos) /*!< MEMSYSCTL MSCR: DCCLEAN Mask */ + +#define MEMSYSCTL_MSCR_ICACTIVE_Pos 13U /*!< MEMSYSCTL MSCR: ICACTIVE Position */ +#define MEMSYSCTL_MSCR_ICACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_ICACTIVE_Pos) /*!< MEMSYSCTL MSCR: ICACTIVE Mask */ + +#define MEMSYSCTL_MSCR_DCACTIVE_Pos 12U /*!< MEMSYSCTL MSCR: DCACTIVE Position */ +#define MEMSYSCTL_MSCR_DCACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_DCACTIVE_Pos) /*!< MEMSYSCTL MSCR: DCACTIVE Mask */ + +#define MEMSYSCTL_MSCR_TECCCHKDIS_Pos 4U /*!< MEMSYSCTL MSCR: TECCCHKDIS Position */ +#define MEMSYSCTL_MSCR_TECCCHKDIS_Msk (0x1UL << MEMSYSCTL_MSCR_TECCCHKDIS_Pos) /*!< MEMSYSCTL MSCR: TECCCHKDIS Mask */ + +#define MEMSYSCTL_MSCR_EVECCFAULT_Pos 3U /*!< MEMSYSCTL MSCR: EVECCFAULT Position */ +#define MEMSYSCTL_MSCR_EVECCFAULT_Msk (0x1UL << MEMSYSCTL_MSCR_EVECCFAULT_Pos) /*!< MEMSYSCTL MSCR: EVECCFAULT Mask */ + +#define MEMSYSCTL_MSCR_FORCEWT_Pos 2U /*!< MEMSYSCTL MSCR: FORCEWT Position */ +#define MEMSYSCTL_MSCR_FORCEWT_Msk (0x1UL << MEMSYSCTL_MSCR_FORCEWT_Pos) /*!< MEMSYSCTL MSCR: FORCEWT Mask */ + +#define MEMSYSCTL_MSCR_ECCEN_Pos 1U /*!< MEMSYSCTL MSCR: ECCEN Position */ +#define MEMSYSCTL_MSCR_ECCEN_Msk (0x1UL << MEMSYSCTL_MSCR_ECCEN_Pos) /*!< MEMSYSCTL MSCR: ECCEN Mask */ + +/* MEMSYSCTL Prefetcher Control Register (PFCR) Register Definitions */ +#define MEMSYSCTL_PFCR_MAX_OS_Pos 7U /*!< MEMSYSCTL PFCR: MAX_OS Position */ +#define MEMSYSCTL_PFCR_MAX_OS_Msk (0x7UL << MEMSYSCTL_PFCR_MAX_OS_Pos) /*!< MEMSYSCTL PFCR: MAX_OS Mask */ + +#define MEMSYSCTL_PFCR_MAX_LA_Pos 4U /*!< MEMSYSCTL PFCR: MAX_LA Position */ +#define MEMSYSCTL_PFCR_MAX_LA_Msk (0x7UL << MEMSYSCTL_PFCR_MAX_LA_Pos) /*!< MEMSYSCTL PFCR: MAX_LA Mask */ + +#define MEMSYSCTL_PFCR_MIN_LA_Pos 1U /*!< MEMSYSCTL PFCR: MIN_LA Position */ +#define MEMSYSCTL_PFCR_MIN_LA_Msk (0x7UL << MEMSYSCTL_PFCR_MIN_LA_Pos) /*!< MEMSYSCTL PFCR: MIN_LA Mask */ + +#define MEMSYSCTL_PFCR_ENABLE_Pos 0U /*!< MEMSYSCTL PFCR: ENABLE Position */ +#define MEMSYSCTL_PFCR_ENABLE_Msk (0x1UL /*<< MEMSYSCTL_PFCR_ENABLE_Pos*/) /*!< MEMSYSCTL PFCR: ENABLE Mask */ + +/* MEMSYSCTL ITCM Control Register (ITCMCR) Register Definitions */ +#define MEMSYSCTL_ITCMCR_SZ_Pos 3U /*!< MEMSYSCTL ITCMCR: SZ Position */ +#define MEMSYSCTL_ITCMCR_SZ_Msk (0xFUL << MEMSYSCTL_ITCMCR_SZ_Pos) /*!< MEMSYSCTL ITCMCR: SZ Mask */ + +#define MEMSYSCTL_ITCMCR_EN_Pos 0U /*!< MEMSYSCTL ITCMCR: EN Position */ +#define MEMSYSCTL_ITCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_ITCMCR_EN_Pos*/) /*!< MEMSYSCTL ITCMCR: EN Mask */ + +/* MEMSYSCTL DTCM Control Register (DTCMCR) Register Definitions */ +#define MEMSYSCTL_DTCMCR_SZ_Pos 3U /*!< MEMSYSCTL DTCMCR: SZ Position */ +#define MEMSYSCTL_DTCMCR_SZ_Msk (0xFUL << MEMSYSCTL_DTCMCR_SZ_Pos) /*!< MEMSYSCTL DTCMCR: SZ Mask */ + +#define MEMSYSCTL_DTCMCR_EN_Pos 0U /*!< MEMSYSCTL DTCMCR: EN Position */ +#define MEMSYSCTL_DTCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_DTCMCR_EN_Pos*/) /*!< MEMSYSCTL DTCMCR: EN Mask */ + +/* MEMSYSCTL P-AHB Control Register (PAHBCR) Register Definitions */ +#define MEMSYSCTL_PAHBCR_SZ_Pos 1U /*!< MEMSYSCTL PAHBCR: SZ Position */ +#define MEMSYSCTL_PAHBCR_SZ_Msk (0x7UL << MEMSYSCTL_PAHBCR_SZ_Pos) /*!< MEMSYSCTL PAHBCR: SZ Mask */ + +#define MEMSYSCTL_PAHBCR_EN_Pos 0U /*!< MEMSYSCTL PAHBCR: EN Position */ +#define MEMSYSCTL_PAHBCR_EN_Msk (0x1UL /*<< MEMSYSCTL_PAHBCR_EN_Pos*/) /*!< MEMSYSCTL PAHBCR: EN Mask */ + +/* MEMSYSCTL ITGU Control Register (ITGU_CTRL) Register Definitions */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL ITGU_CTRL: DEREN Position */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_ITGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL ITGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL ITGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_ITGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL ITGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL ITGU Configuration Register (ITGU_CFG) Register Definitions */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL ITGU_CFG: PRESENT Position */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_ITGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL ITGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL ITGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_ITGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL ITGU_CFG: BLKSZ Mask */ + +/* MEMSYSCTL DTGU Control Registers (DTGU_CTRL) Register Definitions */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL DTGU_CTRL: DEREN Position */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_DTGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL DTGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL DTGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_DTGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL DTGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL DTGU Configuration Register (DTGU_CFG) Register Definitions */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL DTGU_CFG: PRESENT Position */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_DTGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL DTGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL DTGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_DTGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL DTGU_CFG: BLKSZ Mask */ + + +/*@}*/ /* end of group MemSysCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PwrModCtl_Type Power Mode Control Registers + \brief Type definitions for the Power Mode Control Registers (PWRMODCTL) + @{ + */ + +/** + \brief Structure type to access the Power Mode Control Registers (PWRMODCTL). + */ +typedef struct +{ + __IOM uint32_t CPDLPSTATE; /*!< Offset: 0x000 (R/W) Core Power Domain Low Power State Register */ + __IOM uint32_t DPDLPSTATE; /*!< Offset: 0x004 (R/W) Debug Power Domain Low Power State Register */ +} PwrModCtl_Type; + +/* PWRMODCTL Core Power Domain Low Power State (CPDLPSTATE) Register Definitions */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos 8U /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos 4U /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos 0U /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Msk (0x3UL /*<< PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos*/) /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Mask */ + +/* PWRMODCTL Debug Power Domain Low Power State (DPDLPSTATE) Register Definitions */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos 0U /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Position */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Msk (0x3UL /*<< PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos*/) /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Mask */ + +/*@}*/ /* end of group PwrModCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup EWIC_Type External Wakeup Interrupt Controller Registers + \brief Type definitions for the External Wakeup Interrupt Controller Registers (EWIC) + @{ + */ + +/** + \brief Structure type to access the External Wakeup Interrupt Controller Registers (EWIC). + */ +typedef struct +{ + __OM uint32_t EVENTSPR; /*!< Offset: 0x000 ( /W) Event Set Pending Register */ + uint32_t RESERVED0[31U]; + __IM uint32_t EVENTMASKA; /*!< Offset: 0x080 (R/W) Event Mask A Register */ + __IM uint32_t EVENTMASK[15]; /*!< Offset: 0x084 (R/W) Event Mask Register */ +} EWIC_Type; + +/* EWIC External Wakeup Interrupt Controller (EVENTSPR) Register Definitions */ +#define EWIC_EVENTSPR_EDBGREQ_Pos 2U /*!< EWIC EVENTSPR: EDBGREQ Position */ +#define EWIC_EVENTSPR_EDBGREQ_Msk (0x1UL << EWIC_EVENTSPR_EDBGREQ_Pos) /*!< EWIC EVENTSPR: EDBGREQ Mask */ + +#define EWIC_EVENTSPR_NMI_Pos 1U /*!< EWIC EVENTSPR: NMI Position */ +#define EWIC_EVENTSPR_NMI_Msk (0x1UL << EWIC_EVENTSPR_NMI_Pos) /*!< EWIC EVENTSPR: NMI Mask */ + +#define EWIC_EVENTSPR_EVENT_Pos 0U /*!< EWIC EVENTSPR: EVENT Position */ +#define EWIC_EVENTSPR_EVENT_Msk (0x1UL /*<< EWIC_EVENTSPR_EVENT_Pos*/) /*!< EWIC EVENTSPR: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASKA) Register Definitions */ +#define EWIC_EVENTMASKA_EDBGREQ_Pos 2U /*!< EWIC EVENTMASKA: EDBGREQ Position */ +#define EWIC_EVENTMASKA_EDBGREQ_Msk (0x1UL << EWIC_EVENTMASKA_EDBGREQ_Pos) /*!< EWIC EVENTMASKA: EDBGREQ Mask */ + +#define EWIC_EVENTMASKA_NMI_Pos 1U /*!< EWIC EVENTMASKA: NMI Position */ +#define EWIC_EVENTMASKA_NMI_Msk (0x1UL << EWIC_EVENTMASKA_NMI_Pos) /*!< EWIC EVENTMASKA: NMI Mask */ + +#define EWIC_EVENTMASKA_EVENT_Pos 0U /*!< EWIC EVENTMASKA: EVENT Position */ +#define EWIC_EVENTMASKA_EVENT_Msk (0x1UL /*<< EWIC_EVENTMASKA_EVENT_Pos*/) /*!< EWIC EVENTMASKA: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASK) Register Definitions */ +#define EWIC_EVENTMASK_IRQ_Pos 0U /*!< EWIC EVENTMASKA: IRQ Position */ +#define EWIC_EVENTMASK_IRQ_Msk (0xFFFFFFFFUL /*<< EWIC_EVENTMASKA_IRQ_Pos*/) /*!< EWIC EVENTMASKA: IRQ Mask */ + +/*@}*/ /* end of group EWIC_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup ErrBnk_Type Error Banking Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Error Banking Registers (ERRBNK) + @{ + */ + +/** + \brief Structure type to access the Error Banking Registers (ERRBNK). + */ +typedef struct +{ + __IOM uint32_t IEBR0; /*!< Offset: 0x000 (R/W) Instruction Cache Error Bank Register 0 */ + __IOM uint32_t IEBR1; /*!< Offset: 0x004 (R/W) Instruction Cache Error Bank Register 1 */ + uint32_t RESERVED0[2U]; + __IOM uint32_t DEBR0; /*!< Offset: 0x010 (R/W) Data Cache Error Bank Register 0 */ + __IOM uint32_t DEBR1; /*!< Offset: 0x014 (R/W) Data Cache Error Bank Register 1 */ + uint32_t RESERVED1[2U]; + __IOM uint32_t TEBR0; /*!< Offset: 0x020 (R/W) TCM Error Bank Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t TEBR1; /*!< Offset: 0x028 (R/W) TCM Error Bank Register 1 */ +} ErrBnk_Type; + +/* ERRBNK Instruction Cache Error Bank Register 0 (IEBR0) Register Definitions */ +#define ERRBNK_IEBR0_SWDEF_Pos 30U /*!< ERRBNK IEBR0: SWDEF Position */ +#define ERRBNK_IEBR0_SWDEF_Msk (0x3UL << ERRBNK_IEBR0_SWDEF_Pos) /*!< ERRBNK IEBR0: SWDEF Mask */ + +#define ERRBNK_IEBR0_BANK_Pos 16U /*!< ERRBNK IEBR0: BANK Position */ +#define ERRBNK_IEBR0_BANK_Msk (0x1UL << ERRBNK_IEBR0_BANK_Pos) /*!< ERRBNK IEBR0: BANK Mask */ + +#define ERRBNK_IEBR0_LOCATION_Pos 2U /*!< ERRBNK IEBR0: LOCATION Position */ +#define ERRBNK_IEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR0_LOCATION_Pos) /*!< ERRBNK IEBR0: LOCATION Mask */ + +#define ERRBNK_IEBR0_LOCKED_Pos 1U /*!< ERRBNK IEBR0: LOCKED Position */ +#define ERRBNK_IEBR0_LOCKED_Msk (0x1UL << ERRBNK_IEBR0_LOCKED_Pos) /*!< ERRBNK IEBR0: LOCKED Mask */ + +#define ERRBNK_IEBR0_VALID_Pos 0U /*!< ERRBNK IEBR0: VALID Position */ +#define ERRBNK_IEBR0_VALID_Msk (0x1UL << /*ERRBNK_IEBR0_VALID_Pos*/) /*!< ERRBNK IEBR0: VALID Mask */ + +/* ERRBNK Instruction Cache Error Bank Register 1 (IEBR1) Register Definitions */ +#define ERRBNK_IEBR1_SWDEF_Pos 30U /*!< ERRBNK IEBR1: SWDEF Position */ +#define ERRBNK_IEBR1_SWDEF_Msk (0x3UL << ERRBNK_IEBR1_SWDEF_Pos) /*!< ERRBNK IEBR1: SWDEF Mask */ + +#define ERRBNK_IEBR1_BANK_Pos 16U /*!< ERRBNK IEBR1: BANK Position */ +#define ERRBNK_IEBR1_BANK_Msk (0x1UL << ERRBNK_IEBR1_BANK_Pos) /*!< ERRBNK IEBR1: BANK Mask */ + +#define ERRBNK_IEBR1_LOCATION_Pos 2U /*!< ERRBNK IEBR1: LOCATION Position */ +#define ERRBNK_IEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR1_LOCATION_Pos) /*!< ERRBNK IEBR1: LOCATION Mask */ + +#define ERRBNK_IEBR1_LOCKED_Pos 1U /*!< ERRBNK IEBR1: LOCKED Position */ +#define ERRBNK_IEBR1_LOCKED_Msk (0x1UL << ERRBNK_IEBR1_LOCKED_Pos) /*!< ERRBNK IEBR1: LOCKED Mask */ + +#define ERRBNK_IEBR1_VALID_Pos 0U /*!< ERRBNK IEBR1: VALID Position */ +#define ERRBNK_IEBR1_VALID_Msk (0x1UL << /*ERRBNK_IEBR1_VALID_Pos*/) /*!< ERRBNK IEBR1: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 0 (DEBR0) Register Definitions */ +#define ERRBNK_DEBR0_SWDEF_Pos 30U /*!< ERRBNK DEBR0: SWDEF Position */ +#define ERRBNK_DEBR0_SWDEF_Msk (0x3UL << ERRBNK_DEBR0_SWDEF_Pos) /*!< ERRBNK DEBR0: SWDEF Mask */ + +#define ERRBNK_DEBR0_TYPE_Pos 17U /*!< ERRBNK DEBR0: TYPE Position */ +#define ERRBNK_DEBR0_TYPE_Msk (0x1UL << ERRBNK_DEBR0_TYPE_Pos) /*!< ERRBNK DEBR0: TYPE Mask */ + +#define ERRBNK_DEBR0_BANK_Pos 16U /*!< ERRBNK DEBR0: BANK Position */ +#define ERRBNK_DEBR0_BANK_Msk (0x1UL << ERRBNK_DEBR0_BANK_Pos) /*!< ERRBNK DEBR0: BANK Mask */ + +#define ERRBNK_DEBR0_LOCATION_Pos 2U /*!< ERRBNK DEBR0: LOCATION Position */ +#define ERRBNK_DEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR0_LOCATION_Pos) /*!< ERRBNK DEBR0: LOCATION Mask */ + +#define ERRBNK_DEBR0_LOCKED_Pos 1U /*!< ERRBNK DEBR0: LOCKED Position */ +#define ERRBNK_DEBR0_LOCKED_Msk (0x1UL << ERRBNK_DEBR0_LOCKED_Pos) /*!< ERRBNK DEBR0: LOCKED Mask */ + +#define ERRBNK_DEBR0_VALID_Pos 0U /*!< ERRBNK DEBR0: VALID Position */ +#define ERRBNK_DEBR0_VALID_Msk (0x1UL << /*ERRBNK_DEBR0_VALID_Pos*/) /*!< ERRBNK DEBR0: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 1 (DEBR1) Register Definitions */ +#define ERRBNK_DEBR1_SWDEF_Pos 30U /*!< ERRBNK DEBR1: SWDEF Position */ +#define ERRBNK_DEBR1_SWDEF_Msk (0x3UL << ERRBNK_DEBR1_SWDEF_Pos) /*!< ERRBNK DEBR1: SWDEF Mask */ + +#define ERRBNK_DEBR1_TYPE_Pos 17U /*!< ERRBNK DEBR1: TYPE Position */ +#define ERRBNK_DEBR1_TYPE_Msk (0x1UL << ERRBNK_DEBR1_TYPE_Pos) /*!< ERRBNK DEBR1: TYPE Mask */ + +#define ERRBNK_DEBR1_BANK_Pos 16U /*!< ERRBNK DEBR1: BANK Position */ +#define ERRBNK_DEBR1_BANK_Msk (0x1UL << ERRBNK_DEBR1_BANK_Pos) /*!< ERRBNK DEBR1: BANK Mask */ + +#define ERRBNK_DEBR1_LOCATION_Pos 2U /*!< ERRBNK DEBR1: LOCATION Position */ +#define ERRBNK_DEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR1_LOCATION_Pos) /*!< ERRBNK DEBR1: LOCATION Mask */ + +#define ERRBNK_DEBR1_LOCKED_Pos 1U /*!< ERRBNK DEBR1: LOCKED Position */ +#define ERRBNK_DEBR1_LOCKED_Msk (0x1UL << ERRBNK_DEBR1_LOCKED_Pos) /*!< ERRBNK DEBR1: LOCKED Mask */ + +#define ERRBNK_DEBR1_VALID_Pos 0U /*!< ERRBNK DEBR1: VALID Position */ +#define ERRBNK_DEBR1_VALID_Msk (0x1UL << /*ERRBNK_DEBR1_VALID_Pos*/) /*!< ERRBNK DEBR1: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 0 (TEBR0) Register Definitions */ +#define ERRBNK_TEBR0_SWDEF_Pos 30U /*!< ERRBNK TEBR0: SWDEF Position */ +#define ERRBNK_TEBR0_SWDEF_Msk (0x3UL << ERRBNK_TEBR0_SWDEF_Pos) /*!< ERRBNK TEBR0: SWDEF Mask */ + +#define ERRBNK_TEBR0_POISON_Pos 28U /*!< ERRBNK TEBR0: POISON Position */ +#define ERRBNK_TEBR0_POISON_Msk (0x1UL << ERRBNK_TEBR0_POISON_Pos) /*!< ERRBNK TEBR0: POISON Mask */ + +#define ERRBNK_TEBR0_TYPE_Pos 27U /*!< ERRBNK TEBR0: TYPE Position */ +#define ERRBNK_TEBR0_TYPE_Msk (0x1UL << ERRBNK_TEBR0_TYPE_Pos) /*!< ERRBNK TEBR0: TYPE Mask */ + +#define ERRBNK_TEBR0_BANK_Pos 24U /*!< ERRBNK TEBR0: BANK Position */ +#define ERRBNK_TEBR0_BANK_Msk (0x3UL << ERRBNK_TEBR0_BANK_Pos) /*!< ERRBNK TEBR0: BANK Mask */ + +#define ERRBNK_TEBR0_LOCATION_Pos 2U /*!< ERRBNK TEBR0: LOCATION Position */ +#define ERRBNK_TEBR0_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR0_LOCATION_Pos) /*!< ERRBNK TEBR0: LOCATION Mask */ + +#define ERRBNK_TEBR0_LOCKED_Pos 1U /*!< ERRBNK TEBR0: LOCKED Position */ +#define ERRBNK_TEBR0_LOCKED_Msk (0x1UL << ERRBNK_TEBR0_LOCKED_Pos) /*!< ERRBNK TEBR0: LOCKED Mask */ + +#define ERRBNK_TEBR0_VALID_Pos 0U /*!< ERRBNK TEBR0: VALID Position */ +#define ERRBNK_TEBR0_VALID_Msk (0x1UL << /*ERRBNK_TEBR0_VALID_Pos*/) /*!< ERRBNK TEBR0: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 1 (TEBR1) Register Definitions */ +#define ERRBNK_TEBR1_SWDEF_Pos 30U /*!< ERRBNK TEBR1: SWDEF Position */ +#define ERRBNK_TEBR1_SWDEF_Msk (0x3UL << ERRBNK_TEBR1_SWDEF_Pos) /*!< ERRBNK TEBR1: SWDEF Mask */ + +#define ERRBNK_TEBR1_POISON_Pos 28U /*!< ERRBNK TEBR1: POISON Position */ +#define ERRBNK_TEBR1_POISON_Msk (0x1UL << ERRBNK_TEBR1_POISON_Pos) /*!< ERRBNK TEBR1: POISON Mask */ + +#define ERRBNK_TEBR1_TYPE_Pos 27U /*!< ERRBNK TEBR1: TYPE Position */ +#define ERRBNK_TEBR1_TYPE_Msk (0x1UL << ERRBNK_TEBR1_TYPE_Pos) /*!< ERRBNK TEBR1: TYPE Mask */ + +#define ERRBNK_TEBR1_BANK_Pos 24U /*!< ERRBNK TEBR1: BANK Position */ +#define ERRBNK_TEBR1_BANK_Msk (0x3UL << ERRBNK_TEBR1_BANK_Pos) /*!< ERRBNK TEBR1: BANK Mask */ + +#define ERRBNK_TEBR1_LOCATION_Pos 2U /*!< ERRBNK TEBR1: LOCATION Position */ +#define ERRBNK_TEBR1_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR1_LOCATION_Pos) /*!< ERRBNK TEBR1: LOCATION Mask */ + +#define ERRBNK_TEBR1_LOCKED_Pos 1U /*!< ERRBNK TEBR1: LOCKED Position */ +#define ERRBNK_TEBR1_LOCKED_Msk (0x1UL << ERRBNK_TEBR1_LOCKED_Pos) /*!< ERRBNK TEBR1: LOCKED Mask */ + +#define ERRBNK_TEBR1_VALID_Pos 0U /*!< ERRBNK TEBR1: VALID Position */ +#define ERRBNK_TEBR1_VALID_Msk (0x1UL << /*ERRBNK_TEBR1_VALID_Pos*/) /*!< ERRBNK TEBR1: VALID Mask */ + +/*@}*/ /* end of group ErrBnk_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PrcCfgInf_Type Processor Configuration Information Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Processor Configuration Information Registerss (PRCCFGINF) + @{ + */ + +/** + \brief Structure type to access the Processor Configuration Information Registerss (PRCCFGINF). + */ +typedef struct +{ + __OM uint32_t CFGINFOSEL; /*!< Offset: 0x000 ( /W) Processor Configuration Information Selection Register */ + __IM uint32_t CFGINFORD; /*!< Offset: 0x004 (R/ ) Processor Configuration Information Read Data Register */ +} PrcCfgInf_Type; + +/* PRCCFGINF Processor Configuration Information Selection Register (CFGINFOSEL) Definitions */ + +/* PRCCFGINF Processor Configuration Information Read Data Register (CFGINFORD) Definitions */ + +/*@}*/ /* end of group PrcCfgInf_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup STL_Type Software Test Library Observation Registers + \brief Type definitions for the Software Test Library Observation Registerss (STL) + @{ + */ + +/** + \brief Structure type to access the Software Test Library Observation Registerss (STL). + */ +typedef struct +{ + __IM uint32_t STLNVICPENDOR; /*!< Offset: 0x000 (R/ ) NVIC Pending Priority Tree Register */ + __IM uint32_t STLNVICACTVOR; /*!< Offset: 0x004 (R/ ) NVIC Active Priority Tree Register */ + uint32_t RESERVED0[2U]; + __OM uint32_t STLIDMPUSR; /*!< Offset: 0x010 ( /W) MPU Sanple Register */ + __IM uint32_t STLIMPUOR; /*!< Offset: 0x014 (R/ ) MPU Region Hit Register */ + __IM uint32_t STLD0MPUOR; /*!< Offset: 0x018 (R/ ) MPU Memory Attributes Register 0 */ + __IM uint32_t STLD1MPUOR; /*!< Offset: 0x01C (R/ ) MPU Memory Attributes Register 1 */ + +} STL_Type; + +/* STL Software Test Library Observation Register (STLNVICPENDOR) Definitions */ +#define STL_STLNVICPENDOR_VALID_Pos 18U /*!< STL STLNVICPENDOR: VALID Position */ +#define STL_STLNVICPENDOR_VALID_Msk (0x1UL << STL_STLNVICPENDOR_VALID_Pos) /*!< STL STLNVICPENDOR: VALID Mask */ + +#define STL_STLNVICPENDOR_TARGET_Pos 17U /*!< STL STLNVICPENDOR: TARGET Position */ +#define STL_STLNVICPENDOR_TARGET_Msk (0x1UL << STL_STLNVICPENDOR_TARGET_Pos) /*!< STL STLNVICPENDOR: TARGET Mask */ + +#define STL_STLNVICPENDOR_PRIORITY_Pos 9U /*!< STL STLNVICPENDOR: PRIORITY Position */ +#define STL_STLNVICPENDOR_PRIORITY_Msk (0xFFUL << STL_STLNVICPENDOR_PRIORITY_Pos) /*!< STL STLNVICPENDOR: PRIORITY Mask */ + +#define STL_STLNVICPENDOR_INTNUM_Pos 0U /*!< STL STLNVICPENDOR: INTNUM Position */ +#define STL_STLNVICPENDOR_INTNUM_Msk (0x1FFUL /*<< STL_STLNVICPENDOR_INTNUM_Pos*/) /*!< STL STLNVICPENDOR: INTNUM Mask */ + +/* STL Software Test Library Observation Register (STLNVICACTVOR) Definitions */ +#define STL_STLNVICACTVOR_VALID_Pos 18U /*!< STL STLNVICACTVOR: VALID Position */ +#define STL_STLNVICACTVOR_VALID_Msk (0x1UL << STL_STLNVICACTVOR_VALID_Pos) /*!< STL STLNVICACTVOR: VALID Mask */ + +#define STL_STLNVICACTVOR_TARGET_Pos 17U /*!< STL STLNVICACTVOR: TARGET Position */ +#define STL_STLNVICACTVOR_TARGET_Msk (0x1UL << STL_STLNVICACTVOR_TARGET_Pos) /*!< STL STLNVICACTVOR: TARGET Mask */ + +#define STL_STLNVICACTVOR_PRIORITY_Pos 9U /*!< STL STLNVICACTVOR: PRIORITY Position */ +#define STL_STLNVICACTVOR_PRIORITY_Msk (0xFFUL << STL_STLNVICACTVOR_PRIORITY_Pos) /*!< STL STLNVICACTVOR: PRIORITY Mask */ + +#define STL_STLNVICACTVOR_INTNUM_Pos 0U /*!< STL STLNVICACTVOR: INTNUM Position */ +#define STL_STLNVICACTVOR_INTNUM_Msk (0x1FFUL /*<< STL_STLNVICACTVOR_INTNUM_Pos*/) /*!< STL STLNVICACTVOR: INTNUM Mask */ + +/* STL Software Test Library Observation Register (STLIDMPUSR) Definitions */ +#define STL_STLIDMPUSR_ADDR_Pos 5U /*!< STL STLIDMPUSR: ADDR Position */ +#define STL_STLIDMPUSR_ADDR_Msk (0x7FFFFFFUL << STL_STLIDMPUSR_ADDR_Pos) /*!< STL STLIDMPUSR: ADDR Mask */ + +#define STL_STLIDMPUSR_INSTR_Pos 2U /*!< STL STLIDMPUSR: INSTR Position */ +#define STL_STLIDMPUSR_INSTR_Msk (0x1UL << STL_STLIDMPUSR_INSTR_Pos) /*!< STL STLIDMPUSR: INSTR Mask */ + +#define STL_STLIDMPUSR_DATA_Pos 1U /*!< STL STLIDMPUSR: DATA Position */ +#define STL_STLIDMPUSR_DATA_Msk (0x1UL << STL_STLIDMPUSR_DATA_Pos) /*!< STL STLIDMPUSR: DATA Mask */ + +/* STL Software Test Library Observation Register (STLIMPUOR) Definitions */ +#define STL_STLIMPUOR_HITREGION_Pos 9U /*!< STL STLIMPUOR: HITREGION Position */ +#define STL_STLIMPUOR_HITREGION_Msk (0xFFUL << STL_STLIMPUOR_HITREGION_Pos) /*!< STL STLIMPUOR: HITREGION Mask */ + +#define STL_STLIMPUOR_ATTR_Pos 0U /*!< STL STLIMPUOR: ATTR Position */ +#define STL_STLIMPUOR_ATTR_Msk (0x1FFUL /*<< STL_STLIMPUOR_ATTR_Pos*/) /*!< STL STLIMPUOR: ATTR Mask */ + +/* STL Software Test Library Observation Register (STLD0MPUOR) Definitions */ +#define STL_STLD0MPUOR_HITREGION_Pos 9U /*!< STL STLD0MPUOR: HITREGION Position */ +#define STL_STLD0MPUOR_HITREGION_Msk (0xFFUL << STL_STLD0MPUOR_HITREGION_Pos) /*!< STL STLD0MPUOR: HITREGION Mask */ + +#define STL_STLD0MPUOR_ATTR_Pos 0U /*!< STL STLD0MPUOR: ATTR Position */ +#define STL_STLD0MPUOR_ATTR_Msk (0x1FFUL /*<< STL_STLD0MPUOR_ATTR_Pos*/) /*!< STL STLD0MPUOR: ATTR Mask */ + +/* STL Software Test Library Observation Register (STLD1MPUOR) Definitions */ +#define STL_STLD1MPUOR_HITREGION_Pos 9U /*!< STL STLD1MPUOR: HITREGION Position */ +#define STL_STLD1MPUOR_HITREGION_Msk (0xFFUL << STL_STLD1MPUOR_HITREGION_Pos) /*!< STL STLD1MPUOR: HITREGION Mask */ + +#define STL_STLD1MPUOR_ATTR_Pos 0U /*!< STL STLD1MPUOR: ATTR Position */ +#define STL_STLD1MPUOR_ATTR_Msk (0x1FFUL /*<< STL_STLD1MPUOR_ATTR_Pos*/) /*!< STL STLD1MPUOR: ATTR Mask */ + +/*@}*/ /* end of group STL_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[3]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE4 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE8 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFEC (R/W) PMU Peripheral Identification Register 3 */ + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (0xFFFFUL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (0xFFFFUL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (0xFFUL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (0x3FUL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/** \brief PMU Authentication Status Register Definitions */ + +#define PMU_AUTHSTATUS_NSID_Pos 0U /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSID_Msk (0x3UL /*<< PMU_AUTHSTATUS_NSID_Pos*/) /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSNID_Pos 2U /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSNID_Msk (0x3UL << PMU_AUTHSTATUS_NSNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SID_Pos 4U /*!< PMU AUTHSTATUS: Secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_SID_Msk (0x3UL << PMU_AUTHSTATUS_SID_Pos) /*!< PMU AUTHSTATUS: Secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SNID_Pos 6U /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SNID_Msk (0x3UL << PMU_AUTHSTATUS_SNID_Pos) /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUID_Pos 16U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUID_Msk (0x3UL << PMU_AUTHSTATUS_NSUID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUNID_Pos 18U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUNID_Msk (0x3UL << PMU_AUTHSTATUS_NSUNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUID_Pos 20U /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_SUID_Msk (0x3UL << PMU_AUTHSTATUS_SUID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUNID_Pos 22U /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SUNID_Msk (0x3UL << PMU_AUTHSTATUS_SUNID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Mask */ + + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define MEMSYSCTL_BASE (0xE001E000UL) /*!< Memory System Control Base Address */ + #define ERRBNK_BASE (0xE001E100UL) /*!< Error Banking Base Address */ + #define PWRMODCTL_BASE (0xE001E300UL) /*!< Power Mode Control Base Address */ + #define EWIC_BASE (0xE001E400UL) /*!< External Wakeup Interrupt Controller Base Address */ + #define PRCCFGINF_BASE (0xE001E700UL) /*!< Processor Configuration Information Base Address */ + #define STL_BASE (0xE001E800UL) /*!< Software Test Library Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define ICB ((ICB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define MEMSYSCTL ((MemSysCtl_Type *) MEMSYSCTL_BASE ) /*!< Memory System Control configuration struct */ + #define ERRBNK ((ErrBnk_Type *) ERRBNK_BASE ) /*!< Error Banking configuration struct */ + #define PWRMODCTL ((PwrModCtl_Type *) PWRMODCTL_BASE ) /*!< Power Mode Control configuration struct */ + #define EWIC ((EWIC_Type *) EWIC_BASE ) /*!< EWIC configuration struct */ + #define PRCCFGINF ((PrcCfgInf_Type *) PRCCFGINF_BASE ) /*!< Processor Configuration Information configuration struct */ + #define STL ((STL_Type *) STL_BASE ) /*!< Software Test Library configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define ICB_NS ((ICB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ +#define ID_ADR (ID_AFR) /*!< SCB Auxiliary Feature Register */ + +/* 'SCnSCB' is deprecated and replaced by 'ICB' */ +typedef ICB_Type SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISCRITAXIRUW_Pos (ICB_ACTLR_DISCRITAXIRUW_Pos) +#define SCnSCB_ACTLR_DISCRITAXIRUW_Msk (ICB_ACTLR_DISCRITAXIRUW_Msk) + +#define SCnSCB_ACTLR_DISDI_Pos (ICB_ACTLR_DISDI_Pos) +#define SCnSCB_ACTLR_DISDI_Msk (ICB_ACTLR_DISDI_Msk) + +#define SCnSCB_ACTLR_DISCRITAXIRUR_Pos (ICB_ACTLR_DISCRITAXIRUR_Pos) +#define SCnSCB_ACTLR_DISCRITAXIRUR_Msk (ICB_ACTLR_DISCRITAXIRUR_Msk) + +#define SCnSCB_ACTLR_EVENTBUSEN_Pos (ICB_ACTLR_EVENTBUSEN_Pos) +#define SCnSCB_ACTLR_EVENTBUSEN_Msk (ICB_ACTLR_EVENTBUSEN_Msk) + +#define SCnSCB_ACTLR_EVENTBUSEN_S_Pos (ICB_ACTLR_EVENTBUSEN_S_Pos) +#define SCnSCB_ACTLR_EVENTBUSEN_S_Msk (ICB_ACTLR_EVENTBUSEN_S_Msk) + +#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos (ICB_ACTLR_DISITMATBFLUSH_Pos) +#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (ICB_ACTLR_DISITMATBFLUSH_Msk) + +#define SCnSCB_ACTLR_DISNWAMODE_Pos (ICB_ACTLR_DISNWAMODE_Pos) +#define SCnSCB_ACTLR_DISNWAMODE_Msk (ICB_ACTLR_DISNWAMODE_Msk) + +#define SCnSCB_ACTLR_FPEXCODIS_Pos (ICB_ACTLR_FPEXCODIS_Pos) +#define SCnSCB_ACTLR_FPEXCODIS_Msk (ICB_ACTLR_FPEXCODIS_Msk) + +#define SCnSCB_ACTLR_DISOLAP_Pos (ICB_ACTLR_DISOLAP_Pos) +#define SCnSCB_ACTLR_DISOLAP_Msk (ICB_ACTLR_DISOLAP_Msk) + +#define SCnSCB_ACTLR_DISOLAPS_Pos (ICB_ACTLR_DISOLAPS_Pos) +#define SCnSCB_ACTLR_DISOLAPS_Msk (ICB_ACTLR_DISOLAPS_Msk) + +#define SCnSCB_ACTLR_DISLOBR_Pos (ICB_ACTLR_DISLOBR_Pos) +#define SCnSCB_ACTLR_DISLOBR_Msk (ICB_ACTLR_DISLOBR_Msk) + +#define SCnSCB_ACTLR_DISLO_Pos (ICB_ACTLR_DISLO_Pos) +#define SCnSCB_ACTLR_DISLO_Msk (ICB_ACTLR_DISLO_Msk) + +#define SCnSCB_ACTLR_DISLOLEP_Pos (ICB_ACTLR_DISLOLEP_Pos) +#define SCnSCB_ACTLR_DISLOLEP_Msk (ICB_ACTLR_DISLOLEP_Msk) + +#define SCnSCB_ACTLR_DISFOLD_Pos (ICB_ACTLR_DISFOLD_Pos) +#define SCnSCB_ACTLR_DISFOLD_Msk (ICB_ACTLR_DISFOLD_Msk) + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos (ICB_ICTR_INTLINESNUM_Pos) +#define SCnSCB_ICTR_INTLINESNUM_Msk (ICB_ICTR_INTLINESNUM_Msk) + +#define SCnSCB (ICB) +#define SCnSCB_NS (ICB_NS) + +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +/** + \brief Cortex-M55 PMU events + \note Architectural PMU events can be found in pmu_armv8.h +*/ + +#define ARMCM55_PMU_ECC_ERR 0xC000 /*!< Any ECC error */ +#define ARMCM55_PMU_ECC_ERR_FATAL 0xC001 /*!< Any fatal ECC error */ +#define ARMCM55_PMU_ECC_ERR_DCACHE 0xC010 /*!< Any ECC error in the data cache */ +#define ARMCM55_PMU_ECC_ERR_ICACHE 0xC011 /*!< Any ECC error in the instruction cache */ +#define ARMCM55_PMU_ECC_ERR_FATAL_DCACHE 0xC012 /*!< Any fatal ECC error in the data cache */ +#define ARMCM55_PMU_ECC_ERR_FATAL_ICACHE 0xC013 /*!< Any fatal ECC error in the instruction cache*/ +#define ARMCM55_PMU_ECC_ERR_DTCM 0xC020 /*!< Any ECC error in the DTCM */ +#define ARMCM55_PMU_ECC_ERR_ITCM 0xC021 /*!< Any ECC error in the ITCM */ +#define ARMCM55_PMU_ECC_ERR_FATAL_DTCM 0xC022 /*!< Any fatal ECC error in the DTCM */ +#define ARMCM55_PMU_ECC_ERR_FATAL_ITCM 0xC023 /*!< Any fatal ECC error in the ITCM */ +#define ARMCM55_PMU_PF_LINEFILL 0xC100 /*!< A prefetcher starts a line-fill */ +#define ARMCM55_PMU_PF_CANCEL 0xC101 /*!< A prefetcher stops prefetching */ +#define ARMCM55_PMU_PF_DROP_LINEFILL 0xC102 /*!< A linefill triggered by a prefetcher has been dropped because of lack of buffering */ +#define ARMCM55_PMU_NWAMODE_ENTER 0xC200 /*!< No write-allocate mode entry */ +#define ARMCM55_PMU_NWAMODE 0xC201 /*!< Write-allocate store is not allocated into the data cache due to no-write-allocate mode */ +#define ARMCM55_PMU_SAHB_ACCESS 0xC300 /*!< Read or write access on the S-AHB interface to the TCM */ +#define ARMCM55_PMU_PAHB_ACCESS 0xC301 /*!< Read or write access to the P-AHB write interface */ +#define ARMCM55_PMU_AXI_WRITE_ACCESS 0xC302 /*!< Any beat access to M-AXI write interface */ +#define ARMCM55_PMU_AXI_READ_ACCESS 0xC303 /*!< Any beat access to M-AXI read interface */ +#define ARMCM55_PMU_DOSTIMEOUT_DOUBLE 0xC400 /*!< Denial of Service timeout has fired twice and caused buffers to drain to allow forward progress */ +#define ARMCM55_PMU_DOSTIMEOUT_TRIPLE 0xC401 /*!< Denial of Service timeout has fired three times and blocked the LSU to force forward progress */ + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM55_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h new file mode 100644 index 0000000000..010506e9fa --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm7.h @@ -0,0 +1,2366 @@ +/**************************************************************************//** + * @file core_cm7.h + * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File + * @version V5.1.6 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM7_H_GENERIC +#define __CORE_CM7_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M7 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM7 definitions */ +#define __CM7_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM7_CMSIS_VERSION_SUB ( __CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ + __CM7_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (7U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM7_H_DEPENDANT +#define __CORE_CM7_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM7_REV + #define __CM7_REV 0x0000U + #warning "__CM7_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DTCM_PRESENT + #define __DTCM_PRESENT 0U + #warning "__DTCM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M7 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[1U]; + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED3[93U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ + uint32_t RESERVED7[5U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x290 (R/W) Instruction Tightly-Coupled Memory Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x294 (R/W) Data Tightly-Coupled Memory Control Registers */ + __IOM uint32_t AHBPCR; /*!< Offset: 0x298 (R/W) AHBP Control Register */ + __IOM uint32_t CACR; /*!< Offset: 0x29C (R/W) L1 Cache Control Register */ + __IOM uint32_t AHBSCR; /*!< Offset: 0x2A0 (R/W) AHB Slave Control Register */ + uint32_t RESERVED8[1U]; + __IOM uint32_t ABFSR; /*!< Offset: 0x2A8 (R/W) Auxiliary Bus Fault Status Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: Branch prediction enable bit Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: Branch prediction enable bit Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: Instruction cache enable bit Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: Instruction cache enable bit Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: Cache enable bit Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: Cache enable bit Mask */ + +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/* Instruction Tightly-Coupled Memory Control Register Definitions */ +#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ +#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ + +#define SCB_ITCMCR_RETEN_Pos 2U /*!< SCB ITCMCR: RETEN Position */ +#define SCB_ITCMCR_RETEN_Msk (1UL << SCB_ITCMCR_RETEN_Pos) /*!< SCB ITCMCR: RETEN Mask */ + +#define SCB_ITCMCR_RMW_Pos 1U /*!< SCB ITCMCR: RMW Position */ +#define SCB_ITCMCR_RMW_Msk (1UL << SCB_ITCMCR_RMW_Pos) /*!< SCB ITCMCR: RMW Mask */ + +#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ +#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ + +/* Data Tightly-Coupled Memory Control Register Definitions */ +#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ +#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ + +#define SCB_DTCMCR_RETEN_Pos 2U /*!< SCB DTCMCR: RETEN Position */ +#define SCB_DTCMCR_RETEN_Msk (1UL << SCB_DTCMCR_RETEN_Pos) /*!< SCB DTCMCR: RETEN Mask */ + +#define SCB_DTCMCR_RMW_Pos 1U /*!< SCB DTCMCR: RMW Position */ +#define SCB_DTCMCR_RMW_Msk (1UL << SCB_DTCMCR_RMW_Pos) /*!< SCB DTCMCR: RMW Mask */ + +#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ +#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ + +/* AHBP Control Register Definitions */ +#define SCB_AHBPCR_SZ_Pos 1U /*!< SCB AHBPCR: SZ Position */ +#define SCB_AHBPCR_SZ_Msk (7UL << SCB_AHBPCR_SZ_Pos) /*!< SCB AHBPCR: SZ Mask */ + +#define SCB_AHBPCR_EN_Pos 0U /*!< SCB AHBPCR: EN Position */ +#define SCB_AHBPCR_EN_Msk (1UL /*<< SCB_AHBPCR_EN_Pos*/) /*!< SCB AHBPCR: EN Mask */ + +/* L1 Cache Control Register Definitions */ +#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ +#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ + +#define SCB_CACR_ECCEN_Pos 1U /*!< \deprecated SCB CACR: ECCEN Position */ +#define SCB_CACR_ECCEN_Msk (1UL << SCB_CACR_ECCEN_Pos) /*!< \deprecated SCB CACR: ECCEN Mask */ + +#define SCB_CACR_ECCDIS_Pos 1U /*!< SCB CACR: ECCDIS Position */ +#define SCB_CACR_ECCDIS_Msk (1UL << SCB_CACR_ECCDIS_Pos) /*!< SCB CACR: ECCDIS Mask */ + +#define SCB_CACR_SIWT_Pos 0U /*!< SCB CACR: SIWT Position */ +#define SCB_CACR_SIWT_Msk (1UL /*<< SCB_CACR_SIWT_Pos*/) /*!< SCB CACR: SIWT Mask */ + +/* AHBS Control Register Definitions */ +#define SCB_AHBSCR_INITCOUNT_Pos 11U /*!< SCB AHBSCR: INITCOUNT Position */ +#define SCB_AHBSCR_INITCOUNT_Msk (0x1FUL << SCB_AHBSCR_INITCOUNT_Pos) /*!< SCB AHBSCR: INITCOUNT Mask */ + +#define SCB_AHBSCR_TPRI_Pos 2U /*!< SCB AHBSCR: TPRI Position */ +#define SCB_AHBSCR_TPRI_Msk (0x1FFUL << SCB_AHBSCR_TPRI_Pos) /*!< SCB AHBSCR: TPRI Mask */ + +#define SCB_AHBSCR_CTL_Pos 0U /*!< SCB AHBSCR: CTL Position*/ +#define SCB_AHBSCR_CTL_Msk (3UL /*<< SCB_AHBSCR_CTL_Pos*/) /*!< SCB AHBSCR: CTL Mask */ + +/* Auxiliary Bus Fault Status Register Definitions */ +#define SCB_ABFSR_AXIMTYPE_Pos 8U /*!< SCB ABFSR: AXIMTYPE Position*/ +#define SCB_ABFSR_AXIMTYPE_Msk (3UL << SCB_ABFSR_AXIMTYPE_Pos) /*!< SCB ABFSR: AXIMTYPE Mask */ + +#define SCB_ABFSR_EPPB_Pos 4U /*!< SCB ABFSR: EPPB Position*/ +#define SCB_ABFSR_EPPB_Msk (1UL << SCB_ABFSR_EPPB_Pos) /*!< SCB ABFSR: EPPB Mask */ + +#define SCB_ABFSR_AXIM_Pos 3U /*!< SCB ABFSR: AXIM Position*/ +#define SCB_ABFSR_AXIM_Msk (1UL << SCB_ABFSR_AXIM_Pos) /*!< SCB ABFSR: AXIM Mask */ + +#define SCB_ABFSR_AHBP_Pos 2U /*!< SCB ABFSR: AHBP Position*/ +#define SCB_ABFSR_AHBP_Msk (1UL << SCB_ABFSR_AHBP_Pos) /*!< SCB ABFSR: AHBP Mask */ + +#define SCB_ABFSR_DTCM_Pos 1U /*!< SCB ABFSR: DTCM Position*/ +#define SCB_ABFSR_DTCM_Msk (1UL << SCB_ABFSR_DTCM_Pos) /*!< SCB ABFSR: DTCM Mask */ + +#define SCB_ABFSR_ITCM_Pos 0U /*!< SCB ABFSR: ITCM Position*/ +#define SCB_ABFSR_ITCM_Msk (1UL /*<< SCB_ABFSR_ITCM_Pos*/) /*!< SCB ABFSR: ITCM Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISDYNADD_Pos 26U /*!< ACTLR: DISDYNADD Position */ +#define SCnSCB_ACTLR_DISDYNADD_Msk (1UL << SCnSCB_ACTLR_DISDYNADD_Pos) /*!< ACTLR: DISDYNADD Mask */ + +#define SCnSCB_ACTLR_DISISSCH1_Pos 21U /*!< ACTLR: DISISSCH1 Position */ +#define SCnSCB_ACTLR_DISISSCH1_Msk (0x1FUL << SCnSCB_ACTLR_DISISSCH1_Pos) /*!< ACTLR: DISISSCH1 Mask */ + +#define SCnSCB_ACTLR_DISDI_Pos 16U /*!< ACTLR: DISDI Position */ +#define SCnSCB_ACTLR_DISDI_Msk (0x1FUL << SCnSCB_ACTLR_DISDI_Pos) /*!< ACTLR: DISDI Mask */ + +#define SCnSCB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define SCnSCB_ACTLR_DISCRITAXIRUR_Msk (1UL << SCnSCB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define SCnSCB_ACTLR_DISBTACALLOC_Pos 14U /*!< ACTLR: DISBTACALLOC Position */ +#define SCnSCB_ACTLR_DISBTACALLOC_Msk (1UL << SCnSCB_ACTLR_DISBTACALLOC_Pos) /*!< ACTLR: DISBTACALLOC Mask */ + +#define SCnSCB_ACTLR_DISBTACREAD_Pos 13U /*!< ACTLR: DISBTACREAD Position */ +#define SCnSCB_ACTLR_DISBTACREAD_Msk (1UL << SCnSCB_ACTLR_DISBTACREAD_Pos) /*!< ACTLR: DISBTACREAD Mask */ + +#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (1UL << SCnSCB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define SCnSCB_ACTLR_DISRAMODE_Pos 11U /*!< ACTLR: DISRAMODE Position */ +#define SCnSCB_ACTLR_DISRAMODE_Msk (1UL << SCnSCB_ACTLR_DISRAMODE_Pos) /*!< ACTLR: DISRAMODE Mask */ + +#define SCnSCB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define SCnSCB_ACTLR_FPEXCODIS_Msk (1UL << SCnSCB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED3[981U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( W) Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and FP Feature Register 2 Definitions */ + +#define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ +#define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ +#define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = SCB->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + +/*@} end of CMSIS_Core_FpuFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h new file mode 100644 index 0000000000..6046311189 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_cm85.h @@ -0,0 +1,4672 @@ +/**************************************************************************//** + * @file core_cm85.h + * @brief CMSIS Cortex-M85 Core Peripheral Access Layer Header File + * @version V1.0.4 + * @date 21. April 2022 + ******************************************************************************/ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM85_H_GENERIC +#define __CORE_CM85_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M85 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM85 definitions */ + +#define __CORTEX_M (85U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM85_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM85_H_DEPENDANT +#define __CORE_CM85_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM85_REV + #define __CM85_REV 0x0001U + #warning "__CM85_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 8U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 8 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M85 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core EWIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core PMU Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:1; /*!< bit: 20 Reserved */ + uint32_t B:1; /*!< bit: 21 BTI active (read 0) */ + uint32_t _reserved2:2; /*!< bit: 22..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_B_Pos 21U /*!< xPSR: B Position */ +#define xPSR_B_Msk (1UL << xPSR_B_Pos) /*!< xPSR: B Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t BTI_EN:1; /*!< bit: 4 Privileged branch target identification enable */ + uint32_t UBTI_EN:1; /*!< bit: 5 Unprivileged branch target identification enable */ + uint32_t PAC_EN:1; /*!< bit: 6 Privileged pointer authentication enable */ + uint32_t UPAC_EN:1; /*!< bit: 7 Unprivileged pointer authentication enable */ + uint32_t _reserved1:24; /*!< bit: 8..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_UPAC_EN_Pos 7U /*!< CONTROL: UPAC_EN Position */ +#define CONTROL_UPAC_EN_Msk (1UL << CONTROL_UPAC_EN_Pos) /*!< CONTROL: UPAC_EN Mask */ + +#define CONTROL_PAC_EN_Pos 6U /*!< CONTROL: PAC_EN Position */ +#define CONTROL_PAC_EN_Msk (1UL << CONTROL_PAC_EN_Pos) /*!< CONTROL: PAC_EN Mask */ + +#define CONTROL_UBTI_EN_Pos 5U /*!< CONTROL: UBTI_EN Position */ +#define CONTROL_UBTI_EN_Msk (1UL << CONTROL_UBTI_EN_Pos) /*!< CONTROL: UBTI_EN Mask */ + +#define CONTROL_BTI_EN_Pos 4U /*!< CONTROL: BTI_EN Position */ +#define CONTROL_BTI_EN_Msk (1UL << CONTROL_BTI_EN_Pos) /*!< CONTROL: BTI_EN Mask */ + +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED7[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ICB Implementation Control Block register (ICB) + \brief Type definitions for the Implementation Control Block Register + @{ + */ + +/** + \brief Structure type to access the Implementation Control Block (ICB). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} ICB_Type; + +/* Auxiliary Control Register Definitions */ +#define ICB_ACTLR_DISCRITAXIRUW_Pos 27U /*!< ACTLR: DISCRITAXIRUW Position */ +#define ICB_ACTLR_DISCRITAXIRUW_Msk (1UL << ICB_ACTLR_DISCRITAXIRUW_Pos) /*!< ACTLR: DISCRITAXIRUW Mask */ + +#define ICB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define ICB_ACTLR_DISCRITAXIRUR_Msk (1UL << ICB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define ICB_ACTLR_EVENTBUSEN_Pos 14U /*!< ACTLR: EVENTBUSEN Position */ +#define ICB_ACTLR_EVENTBUSEN_Msk (1UL << ICB_ACTLR_EVENTBUSEN_Pos) /*!< ACTLR: EVENTBUSEN Mask */ + +#define ICB_ACTLR_EVENTBUSEN_S_Pos 13U /*!< ACTLR: EVENTBUSEN_S Position */ +#define ICB_ACTLR_EVENTBUSEN_S_Msk (1UL << ICB_ACTLR_EVENTBUSEN_S_Pos) /*!< ACTLR: EVENTBUSEN_S Mask */ + +#define ICB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define ICB_ACTLR_DISITMATBFLUSH_Msk (1UL << ICB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define ICB_ACTLR_DISNWAMODE_Pos 11U /*!< ACTLR: DISNWAMODE Position */ +#define ICB_ACTLR_DISNWAMODE_Msk (1UL << ICB_ACTLR_DISNWAMODE_Pos) /*!< ACTLR: DISNWAMODE Mask */ + +#define ICB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define ICB_ACTLR_FPEXCODIS_Msk (1UL << ICB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +/* Interrupt Controller Type Register Definitions */ +#define ICB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define ICB_ICTR_INTLINESNUM_Msk (0xFUL /*<< ICB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_ICB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup MemSysCtl_Type Memory System Control Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Memory System Control Registers (MEMSYSCTL) + @{ + */ + +/** + \brief Structure type to access the Memory System Control Registers (MEMSYSCTL). + */ +typedef struct +{ + __IOM uint32_t MSCR; /*!< Offset: 0x000 (R/W) Memory System Control Register */ + __IOM uint32_t PFCR; /*!< Offset: 0x004 (R/W) Prefetcher Control Register */ + uint32_t RESERVED1[2U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x010 (R/W) ITCM Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x014 (R/W) DTCM Control Register */ + __IOM uint32_t PAHBCR; /*!< Offset: 0x018 (R/W) P-AHB Control Register */ + uint32_t RESERVED2[313U]; + __IOM uint32_t ITGU_CTRL; /*!< Offset: 0x500 (R/W) ITGU Control Register */ + __IOM uint32_t ITGU_CFG; /*!< Offset: 0x504 (R/W) ITGU Configuration Register */ + uint32_t RESERVED3[2U]; + __IOM uint32_t ITGU_LUT[16U]; /*!< Offset: 0x510 (R/W) ITGU Look Up Table Register */ + uint32_t RESERVED4[44U]; + __IOM uint32_t DTGU_CTRL; /*!< Offset: 0x600 (R/W) DTGU Control Registers */ + __IOM uint32_t DTGU_CFG; /*!< Offset: 0x604 (R/W) DTGU Configuration Register */ + uint32_t RESERVED5[2U]; + __IOM uint32_t DTGU_LUT[16U]; /*!< Offset: 0x610 (R/W) DTGU Look Up Table Register */ +} MemSysCtl_Type; + +/* MEMSYSCTL Memory System Control Register (MSCR) Register Definitions */ +#define MEMSYSCTL_MSCR_CPWRDN_Pos 17U /*!< MEMSYSCTL MSCR: CPWRDN Position */ +#define MEMSYSCTL_MSCR_CPWRDN_Msk (0x1UL << MEMSYSCTL_MSCR_CPWRDN_Pos) /*!< MEMSYSCTL MSCR: CPWRDN Mask */ + +#define MEMSYSCTL_MSCR_DCCLEAN_Pos 16U /*!< MEMSYSCTL MSCR: DCCLEAN Position */ +#define MEMSYSCTL_MSCR_DCCLEAN_Msk (0x1UL << MEMSYSCTL_MSCR_DCCLEAN_Pos) /*!< MEMSYSCTL MSCR: DCCLEAN Mask */ + +#define MEMSYSCTL_MSCR_ICACTIVE_Pos 13U /*!< MEMSYSCTL MSCR: ICACTIVE Position */ +#define MEMSYSCTL_MSCR_ICACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_ICACTIVE_Pos) /*!< MEMSYSCTL MSCR: ICACTIVE Mask */ + +#define MEMSYSCTL_MSCR_DCACTIVE_Pos 12U /*!< MEMSYSCTL MSCR: DCACTIVE Position */ +#define MEMSYSCTL_MSCR_DCACTIVE_Msk (0x1UL << MEMSYSCTL_MSCR_DCACTIVE_Pos) /*!< MEMSYSCTL MSCR: DCACTIVE Mask */ + +#define MEMSYSCTL_MSCR_EVECCFAULT_Pos 3U /*!< MEMSYSCTL MSCR: EVECCFAULT Position */ +#define MEMSYSCTL_MSCR_EVECCFAULT_Msk (0x1UL << MEMSYSCTL_MSCR_EVECCFAULT_Pos) /*!< MEMSYSCTL MSCR: EVECCFAULT Mask */ + +#define MEMSYSCTL_MSCR_FORCEWT_Pos 2U /*!< MEMSYSCTL MSCR: FORCEWT Position */ +#define MEMSYSCTL_MSCR_FORCEWT_Msk (0x1UL << MEMSYSCTL_MSCR_FORCEWT_Pos) /*!< MEMSYSCTL MSCR: FORCEWT Mask */ + +#define MEMSYSCTL_MSCR_ECCEN_Pos 1U /*!< MEMSYSCTL MSCR: ECCEN Position */ +#define MEMSYSCTL_MSCR_ECCEN_Msk (0x1UL << MEMSYSCTL_MSCR_ECCEN_Pos) /*!< MEMSYSCTL MSCR: ECCEN Mask */ + +/* MEMSYSCTL Prefetcher Control Register (PFCR) Register Definitions */ +#define MEMSYSCTL_PFCR_DIS_NLP_Pos 7U /*!< MEMSYSCTL PFCR: DIS_NLP Position */ +#define MEMSYSCTL_PFCR_DIS_NLP_Msk (0x1UL << MEMSYSCTL_PFCR_DIS_NLP_Pos) /*!< MEMSYSCTL PFCR: DIS_NLP Mask */ + +#define MEMSYSCTL_PFCR_ENABLE_Pos 0U /*!< MEMSYSCTL PFCR: ENABLE Position */ +#define MEMSYSCTL_PFCR_ENABLE_Msk (0x1UL /*<< MEMSYSCTL_PFCR_ENABLE_Pos*/) /*!< MEMSYSCTL PFCR: ENABLE Mask */ + +/* MEMSYSCTL ITCM Control Register (ITCMCR) Register Definitions */ +#define MEMSYSCTL_ITCMCR_SZ_Pos 3U /*!< MEMSYSCTL ITCMCR: SZ Position */ +#define MEMSYSCTL_ITCMCR_SZ_Msk (0xFUL << MEMSYSCTL_ITCMCR_SZ_Pos) /*!< MEMSYSCTL ITCMCR: SZ Mask */ + +#define MEMSYSCTL_ITCMCR_EN_Pos 0U /*!< MEMSYSCTL ITCMCR: EN Position */ +#define MEMSYSCTL_ITCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_ITCMCR_EN_Pos*/) /*!< MEMSYSCTL ITCMCR: EN Mask */ + +/* MEMSYSCTL DTCM Control Register (DTCMCR) Register Definitions */ +#define MEMSYSCTL_DTCMCR_SZ_Pos 3U /*!< MEMSYSCTL DTCMCR: SZ Position */ +#define MEMSYSCTL_DTCMCR_SZ_Msk (0xFUL << MEMSYSCTL_DTCMCR_SZ_Pos) /*!< MEMSYSCTL DTCMCR: SZ Mask */ + +#define MEMSYSCTL_DTCMCR_EN_Pos 0U /*!< MEMSYSCTL DTCMCR: EN Position */ +#define MEMSYSCTL_DTCMCR_EN_Msk (0x1UL /*<< MEMSYSCTL_DTCMCR_EN_Pos*/) /*!< MEMSYSCTL DTCMCR: EN Mask */ + +/* MEMSYSCTL P-AHB Control Register (PAHBCR) Register Definitions */ +#define MEMSYSCTL_PAHBCR_SZ_Pos 1U /*!< MEMSYSCTL PAHBCR: SZ Position */ +#define MEMSYSCTL_PAHBCR_SZ_Msk (0x7UL << MEMSYSCTL_PAHBCR_SZ_Pos) /*!< MEMSYSCTL PAHBCR: SZ Mask */ + +#define MEMSYSCTL_PAHBCR_EN_Pos 0U /*!< MEMSYSCTL PAHBCR: EN Position */ +#define MEMSYSCTL_PAHBCR_EN_Msk (0x1UL /*<< MEMSYSCTL_PAHBCR_EN_Pos*/) /*!< MEMSYSCTL PAHBCR: EN Mask */ + +/* MEMSYSCTL ITGU Control Register (ITGU_CTRL) Register Definitions */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL ITGU_CTRL: DEREN Position */ +#define MEMSYSCTL_ITGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_ITGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL ITGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL ITGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_ITGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_ITGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL ITGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL ITGU Configuration Register (ITGU_CFG) Register Definitions */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL ITGU_CFG: PRESENT Position */ +#define MEMSYSCTL_ITGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_ITGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL ITGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_ITGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_ITGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL ITGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL ITGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_ITGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_ITGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL ITGU_CFG: BLKSZ Mask */ + +/* MEMSYSCTL DTGU Control Registers (DTGU_CTRL) Register Definitions */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Pos 1U /*!< MEMSYSCTL DTGU_CTRL: DEREN Position */ +#define MEMSYSCTL_DTGU_CTRL_DEREN_Msk (0x1UL << MEMSYSCTL_DTGU_CTRL_DEREN_Pos) /*!< MEMSYSCTL DTGU_CTRL: DEREN Mask */ + +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Pos 0U /*!< MEMSYSCTL DTGU_CTRL: DBFEN Position */ +#define MEMSYSCTL_DTGU_CTRL_DBFEN_Msk (0x1UL /*<< MEMSYSCTL_DTGU_CTRL_DBFEN_Pos*/) /*!< MEMSYSCTL DTGU_CTRL: DBFEN Mask */ + +/* MEMSYSCTL DTGU Configuration Register (DTGU_CFG) Register Definitions */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Pos 31U /*!< MEMSYSCTL DTGU_CFG: PRESENT Position */ +#define MEMSYSCTL_DTGU_CFG_PRESENT_Msk (0x1UL << MEMSYSCTL_DTGU_CFG_PRESENT_Pos) /*!< MEMSYSCTL DTGU_CFG: PRESENT Mask */ + +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos 8U /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Position */ +#define MEMSYSCTL_DTGU_CFG_NUMBLKS_Msk (0xFUL << MEMSYSCTL_DTGU_CFG_NUMBLKS_Pos) /*!< MEMSYSCTL DTGU_CFG: NUMBLKS Mask */ + +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Pos 0U /*!< MEMSYSCTL DTGU_CFG: BLKSZ Position */ +#define MEMSYSCTL_DTGU_CFG_BLKSZ_Msk (0xFUL /*<< MEMSYSCTL_DTGU_CFG_BLKSZ_Pos*/) /*!< MEMSYSCTL DTGU_CFG: BLKSZ Mask */ + + +/*@}*/ /* end of group MemSysCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PwrModCtl_Type Power Mode Control Registers + \brief Type definitions for the Power Mode Control Registers (PWRMODCTL) + @{ + */ + +/** + \brief Structure type to access the Power Mode Control Registers (PWRMODCTL). + */ +typedef struct +{ + __IOM uint32_t CPDLPSTATE; /*!< Offset: 0x000 (R/W) Core Power Domain Low Power State Register */ + __IOM uint32_t DPDLPSTATE; /*!< Offset: 0x004 (R/W) Debug Power Domain Low Power State Register */ +} PwrModCtl_Type; + +/* PWRMODCTL Core Power Domain Low Power State (CPDLPSTATE) Register Definitions */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos 8U /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_RLPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_RLPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: RLPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos 4U /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_ELPSTATE_Msk (0x3UL << PWRMODCTL_CPDLPSTATE_ELPSTATE_Pos) /*!< PWRMODCTL CPDLPSTATE: ELPSTATE Mask */ + +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos 0U /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Position */ +#define PWRMODCTL_CPDLPSTATE_CLPSTATE_Msk (0x3UL /*<< PWRMODCTL_CPDLPSTATE_CLPSTATE_Pos*/) /*!< PWRMODCTL CPDLPSTATE: CLPSTATE Mask */ + +/* PWRMODCTL Debug Power Domain Low Power State (DPDLPSTATE) Register Definitions */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos 0U /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Position */ +#define PWRMODCTL_DPDLPSTATE_DLPSTATE_Msk (0x3UL /*<< PWRMODCTL_DPDLPSTATE_DLPSTATE_Pos*/) /*!< PWRMODCTL DPDLPSTATE: DLPSTATE Mask */ + +/*@}*/ /* end of group PwrModCtl_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup EWIC_Type External Wakeup Interrupt Controller Registers + \brief Type definitions for the External Wakeup Interrupt Controller Registers (EWIC) + @{ + */ + +/** + \brief Structure type to access the External Wakeup Interrupt Controller Registers (EWIC). + */ +typedef struct +{ + __OM uint32_t EVENTSPR; /*!< Offset: 0x000 ( /W) Event Set Pending Register */ + uint32_t RESERVED0[31U]; + __IM uint32_t EVENTMASKA; /*!< Offset: 0x080 (R/W) Event Mask A Register */ + __IM uint32_t EVENTMASK[15]; /*!< Offset: 0x084 (R/W) Event Mask Register */ +} EWIC_Type; + +/* EWIC External Wakeup Interrupt Controller (EVENTSPR) Register Definitions */ +#define EWIC_EVENTSPR_EDBGREQ_Pos 2U /*!< EWIC EVENTSPR: EDBGREQ Position */ +#define EWIC_EVENTSPR_EDBGREQ_Msk (0x1UL << EWIC_EVENTSPR_EDBGREQ_Pos) /*!< EWIC EVENTSPR: EDBGREQ Mask */ + +#define EWIC_EVENTSPR_NMI_Pos 1U /*!< EWIC EVENTSPR: NMI Position */ +#define EWIC_EVENTSPR_NMI_Msk (0x1UL << EWIC_EVENTSPR_NMI_Pos) /*!< EWIC EVENTSPR: NMI Mask */ + +#define EWIC_EVENTSPR_EVENT_Pos 0U /*!< EWIC EVENTSPR: EVENT Position */ +#define EWIC_EVENTSPR_EVENT_Msk (0x1UL /*<< EWIC_EVENTSPR_EVENT_Pos*/) /*!< EWIC EVENTSPR: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASKA) Register Definitions */ +#define EWIC_EVENTMASKA_EDBGREQ_Pos 2U /*!< EWIC EVENTMASKA: EDBGREQ Position */ +#define EWIC_EVENTMASKA_EDBGREQ_Msk (0x1UL << EWIC_EVENTMASKA_EDBGREQ_Pos) /*!< EWIC EVENTMASKA: EDBGREQ Mask */ + +#define EWIC_EVENTMASKA_NMI_Pos 1U /*!< EWIC EVENTMASKA: NMI Position */ +#define EWIC_EVENTMASKA_NMI_Msk (0x1UL << EWIC_EVENTMASKA_NMI_Pos) /*!< EWIC EVENTMASKA: NMI Mask */ + +#define EWIC_EVENTMASKA_EVENT_Pos 0U /*!< EWIC EVENTMASKA: EVENT Position */ +#define EWIC_EVENTMASKA_EVENT_Msk (0x1UL /*<< EWIC_EVENTMASKA_EVENT_Pos*/) /*!< EWIC EVENTMASKA: EVENT Mask */ + +/* EWIC External Wakeup Interrupt Controller (EVENTMASK) Register Definitions */ +#define EWIC_EVENTMASK_IRQ_Pos 0U /*!< EWIC EVENTMASKA: IRQ Position */ +#define EWIC_EVENTMASK_IRQ_Msk (0xFFFFFFFFUL /*<< EWIC_EVENTMASKA_IRQ_Pos*/) /*!< EWIC EVENTMASKA: IRQ Mask */ + +/*@}*/ /* end of group EWIC_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup ErrBnk_Type Error Banking Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Error Banking Registers (ERRBNK) + @{ + */ + +/** + \brief Structure type to access the Error Banking Registers (ERRBNK). + */ +typedef struct +{ + __IOM uint32_t IEBR0; /*!< Offset: 0x000 (R/W) Instruction Cache Error Bank Register 0 */ + __IOM uint32_t IEBR1; /*!< Offset: 0x004 (R/W) Instruction Cache Error Bank Register 1 */ + uint32_t RESERVED0[2U]; + __IOM uint32_t DEBR0; /*!< Offset: 0x010 (R/W) Data Cache Error Bank Register 0 */ + __IOM uint32_t DEBR1; /*!< Offset: 0x014 (R/W) Data Cache Error Bank Register 1 */ + uint32_t RESERVED1[2U]; + __IOM uint32_t TEBR0; /*!< Offset: 0x020 (R/W) TCM Error Bank Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t TEBR1; /*!< Offset: 0x028 (R/W) TCM Error Bank Register 1 */ +} ErrBnk_Type; + +/* ERRBNK Instruction Cache Error Bank Register 0 (IEBR0) Register Definitions */ +#define ERRBNK_IEBR0_SWDEF_Pos 30U /*!< ERRBNK IEBR0: SWDEF Position */ +#define ERRBNK_IEBR0_SWDEF_Msk (0x3UL << ERRBNK_IEBR0_SWDEF_Pos) /*!< ERRBNK IEBR0: SWDEF Mask */ + +#define ERRBNK_IEBR0_BANK_Pos 16U /*!< ERRBNK IEBR0: BANK Position */ +#define ERRBNK_IEBR0_BANK_Msk (0x1UL << ERRBNK_IEBR0_BANK_Pos) /*!< ERRBNK IEBR0: BANK Mask */ + +#define ERRBNK_IEBR0_LOCATION_Pos 2U /*!< ERRBNK IEBR0: LOCATION Position */ +#define ERRBNK_IEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR0_LOCATION_Pos) /*!< ERRBNK IEBR0: LOCATION Mask */ + +#define ERRBNK_IEBR0_LOCKED_Pos 1U /*!< ERRBNK IEBR0: LOCKED Position */ +#define ERRBNK_IEBR0_LOCKED_Msk (0x1UL << ERRBNK_IEBR0_LOCKED_Pos) /*!< ERRBNK IEBR0: LOCKED Mask */ + +#define ERRBNK_IEBR0_VALID_Pos 0U /*!< ERRBNK IEBR0: VALID Position */ +#define ERRBNK_IEBR0_VALID_Msk (0x1UL << /*ERRBNK_IEBR0_VALID_Pos*/) /*!< ERRBNK IEBR0: VALID Mask */ + +/* ERRBNK Instruction Cache Error Bank Register 1 (IEBR1) Register Definitions */ +#define ERRBNK_IEBR1_SWDEF_Pos 30U /*!< ERRBNK IEBR1: SWDEF Position */ +#define ERRBNK_IEBR1_SWDEF_Msk (0x3UL << ERRBNK_IEBR1_SWDEF_Pos) /*!< ERRBNK IEBR1: SWDEF Mask */ + +#define ERRBNK_IEBR1_BANK_Pos 16U /*!< ERRBNK IEBR1: BANK Position */ +#define ERRBNK_IEBR1_BANK_Msk (0x1UL << ERRBNK_IEBR1_BANK_Pos) /*!< ERRBNK IEBR1: BANK Mask */ + +#define ERRBNK_IEBR1_LOCATION_Pos 2U /*!< ERRBNK IEBR1: LOCATION Position */ +#define ERRBNK_IEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_IEBR1_LOCATION_Pos) /*!< ERRBNK IEBR1: LOCATION Mask */ + +#define ERRBNK_IEBR1_LOCKED_Pos 1U /*!< ERRBNK IEBR1: LOCKED Position */ +#define ERRBNK_IEBR1_LOCKED_Msk (0x1UL << ERRBNK_IEBR1_LOCKED_Pos) /*!< ERRBNK IEBR1: LOCKED Mask */ + +#define ERRBNK_IEBR1_VALID_Pos 0U /*!< ERRBNK IEBR1: VALID Position */ +#define ERRBNK_IEBR1_VALID_Msk (0x1UL << /*ERRBNK_IEBR1_VALID_Pos*/) /*!< ERRBNK IEBR1: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 0 (DEBR0) Register Definitions */ +#define ERRBNK_DEBR0_SWDEF_Pos 30U /*!< ERRBNK DEBR0: SWDEF Position */ +#define ERRBNK_DEBR0_SWDEF_Msk (0x3UL << ERRBNK_DEBR0_SWDEF_Pos) /*!< ERRBNK DEBR0: SWDEF Mask */ + +#define ERRBNK_DEBR0_TYPE_Pos 17U /*!< ERRBNK DEBR0: TYPE Position */ +#define ERRBNK_DEBR0_TYPE_Msk (0x1UL << ERRBNK_DEBR0_TYPE_Pos) /*!< ERRBNK DEBR0: TYPE Mask */ + +#define ERRBNK_DEBR0_BANK_Pos 16U /*!< ERRBNK DEBR0: BANK Position */ +#define ERRBNK_DEBR0_BANK_Msk (0x1UL << ERRBNK_DEBR0_BANK_Pos) /*!< ERRBNK DEBR0: BANK Mask */ + +#define ERRBNK_DEBR0_LOCATION_Pos 2U /*!< ERRBNK DEBR0: LOCATION Position */ +#define ERRBNK_DEBR0_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR0_LOCATION_Pos) /*!< ERRBNK DEBR0: LOCATION Mask */ + +#define ERRBNK_DEBR0_LOCKED_Pos 1U /*!< ERRBNK DEBR0: LOCKED Position */ +#define ERRBNK_DEBR0_LOCKED_Msk (0x1UL << ERRBNK_DEBR0_LOCKED_Pos) /*!< ERRBNK DEBR0: LOCKED Mask */ + +#define ERRBNK_DEBR0_VALID_Pos 0U /*!< ERRBNK DEBR0: VALID Position */ +#define ERRBNK_DEBR0_VALID_Msk (0x1UL << /*ERRBNK_DEBR0_VALID_Pos*/) /*!< ERRBNK DEBR0: VALID Mask */ + +/* ERRBNK Data Cache Error Bank Register 1 (DEBR1) Register Definitions */ +#define ERRBNK_DEBR1_SWDEF_Pos 30U /*!< ERRBNK DEBR1: SWDEF Position */ +#define ERRBNK_DEBR1_SWDEF_Msk (0x3UL << ERRBNK_DEBR1_SWDEF_Pos) /*!< ERRBNK DEBR1: SWDEF Mask */ + +#define ERRBNK_DEBR1_TYPE_Pos 17U /*!< ERRBNK DEBR1: TYPE Position */ +#define ERRBNK_DEBR1_TYPE_Msk (0x1UL << ERRBNK_DEBR1_TYPE_Pos) /*!< ERRBNK DEBR1: TYPE Mask */ + +#define ERRBNK_DEBR1_BANK_Pos 16U /*!< ERRBNK DEBR1: BANK Position */ +#define ERRBNK_DEBR1_BANK_Msk (0x1UL << ERRBNK_DEBR1_BANK_Pos) /*!< ERRBNK DEBR1: BANK Mask */ + +#define ERRBNK_DEBR1_LOCATION_Pos 2U /*!< ERRBNK DEBR1: LOCATION Position */ +#define ERRBNK_DEBR1_LOCATION_Msk (0x3FFFUL << ERRBNK_DEBR1_LOCATION_Pos) /*!< ERRBNK DEBR1: LOCATION Mask */ + +#define ERRBNK_DEBR1_LOCKED_Pos 1U /*!< ERRBNK DEBR1: LOCKED Position */ +#define ERRBNK_DEBR1_LOCKED_Msk (0x1UL << ERRBNK_DEBR1_LOCKED_Pos) /*!< ERRBNK DEBR1: LOCKED Mask */ + +#define ERRBNK_DEBR1_VALID_Pos 0U /*!< ERRBNK DEBR1: VALID Position */ +#define ERRBNK_DEBR1_VALID_Msk (0x1UL << /*ERRBNK_DEBR1_VALID_Pos*/) /*!< ERRBNK DEBR1: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 0 (TEBR0) Register Definitions */ +#define ERRBNK_TEBR0_SWDEF_Pos 30U /*!< ERRBNK TEBR0: SWDEF Position */ +#define ERRBNK_TEBR0_SWDEF_Msk (0x3UL << ERRBNK_TEBR0_SWDEF_Pos) /*!< ERRBNK TEBR0: SWDEF Mask */ + +#define ERRBNK_TEBR0_POISON_Pos 28U /*!< ERRBNK TEBR0: POISON Position */ +#define ERRBNK_TEBR0_POISON_Msk (0x1UL << ERRBNK_TEBR0_POISON_Pos) /*!< ERRBNK TEBR0: POISON Mask */ + +#define ERRBNK_TEBR0_TYPE_Pos 27U /*!< ERRBNK TEBR0: TYPE Position */ +#define ERRBNK_TEBR0_TYPE_Msk (0x1UL << ERRBNK_TEBR0_TYPE_Pos) /*!< ERRBNK TEBR0: TYPE Mask */ + +#define ERRBNK_TEBR0_BANK_Pos 24U /*!< ERRBNK TEBR0: BANK Position */ +#define ERRBNK_TEBR0_BANK_Msk (0x3UL << ERRBNK_TEBR0_BANK_Pos) /*!< ERRBNK TEBR0: BANK Mask */ + +#define ERRBNK_TEBR0_LOCATION_Pos 2U /*!< ERRBNK TEBR0: LOCATION Position */ +#define ERRBNK_TEBR0_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR0_LOCATION_Pos) /*!< ERRBNK TEBR0: LOCATION Mask */ + +#define ERRBNK_TEBR0_LOCKED_Pos 1U /*!< ERRBNK TEBR0: LOCKED Position */ +#define ERRBNK_TEBR0_LOCKED_Msk (0x1UL << ERRBNK_TEBR0_LOCKED_Pos) /*!< ERRBNK TEBR0: LOCKED Mask */ + +#define ERRBNK_TEBR0_VALID_Pos 0U /*!< ERRBNK TEBR0: VALID Position */ +#define ERRBNK_TEBR0_VALID_Msk (0x1UL << /*ERRBNK_TEBR0_VALID_Pos*/) /*!< ERRBNK TEBR0: VALID Mask */ + +/* ERRBNK TCM Error Bank Register 1 (TEBR1) Register Definitions */ +#define ERRBNK_TEBR1_SWDEF_Pos 30U /*!< ERRBNK TEBR1: SWDEF Position */ +#define ERRBNK_TEBR1_SWDEF_Msk (0x3UL << ERRBNK_TEBR1_SWDEF_Pos) /*!< ERRBNK TEBR1: SWDEF Mask */ + +#define ERRBNK_TEBR1_POISON_Pos 28U /*!< ERRBNK TEBR1: POISON Position */ +#define ERRBNK_TEBR1_POISON_Msk (0x1UL << ERRBNK_TEBR1_POISON_Pos) /*!< ERRBNK TEBR1: POISON Mask */ + +#define ERRBNK_TEBR1_TYPE_Pos 27U /*!< ERRBNK TEBR1: TYPE Position */ +#define ERRBNK_TEBR1_TYPE_Msk (0x1UL << ERRBNK_TEBR1_TYPE_Pos) /*!< ERRBNK TEBR1: TYPE Mask */ + +#define ERRBNK_TEBR1_BANK_Pos 24U /*!< ERRBNK TEBR1: BANK Position */ +#define ERRBNK_TEBR1_BANK_Msk (0x3UL << ERRBNK_TEBR1_BANK_Pos) /*!< ERRBNK TEBR1: BANK Mask */ + +#define ERRBNK_TEBR1_LOCATION_Pos 2U /*!< ERRBNK TEBR1: LOCATION Position */ +#define ERRBNK_TEBR1_LOCATION_Msk (0x3FFFFFUL << ERRBNK_TEBR1_LOCATION_Pos) /*!< ERRBNK TEBR1: LOCATION Mask */ + +#define ERRBNK_TEBR1_LOCKED_Pos 1U /*!< ERRBNK TEBR1: LOCKED Position */ +#define ERRBNK_TEBR1_LOCKED_Msk (0x1UL << ERRBNK_TEBR1_LOCKED_Pos) /*!< ERRBNK TEBR1: LOCKED Mask */ + +#define ERRBNK_TEBR1_VALID_Pos 0U /*!< ERRBNK TEBR1: VALID Position */ +#define ERRBNK_TEBR1_VALID_Msk (0x1UL << /*ERRBNK_TEBR1_VALID_Pos*/) /*!< ERRBNK TEBR1: VALID Mask */ + +/*@}*/ /* end of group ErrBnk_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup PrcCfgInf_Type Processor Configuration Information Registers (IMPLEMENTATION DEFINED) + \brief Type definitions for the Processor Configuration Information Registerss (PRCCFGINF) + @{ + */ + +/** + \brief Structure type to access the Processor Configuration Information Registerss (PRCCFGINF). + */ +typedef struct +{ + __OM uint32_t CFGINFOSEL; /*!< Offset: 0x000 ( /W) Processor Configuration Information Selection Register */ + __IM uint32_t CFGINFORD; /*!< Offset: 0x004 (R/ ) Processor Configuration Information Read Data Register */ +} PrcCfgInf_Type; + +/* PRCCFGINF Processor Configuration Information Selection Register (CFGINFOSEL) Definitions */ + +/* PRCCFGINF Processor Configuration Information Read Data Register (CFGINFORD) Definitions */ + +/*@}*/ /* end of group PrcCfgInf_Type */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[3]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE4 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE8 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFEC (R/W) PMU Peripheral Identification Register 3 */ + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (0xFFFFUL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (0xFFFFUL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (0xFFUL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (0x3FUL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/** \brief PMU Authentication Status Register Definitions */ + +#define PMU_AUTHSTATUS_NSID_Pos 0U /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSID_Msk (0x3UL /*<< PMU_AUTHSTATUS_NSID_Pos*/) /*!< PMU AUTHSTATUS: Non-secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSNID_Pos 2U /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSNID_Msk (0x3UL << PMU_AUTHSTATUS_NSNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SID_Pos 4U /*!< PMU AUTHSTATUS: Secure Invasive Debug Position */ +#define PMU_AUTHSTATUS_SID_Msk (0x3UL << PMU_AUTHSTATUS_SID_Pos) /*!< PMU AUTHSTATUS: Secure Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SNID_Pos 6U /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SNID_Msk (0x3UL << PMU_AUTHSTATUS_SNID_Pos) /*!< PMU AUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUID_Pos 16U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUID_Msk (0x3UL << PMU_AUTHSTATUS_NSUID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_NSUNID_Pos 18U /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_NSUNID_Msk (0x3UL << PMU_AUTHSTATUS_NSUNID_Pos) /*!< PMU AUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUID_Pos 20U /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Position */ +#define PMU_AUTHSTATUS_SUID_Msk (0x3UL << PMU_AUTHSTATUS_SUID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Invasive Debug Mask */ + +#define PMU_AUTHSTATUS_SUNID_Pos 22U /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Position */ +#define PMU_AUTHSTATUS_SUNID_Msk (0x3UL << PMU_AUTHSTATUS_SUNID_Pos) /*!< PMU AUTHSTATUS: Secure Unprivileged Non-invasive Debug Mask */ + + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define MEMSYSCTL_BASE (0xE001E000UL) /*!< Memory System Control Base Address */ + #define ERRBNK_BASE (0xE001E100UL) /*!< Error Banking Base Address */ + #define PWRMODCTL_BASE (0xE001E300UL) /*!< Power Mode Control Base Address */ + #define EWIC_BASE (0xE001E400UL) /*!< External Wakeup Interrupt Controller Base Address */ + #define PRCCFGINF_BASE (0xE001E700UL) /*!< Processor Configuration Information Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define ICB ((ICB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define MEMSYSCTL ((MemSysCtl_Type *) MEMSYSCTL_BASE ) /*!< Memory System Control configuration struct */ + #define ERRBNK ((ErrBnk_Type *) ERRBNK_BASE ) /*!< Error Banking configuration struct */ + #define PWRMODCTL ((PwrModCtl_Type *) PWRMODCTL_BASE ) /*!< Power Mode Control configuration struct */ + #define EWIC ((EWIC_Type *) EWIC_BASE ) /*!< EWIC configuration struct */ + #define PRCCFGINF ((PrcCfgInf_Type *) PRCCFGINF_BASE ) /*!< Processor Configuration Information configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define ICB_NS ((ICB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_register_aliases Backwards Compatibility Aliases + \brief Register alias definitions for backwards compatibility. + @{ + */ + +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +/** + \brief Cortex-M85 PMU events + \note Architectural PMU events can be found in pmu_armv8.h +*/ + +#define ARMCM85_PMU_ECC_ERR 0xC000 /*!< One or more Error Correcting Code (ECC) errors detected */ +#define ARMCM85_PMU_ECC_ERR_MBIT 0xC001 /*!< One or more multi-bit ECC errors detected */ +#define ARMCM85_PMU_ECC_ERR_DCACHE 0xC010 /*!< One or more ECC errors in the data cache */ +#define ARMCM85_PMU_ECC_ERR_ICACHE 0xC011 /*!< One or more ECC errors in the instruction cache */ +#define ARMCM85_PMU_ECC_ERR_MBIT_DCACHE 0xC012 /*!< One or more multi-bit ECC errors in the data cache */ +#define ARMCM85_PMU_ECC_ERR_MBIT_ICACHE 0xC013 /*!< One or more multi-bit ECC errors in the instruction cache */ +#define ARMCM85_PMU_ECC_ERR_DTCM 0xC020 /*!< One or more ECC errors in the Data Tightly Coupled Memory (DTCM) */ +#define ARMCM85_PMU_ECC_ERR_ITCM 0xC021 /*!< One or more ECC errors in the Instruction Tightly Coupled Memory (ITCM) */ +#define ARMCM85_PMU_ECC_ERR_MBIT_DTCM 0xC022 /*!< One or more multi-bit ECC errors in the DTCM */ +#define ARMCM85_PMU_ECC_ERR_MBIT_ITCM 0xC023 /*!< One or more multi-bit ECC errors in the ITCM */ +#define ARMCM85_PMU_PF_LINEFILL 0xC100 /*!< The prefetcher starts a line-fill */ +#define ARMCM85_PMU_PF_CANCEL 0xC101 /*!< The prefetcher stops prefetching */ +#define ARMCM85_PMU_PF_DROP_LINEFILL 0xC102 /*!< A linefill triggered by a prefetcher has been dropped because of lack of buffering */ +#define ARMCM85_PMU_NWAMODE_ENTER 0xC200 /*!< No write-allocate mode entry */ +#define ARMCM85_PMU_NWAMODE 0xC201 /*!< Write-allocate store is not allocated into the data cache due to no-write-allocate mode */ +#define ARMCM85_PMU_SAHB_ACCESS 0xC300 /*!< Read or write access on the S-AHB interface to the TCM */ +#define ARMCM85_PMU_PAHB_ACCESS 0xC301 /*!< Read or write access on the P-AHB write interface */ +#define ARMCM85_PMU_AXI_WRITE_ACCESS 0xC302 /*!< Any beat access to M-AXI write interface */ +#define ARMCM85_PMU_AXI_READ_ACCESS 0xC303 /*!< Any beat access to M-AXI read interface */ +#define ARMCM85_PMU_DOSTIMEOUT_DOUBLE 0xC400 /*!< Denial of Service timeout has fired twice and caused buffers to drain to allow forward progress */ +#define ARMCM85_PMU_DOSTIMEOUT_TRIPLE 0xC401 /*!< Denial of Service timeout has fired three times and blocked the LSU to force forward progress */ + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + +/* ################### PAC Key functions ########################### */ + +#if (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) +#include "pac_armv81.h" +#endif + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM85_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h new file mode 100644 index 0000000000..e252068ce6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc000.h @@ -0,0 +1,1030 @@ +/**************************************************************************//** + * @file core_sc000.h + * @brief CMSIS SC000 Core Peripheral Access Layer Header File + * @version V5.0.7 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC000_H_GENERIC +#define __CORE_SC000_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC000 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS SC000 definitions */ +#define __SC000_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __SC000_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \ + __SC000_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_SC (000U) /*!< Cortex secure core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC000_H_DEPENDANT +#define __CORE_SC000_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC000_REV + #define __SC000_REV 0x0000U + #warning "__SC000_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC000 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + uint32_t RESERVED1[154U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the SC000 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else +/*#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping not available for SC000 */ +/*#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping not available for SC000 */ + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for SC000 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M0 and M0+ do not require the architectural barrier - assume SC000 is the same */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h new file mode 100644 index 0000000000..d66621031e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_sc300.h @@ -0,0 +1,1917 @@ +/**************************************************************************//** + * @file core_sc300.h + * @brief CMSIS SC300 Core Peripheral Access Layer Header File + * @version V5.0.10 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC300_H_GENERIC +#define __CORE_SC300_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC3000 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS SC300 definitions */ +#define __SC300_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __SC300_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16U) | \ + __SC300_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_SC (300U) /*!< Cortex secure core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC300_H_DEPENDANT +#define __CORE_SC300_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC300_REV + #define __SC300_REV 0x0000U + #warning "__SC300_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC300 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED1[129U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h new file mode 100644 index 0000000000..ebc0f77eb7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/core_starmc1.h @@ -0,0 +1,3592 @@ +/**************************************************************************//** + * @file core_starmc1.h + * @brief CMSIS ArmChina STAR-MC1 Core Peripheral Access Layer Header File + * @version V1.0.2 + * @date 07. April 2022 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. + * Copyright (c) 2018-2022 Arm China. + * All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_STAR_H_GENERIC +#define __CORE_STAR_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup STAR-MC1 + @{ + */ + +#include "cmsis_version.h" + +/* Macro Define for STAR-MC1 */ +#define __STAR_MC (1U) /*!< STAR-MC Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_STAR_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_STAR_H_DEPENDANT +#define __CORE_STAR_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __STAR_REV + #define __STAR_REV 0x0000U + #warning "__STAR_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DTCM_PRESENT + #define __DTCM_PRESENT 0U + #warning "__DTCM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group STAR-MC1 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for STAR-MC1 processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[1U]; + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED_ADD1[21U]; + __IOM uint32_t SFSR; /*!< Offset: 0x0E4 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x0E8 (R/W) Secure Fault Address Register */ + uint32_t RESERVED3[69U]; + __OM uint32_t STIR; /*!< Offset: F00-D00=0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ +} SCB_Type; + +typedef struct +{ + __IOM uint32_t CACR; /*!< Offset: 0x0 (R/W) L1 Cache Control Register */ + __IOM uint32_t ITCMCR; /*!< Offset: 0x10 (R/W) Instruction Tightly-Coupled Memory Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x14 (R/W) Data Tightly-Coupled Memory Control Registers */ +}EMSS_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +#define SCB_CLIDR_IC_Pos 0U /*!< SCB CLIDR: IC Position */ +#define SCB_CLIDR_IC_Msk (1UL << SCB_CLIDR_IC_Pos) /*!< SCB CLIDR: IC Mask */ + +#define SCB_CLIDR_DC_Pos 1U /*!< SCB CLIDR: DC Position */ +#define SCB_CLIDR_DC_Msk (1UL << SCB_CLIDR_DC_Pos) /*!< SCB CLIDR: DC Mask */ + + + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache line Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_LEVEL_Pos 1U /*!< SCB DCISW: Level Position */ +#define SCB_DCISW_LEVEL_Msk (7UL << SCB_DCISW_LEVEL_Pos) /*!< SCB DCISW: Level Mask */ + +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0xFFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean line by Set-way Register Definitions */ +#define SCB_DCCSW_LEVEL_Pos 1U /*!< SCB DCCSW: Level Position */ +#define SCB_DCCSW_LEVEL_Msk (7UL << SCB_DCCSW_LEVEL_Pos) /*!< SCB DCCSW: Level Mask */ + +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0xFFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_LEVEL_Pos 1U /*!< SCB DCCISW: Level Position */ +#define SCB_DCCISW_LEVEL_Msk (7UL << SCB_DCCISW_LEVEL_Pos) /*!< SCB DCCISW: Level Mask */ + +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0xFFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/* ArmChina: Implementation Defined */ +/* Instruction Tightly-Coupled Memory Control Register Definitions */ +#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ +#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ + +#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ +#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ + +/* Data Tightly-Coupled Memory Control Register Definitions */ +#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ +#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ + +#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ +#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ + +/* L1 Cache Control Register Definitions */ +#define SCB_CACR_DCCLEAN_Pos 16U /*!< SCB CACR: DCCLEAN Position */ +#define SCB_CACR_DCCLEAN_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: DCCLEAN Mask */ + +#define SCB_CACR_ICACTIVE_Pos 13U /*!< SCB CACR: ICACTIVE Position */ +#define SCB_CACR_ICACTIVE_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: ICACTIVE Mask */ + +#define SCB_CACR_DCACTIVE_Pos 12U /*!< SCB CACR: DCACTIVE Position */ +#define SCB_CACR_DCACTIVE_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: DCACTIVE Mask */ + +#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ +#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define EMSS_BASE (0xE001E000UL) /*!AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses including + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/** + \brief Software Reset + \details Initiates a system reset request to reset the CPU. + */ +__NO_RETURN __STATIC_INLINE void __SW_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses including + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_BFHFNMINS_Msk) | /* Keep BFHFNMINS unchanged. Use this Reset function in case your case need to keep it */ + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | /* Keep priority group unchanged */ + SCB_AIRCR_SYSRESETREQ_Msk ); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) + +/* ########################## Cache functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_CacheFunctions Cache Functions + \brief Functions that configure Instruction and Data cache. + @{ + */ + +/* Cache Size ID Register Macros */ +#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) +#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) + +#define __SCB_DCACHE_LINE_SIZE 32U /*!< STAR-MC1 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#define __SCB_ICACHE_LINE_SIZE 32U /*!< STAR-MC1 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */ + + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate I-Cache + \details Invalidates I-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief I-Cache Invalidate by address + \details Invalidates I-Cache for the given address. + I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + I-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] isize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (void *addr, int32_t isize) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if ( isize > 0 ) { + int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_ICACHE_LINE_SIZE; + op_size -= __SCB_ICACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */ + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + __DSB(); + + SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable D-Cache + \details Turns off D-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | + ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address. + D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned and invalidated. + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + +/*@} end of CMSIS_Core_CacheFunctions */ +#endif + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_STAR_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h new file mode 100644 index 0000000000..9909f83990 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv7.h @@ -0,0 +1,275 @@ +/****************************************************************************** + * @file mpu_armv7.h + * @brief CMSIS MPU API for Armv7-M MPU + * @version V5.1.2 + * @date 25. May 2020 + ******************************************************************************/ +/* + * Copyright (c) 2017-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV7_H +#define ARM_MPU_ARMV7_H + +#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes +#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes +#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes +#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes +#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes +#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte +#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes +#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes +#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes +#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes +#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes +#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes +#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes +#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes +#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes +#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte +#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes +#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes +#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes +#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes +#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes +#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes +#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes +#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes +#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes +#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte +#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes +#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes + +#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access +#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only +#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only +#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access +#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only +#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access + +/** MPU Region Base Address Register Value +* +* \param Region The region to be configured, number 0 to 15. +* \param BaseAddress The base address for the region. +*/ +#define ARM_MPU_RBAR(Region, BaseAddress) \ + (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ + ((Region) & MPU_RBAR_REGION_Msk) | \ + (MPU_RBAR_VALID_Msk)) + +/** +* MPU Memory Access Attributes +* +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +*/ +#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \ + ((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ + (((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ + (((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ + (((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk)) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \ + ((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ + (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ + (((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \ + (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ + (((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ + (((MPU_RASR_ENABLE_Msk)))) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ + ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size) + +/** +* MPU Memory Access Attribute for strongly ordered memory. +* - TEX: 000b +* - Shareable +* - Non-cacheable +* - Non-bufferable +*/ +#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U) + +/** +* MPU Memory Access Attribute for device memory. +* - TEX: 000b (if shareable) or 010b (if non-shareable) +* - Shareable or non-shareable +* - Non-cacheable +* - Bufferable (if shareable) or non-bufferable (if non-shareable) +* +* \param IsShareable Configures the device memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U)) + +/** +* MPU Memory Access Attribute for normal memory. +* - TEX: 1BBb (reflecting outer cacheability rules) +* - Shareable or non-shareable +* - Cacheable or non-cacheable (reflecting inner cacheability rules) +* - Bufferable or non-bufferable (reflecting inner cacheability rules) +* +* \param OuterCp Configures the outer cache policy. +* \param InnerCp Configures the inner cache policy. +* \param IsShareable Configures the memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U)) + +/** +* MPU Memory Access Attribute non-cacheable policy. +*/ +#define ARM_MPU_CACHEP_NOCACHE 0U + +/** +* MPU Memory Access Attribute write-back, write and read allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_WRA 1U + +/** +* MPU Memory Access Attribute write-through, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WT_NWA 2U + +/** +* MPU Memory Access Attribute write-back, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_NWA 3U + + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; //!< The region base address register value (RBAR) + uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + MPU->RNR = rnr; + MPU->RASR = 0U; +} + +/** Configure an MPU region. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) +{ + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) +{ + MPU->RNR = rnr; + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_Load(). +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + while (cnt > MPU_TYPE_RALIASES) { + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); + table += MPU_TYPE_RALIASES; + cnt -= MPU_TYPE_RALIASES; + } + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); +} + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h new file mode 100644 index 0000000000..19855b9667 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/mpu_armv8.h @@ -0,0 +1,352 @@ +/****************************************************************************** + * @file mpu_armv8.h + * @brief CMSIS MPU API for Armv8-M and Armv8.1-M MPU + * @version V5.1.3 + * @date 03. February 2021 + ******************************************************************************/ +/* + * Copyright (c) 2017-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV8_H +#define ARM_MPU_ARMV8_H + +/** \brief Attribute for device memory (outer only) */ +#define ARM_MPU_ATTR_DEVICE ( 0U ) + +/** \brief Attribute for non-cacheable, normal memory */ +#define ARM_MPU_ATTR_NON_CACHEABLE ( 4U ) + +/** \brief Attribute for normal memory (outer and inner) +* \param NT Non-Transient: Set to 1 for non-transient data. +* \param WB Write-Back: Set to 1 to use write-back update policy. +* \param RA Read Allocation: Set to 1 to use cache allocation on read miss. +* \param WA Write Allocation: Set to 1 to use cache allocation on write miss. +*/ +#define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \ + ((((NT) & 1U) << 3U) | (((WB) & 1U) << 2U) | (((RA) & 1U) << 1U) | ((WA) & 1U)) + +/** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRnE (0U) + +/** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRE (1U) + +/** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGRE (2U) + +/** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_GRE (3U) + +/** \brief Memory Attribute +* \param O Outer memory attributes +* \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes +*/ +#define ARM_MPU_ATTR(O, I) ((((O) & 0xFU) << 4U) | ((((O) & 0xFU) != 0U) ? ((I) & 0xFU) : (((I) & 0x3U) << 2U))) + +/** \brief Normal memory non-shareable */ +#define ARM_MPU_SH_NON (0U) + +/** \brief Normal memory outer shareable */ +#define ARM_MPU_SH_OUTER (2U) + +/** \brief Normal memory inner shareable */ +#define ARM_MPU_SH_INNER (3U) + +/** \brief Memory access permissions +* \param RO Read-Only: Set to 1 for read-only memory. +* \param NP Non-Privileged: Set to 1 for non-privileged memory. +*/ +#define ARM_MPU_AP_(RO, NP) ((((RO) & 1U) << 1U) | ((NP) & 1U)) + +/** \brief Region Base Address Register value +* \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned. +* \param SH Defines the Shareability domain for this memory region. +* \param RO Read-Only: Set to 1 for a read-only memory region. +* \param NP Non-Privileged: Set to 1 for a non-privileged memory region. +* \oaram XN eXecute Never: Set to 1 for a non-executable memory region. +*/ +#define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \ + (((BASE) & MPU_RBAR_BASE_Msk) | \ + (((SH) << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \ + ((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \ + (((XN) << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk)) + +/** \brief Region Limit Address Register value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR(LIMIT, IDX) \ + (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \ + (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#if defined(MPU_RLAR_PXN_Pos) + +/** \brief Region Limit Address Register with PXN value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param PXN Privileged execute never. Defines whether code can be executed from this privileged region. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR_PXN(LIMIT, PXN, IDX) \ + (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \ + (((PXN) << MPU_RLAR_PXN_Pos) & MPU_RLAR_PXN_Msk) | \ + (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#endif + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; /*!< Region Base Address Register value */ + uint32_t RLAR; /*!< Region Limit Address Register value */ +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +#ifdef MPU_NS +/** Enable the Non-secure MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control) +{ + __DMB(); + MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the Non-secure MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable_NS(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} +#endif + +/** Set the memory attribute encoding to the given MPU. +* \param mpu Pointer to the MPU to be configured. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr) +{ + const uint8_t reg = idx / 4U; + const uint32_t pos = ((idx % 4U) * 8U); + const uint32_t mask = 0xFFU << pos; + + if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) { + return; // invalid index + } + + mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask)); +} + +/** Set the memory attribute encoding. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU, idx, attr); +} + +#ifdef MPU_NS +/** Set the memory attribute encoding to the Non-secure MPU. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr); +} +#endif + +/** Clear and disable the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr) +{ + mpu->RNR = rnr; + mpu->RLAR = 0U; +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU, rnr); +} + +#ifdef MPU_NS +/** Clear and disable the given Non-secure MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU_NS, rnr); +} +#endif + +/** Configure the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + mpu->RNR = rnr; + mpu->RBAR = rbar; + mpu->RLAR = rlar; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar); +} + +#ifdef MPU_NS +/** Configure the given Non-secure MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar); +} +#endif + +/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_LoadEx() +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table to the given MPU. +* \param mpu Pointer to the MPU registers to be used. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + if (cnt == 1U) { + mpu->RNR = rnr; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR), &(table->RBAR), rowWordSize); + } else { + uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U); + uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES; + + mpu->RNR = rnrBase; + while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) { + uint32_t c = MPU_TYPE_RALIASES - rnrOffset; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize); + table += c; + cnt -= c; + rnrOffset = 0U; + rnrBase += MPU_TYPE_RALIASES; + mpu->RNR = rnrBase; + } + + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize); + } +} + +/** Load the given number of MPU regions from a table. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU, rnr, table, cnt); +} + +#ifdef MPU_NS +/** Load the given number of MPU regions from a table to the Non-secure MPU. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt); +} +#endif + +#endif + diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h new file mode 100644 index 0000000000..854b60a204 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pac_armv81.h @@ -0,0 +1,206 @@ +/****************************************************************************** + * @file pac_armv81.h + * @brief CMSIS PAC key functions for Armv8.1-M PAC extension + * @version V1.0.0 + * @date 23. March 2022 + ******************************************************************************/ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef PAC_ARMV81_H +#define PAC_ARMV81_H + + +/* ################### PAC Key functions ########################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_PacKeyFunctions PAC Key functions + \brief Functions that access the PAC keys. + @{ + */ + +#if (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) + +/** + \brief read the PAC key used for privileged mode + \details Reads the PAC key stored in the PAC_KEY_P registers. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __get_PAC_KEY_P (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_p_0\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_p_1\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_p_2\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_p_3\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for privileged mode + \details writes the given PAC key to the PAC_KEY_P registers. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __set_PAC_KEY_P (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_p_0, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_p_1, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_p_2, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_p_3, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief read the PAC key used for unprivileged mode + \details Reads the PAC key stored in the PAC_KEY_U registers. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __get_PAC_KEY_U (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_u_0\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_u_1\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_u_2\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_u_3\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for unprivileged mode + \details writes the given PAC key to the PAC_KEY_U registers. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __set_PAC_KEY_U (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_u_0, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_u_1, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_u_2, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_u_3, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) + +/** + \brief read the PAC key used for privileged mode (non-secure) + \details Reads the PAC key stored in the non-secure PAC_KEY_P registers when in secure mode. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_get_PAC_KEY_P_NS (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_p_0_ns\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_p_1_ns\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_p_2_ns\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_p_3_ns\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for privileged mode (non-secure) + \details writes the given PAC key to the non-secure PAC_KEY_P registers when in secure mode. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_set_PAC_KEY_P_NS (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_p_0_ns, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_p_1_ns, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_p_2_ns, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_p_3_ns, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief read the PAC key used for unprivileged mode (non-secure) + \details Reads the PAC key stored in the non-secure PAC_KEY_U registers when in secure mode. + \param [out] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_get_PAC_KEY_U_NS (uint32_t* pPacKey) { + __ASM volatile ( + "mrs r1, pac_key_u_0_ns\n" + "str r1,[%0,#0]\n" + "mrs r1, pac_key_u_1_ns\n" + "str r1,[%0,#4]\n" + "mrs r1, pac_key_u_2_ns\n" + "str r1,[%0,#8]\n" + "mrs r1, pac_key_u_3_ns\n" + "str r1,[%0,#12]\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +/** + \brief write the PAC key used for unprivileged mode (non-secure) + \details writes the given PAC key to the non-secure PAC_KEY_U registers when in secure mode. + \param [in] pPacKey 128bit PAC key + */ +__STATIC_FORCEINLINE void __TZ_set_PAC_KEY_U_NS (uint32_t* pPacKey) { + __ASM volatile ( + "ldr r1,[%0,#0]\n" + "msr pac_key_u_0_ns, r1\n" + "ldr r1,[%0,#4]\n" + "msr pac_key_u_1_ns, r1\n" + "ldr r1,[%0,#8]\n" + "msr pac_key_u_2_ns, r1\n" + "ldr r1,[%0,#12]\n" + "msr pac_key_u_3_ns, r1\n" + : : "r" (pPacKey) : "memory", "r1" + ); +} + +#endif /* (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) */ + +#endif /* (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) */ + +/*@} end of CMSIS_Core_PacKeyFunctions */ + + +#endif /* PAC_ARMV81_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h new file mode 100644 index 0000000000..aa53bb47c1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/pmu_armv8.h @@ -0,0 +1,337 @@ +/****************************************************************************** + * @file pmu_armv8.h + * @brief CMSIS PMU API for Armv8.1-M PMU + * @version V1.0.1 + * @date 15. April 2020 + ******************************************************************************/ +/* + * Copyright (c) 2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_PMU_ARMV8_H +#define ARM_PMU_ARMV8_H + +/** + * \brief PMU Events + * \note See the Armv8.1-M Architecture Reference Manual for full details on these PMU events. + * */ + +#define ARM_PMU_SW_INCR 0x0000 /*!< Software update to the PMU_SWINC register, architecturally executed and condition code check pass */ +#define ARM_PMU_L1I_CACHE_REFILL 0x0001 /*!< L1 I-Cache refill */ +#define ARM_PMU_L1D_CACHE_REFILL 0x0003 /*!< L1 D-Cache refill */ +#define ARM_PMU_L1D_CACHE 0x0004 /*!< L1 D-Cache access */ +#define ARM_PMU_LD_RETIRED 0x0006 /*!< Memory-reading instruction architecturally executed and condition code check pass */ +#define ARM_PMU_ST_RETIRED 0x0007 /*!< Memory-writing instruction architecturally executed and condition code check pass */ +#define ARM_PMU_INST_RETIRED 0x0008 /*!< Instruction architecturally executed */ +#define ARM_PMU_EXC_TAKEN 0x0009 /*!< Exception entry */ +#define ARM_PMU_EXC_RETURN 0x000A /*!< Exception return instruction architecturally executed and the condition code check pass */ +#define ARM_PMU_PC_WRITE_RETIRED 0x000C /*!< Software change to the Program Counter (PC). Instruction is architecturally executed and condition code check pass */ +#define ARM_PMU_BR_IMMED_RETIRED 0x000D /*!< Immediate branch architecturally executed */ +#define ARM_PMU_BR_RETURN_RETIRED 0x000E /*!< Function return instruction architecturally executed and the condition code check pass */ +#define ARM_PMU_UNALIGNED_LDST_RETIRED 0x000F /*!< Unaligned memory memory-reading or memory-writing instruction architecturally executed and condition code check pass */ +#define ARM_PMU_BR_MIS_PRED 0x0010 /*!< Mispredicted or not predicted branch speculatively executed */ +#define ARM_PMU_CPU_CYCLES 0x0011 /*!< Cycle */ +#define ARM_PMU_BR_PRED 0x0012 /*!< Predictable branch speculatively executed */ +#define ARM_PMU_MEM_ACCESS 0x0013 /*!< Data memory access */ +#define ARM_PMU_L1I_CACHE 0x0014 /*!< Level 1 instruction cache access */ +#define ARM_PMU_L1D_CACHE_WB 0x0015 /*!< Level 1 data cache write-back */ +#define ARM_PMU_L2D_CACHE 0x0016 /*!< Level 2 data cache access */ +#define ARM_PMU_L2D_CACHE_REFILL 0x0017 /*!< Level 2 data cache refill */ +#define ARM_PMU_L2D_CACHE_WB 0x0018 /*!< Level 2 data cache write-back */ +#define ARM_PMU_BUS_ACCESS 0x0019 /*!< Bus access */ +#define ARM_PMU_MEMORY_ERROR 0x001A /*!< Local memory error */ +#define ARM_PMU_INST_SPEC 0x001B /*!< Instruction speculatively executed */ +#define ARM_PMU_BUS_CYCLES 0x001D /*!< Bus cycles */ +#define ARM_PMU_CHAIN 0x001E /*!< For an odd numbered counter, increment when an overflow occurs on the preceding even-numbered counter on the same PE */ +#define ARM_PMU_L1D_CACHE_ALLOCATE 0x001F /*!< Level 1 data cache allocation without refill */ +#define ARM_PMU_L2D_CACHE_ALLOCATE 0x0020 /*!< Level 2 data cache allocation without refill */ +#define ARM_PMU_BR_RETIRED 0x0021 /*!< Branch instruction architecturally executed */ +#define ARM_PMU_BR_MIS_PRED_RETIRED 0x0022 /*!< Mispredicted branch instruction architecturally executed */ +#define ARM_PMU_STALL_FRONTEND 0x0023 /*!< No operation issued because of the frontend */ +#define ARM_PMU_STALL_BACKEND 0x0024 /*!< No operation issued because of the backend */ +#define ARM_PMU_L2I_CACHE 0x0027 /*!< Level 2 instruction cache access */ +#define ARM_PMU_L2I_CACHE_REFILL 0x0028 /*!< Level 2 instruction cache refill */ +#define ARM_PMU_L3D_CACHE_ALLOCATE 0x0029 /*!< Level 3 data cache allocation without refill */ +#define ARM_PMU_L3D_CACHE_REFILL 0x002A /*!< Level 3 data cache refill */ +#define ARM_PMU_L3D_CACHE 0x002B /*!< Level 3 data cache access */ +#define ARM_PMU_L3D_CACHE_WB 0x002C /*!< Level 3 data cache write-back */ +#define ARM_PMU_LL_CACHE_RD 0x0036 /*!< Last level data cache read */ +#define ARM_PMU_LL_CACHE_MISS_RD 0x0037 /*!< Last level data cache read miss */ +#define ARM_PMU_L1D_CACHE_MISS_RD 0x0039 /*!< Level 1 data cache read miss */ +#define ARM_PMU_OP_COMPLETE 0x003A /*!< Operation retired */ +#define ARM_PMU_OP_SPEC 0x003B /*!< Operation speculatively executed */ +#define ARM_PMU_STALL 0x003C /*!< Stall cycle for instruction or operation not sent for execution */ +#define ARM_PMU_STALL_OP_BACKEND 0x003D /*!< Stall cycle for instruction or operation not sent for execution due to pipeline backend */ +#define ARM_PMU_STALL_OP_FRONTEND 0x003E /*!< Stall cycle for instruction or operation not sent for execution due to pipeline frontend */ +#define ARM_PMU_STALL_OP 0x003F /*!< Instruction or operation slots not occupied each cycle */ +#define ARM_PMU_L1D_CACHE_RD 0x0040 /*!< Level 1 data cache read */ +#define ARM_PMU_LE_RETIRED 0x0100 /*!< Loop end instruction executed */ +#define ARM_PMU_LE_SPEC 0x0101 /*!< Loop end instruction speculatively executed */ +#define ARM_PMU_BF_RETIRED 0x0104 /*!< Branch future instruction architecturally executed and condition code check pass */ +#define ARM_PMU_BF_SPEC 0x0105 /*!< Branch future instruction speculatively executed and condition code check pass */ +#define ARM_PMU_LE_CANCEL 0x0108 /*!< Loop end instruction not taken */ +#define ARM_PMU_BF_CANCEL 0x0109 /*!< Branch future instruction not taken */ +#define ARM_PMU_SE_CALL_S 0x0114 /*!< Call to secure function, resulting in Security state change */ +#define ARM_PMU_SE_CALL_NS 0x0115 /*!< Call to non-secure function, resulting in Security state change */ +#define ARM_PMU_DWT_CMPMATCH0 0x0118 /*!< DWT comparator 0 match */ +#define ARM_PMU_DWT_CMPMATCH1 0x0119 /*!< DWT comparator 1 match */ +#define ARM_PMU_DWT_CMPMATCH2 0x011A /*!< DWT comparator 2 match */ +#define ARM_PMU_DWT_CMPMATCH3 0x011B /*!< DWT comparator 3 match */ +#define ARM_PMU_MVE_INST_RETIRED 0x0200 /*!< MVE instruction architecturally executed */ +#define ARM_PMU_MVE_INST_SPEC 0x0201 /*!< MVE instruction speculatively executed */ +#define ARM_PMU_MVE_FP_RETIRED 0x0204 /*!< MVE floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_SPEC 0x0205 /*!< MVE floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_HP_RETIRED 0x0208 /*!< MVE half-precision floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_HP_SPEC 0x0209 /*!< MVE half-precision floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_SP_RETIRED 0x020C /*!< MVE single-precision floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_SP_SPEC 0x020D /*!< MVE single-precision floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_MAC_RETIRED 0x0214 /*!< MVE floating-point multiply or multiply-accumulate instruction architecturally executed */ +#define ARM_PMU_MVE_FP_MAC_SPEC 0x0215 /*!< MVE floating-point multiply or multiply-accumulate instruction speculatively executed */ +#define ARM_PMU_MVE_INT_RETIRED 0x0224 /*!< MVE integer instruction architecturally executed */ +#define ARM_PMU_MVE_INT_SPEC 0x0225 /*!< MVE integer instruction speculatively executed */ +#define ARM_PMU_MVE_INT_MAC_RETIRED 0x0228 /*!< MVE multiply or multiply-accumulate instruction architecturally executed */ +#define ARM_PMU_MVE_INT_MAC_SPEC 0x0229 /*!< MVE multiply or multiply-accumulate instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_RETIRED 0x0238 /*!< MVE load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_SPEC 0x0239 /*!< MVE load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_RETIRED 0x023C /*!< MVE load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_SPEC 0x023D /*!< MVE load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_RETIRED 0x0240 /*!< MVE store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_SPEC 0x0241 /*!< MVE store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_CONTIG_RETIRED 0x0244 /*!< MVE contiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_CONTIG_SPEC 0x0245 /*!< MVE contiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_CONTIG_RETIRED 0x0248 /*!< MVE contiguous load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_CONTIG_SPEC 0x0249 /*!< MVE contiguous load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_CONTIG_RETIRED 0x024C /*!< MVE contiguous store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_CONTIG_SPEC 0x024D /*!< MVE contiguous store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_NONCONTIG_RETIRED 0x0250 /*!< MVE non-contiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_NONCONTIG_SPEC 0x0251 /*!< MVE non-contiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_NONCONTIG_RETIRED 0x0254 /*!< MVE non-contiguous load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_NONCONTIG_SPEC 0x0255 /*!< MVE non-contiguous load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_NONCONTIG_RETIRED 0x0258 /*!< MVE non-contiguous store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_NONCONTIG_SPEC 0x0259 /*!< MVE non-contiguous store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_MULTI_RETIRED 0x025C /*!< MVE memory instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_LDST_MULTI_SPEC 0x025D /*!< MVE memory instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_LD_MULTI_RETIRED 0x0260 /*!< MVE memory load instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_LD_MULTI_SPEC 0x0261 /*!< MVE memory load instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_ST_MULTI_RETIRED 0x0261 /*!< MVE memory store instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_ST_MULTI_SPEC 0x0265 /*!< MVE memory store instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_RETIRED 0x028C /*!< MVE unaligned memory load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_SPEC 0x028D /*!< MVE unaligned memory load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_UNALIGNED_RETIRED 0x0290 /*!< MVE unaligned load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_UNALIGNED_SPEC 0x0291 /*!< MVE unaligned load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_UNALIGNED_RETIRED 0x0294 /*!< MVE unaligned store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_UNALIGNED_SPEC 0x0295 /*!< MVE unaligned store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_NONCONTIG_RETIRED 0x0298 /*!< MVE unaligned noncontiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_NONCONTIG_SPEC 0x0299 /*!< MVE unaligned noncontiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_RETIRED 0x02A0 /*!< MVE vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_SPEC 0x02A1 /*!< MVE vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_FP_RETIRED 0x02A4 /*!< MVE floating-point vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_FP_SPEC 0x02A5 /*!< MVE floating-point vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_INT_RETIRED 0x02A8 /*!< MVE integer vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_INT_SPEC 0x02A9 /*!< MVE integer vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_PRED 0x02B8 /*!< Cycles where one or more predicated beats architecturally executed */ +#define ARM_PMU_MVE_STALL 0x02CC /*!< Stall cycles caused by an MVE instruction */ +#define ARM_PMU_MVE_STALL_RESOURCE 0x02CD /*!< Stall cycles caused by an MVE instruction because of resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_MEM 0x02CE /*!< Stall cycles caused by an MVE instruction because of memory resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_FP 0x02CF /*!< Stall cycles caused by an MVE instruction because of floating-point resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_INT 0x02D0 /*!< Stall cycles caused by an MVE instruction because of integer resource conflicts */ +#define ARM_PMU_MVE_STALL_BREAK 0x02D3 /*!< Stall cycles caused by an MVE chain break */ +#define ARM_PMU_MVE_STALL_DEPENDENCY 0x02D4 /*!< Stall cycles caused by MVE register dependency */ +#define ARM_PMU_ITCM_ACCESS 0x4007 /*!< Instruction TCM access */ +#define ARM_PMU_DTCM_ACCESS 0x4008 /*!< Data TCM access */ +#define ARM_PMU_TRCEXTOUT0 0x4010 /*!< ETM external output 0 */ +#define ARM_PMU_TRCEXTOUT1 0x4011 /*!< ETM external output 1 */ +#define ARM_PMU_TRCEXTOUT2 0x4012 /*!< ETM external output 2 */ +#define ARM_PMU_TRCEXTOUT3 0x4013 /*!< ETM external output 3 */ +#define ARM_PMU_CTI_TRIGOUT4 0x4018 /*!< Cross-trigger Interface output trigger 4 */ +#define ARM_PMU_CTI_TRIGOUT5 0x4019 /*!< Cross-trigger Interface output trigger 5 */ +#define ARM_PMU_CTI_TRIGOUT6 0x401A /*!< Cross-trigger Interface output trigger 6 */ +#define ARM_PMU_CTI_TRIGOUT7 0x401B /*!< Cross-trigger Interface output trigger 7 */ + +/** \brief PMU Functions */ + +__STATIC_INLINE void ARM_PMU_Enable(void); +__STATIC_INLINE void ARM_PMU_Disable(void); + +__STATIC_INLINE void ARM_PMU_Set_EVTYPER(uint32_t num, uint32_t type); + +__STATIC_INLINE void ARM_PMU_CYCCNT_Reset(void); +__STATIC_INLINE void ARM_PMU_EVCNTR_ALL_Reset(void); + +__STATIC_INLINE void ARM_PMU_CNTR_Enable(uint32_t mask); +__STATIC_INLINE void ARM_PMU_CNTR_Disable(uint32_t mask); + +__STATIC_INLINE uint32_t ARM_PMU_Get_CCNTR(void); +__STATIC_INLINE uint32_t ARM_PMU_Get_EVCNTR(uint32_t num); + +__STATIC_INLINE uint32_t ARM_PMU_Get_CNTR_OVS(void); +__STATIC_INLINE void ARM_PMU_Set_CNTR_OVS(uint32_t mask); + +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Enable(uint32_t mask); +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Disable(uint32_t mask); + +__STATIC_INLINE void ARM_PMU_CNTR_Increment(uint32_t mask); + +/** + \brief Enable the PMU +*/ +__STATIC_INLINE void ARM_PMU_Enable(void) +{ + PMU->CTRL |= PMU_CTRL_ENABLE_Msk; +} + +/** + \brief Disable the PMU +*/ +__STATIC_INLINE void ARM_PMU_Disable(void) +{ + PMU->CTRL &= ~PMU_CTRL_ENABLE_Msk; +} + +/** + \brief Set event to count for PMU eventer counter + \param [in] num Event counter (0-30) to configure + \param [in] type Event to count +*/ +__STATIC_INLINE void ARM_PMU_Set_EVTYPER(uint32_t num, uint32_t type) +{ + PMU->EVTYPER[num] = type; +} + +/** + \brief Reset cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CYCCNT_Reset(void) +{ + PMU->CTRL |= PMU_CTRL_CYCCNT_RESET_Msk; +} + +/** + \brief Reset all event counters +*/ +__STATIC_INLINE void ARM_PMU_EVCNTR_ALL_Reset(void) +{ + PMU->CTRL |= PMU_CTRL_EVENTCNT_RESET_Msk; +} + +/** + \brief Enable counters + \param [in] mask Counters to enable + \note Enables one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Enable(uint32_t mask) +{ + PMU->CNTENSET = mask; +} + +/** + \brief Disable counters + \param [in] mask Counters to enable + \note Disables one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Disable(uint32_t mask) +{ + PMU->CNTENCLR = mask; +} + +/** + \brief Read cycle counter + \return Cycle count +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_CCNTR(void) +{ + return PMU->CCNTR; +} + +/** + \brief Read event counter + \param [in] num Event counter (0-30) to read + \return Event count +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_EVCNTR(uint32_t num) +{ + return PMU_EVCNTR_CNT_Msk & PMU->EVCNTR[num]; +} + +/** + \brief Read counter overflow status + \return Counter overflow status bits for the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_CNTR_OVS(void) +{ + return PMU->OVSSET; +} + +/** + \brief Clear counter overflow status + \param [in] mask Counter overflow status bits to clear + \note Clears overflow status bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_OVS(uint32_t mask) +{ + PMU->OVSCLR = mask; +} + +/** + \brief Enable counter overflow interrupt request + \param [in] mask Counter overflow interrupt request bits to set + \note Sets overflow interrupt request bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Enable(uint32_t mask) +{ + PMU->INTENSET = mask; +} + +/** + \brief Disable counter overflow interrupt request + \param [in] mask Counter overflow interrupt request bits to clear + \note Clears overflow interrupt request bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Disable(uint32_t mask) +{ + PMU->INTENCLR = mask; +} + +/** + \brief Software increment event counter + \param [in] mask Counters to increment + \note Software increment bits for one or more event counters (0-30) +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Increment(uint32_t mask) +{ + PMU->SWINC = mask; +} + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h new file mode 100644 index 0000000000..facc2c9a47 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Include/tz_context.h @@ -0,0 +1,70 @@ +/****************************************************************************** + * @file tz_context.h + * @brief Context Management for Armv8-M TrustZone + * @version V1.0.1 + * @date 10. January 2018 + ******************************************************************************/ +/* + * Copyright (c) 2017-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef TZ_CONTEXT_H +#define TZ_CONTEXT_H + +#include + +#ifndef TZ_MODULEID_T +#define TZ_MODULEID_T +/// \details Data type that identifies secure software modules called by a process. +typedef uint32_t TZ_ModuleId_t; +#endif + +/// \details TZ Memory ID identifies an allocated memory slot. +typedef uint32_t TZ_MemoryId_t; + +/// Initialize secure context memory system +/// \return execution status (1: success, 0: error) +uint32_t TZ_InitContextSystem_S (void); + +/// Allocate context memory for calling secure software modules in TrustZone +/// \param[in] module identifies software modules called from non-secure mode +/// \return value != 0 id TrustZone memory slot identifier +/// \return value 0 no memory available or internal error +TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); + +/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); + +/// Load secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); + +/// Store secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); + +#endif // TZ_CONTEXT_H diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c new file mode 100644 index 0000000000..0e56b7cb94 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/main_s.c @@ -0,0 +1,58 @@ +/****************************************************************************** + * @file main_s.c + * @brief Code template for secure main function + * @version V1.1.1 + * @date 10. January 2018 + ******************************************************************************/ +/* + * Copyright (c) 2013-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Use CMSE intrinsics */ +#include + +#include "RTE_Components.h" +#include CMSIS_device_header + +/* TZ_START_NS: Start address of non-secure application */ +#ifndef TZ_START_NS +#define TZ_START_NS (0x200000U) +#endif + +/* typedef for non-secure callback functions */ +typedef void (*funcptr_void) (void) __attribute__((cmse_nonsecure_call)); + +/* Secure main() */ +int main(void) { + funcptr_void NonSecure_ResetHandler; + + /* Add user setup code for secure part here*/ + + /* Set non-secure main stack (MSP_NS) */ + __TZ_set_MSP_NS(*((uint32_t *)(TZ_START_NS))); + + /* Get non-secure reset handler */ + NonSecure_ResetHandler = (funcptr_void)(*((uint32_t *)((TZ_START_NS) + 4U))); + + /* Start non-secure state software application */ + NonSecure_ResetHandler(); + + /* Non-secure software does not return, this code is not executed */ + while (1) { + __NOP(); + } +} diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c new file mode 100644 index 0000000000..e2e82942f8 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Core/Template/ARMv8-M/tz_context.c @@ -0,0 +1,200 @@ +/****************************************************************************** + * @file tz_context.c + * @brief Context Management for Armv8-M TrustZone - Sample implementation + * @version V1.1.1 + * @date 10. January 2018 + ******************************************************************************/ +/* + * Copyright (c) 2016-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "RTE_Components.h" +#include CMSIS_device_header +#include "tz_context.h" + +/// Number of process slots (threads may call secure library code) +#ifndef TZ_PROCESS_STACK_SLOTS +#define TZ_PROCESS_STACK_SLOTS 8U +#endif + +/// Stack size of the secure library code +#ifndef TZ_PROCESS_STACK_SIZE +#define TZ_PROCESS_STACK_SIZE 256U +#endif + +typedef struct { + uint32_t sp_top; // stack space top + uint32_t sp_limit; // stack space limit + uint32_t sp; // current stack pointer +} stack_info_t; + +static stack_info_t ProcessStackInfo [TZ_PROCESS_STACK_SLOTS]; +static uint64_t ProcessStackMemory[TZ_PROCESS_STACK_SLOTS][TZ_PROCESS_STACK_SIZE/8U]; +static uint32_t ProcessStackFreeSlot = 0xFFFFFFFFU; + + +/// Initialize secure context memory system +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_InitContextSystem_S (void) { + uint32_t n; + + if (__get_IPSR() == 0U) { + return 0U; // Thread Mode + } + + for (n = 0U; n < TZ_PROCESS_STACK_SLOTS; n++) { + ProcessStackInfo[n].sp = 0U; + ProcessStackInfo[n].sp_limit = (uint32_t)&ProcessStackMemory[n]; + ProcessStackInfo[n].sp_top = (uint32_t)&ProcessStackMemory[n] + TZ_PROCESS_STACK_SIZE; + *((uint32_t *)ProcessStackMemory[n]) = n + 1U; + } + *((uint32_t *)ProcessStackMemory[--n]) = 0xFFFFFFFFU; + + ProcessStackFreeSlot = 0U; + + // Default process stack pointer and stack limit + __set_PSPLIM((uint32_t)ProcessStackMemory); + __set_PSP ((uint32_t)ProcessStackMemory); + + // Privileged Thread Mode using PSP + __set_CONTROL(0x02U); + + return 1U; // Success +} + + +/// Allocate context memory for calling secure software modules in TrustZone +/// \param[in] module identifies software modules called from non-secure mode +/// \return value != 0 id TrustZone memory slot identifier +/// \return value 0 no memory available or internal error +__attribute__((cmse_nonsecure_entry)) +TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module) { + uint32_t slot; + + (void)module; // Ignore (fixed Stack size) + + if (__get_IPSR() == 0U) { + return 0U; // Thread Mode + } + + if (ProcessStackFreeSlot == 0xFFFFFFFFU) { + return 0U; // No slot available + } + + slot = ProcessStackFreeSlot; + ProcessStackFreeSlot = *((uint32_t *)ProcessStackMemory[slot]); + + ProcessStackInfo[slot].sp = ProcessStackInfo[slot].sp_top; + + return (slot + 1U); +} + + +/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id) { + uint32_t slot; + + if (__get_IPSR() == 0U) { + return 0U; // Thread Mode + } + + if ((id == 0U) || (id > TZ_PROCESS_STACK_SLOTS)) { + return 0U; // Invalid ID + } + + slot = id - 1U; + + if (ProcessStackInfo[slot].sp == 0U) { + return 0U; // Inactive slot + } + ProcessStackInfo[slot].sp = 0U; + + *((uint32_t *)ProcessStackMemory[slot]) = ProcessStackFreeSlot; + ProcessStackFreeSlot = slot; + + return 1U; // Success +} + + +/// Load secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_LoadContext_S (TZ_MemoryId_t id) { + uint32_t slot; + + if ((__get_IPSR() == 0U) || ((__get_CONTROL() & 2U) == 0U)) { + return 0U; // Thread Mode or using Main Stack for threads + } + + if ((id == 0U) || (id > TZ_PROCESS_STACK_SLOTS)) { + return 0U; // Invalid ID + } + + slot = id - 1U; + + if (ProcessStackInfo[slot].sp == 0U) { + return 0U; // Inactive slot + } + + // Setup process stack pointer and stack limit + __set_PSPLIM(ProcessStackInfo[slot].sp_limit); + __set_PSP (ProcessStackInfo[slot].sp); + + return 1U; // Success +} + + +/// Store secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +__attribute__((cmse_nonsecure_entry)) +uint32_t TZ_StoreContext_S (TZ_MemoryId_t id) { + uint32_t slot; + uint32_t sp; + + if ((__get_IPSR() == 0U) || ((__get_CONTROL() & 2U) == 0U)) { + return 0U; // Thread Mode or using Main Stack for threads + } + + if ((id == 0U) || (id > TZ_PROCESS_STACK_SLOTS)) { + return 0U; // Invalid ID + } + + slot = id - 1U; + + if (ProcessStackInfo[slot].sp == 0U) { + return 0U; // Inactive slot + } + + sp = __get_PSP(); + if ((sp < ProcessStackInfo[slot].sp_limit) || + (sp > ProcessStackInfo[slot].sp_top)) { + return 0U; // SP out of range + } + ProcessStackInfo[slot].sp = sp; + + // Default process stack pointer and stack limit + __set_PSPLIM((uint32_t)ProcessStackMemory); + __set_PSP ((uint32_t)ProcessStackMemory); + + return 1U; // Success +} diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h new file mode 100644 index 0000000000..a955d47139 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armcc.h @@ -0,0 +1,888 @@ +/**************************************************************************//** + * @file cmsis_armcc.h + * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file + * @version V5.3.2 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_ARMCC_H +#define __CMSIS_ARMCC_H + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) + #error "Please use Arm Compiler Toolchain V4.0.677 or later!" +#endif + +/* CMSIS compiler control architecture macros */ +#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \ + (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) ) + #define __ARM_ARCH_6M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1)) + #define __ARM_ARCH_7M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1)) + #define __ARM_ARCH_7EM__ 1 +#endif + + /* __ARM_ARCH_8M_BASE__ not applicable */ + /* __ARM_ARCH_8M_MAIN__ not applicable */ + /* __ARM_ARCH_8_1M_MAIN__ not applicable */ + +/* CMSIS compiler control DSP macros */ +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __ARM_FEATURE_DSP 1 +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE static __forceinline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __declspec(noreturn) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed)) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT __packed struct +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION __packed union +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x))) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr))) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __memory_changed() +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __nop + + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __dsb(0xF) + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) +{ + rev16 r0, r0 + bx lr +} +#endif + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value) +{ + revsh r0, r0 + bx lr +} +#endif + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +#define __ROR __ror + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __breakpoint(value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __RBIT __rbit +#else +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ + return result; +} +#endif + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __clz + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) +#else + #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) +#else + #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) +#else + #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXB(value, ptr) __strex(value, ptr) +#else + #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXH(value, ptr) __strex(value, ptr) +#else + #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXW(value, ptr) __strex(value, ptr) +#else + #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __clrex + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) +{ + rrx r0, r0 + bx lr +} +#endif + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRBT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRHT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRT(value, ptr) __strt(value, ptr) + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __enable_irq(); */ + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +/* intrinsic void __disable_irq(); */ + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; + __ISB(); +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_INLINE uint32_t __get_IPSR(void) +{ + register uint32_t __regIPSR __ASM("ipsr"); + return(__regIPSR); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_INLINE uint32_t __get_APSR(void) +{ + register uint32_t __regAPSR __ASM("apsr"); + return(__regAPSR); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_INLINE uint32_t __get_xPSR(void) +{ + register uint32_t __regXPSR __ASM("xpsr"); + return(__regXPSR); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + return(__regProcessStackPointer); +} + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + __regProcessStackPointer = topOfProcStack; +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + return(__regMainStackPointer); +} + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + __regMainStackPointer = topOfMainStack; +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xFFU); +} + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + register uint32_t __regBasePriMax __ASM("basepri_max"); + __regBasePriMax = (basePri & 0xFFU); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & (uint32_t)1U); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + return(__regfpscr); +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +#define __SADD8 __sadd8 +#define __QADD8 __qadd8 +#define __SHADD8 __shadd8 +#define __UADD8 __uadd8 +#define __UQADD8 __uqadd8 +#define __UHADD8 __uhadd8 +#define __SSUB8 __ssub8 +#define __QSUB8 __qsub8 +#define __SHSUB8 __shsub8 +#define __USUB8 __usub8 +#define __UQSUB8 __uqsub8 +#define __UHSUB8 __uhsub8 +#define __SADD16 __sadd16 +#define __QADD16 __qadd16 +#define __SHADD16 __shadd16 +#define __UADD16 __uadd16 +#define __UQADD16 __uqadd16 +#define __UHADD16 __uhadd16 +#define __SSUB16 __ssub16 +#define __QSUB16 __qsub16 +#define __SHSUB16 __shsub16 +#define __USUB16 __usub16 +#define __UQSUB16 __uqsub16 +#define __UHSUB16 __uhsub16 +#define __SASX __sasx +#define __QASX __qasx +#define __SHASX __shasx +#define __UASX __uasx +#define __UQASX __uqasx +#define __UHASX __uhasx +#define __SSAX __ssax +#define __QSAX __qsax +#define __SHSAX __shsax +#define __USAX __usax +#define __UQSAX __uqsax +#define __UHSAX __uhsax +#define __USAD8 __usad8 +#define __USADA8 __usada8 +#define __SSAT16 __ssat16 +#define __USAT16 __usat16 +#define __UXTB16 __uxtb16 +#define __UXTAB16 __uxtab16 +#define __SXTB16 __sxtb16 +#define __SXTAB16 __sxtab16 +#define __SMUAD __smuad +#define __SMUADX __smuadx +#define __SMLAD __smlad +#define __SMLADX __smladx +#define __SMLALD __smlald +#define __SMLALDX __smlaldx +#define __SMUSD __smusd +#define __SMUSDX __smusdx +#define __SMLSD __smlsd +#define __SMLSDX __smlsdx +#define __SMLSLD __smlsld +#define __SMLSLDX __smlsldx +#define __SEL __sel +#define __QADD __qadd +#define __QSUB __qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ + ((int64_t)(ARG3) << 32U) ) >> 32U)) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h new file mode 100644 index 0000000000..6911417747 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang.h @@ -0,0 +1,1503 @@ +/**************************************************************************//** + * @file cmsis_armclang.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V5.4.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +#define __SADD8 __builtin_arm_sadd8 +#define __QADD8 __builtin_arm_qadd8 +#define __SHADD8 __builtin_arm_shadd8 +#define __UADD8 __builtin_arm_uadd8 +#define __UQADD8 __builtin_arm_uqadd8 +#define __UHADD8 __builtin_arm_uhadd8 +#define __SSUB8 __builtin_arm_ssub8 +#define __QSUB8 __builtin_arm_qsub8 +#define __SHSUB8 __builtin_arm_shsub8 +#define __USUB8 __builtin_arm_usub8 +#define __UQSUB8 __builtin_arm_uqsub8 +#define __UHSUB8 __builtin_arm_uhsub8 +#define __SADD16 __builtin_arm_sadd16 +#define __QADD16 __builtin_arm_qadd16 +#define __SHADD16 __builtin_arm_shadd16 +#define __UADD16 __builtin_arm_uadd16 +#define __UQADD16 __builtin_arm_uqadd16 +#define __UHADD16 __builtin_arm_uhadd16 +#define __SSUB16 __builtin_arm_ssub16 +#define __QSUB16 __builtin_arm_qsub16 +#define __SHSUB16 __builtin_arm_shsub16 +#define __USUB16 __builtin_arm_usub16 +#define __UQSUB16 __builtin_arm_uqsub16 +#define __UHSUB16 __builtin_arm_uhsub16 +#define __SASX __builtin_arm_sasx +#define __QASX __builtin_arm_qasx +#define __SHASX __builtin_arm_shasx +#define __UASX __builtin_arm_uasx +#define __UQASX __builtin_arm_uqasx +#define __UHASX __builtin_arm_uhasx +#define __SSAX __builtin_arm_ssax +#define __QSAX __builtin_arm_qsax +#define __SHSAX __builtin_arm_shsax +#define __USAX __builtin_arm_usax +#define __UQSAX __builtin_arm_uqsax +#define __UHSAX __builtin_arm_uhsax +#define __USAD8 __builtin_arm_usad8 +#define __USADA8 __builtin_arm_usada8 +#define __SSAT16 __builtin_arm_ssat16 +#define __USAT16 __builtin_arm_usat16 +#define __UXTB16 __builtin_arm_uxtb16 +#define __UXTAB16 __builtin_arm_uxtab16 +#define __SXTB16 __builtin_arm_sxtb16 +#define __SXTAB16 __builtin_arm_sxtab16 +#define __SMUAD __builtin_arm_smuad +#define __SMUADX __builtin_arm_smuadx +#define __SMLAD __builtin_arm_smlad +#define __SMLADX __builtin_arm_smladx +#define __SMLALD __builtin_arm_smlald +#define __SMLALDX __builtin_arm_smlaldx +#define __SMUSD __builtin_arm_smusd +#define __SMUSDX __builtin_arm_smusdx +#define __SMLSD __builtin_arm_smlsd +#define __SMLSDX __builtin_arm_smlsdx +#define __SMLSLD __builtin_arm_smlsld +#define __SMLSLDX __builtin_arm_smlsldx +#define __SEL __builtin_arm_sel +#define __QADD __builtin_arm_qadd +#define __QSUB __builtin_arm_qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h new file mode 100644 index 0000000000..1e255d5907 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_armclang_ltm.h @@ -0,0 +1,1928 @@ +/**************************************************************************//** + * @file cmsis_armclang_ltm.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V1.5.3 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2018-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} +#endif + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +#ifndef __ARM_COMPAT_H +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} +#endif + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h new file mode 100644 index 0000000000..adbf296f15 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_compiler.h @@ -0,0 +1,283 @@ +/**************************************************************************//** + * @file cmsis_compiler.h + * @brief CMSIS compiler generic header file + * @version V5.1.0 + * @date 09. October 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_COMPILER_H +#define __CMSIS_COMPILER_H + +#include + +/* + * Arm Compiler 4/5 + */ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + + +/* + * Arm Compiler 6.6 LTM (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) + #include "cmsis_armclang_ltm.h" + + /* + * Arm Compiler above 6.10.1 (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) + #include "cmsis_armclang.h" + + +/* + * GNU Compiler + */ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + + +/* + * IAR Compiler + */ +#elif defined ( __ICCARM__ ) + #include + + +/* + * TI Arm Compiler + */ +#elif defined ( __TI_ARM__ ) + #include + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __attribute__((packed)) + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed)) + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed)) + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) + #endif + #ifndef __RESTRICT + #define __RESTRICT __restrict + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * TASKING Compiler + */ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __packed__ + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __packed__ + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __packed__ + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __packed__ T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __align(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * COSMIC Compiler + */ +#elif defined ( __CSMC__ ) + #include + + #ifndef __ASM + #define __ASM _asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + // NO RETURN is automatically detected hence no warning here + #define __NO_RETURN + #endif + #ifndef __USED + #warning No compiler specific solution for __USED. __USED is ignored. + #define __USED + #endif + #ifndef __WEAK + #define __WEAK __weak + #endif + #ifndef __PACKED + #define __PACKED @packed + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT @packed struct + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION @packed union + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + @packed struct T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. + #define __ALIGNED(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +#else + #error Unknown compiler. +#endif + + +#endif /* __CMSIS_COMPILER_H */ + diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h new file mode 100644 index 0000000000..67bda4ef3c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_gcc.h @@ -0,0 +1,2211 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS compiler GCC header file + * @version V5.4.1 + * @date 27. May 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" + +/* Fallback for __has_builtin */ +#ifndef __has_builtin + #define __has_builtin(x) (0) +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START + +/** + \brief Initializes data and bss sections + \details This default implementations initialized all data and additional bss + sections relying on .copy.table and .zero.table specified properly + in the used linker script. + + */ +__STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) +{ + extern void _start(void) __NO_RETURN; + + typedef struct { + uint32_t const* src; + uint32_t* dest; + uint32_t wlen; + } __copy_table_t; + + typedef struct { + uint32_t* dest; + uint32_t wlen; + } __zero_table_t; + + extern const __copy_table_t __copy_table_start__; + extern const __copy_table_t __copy_table_end__; + extern const __zero_table_t __zero_table_start__; + extern const __zero_table_t __zero_table_end__; + + for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = pTable->src[i]; + } + } + + for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = 0u; + } + } + + _start(); +} + +#define __PROGRAM_START __cmsis_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP __StackTop +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT __StackLimit +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section(".vectors"))) +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL __StackSeal +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP() __ASM volatile ("nop") + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI() __ASM volatile ("wfi":::"memory") + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE() __ASM volatile ("wfe":::"memory") + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV() __ASM volatile ("sev") + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__STATIC_FORCEINLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__STATIC_FORCEINLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__STATIC_FORCEINLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (int16_t)__builtin_bswap16(value); +#else + int16_t result; + + __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + __ASM ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return result; +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__STATIC_FORCEINLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting special-purpose register PRIMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); + __ISB(); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); + __ISB(); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting special-purpose register FAULTMASK. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_FORCEINLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_get_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + return __builtin_arm_get_fpscr(); +#else + uint32_t result; + + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + return(result); +#endif +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_set_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + __builtin_arm_set_fpscr(fpscr); +#else + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); +#endif +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +#define __USAT16(ARG1, ARG2) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16_RORn(uint32_t op1, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtb16 %0, %1, ROR %2" : "=r" (result) : "r" (op1), "i" (rotate) ); + } else { + result = __SXTB16(__ROR(op1, rotate)) ; + } + return result; +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16_RORn(uint32_t op1, uint32_t op2, uint32_t rotate) +{ + uint32_t result; + if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U))) { + __ASM volatile ("sxtab16 %0, %1, %2, ROR %3" : "=r" (result) : "r" (op1) , "r" (op2) , "i" (rotate)); + } else { + result = __SXTAB16(op1, __ROR(op2, rotate)); + } + return result; +} + + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +#define __PKHBT(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +__extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#pragma GCC diagnostic pop + +#endif /* __CMSIS_GCC_H */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h new file mode 100644 index 0000000000..65b824b009 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_iccarm.h @@ -0,0 +1,1002 @@ +/**************************************************************************//** + * @file cmsis_iccarm.h + * @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file + * @version V5.3.0 + * @date 14. April 2021 + ******************************************************************************/ + +//------------------------------------------------------------------------------ +// +// Copyright (c) 2017-2021 IAR Systems +// Copyright (c) 2017-2021 Arm Limited. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//------------------------------------------------------------------------------ + + +#ifndef __CMSIS_ICCARM_H__ +#define __CMSIS_ICCARM_H__ + +#ifndef __ICCARM__ + #error This file should only be compiled by ICCARM +#endif + +#pragma system_include + +#define __IAR_FT _Pragma("inline=forced") __intrinsic + +#if (__VER__ >= 8000000) + #define __ICCARM_V8 1 +#else + #define __ICCARM_V8 0 +#endif + +#ifndef __ALIGNED + #if __ICCARM_V8 + #define __ALIGNED(x) __attribute__((aligned(x))) + #elif (__VER__ >= 7080000) + /* Needs IAR language extensions */ + #define __ALIGNED(x) __attribute__((aligned(x))) + #else + #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored. + #define __ALIGNED(x) + #endif +#endif + + +/* Define compiler macros for CPU architecture, used in CMSIS 5. + */ +#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__ +/* Macros already defined */ +#else + #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M' + #if __ARM_ARCH == 6 + #define __ARM_ARCH_6M__ 1 + #elif __ARM_ARCH == 7 + #if __ARM_FEATURE_DSP + #define __ARM_ARCH_7EM__ 1 + #else + #define __ARM_ARCH_7M__ 1 + #endif + #endif /* __ARM_ARCH */ + #endif /* __ARM_ARCH_PROFILE == 'M' */ +#endif + +/* Alternativ core deduction for older ICCARM's */ +#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \ + !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__) + #if defined(__ARM6M__) && (__CORE__ == __ARM6M__) + #define __ARM_ARCH_6M__ 1 + #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__) + #define __ARM_ARCH_7M__ 1 + #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__) + #define __ARM_ARCH_7EM__ 1 + #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #else + #error "Unknown target." + #endif +#endif + + + +#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1 + #define __IAR_M0_FAMILY 1 +#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1 + #define __IAR_M0_FAMILY 1 +#else + #define __IAR_M0_FAMILY 0 +#endif + + +#ifndef __ASM + #define __ASM __asm +#endif + +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +#ifndef __INLINE + #define __INLINE inline +#endif + +#ifndef __NO_RETURN + #if __ICCARM_V8 + #define __NO_RETURN __attribute__((__noreturn__)) + #else + #define __NO_RETURN _Pragma("object_attribute=__noreturn") + #endif +#endif + +#ifndef __PACKED + #if __ICCARM_V8 + #define __PACKED __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED __packed + #endif +#endif + +#ifndef __PACKED_STRUCT + #if __ICCARM_V8 + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_STRUCT __packed struct + #endif +#endif + +#ifndef __PACKED_UNION + #if __ICCARM_V8 + #define __PACKED_UNION union __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_UNION __packed union + #endif +#endif + +#ifndef __RESTRICT + #if __ICCARM_V8 + #define __RESTRICT __restrict + #else + /* Needs IAR language extensions */ + #define __RESTRICT restrict + #endif +#endif + +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif + +#ifndef __FORCEINLINE + #define __FORCEINLINE _Pragma("inline=forced") +#endif + +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE +#endif + +#ifndef __UNALIGNED_UINT16_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint16_t __iar_uint16_read(void const *ptr) +{ + return *(__packed uint16_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR) +#endif + + +#ifndef __UNALIGNED_UINT16_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val) +{ + *(__packed uint16_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint32_t __iar_uint32_read(void const *ptr) +{ + return *(__packed uint32_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR) +#endif + +#ifndef __UNALIGNED_UINT32_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val) +{ + *(__packed uint32_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32 /* deprecated */ +#pragma language=save +#pragma language=extended +__packed struct __iar_u32 { uint32_t v; }; +#pragma language=restore +#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v) +#endif + +#ifndef __USED + #if __ICCARM_V8 + #define __USED __attribute__((used)) + #else + #define __USED _Pragma("__root") + #endif +#endif + +#undef __WEAK /* undo the definition from DLib_Defaults.h */ +#ifndef __WEAK + #if __ICCARM_V8 + #define __WEAK __attribute__((weak)) + #else + #define __WEAK _Pragma("__weak") + #endif +#endif + +#ifndef __PROGRAM_START +#define __PROGRAM_START __iar_program_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP CSTACK$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT CSTACK$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __vector_table +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE @".intvec" +#endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +#ifndef __STACK_SEAL +#define __STACK_SEAL STACKSEAL$$Base +#endif + +#ifndef __TZ_STACK_SEAL_SIZE +#define __TZ_STACK_SEAL_SIZE 8U +#endif + +#ifndef __TZ_STACK_SEAL_VALUE +#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL +#endif + +__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) { + *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE; +} +#endif + +#ifndef __ICCARM_INTRINSICS_VERSION__ + #define __ICCARM_INTRINSICS_VERSION__ 0 +#endif + +#if __ICCARM_INTRINSICS_VERSION__ == 2 + + #if defined(__CLZ) + #undef __CLZ + #endif + #if defined(__REVSH) + #undef __REVSH + #endif + #if defined(__RBIT) + #undef __RBIT + #endif + #if defined(__SSAT) + #undef __SSAT + #endif + #if defined(__USAT) + #undef __USAT + #endif + + #include "iccarm_builtin.h" + + #define __disable_fault_irq __iar_builtin_disable_fiq + #define __disable_irq __iar_builtin_disable_interrupt + #define __enable_fault_irq __iar_builtin_enable_fiq + #define __enable_irq __iar_builtin_enable_interrupt + #define __arm_rsr __iar_builtin_rsr + #define __arm_wsr __iar_builtin_wsr + + + #define __get_APSR() (__arm_rsr("APSR")) + #define __get_BASEPRI() (__arm_rsr("BASEPRI")) + #define __get_CONTROL() (__arm_rsr("CONTROL")) + #define __get_FAULTMASK() (__arm_rsr("FAULTMASK")) + + #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + #define __get_FPSCR() (__arm_rsr("FPSCR")) + #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE))) + #else + #define __get_FPSCR() ( 0 ) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #define __get_IPSR() (__arm_rsr("IPSR")) + #define __get_MSP() (__arm_rsr("MSP")) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __get_MSPLIM() (0U) + #else + #define __get_MSPLIM() (__arm_rsr("MSPLIM")) + #endif + #define __get_PRIMASK() (__arm_rsr("PRIMASK")) + #define __get_PSP() (__arm_rsr("PSP")) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __get_PSPLIM() (0U) + #else + #define __get_PSPLIM() (__arm_rsr("PSPLIM")) + #endif + + #define __get_xPSR() (__arm_rsr("xPSR")) + + #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE))) + #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE))) + +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __arm_wsr("CONTROL", control); + __iar_builtin_ISB(); +} + + #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE))) + #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __set_MSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE))) + #endif + #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE))) + #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE))) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __set_PSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE))) + #endif + + #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS")) + +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __arm_wsr("CONTROL_NS", control); + __iar_builtin_ISB(); +} + + #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS")) + #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE))) + #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS")) + #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE))) + #define __TZ_get_SP_NS() (__arm_rsr("SP_NS")) + #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE))) + #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS")) + #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE))) + #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS")) + #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE))) + #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS")) + #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __TZ_get_PSPLIM_NS() (0U) + #define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE)) + #else + #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS")) + #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE))) + #endif + + #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS")) + #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE))) + + #define __NOP __iar_builtin_no_operation + + #define __CLZ __iar_builtin_CLZ + #define __CLREX __iar_builtin_CLREX + + #define __DMB __iar_builtin_DMB + #define __DSB __iar_builtin_DSB + #define __ISB __iar_builtin_ISB + + #define __LDREXB __iar_builtin_LDREXB + #define __LDREXH __iar_builtin_LDREXH + #define __LDREXW __iar_builtin_LDREX + + #define __RBIT __iar_builtin_RBIT + #define __REV __iar_builtin_REV + #define __REV16 __iar_builtin_REV16 + + __IAR_FT int16_t __REVSH(int16_t val) + { + return (int16_t) __iar_builtin_REVSH(val); + } + + #define __ROR __iar_builtin_ROR + #define __RRX __iar_builtin_RRX + + #define __SEV __iar_builtin_SEV + + #if !__IAR_M0_FAMILY + #define __SSAT __iar_builtin_SSAT + #endif + + #define __STREXB __iar_builtin_STREXB + #define __STREXH __iar_builtin_STREXH + #define __STREXW __iar_builtin_STREX + + #if !__IAR_M0_FAMILY + #define __USAT __iar_builtin_USAT + #endif + + #define __WFE __iar_builtin_WFE + #define __WFI __iar_builtin_WFI + + #if __ARM_MEDIA__ + #define __SADD8 __iar_builtin_SADD8 + #define __QADD8 __iar_builtin_QADD8 + #define __SHADD8 __iar_builtin_SHADD8 + #define __UADD8 __iar_builtin_UADD8 + #define __UQADD8 __iar_builtin_UQADD8 + #define __UHADD8 __iar_builtin_UHADD8 + #define __SSUB8 __iar_builtin_SSUB8 + #define __QSUB8 __iar_builtin_QSUB8 + #define __SHSUB8 __iar_builtin_SHSUB8 + #define __USUB8 __iar_builtin_USUB8 + #define __UQSUB8 __iar_builtin_UQSUB8 + #define __UHSUB8 __iar_builtin_UHSUB8 + #define __SADD16 __iar_builtin_SADD16 + #define __QADD16 __iar_builtin_QADD16 + #define __SHADD16 __iar_builtin_SHADD16 + #define __UADD16 __iar_builtin_UADD16 + #define __UQADD16 __iar_builtin_UQADD16 + #define __UHADD16 __iar_builtin_UHADD16 + #define __SSUB16 __iar_builtin_SSUB16 + #define __QSUB16 __iar_builtin_QSUB16 + #define __SHSUB16 __iar_builtin_SHSUB16 + #define __USUB16 __iar_builtin_USUB16 + #define __UQSUB16 __iar_builtin_UQSUB16 + #define __UHSUB16 __iar_builtin_UHSUB16 + #define __SASX __iar_builtin_SASX + #define __QASX __iar_builtin_QASX + #define __SHASX __iar_builtin_SHASX + #define __UASX __iar_builtin_UASX + #define __UQASX __iar_builtin_UQASX + #define __UHASX __iar_builtin_UHASX + #define __SSAX __iar_builtin_SSAX + #define __QSAX __iar_builtin_QSAX + #define __SHSAX __iar_builtin_SHSAX + #define __USAX __iar_builtin_USAX + #define __UQSAX __iar_builtin_UQSAX + #define __UHSAX __iar_builtin_UHSAX + #define __USAD8 __iar_builtin_USAD8 + #define __USADA8 __iar_builtin_USADA8 + #define __SSAT16 __iar_builtin_SSAT16 + #define __USAT16 __iar_builtin_USAT16 + #define __UXTB16 __iar_builtin_UXTB16 + #define __UXTAB16 __iar_builtin_UXTAB16 + #define __SXTB16 __iar_builtin_SXTB16 + #define __SXTAB16 __iar_builtin_SXTAB16 + #define __SMUAD __iar_builtin_SMUAD + #define __SMUADX __iar_builtin_SMUADX + #define __SMMLA __iar_builtin_SMMLA + #define __SMLAD __iar_builtin_SMLAD + #define __SMLADX __iar_builtin_SMLADX + #define __SMLALD __iar_builtin_SMLALD + #define __SMLALDX __iar_builtin_SMLALDX + #define __SMUSD __iar_builtin_SMUSD + #define __SMUSDX __iar_builtin_SMUSDX + #define __SMLSD __iar_builtin_SMLSD + #define __SMLSDX __iar_builtin_SMLSDX + #define __SMLSLD __iar_builtin_SMLSLD + #define __SMLSLDX __iar_builtin_SMLSLDX + #define __SEL __iar_builtin_SEL + #define __QADD __iar_builtin_QADD + #define __QSUB __iar_builtin_QSUB + #define __PKHBT __iar_builtin_PKHBT + #define __PKHTB __iar_builtin_PKHTB + #endif + +#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #define __CLZ __cmsis_iar_clz_not_active + #define __SSAT __cmsis_iar_ssat_not_active + #define __USAT __cmsis_iar_usat_not_active + #define __RBIT __cmsis_iar_rbit_not_active + #define __get_APSR __cmsis_iar_get_APSR_not_active + #endif + + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #define __get_FPSCR __cmsis_iar_get_FPSR_not_active + #define __set_FPSCR __cmsis_iar_set_FPSR_not_active + #endif + + #ifdef __INTRINSICS_INCLUDED + #error intrinsics.h is already included previously! + #endif + + #include + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #undef __CLZ + #undef __SSAT + #undef __USAT + #undef __RBIT + #undef __get_APSR + + __STATIC_INLINE uint8_t __CLZ(uint32_t data) + { + if (data == 0U) { return 32U; } + + uint32_t count = 0U; + uint32_t mask = 0x80000000U; + + while ((data & mask) == 0U) + { + count += 1U; + mask = mask >> 1U; + } + return count; + } + + __STATIC_INLINE uint32_t __RBIT(uint32_t v) + { + uint8_t sc = 31U; + uint32_t r = v; + for (v >>= 1U; v; v >>= 1U) + { + r <<= 1U; + r |= v & 1U; + sc--; + } + return (r << sc); + } + + __STATIC_INLINE uint32_t __get_APSR(void) + { + uint32_t res; + __asm("MRS %0,APSR" : "=r" (res)); + return res; + } + + #endif + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #undef __get_FPSCR + #undef __set_FPSCR + #define __get_FPSCR() (0) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #pragma diag_suppress=Pe940 + #pragma diag_suppress=Pe177 + + #define __enable_irq __enable_interrupt + #define __disable_irq __disable_interrupt + #define __NOP __no_operation + + #define __get_xPSR __get_PSR + + #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0) + + __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr) + { + return __LDREX((unsigned long *)ptr); + } + + __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr) + { + return __STREX(value, (unsigned long *)ptr); + } + #endif + + + /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + #if (__CORTEX_M >= 0x03) + + __IAR_FT uint32_t __RRX(uint32_t value) + { + uint32_t result; + __ASM volatile("RRX %0, %1" : "=r"(result) : "r" (value)); + return(result); + } + + __IAR_FT void __set_BASEPRI_MAX(uint32_t value) + { + __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value)); + } + + + #define __enable_fault_irq __enable_fiq + #define __disable_fault_irq __disable_fiq + + + #endif /* (__CORTEX_M >= 0x03) */ + + __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2) + { + return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2)); + } + + #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + __IAR_FT uint32_t __get_MSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,MSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_MSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR MSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __get_PSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_PSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_CONTROL_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,CONTROL_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value) + { + __asm volatile("MSR CONTROL_NS,%0" :: "r" (value)); + __iar_builtin_ISB(); + } + + __IAR_FT uint32_t __TZ_get_PSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PSP_NS(uint32_t value) + { + __asm volatile("MSR PSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_MSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSP_NS(uint32_t value) + { + __asm volatile("MSR MSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_SP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,SP_NS" : "=r" (res)); + return res; + } + __IAR_FT void __TZ_set_SP_NS(uint32_t value) + { + __asm volatile("MSR SP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value) + { + __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value) + { + __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value) + { + __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value) + { + __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value)); + } + + #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + +#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value)) + +#if __IAR_M0_FAMILY + __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) + { + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; + } + + __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) + { + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; + } +#endif + +#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + + __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr) + { + uint32_t res; + __ASM volatile ("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr) + { + uint32_t res; + __ASM volatile ("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDRT(volatile uint32_t *addr) + { + uint32_t res; + __ASM volatile ("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return res; + } + + __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr) + { + __ASM volatile ("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr) + { + __ASM volatile ("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr) + { + __ASM volatile ("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory"); + } + +#endif /* (__CORTEX_M >= 0x03) */ + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + + __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDA(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr) + { + __ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr) + { + __ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr) + { + __ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + +#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#undef __IAR_FT +#undef __IAR_M0_FAMILY +#undef __ICCARM_V8 + +#pragma diag_default=Pe940 +#pragma diag_default=Pe177 + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) + +#endif /* __CMSIS_ICCARM_H__ */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_version.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_version.h new file mode 100644 index 0000000000..8b4765f186 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/cmsis_version.h @@ -0,0 +1,39 @@ +/**************************************************************************//** + * @file cmsis_version.h + * @brief CMSIS Core(M) Version definitions + * @version V5.0.5 + * @date 02. February 2022 + ******************************************************************************/ +/* + * Copyright (c) 2009-2022 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CMSIS_VERSION_H +#define __CMSIS_VERSION_H + +/* CMSIS Version definitions */ +#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ +#define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */ +#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ + __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h new file mode 100644 index 0000000000..879a384124 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm0plus.h @@ -0,0 +1,1087 @@ +/**************************************************************************//** + * @file core_cm0plus.h + * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File + * @version V5.0.9 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0PLUS_H_GENERIC +#define __CORE_CM0PLUS_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex-M0+ + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0+ definitions */ +#define __CM0PLUS_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0PLUS_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ + __CM0PLUS_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0PLUS_H_DEPENDANT +#define __CORE_CM0PLUS_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0PLUS_REV + #define __CM0PLUS_REV 0x0000U + #warning "__CM0PLUS_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex-M0+ */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0+ header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0+ */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ +#endif + /* ARM Application Note 321 states that the M0+ does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +#endif +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm3.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm3.h new file mode 100644 index 0000000000..74fb87e5c5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/core_cm3.h @@ -0,0 +1,1943 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V5.1.2 + * @date 04. June 2021 + ******************************************************************************/ +/* + * Copyright (c) 2009-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM3_H_GENERIC +#define __CORE_CM3_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M3 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (3U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM3_H_DEPENDANT +#define __CORE_CM3_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM3_REV + #define __CM3_REV 0x0200U + #warning "__CM3_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M3 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV < 0x0201U) /* core r2p1 */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#else +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_CFSR_MEMFAULTSR_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_CFSR_MEMFAULTSR_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_CFSR_MEMFAULTSR_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +#else + uint32_t RESERVED1[1U]; +#endif +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ +#endif + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h new file mode 100644 index 0000000000..9909f83990 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/Include/mpu_armv7.h @@ -0,0 +1,275 @@ +/****************************************************************************** + * @file mpu_armv7.h + * @brief CMSIS MPU API for Armv7-M MPU + * @version V5.1.2 + * @date 25. May 2020 + ******************************************************************************/ +/* + * Copyright (c) 2017-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV7_H +#define ARM_MPU_ARMV7_H + +#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes +#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes +#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes +#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes +#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes +#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte +#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes +#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes +#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes +#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes +#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes +#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes +#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes +#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes +#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes +#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte +#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes +#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes +#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes +#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes +#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes +#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes +#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes +#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes +#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes +#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte +#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes +#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes + +#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access +#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only +#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only +#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access +#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only +#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access + +/** MPU Region Base Address Register Value +* +* \param Region The region to be configured, number 0 to 15. +* \param BaseAddress The base address for the region. +*/ +#define ARM_MPU_RBAR(Region, BaseAddress) \ + (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ + ((Region) & MPU_RBAR_REGION_Msk) | \ + (MPU_RBAR_VALID_Msk)) + +/** +* MPU Memory Access Attributes +* +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +*/ +#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \ + ((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ + (((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ + (((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ + (((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk)) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \ + ((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ + (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ + (((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \ + (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ + (((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ + (((MPU_RASR_ENABLE_Msk)))) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ + ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size) + +/** +* MPU Memory Access Attribute for strongly ordered memory. +* - TEX: 000b +* - Shareable +* - Non-cacheable +* - Non-bufferable +*/ +#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U) + +/** +* MPU Memory Access Attribute for device memory. +* - TEX: 000b (if shareable) or 010b (if non-shareable) +* - Shareable or non-shareable +* - Non-cacheable +* - Bufferable (if shareable) or non-bufferable (if non-shareable) +* +* \param IsShareable Configures the device memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U)) + +/** +* MPU Memory Access Attribute for normal memory. +* - TEX: 1BBb (reflecting outer cacheability rules) +* - Shareable or non-shareable +* - Cacheable or non-cacheable (reflecting inner cacheability rules) +* - Bufferable or non-bufferable (reflecting inner cacheability rules) +* +* \param OuterCp Configures the outer cache policy. +* \param InnerCp Configures the inner cache policy. +* \param IsShareable Configures the memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U)) + +/** +* MPU Memory Access Attribute non-cacheable policy. +*/ +#define ARM_MPU_CACHEP_NOCACHE 0U + +/** +* MPU Memory Access Attribute write-back, write and read allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_WRA 1U + +/** +* MPU Memory Access Attribute write-through, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WT_NWA 2U + +/** +* MPU Memory Access Attribute write-back, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_NWA 3U + + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; //!< The region base address register value (RBAR) + uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + MPU->RNR = rnr; + MPU->RASR = 0U; +} + +/** Configure an MPU region. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) +{ + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rasr Value for RASR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) +{ + MPU->RNR = rnr; + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_Load(). +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + while (cnt > MPU_TYPE_RALIASES) { + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); + table += MPU_TYPE_RALIASES; + cnt -= MPU_TYPE_RALIASES; + } + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); +} + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/LICENSE.txt b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/LICENSE.txt new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/README.md b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/README.md new file mode 100644 index 0000000000..0630bf8cd4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/CMSIS/README.md @@ -0,0 +1,141 @@ +# CMSIS Version 5 + +[![Version](https://img.shields.io/github/v/release/arm-software/CMSIS_5)](https://github.com/ARM-software/CMSIS_5/releases/latest) [![License](https://img.shields.io/github/license/arm-software/CMSIS_5)](https://arm-software.github.io/CMSIS_5/General/html/LICENSE.txt) + +The branch *master* of this GitHub repository contains ![Version](https://img.shields.io/github/v/release/arm-software/CMSIS_5?display_name=release&label=%20&sort=semver). +The [documentation](http://arm-software.github.io/CMSIS_5/General/html/index.html) is available under http://arm-software.github.io/CMSIS_5/General/html/index.html + +Use [Issues](https://github.com/ARM-software/CMSIS_5#issues-and-labels) to provide feedback and report problems for CMSIS Version 5. + +**Note:** The branch *develop* of this GitHub repository reflects our current state of development and is constantly updated. It gives our users and partners contiguous access to the CMSIS development. It allows you to review the work and provide feedback or create pull requests for contributions. + +A [pre-built documentation](https://arm-software.github.io/CMSIS_5/develop/General/html/index.html) is updated from time to time, but may be also generated using the instructions under [Generate CMSIS Pack for Release](https://github.com/ARM-software/CMSIS_5#generate-cmsis-pack-for-release). + +## Overview of CMSIS Components + +The following is an list of all CMSIS components that are available. + +| CMSIS-... | Target Processors | Description | +|:----------|:--------------------|:-------------| +|[Core(M)](http://arm-software.github.io/CMSIS_5/Core/html/index.html) | All Cortex-M, SecurCore | Standardized API for the Cortex-M processor core and peripherals. Includes intrinsic functions for Cortex-M4/M7/M33/M35P SIMD instructions.| +|[Core(A)](http://arm-software.github.io/CMSIS_5/Core_A/html/index.html)| Cortex-A5/A7/A9 | API and basic run-time system for the Cortex-A5/A7/A9 processor core and peripherals.| +|[Driver](http://arm-software.github.io/CMSIS_5/Driver/html/index.html) | All Cortex-M, SecurCore | Generic peripheral driver interfaces for middleware. Connects microcontroller peripherals with middleware that implements for example communication stacks, file systems, or graphic user interfaces.| +|[DSP](http://arm-software.github.io/CMSIS_5/DSP/html/index.html) | All Cortex-M | DSP library collection with over 60 Functions for various data types: fixed-point (fractional q7, q15, q31) and single precision floating-point (32-bit). Implementations optimized for the SIMD instruction set are available for Cortex-M4/M7/M33/M35P.| +|[NN](http://arm-software.github.io/CMSIS_5/NN/html/index.html) | All Cortex-M | Collection of efficient neural network kernels developed to maximize the performance and minimize the memory footprint on Cortex-M processor cores.| +|[RTOS v1](http://arm-software.github.io/CMSIS_5/RTOS/html/index.html) | Cortex-M0/M0+/M3/M4/M7 | Common API for real-time operating systems along with a reference implementation based on RTX. It enables software components that can work across multiple RTOS systems.| +|[RTOS v2](http://arm-software.github.io/CMSIS_5/RTOS2/html/index.html)| All Cortex-M, Cortex-A5/A7/A9 | Extends CMSIS-RTOS v1 with Armv8-M support, dynamic object creation, provisions for multi-core systems, binary compatible interface. | +|[Pack](http://arm-software.github.io/CMSIS_5/Pack/html/index.html) | All Cortex-M, SecurCore, Cortex-A5/A7/A9 | Describes a delivery mechanism for software components, device parameters, and evaluation board support. It simplifies software re-use and product life-cycle management (PLM).
Is part of the [Open CMSIS Pack project](https://www.open-cmsis-pack.org). | +|[Build](http://arm-software.github.io/CMSIS_5/Build/html/index.html) | All Cortex-M, SecurCore, Cortex-A5/A7/A9 | A set of tools, software frameworks, and work flows that improve productivity, for example with Continuous Integration (CI) support.
Is replaced with the [CMSIS-Toolbox](https://github.com/Open-CMSIS-Pack/devtools/tree/main/tools). | +|[SVD](http://arm-software.github.io/CMSIS_5/SVD/html/index.html) | All Cortex-M, SecurCore | Peripheral description of a device that can be used to create peripheral awareness in debuggers or CMSIS-Core header files.| +|[DAP](http://arm-software.github.io/CMSIS_5/DAP/html/index.html) | All Cortex | Firmware for a debug unit that interfaces to the CoreSight Debug Access Port. | +|[Zone](http://arm-software.github.io/CMSIS_5/Zone/html/index.html) | All Cortex-M | Defines methods to describe system resources and to partition these resources into multiple projects and execution areas. | + +## Implemented Enhancements + - CMSIS-Pack generation with [shell script template](https://arm-software.github.io/CMSIS_5/Pack/html/bash_script.html) for Windows and Linux + - CMSIS-Pack: [Git workflow](https://arm-software.github.io/CMSIS_5/Pack/html/element_repository.html) via Eclipse menu *Window - Preferences - CMSIS Packs - Manage Local Repositories* and [MDK](http://www.keil.com/support/man/docs/uv4/uv4_ca_packinst_repo.htm) + - [CMSIS-Zone release 1.0](https://arm-software.github.io/CMSIS_5/Zone/html/index.html) with support for multi-processor, TrustZone, and MPU configuration + - Support for Armv8.1M Architecture and Cortex-M55 (release in March 2020) + - CMSIS-DSP is fully ported to SIMD for Cortex-M family (Armv8.1-M) and Cortex-A & Cortex-R with NEON, using the same APIs. + +## Further Planned Enhancements + - CMSIS-Pack: + - System Description SDF Format: describe more complex debug topologies than with a Debug Description in a tool agnostic way + - CPDSC project file format: allows project templates that are agnostic of an IDE + - Minimize need for IDE specific settings: CMSIS-Pack supports IDE specific parameters. Analyze and minimize + - CMSIS-Build: command-line driven make system for CMSIS-Pack based projects (to support CI tests) + +For further details see also the [Slides of the Embedded World CMSIS Partner Meeting](https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS_Review_Meeting_2020.pdf). + +## Other related GitHub repositories + +| Repository | Description | +|:--------------------------- |:--------------------------------------------------------- | +| [cmsis-pack-eclipse](https://github.com/ARM-software/cmsis-pack-eclipse) | CMSIS-Pack Management for Eclipse reference implementation Pack support | +| [CMSIS-FreeRTOS](https://github.com/arm-software/CMSIS-FreeRTOS) | CMSIS-RTOS adoption of FreeRTOS | +| [CMSIS-Driver](https://github.com/arm-software/CMSIS-Driver) | Generic MCU driver implementations and templates for Ethernet MAC/PHY and Flash. | +| [CMSIS-Driver_Validation](https://github.com/ARM-software/CMSIS-Driver_Validation) | CMSIS-Driver Validation can be used to verify CMSIS-Driver in a user system | +| [CMSIS-Zone](https://github.com/ARM-software/CMSIS-Zone) | CMSIS-Zone Utility along with example projects and FreeMarker templates | +| [NXP_LPC](https://github.com/ARM-software/NXP_LPC) | CMSIS Driver Implementations for the NXP LPC Microcontroller Series | +| [mdk-packs](https://github.com/mdk-packs) | IoT cloud connectors as trail implementations for MDK (help us to make it generic)| +| [trustedfirmware.org](https://www.trustedfirmware.org/) | Arm Trusted Firmware provides a reference implementation of secure world software for Armv8-A and Armv8-M.| + + +## Directory Structure + +| Directory | Content | +|:-------------------- |:--------------------------------------------------------- | +| CMSIS/Core | CMSIS-Core(M) related files (for release) | +| CMSIS/Core_A | CMSIS-Core(A) related files (for release) | +| CMSIS/CoreValidation | Validation for Core(M) and Core(A) (NOT part of release) | +| CMSIS/DAP | CMSIS-DAP related files and examples | +| CMSIS/Driver | CMSIS-Driver API headers and template files | +| CMSIS/DSP | CMSIS-DSP related files | +| CMSIS/NN | CMSIS-NN related files | +| CMSIS/RTOS | RTOS v1 related files (for Cortex-M) | +| CMSIS/RTOS2 | RTOS v2 related files (for Cortex-M & Armv8-M) | +| CMSIS/Pack | CMSIS-Pack examples and tutorials | +| CMSIS/DoxyGen | Source of the documentation | +| CMSIS/Utilities | Utility programs | + +## Generate CMSIS Pack for Release + +This GitHub development repository lacks pre-built libraries of various software components (RTOS, RTOS2). +In order to generate a full pack one needs to have the build environment available to build these libraries. +This causes some sort of inconvenience. Hence the pre-built libraries may be moved out into separate pack(s) +in the future. + +To build a complete CMSIS pack for installation the following additional tools are required: + - **doxygen.exe** Version: 1.8.6 (Documentation Generator) + - **mscgen.exe** Version: 0.20 (Message Sequence Chart Converter) + - **7z.exe (7-Zip)** Version: 16.02 (File Archiver) + +Using these tools, you can generate on a Windows PC: + - **CMSIS Documentation** using the batch file **gen_doc.sh** (located in ./CMSIS/Doxygen). + - **CMSIS Software Pack** using the batch file **gen_pack.sh** (located in ./CMSIS/Utilities). + The bash script does not generate the documentation. The pre-built libraries for RTX4 and RTX5 + are not included within this repository. + +The file ./CMSIS/DoxyGen/How2Doc.txt describes the rules for creating API documentation. + +## License + +Arm CMSIS is licensed under Apache 2.0. + +## Contributions and Pull Requests + +Contributions are accepted under Apache 2.0. Only submit contributions where you have authored all of the code. + +### Issues and Labels + +Please feel free to raise an [issue on GitHub](https://github.com/ARM-software/CMSIS_5/issues) +to report misbehavior (i.e. bugs) or start discussions about enhancements. This +is your best way to interact directly with the maintenance team and the community. +We encourage you to append implementation suggestions as this helps to decrease the +workload of the very limited maintenance team. + +We will be monitoring and responding to issues as best we can. +Please attempt to avoid filing duplicates of open or closed items when possible. +In the spirit of openness we will be tagging issues with the following: + +- **bug** – We consider this issue to be a bug that will be investigated. + +- **wontfix** - We appreciate this issue but decided not to change the current behavior. + +- **enhancement** – Denotes something that will be implemented soon. + +- **future** - Denotes something not yet schedule for implementation. + +- **out-of-scope** - We consider this issue loosely related to CMSIS. It might by implemented outside of CMSIS. Let us know about your work. + +- **question** – We have further questions to this issue. Please review and provide feedback. + +- **documentation** - This issue is a documentation flaw that will be improved in future. + +- **review** - This issue is under review. Please be patient. + +- **DONE** - We consider this issue as resolved - please review and close it. In case of no further activity this issues will be closed after a week. + +- **duplicate** - This issue is already addressed elsewhere, see comment with provided references. + +- **Important Information** - We provide essential information regarding planned or resolved major enhancements. + diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/ht32f5xxxx_01.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/ht32f5xxxx_01.h new file mode 100644 index 0000000000..f72fd72a6f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/ht32f5xxxx_01.h @@ -0,0 +1,2749 @@ +/***************************************************************************//** + * @file ht32f5xxxx_01.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Header File + * @version $Rev:: 7319 $ + * @date $Date:: 2023-10-28 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * Holtek supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within + * development tools that are supporting such ARM-based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F50020, HT32F50030 +// HT32F50220, HT32F50230 +// HT32F50231, HT32F50241 +// HT32F50343 +// HT32F50431, HT32F50441 +// HT32F50442, HT32F50452 +// HT32F52220, HT32F52230 +// HT32F52231, HT32F52241 +// HT32F52243, HT32F52253 +// HT32F52331, HT32F52341 +// HT32F52342, HT32F52352 +// HT32F52344, HT32F52354 +// HT32F52357, HT32F52367 +// HT32F53231, HT32F53241 +// HT32F53242, HT32F53252 +// HT32F54231, HT32F54241 +// HT32F54243, HT32F54253 +// HT32F57331, HT32F57341 +// HT32F57342, HT32F57352 +// HT32F5826, HT32F5828 +// HT32F0006 +// HT32F0008 +// HT32F61141 +// HT32F61244, HT32F61245 +// HT32F65230, HT32F65240 +// HT32F65232 +// HT32F66242, HT32F66246 +// HT32F67041, HT32F67051 +// HT32F52234, HT32F52244 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx HT32F5xxxx + * @{ + */ + + +#ifndef __HT32F5XXXX_01_H__ +#define __HT32F5XXXX_01_H__ + +#include "ht32_config.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#if !defined(USE_HT32F52220_30) && \ + !defined(USE_HT32F52231_41) && \ + !defined(USE_HT32F52331_41) && \ + !defined(USE_HT32F52342_52) && \ + !defined(USE_HT32F52243_53) && \ + !defined(USE_HT32F5826) && \ + !defined(USE_HT32F0008) && \ + !defined(USE_HT32F50220_30) && \ + !defined(USE_HT32F50231_41) && \ + !defined(USE_HT32F52344_54) && \ + !defined(USE_HT32F0006) && \ + !defined(USE_HT32F52357_67) && \ + !defined(USE_HT32F65230_40) && \ + !defined(USE_HT32F54231_41) && \ + !defined(USE_HT32F54243_53) && \ + !defined(USE_HT32F57331_41) && \ + !defined(USE_HT32F57342_52) && \ + !defined(USE_HT32F50343) && \ + !defined(USE_HT32F65232) && \ + !defined(USE_HT32F61141) && \ + !defined(USE_HT32F61244_45) && \ + !defined(USE_HT32F50020_30) && \ + !defined(USE_HT32F67041_51) && \ + !defined(USE_HT32F50431_41) && \ + !defined(USE_HT32F50442_52) && \ + !defined(USE_HT32F53231_41) && \ + !defined(USE_HT32F53242_52) && \ + !defined(USE_HT32F66242) && \ + !defined(USE_HT32F66246) && \ + !defined(USE_HT32F52234_44) + + //#define USE_HT32F52220_30 + //#define USE_HT32F52231_41 + //#define USE_HT32F52331_41 + //#define USE_HT32F52342_52 + //#define USE_HT32F52243_53 + //#define USE_HT32F5826 + //#define USE_HT32F0008 + //#define USE_HT32F50220_30 + //#define USE_HT32F50231_41 + //#define USE_HT32F52344_54 + //#define USE_HT32F0006 + //#define USE_HT32F52357_67 + //#define USE_HT32F65230_40 + //#define USE_HT32F54231_41 + //#define USE_HT32F54243_53 + //#define USE_HT32F57331_41 + //#define USE_HT32F57342_52 + //#define USE_HT32F50343 + //#define USE_HT32F65232 + //#define USE_HT32F61141 + //#define USE_HT32F61244_45 + //#define USE_HT32F50020_30 + //#define USE_HT32F67041_51 + //#define USE_HT32F50431_41 + //#define USE_HT32F50442_52 + //#define USE_HT32F53231_41 + //#define USE_HT32F53242_52 + //#define USE_HT32F66242 + //#define USE_HT32F66246 + //#define USE_HT32F52234_44 + +#endif + +#if !defined(USE_NOCHIP) && \ + !defined(USE_HT32F52220_30) && \ + !defined(USE_HT32F52231_41) && \ + !defined(USE_HT32F52331_41) && \ + !defined(USE_HT32F52342_52) && \ + !defined(USE_HT32F52243_53) && \ + !defined(USE_HT32F5826) && \ + !defined(USE_HT32F0008) && \ + !defined(USE_HT32F50220_30) && \ + !defined(USE_HT32F50231_41) && \ + !defined(USE_HT32F52344_54) && \ + !defined(USE_HT32F0006) && \ + !defined(USE_HT32F52357_67) && \ + !defined(USE_HT32F65230_40) && \ + !defined(USE_HT32F54231_41) && \ + !defined(USE_HT32F54243_53) && \ + !defined(USE_HT32F57331_41) && \ + !defined(USE_HT32F57342_52) && \ + !defined(USE_HT32F50343) && \ + !defined(USE_HT32F65232) && \ + !defined(USE_HT32F61141) && \ + !defined(USE_HT32F61244_45) && \ + !defined(USE_HT32F50020_30) && \ + !defined(USE_HT32F67041_51) && \ + !defined(USE_HT32F50431_41) && \ + !defined(USE_HT32F50442_52) && \ + !defined(USE_HT32F53231_41) && \ + !defined(USE_HT32F53242_52) && \ + !defined(USE_HT32F66242) && \ + !defined(USE_HT32F66246) && \ + !defined(USE_HT32F52234_44) + + #error Please add "USE_HT32Fxxxxx_xx" define into C Preprocessor Symbols of the Project configuration. + +#endif + +/** @addtogroup Library_configuration_section + * @{ + */ +/** + * @brief Value of the High Speed Internal oscillator in Hz + */ +#if defined(USE_HT32F50220_30) || defined(USE_HT32F50231_41) + #define HSI_VALUE 20000000UL /*!< Value of the Internal High Speed oscillator in Hz */ +#elif defined(USE_HT32F50020_30) + #define HSI_VALUE 16000000UL /*!< Value of the Internal High Speed oscillator in Hz */ +#else + #define HSI_VALUE 8000000UL /*!< Value of the High Speed Internal oscillator in Hz */ +#endif + +/** + * @brief Value of the Low Speed Internal oscillator in Hz + */ +#define LSI_VALUE 32000UL /*!< Value of the Low Speed Internal oscillator in Hz */ + +#if !defined(USE_HT32F52220_30) && !defined(USE_HT32F66242) && !defined(USE_HT32F66246) +/** + * @brief Value of the Low Speed External oscillator in Hz + */ +#define LSE_VALUE 32768UL /*!< Value of the Low Speed External oscillator in Hz */ +#endif + +/** + * @brief Adjust the High Speed External oscillator (HSE) Startup Timeout value + */ +#define HSE_READY_TIME ((uint16_t)0xFFFF) /*!< Time out for HSE start up */ +/** + * @} + */ + +/** @addtogroup Configuration_section_for_CMSIS + * @{ + */ +#define __MPU_PRESENT 0 /*!< MPU present or not */ +#define __VTOR_PRESENT 1 /*!< VTOR present or not */ +#define __NVIC_PRIO_BITS 2 /*!< Number of Bits used for Priority Levels */ +#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ + +/** + * @} + */ + + +/** @addtogroup Configuration_for_Interrupt_Number + * @{ + */ +typedef enum IRQn +{ +/****** Cortex-M0+ Processor Exceptions Numbers ******************************** */ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ + HardFault_IRQn = -13, /*!< 3 Cortex-M0+ Hard Fault Interrupt */ + SVCall_IRQn = -5, /*!< 11 Cortex-M0+ SV Call Interrupt */ + PendSV_IRQn = -2, /*!< 14 Cortex-M0+ Pend SV Interrupt */ + SysTick_IRQn = -1, /*!< 15 Cortex-M0+ System Tick Interrupt */ + +/****** HT32 Specific Interrupt Numbers *************************************** */ + LVD_BOD_IRQn = 0, /*!< Low voltage & Brown-out detection interrupt */ + #if !defined(USE_HT32F52220_30) + RTC_IRQn = 1, /*!< RTC Wake-up Interrupt */ + #endif + FLASH_IRQn = 2, /*!< FLASH global Interrupt */ + EVWUP_IRQn = 3, /*!< EXTI Event Wake-up & WAKEUP pin Interrupt */ + EXTI0_1_IRQn = 4, /*!< EXTI0-1 Line detection Interrupt */ + EXTI2_3_IRQn = 5, /*!< EXTI2-3 Line detection Interrupt */ + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) + EXTI4_9_IRQn = 6, /*!< EXTI4-9 Line detection Interrupt */ + #elif defined(USE_HT32F50020_30) + EXTI4_7_IRQn = 6, /*!< EXTI4-7 Line detection Interrupt */ + #else + EXTI4_15_IRQn = 6, /*!< EXTI4-15 Line detection Interrupt */ + #endif + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F66242) || defined(USE_HT32F66246) + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) + EXTI10_15_IRQn = 7, /*!< EXTI10-15 Line detection Interrupt */ + #elif defined(USE_HT32F66246) + CAN0_IRQn = 7, /*!< CAN0 global Interrupt */ + #endif + ADC0_IRQn = 8, /*!< ADC0 Interrupt */ + #if defined(USE_HT32F65230_40) + ADC1_IRQn = 9, /*!< ADC1 Interrupt */ + #elif defined(USE_HT32F66242) + CORDIC_IRQn = 9, /*!< CORDIC global Interrupt */ + #elif defined(USE_HT32F66246) + CORDIC_IRQn = 9, /*!< CORDIC global Interrupt */ + #endif + MCTM0_BRK_IRQn = 10, /*!< MCTM BRK Interrupt */ + MCTM0_UP_IRQn = 11, /*!< MCTM UP Interrupt */ + MCTM0_TR_UP2_IRQn = 12, /*!< MCTM TR & UP2 Interrupt */ + MCTM0_CC_IRQn = 13, /*!< MCTM CC Interrupt */ + GPTM0_G_IRQn = 14, /*!< GPTM G Interrupt */ + GPTM0_VCLK_IRQn = 15, /*!< GPTM VCLK Interrupt */ + BFTM0_IRQn = 16, /*!< Basic Function Timer0 Interrupt */ + BFTM1_IRQn = 17, /*!< Basic Function Timer1 Interrupt */ + CMP0_IRQn = 18, /*!< Comparator0 Interrupt */ + CMP1_IRQn = 19, /*!< Comparator1 Interrupt */ + #if defined(USE_HT32F65230_40) + CMP2_IRQn = 20, /*!< Comparator2 Interrupt */ + #elif defined(USE_HT32F66242) + PID_IRQn = 20, /*!< PID global Interrupt */ + #elif defined(USE_HT32F66246) + PID_IRQn = 20, /*!< PID global Interrupt */ + #endif + I2C0_IRQn = 21, /*!< I2C global Interrupt */ + SPI0_IRQn = 22, /*!< SPI global Interrupt */ + USART0_IRQn = 23, /*!< USART global Interrupt */ + UART0_IRQn = 24, /*!< UART global Interrupt */ + PDMACH0_1_IRQn = 25, /*!< PDMA channel 0-1 Interrupt */ + PDMACH2_3_IRQn = 26, /*!< PDMA channel 2-3 Interrupt */ + PDMACH4_5_IRQn = 27, /*!< PDMA channel 4-5 Interrupt */ + SCTM0_IRQn = 28, /*!< Single Channel Timer0 Interrupt */ + SCTM1_IRQn = 29, /*!< Single Channel Timer1 Interrupt */ + SCTM2_IRQn = 30, /*!< Single Channel Timer2 Interrupt */ + SCTM3_IRQn = 31, /*!< Single Channel Timer3 Interrupt */ + #else + #if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F52344_54) || defined(USE_HT32F54243_53) || defined(USE_HT32F53242_52) || defined(USE_HT32F50442_52) + COMP_IRQn = 7, /*!< Comparator global Interrupt */ + #endif + #if defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) + COMP_DAC_IRQn = 7, /*!< Comparator & DAC global Interrupt */ + #endif + #if defined(USE_HT32F52234_44) + DAC0_1_IRQn = 7, /*!< DAC0 & DAC1 global Interrupt */ + #endif + #if !defined(USE_HT32F0008) + ADC0_IRQn = 8, /*!< ADC Interrupt */ + #endif + #if defined(USE_HT32F52243_53) || defined(USE_HT32F54243_53) || defined(USE_HT32F52234_44) + I2C2_IRQn = 9, /*!< I2C2 global Interrupt */ + #endif + #if defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F67041_51) + AES_IRQn = 9, /*!< AES global Interrupt */ + #endif + #if !defined(USE_HT32F52220_30) && !defined(USE_HT32F0008) && !defined(USE_HT32F50220_30) && !defined(USE_HT32F0006) && !defined(USE_HT32F57342_52) && !defined(USE_HT32F57331_41) && !defined(USE_HT32F50343) && !defined(USE_HT32F61244_45) && !defined(USE_HT32F50020_30) && !defined(USE_HT32F67041_51) && !defined(USE_HT32F52234_44) + MCTM0_IRQn = 10, /*!< Motor Control Timer0 interrupt */ + #endif + #if defined(USE_HT32F50343) + PWM2_IRQn = 10, /*!< PWM Timer2 interrupt */ + #endif + #if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) + GPTM1_IRQn = 11, /*!< General-Purpose Timer1 Interrupt */ + #endif + #if defined(USE_HT32F52357_67) + QSPI_IRQn = 11, /*!< QSPI global Interrupt */ + #endif + #if defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) + LCD_IRQn = 11, /*!< LCD global Interrupt */ + #endif + #if defined(USE_HT32F54231_41) || defined(USE_HT32F54243_53) + TKEY_IRQn = 11, /*!< Touch-Key global Interrupt */ + #endif + #if defined(USE_HT32F67041_51) + RF_IRQn = 11, /*!< 2.4G RF global Interrupt */ + #endif + #if !defined(USE_HT32F50020_30) && !defined(USE_HT32F52234_44) + GPTM0_IRQn = 12, /*!< General-Purpose Timer0 Interrupt */ + #endif + #if !defined(USE_HT32F0008) && !defined(USE_HT32F50220_30) && !defined(USE_HT32F50231_41) && !defined(USE_HT32F57331_41) && !defined(USE_HT32F53231_41) && !defined(USE_HT32F53242_52) && !defined(USE_HT32F50431_41) && !defined(USE_HT32F50442_52) + SCTM0_IRQn = 13, /*!< Single Channel Timer0 Interrupt */ + SCTM1_IRQn = 14, /*!< Single Channel Timer1 Interrupt */ + #endif + #if defined(USE_HT32F52231_41) || defined(USE_HT32F52331_41) || defined(USE_HT32F52243_53) || defined(USE_HT32F0006) || defined(USE_HT32F54243_53) || defined(USE_HT32F50020_30) || defined(USE_HT32F67041_51) + SCTM2_IRQn = 15, /*!< Single Channel Timer2 Interrupt */ + #endif + #if defined(USE_HT32F52231_41) || defined(USE_HT32F52331_41) || defined(USE_HT32F52243_53) || defined(USE_HT32F0006) || defined(USE_HT32F54243_53) || defined(USE_HT32F67041_51) + SCTM3_IRQn = 16, /*!< Single Channel Timer3 Interrupt */ + #endif + #if defined(USE_HT32F0008) || defined(USE_HT32F50220_30) || defined(USE_HT32F50231_41) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F50343) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) || defined(USE_HT32F52234_44) + PWM0_IRQn = 15, /*!< PWM Timer0 Interrupt */ + #endif + #if defined(USE_HT32F0008) || defined(USE_HT32F50220_30) || defined(USE_HT32F50231_41) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F50343) || defined(USE_HT32F53242_52) || defined(USE_HT32F50442_52) + PWM1_IRQn = 16, /*!< PWM Timer1 Interrupt */ + #endif + BFTM0_IRQn = 17, /*!< Basic Function Timer0 Interrupt */ + #if !defined(USE_HT32F52220_30) && !defined(USE_HT32F50220_30) && !defined(USE_HT32F50020_30) + BFTM1_IRQn = 18, /*!< Basic Function Timer1 Interrupt */ + #endif + I2C0_IRQn = 19, /*!< I2C0 global Interrupt */ + #if !defined(USE_HT32F52220_30) && !defined(USE_HT32F0008) && !defined(USE_HT32F50220_30) && !defined(USE_HT32F52344_54) && !defined(USE_HT32F0006) && !defined(USE_HT32F61244_45) && !defined(USE_HT32F50020_30) + I2C1_IRQn = 20, /*!< I2C1 global Interrupt */ + #endif + SPI0_IRQn = 21, /*!< SPI0 global Interrupt */ + #if !defined(USE_HT32F52220_30) && !defined(USE_HT32F0008) && !defined(USE_HT32F0006) && !defined(USE_HT32F50020_30) && !defined(USE_HT32F61244_45) && !defined(USE_HT32F52234_44) + SPI1_IRQn = 22, /*!< SPI1 global Interrupt */ + #endif + #if defined(USE_HT32F0006) || defined(USE_HT32F61244_45) + QSPI_IRQn = 22, /*!< QSPI global Interrupt */ + #endif + #if !defined(USE_HT32F50220_30) && !defined(USE_HT32F52344_54) && !defined(USE_HT32F50343) && !defined(USE_HT32F61244_45) && !defined(USE_HT32F50020_30) && !defined(USE_HT32F67041_51) + USART0_IRQn = 23, /*!< USART0 global Interrupt */ + #endif + #if defined(USE_HT32F52342_52) || defined(USE_HT32F52243_53) || defined(USE_HT32F5826) || defined(USE_HT32F52357_67) || defined(USE_HT32F54243_53) || defined(USE_HT32F53242_52) || defined(USE_HT32F50442_52) + USART1_IRQn = 24, /*!< USART1 global Interrupt */ + #endif + UART0_IRQn = 25, /*!< UART0 global Interrupt */ + #if !defined(USE_HT32F52220_30) && !defined(USE_HT32F0008) && !defined(USE_HT32F0006) && !defined(USE_HT32F61244_45) && !defined(USE_HT32F52234_44) + UART1_IRQn = 26, /*!< UART1 global Interrupt */ + #endif + #if defined(USE_HT32F52357_67) + UART0_UART2_IRQn = 25, /*!< UART0 & UART2 global Interrupt */ + UART1_UART3_IRQn = 26, /*!< UART1 & UART3 global Interrupt */ + #endif + #if defined(USE_HT32F52331_41) || defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F61141) + SCI_IRQn = 27, /*!< Smart Card Interface Interrupt */ + #endif + #if defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) + CAN0_IRQn = 27, /*!< CAN0 global Interrupt */ + #endif + #if defined(USE_HT32F0006) || defined(USE_HT32F61244_45) + MIDI_IRQn = 27, /*!< MIDI global Interrupt */ + #endif + #if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F0006) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) + I2S_IRQn = 28, /*!< I2S global Interrupt */ + #endif + #if defined(USE_HT32F52243_53) || defined(USE_HT32F54243_53) + UART2_IRQn = 27, /*!< UART2 global Interrupt */ + UART3_IRQn = 28, /*!< UART3 global Interrupt */ + #endif + #if defined(USE_HT32F0008) + AES_IRQn = 28, /*!< AES global Interrupt */ + #endif + #if defined(USE_HT32F50343) + SLED0_IRQn = 27, /*!< SLED0 global Interrupt */ + SLED1_IRQn = 28, /*!< SLED1 global Interrupt */ + #endif + #if defined(USE_HT32F52331_41) || defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F0008) || defined(USE_HT32F52344_54) || defined(USE_HT32F0006) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F50343) || defined(USE_HT32F61141) + USB_IRQn = 29, /*!< USB interrupt */ + #endif + #if defined(USE_HT32F54231_41) || defined(USE_HT32F54243_53) || defined(USE_HT32F50020_30) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) + LEDC_IRQn = 29, /*!< LEDC global Interrupt */ + #endif + #if defined(USE_HT32F52342_52) || defined(USE_HT32F52243_53) || defined(USE_HT32F5826) || defined(USE_HT32F0008) || defined(USE_HT32F52344_54) || defined(USE_HT32F0006) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F50343) || defined(USE_HT32F54243_53) || defined(USE_HT32F61244_45) || defined(USE_HT32F67041_51) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) || defined(USE_HT32F52234_44) + PDMACH0_1_IRQn = 30, /*!< PDMA channel 0-1 interrupt */ + PDMACH2_5_IRQn = 31, /*!< PDMA channel 2-5 interrupt */ + #endif + #endif +} IRQn_Type; + +#define EXTI0_IRQn EXTI0_1_IRQn +#define EXTI1_IRQn EXTI0_1_IRQn +#define EXTI2_IRQn EXTI2_3_IRQn +#define EXTI3_IRQn EXTI2_3_IRQn +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) +#define EXTI4_IRQn EXTI4_9_IRQn +#define EXTI5_IRQn EXTI4_9_IRQn +#define EXTI6_IRQn EXTI4_9_IRQn +#define EXTI7_IRQn EXTI4_9_IRQn +#define EXTI8_IRQn EXTI4_9_IRQn +#define EXTI9_IRQn EXTI4_9_IRQn +#define EXTI10_IRQn EXTI10_15_IRQn +#define EXTI11_IRQn EXTI10_15_IRQn +#define EXTI12_IRQn EXTI10_15_IRQn +#define EXTI13_IRQn EXTI10_15_IRQn +#define EXTI14_IRQn EXTI10_15_IRQn +#define EXTI15_IRQn EXTI10_15_IRQn +#elif defined(USE_HT32F50020_30) +#define EXTI4_IRQn EXTI4_7_IRQn +#define EXTI5_IRQn EXTI4_7_IRQn +#define EXTI6_IRQn EXTI4_7_IRQn +#define EXTI7_IRQn EXTI4_7_IRQn +#else +#define EXTI4_IRQn EXTI4_15_IRQn +#define EXTI5_IRQn EXTI4_15_IRQn +#define EXTI6_IRQn EXTI4_15_IRQn +#define EXTI7_IRQn EXTI4_15_IRQn +#define EXTI8_IRQn EXTI4_15_IRQn +#define EXTI9_IRQn EXTI4_15_IRQn +#define EXTI10_IRQn EXTI4_15_IRQn +#define EXTI11_IRQn EXTI4_15_IRQn +#define EXTI12_IRQn EXTI4_15_IRQn +#define EXTI13_IRQn EXTI4_15_IRQn +#define EXTI14_IRQn EXTI4_15_IRQn +#define EXTI15_IRQn EXTI4_15_IRQn +#endif + +#define PDMACH0_IRQn PDMACH0_1_IRQn +#define PDMACH1_IRQn PDMACH0_1_IRQn +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F66242) || defined(USE_HT32F66246) +#define PDMACH2_IRQn PDMACH2_3_IRQn +#define PDMACH3_IRQn PDMACH2_3_IRQn +#define PDMACH4_IRQn PDMACH4_5_IRQn +#define PDMACH5_IRQn PDMACH4_5_IRQn +#else +#define PDMACH2_IRQn PDMACH2_5_IRQn +#define PDMACH3_IRQn PDMACH2_5_IRQn +#define PDMACH4_IRQn PDMACH2_5_IRQn +#define PDMACH5_IRQn PDMACH2_5_IRQn +#endif + + +/** + * @} + */ + +#include "core_cm0plus.h" /* Cortex-M0+ processor and core peripherals */ +#include "system_ht32f5xxxx_01.h" /* HT32 system */ + + +/** @addtogroup Exported_Types + * @{ + */ + +typedef signed long long s64; +typedef signed int s32; +typedef signed short s16; +typedef signed char s8; + +typedef const s64 sc64; /*!< Read Only */ +typedef const s32 sc32; /*!< Read Only */ +typedef const s16 sc16; /*!< Read Only */ +typedef const s8 sc8; /*!< Read Only */ + +typedef __IO s64 vs64; +typedef __IO s32 vs32; +typedef __IO s16 vs16; +typedef __IO s8 vs8; + +typedef __I s64 vsc64; /*!< Read Only */ +typedef __I s32 vsc32; /*!< Read Only */ +typedef __I s16 vsc16; /*!< Read Only */ +typedef __I s8 vsc8; /*!< Read Only */ + +typedef unsigned long long u64; +typedef unsigned int u32; +typedef unsigned short u16; +typedef unsigned char u8; + +typedef const u64 uc64; /*!< Read Only */ +typedef const u32 uc32; /*!< Read Only */ +typedef const u16 uc16; /*!< Read Only */ +typedef const u8 uc8; /*!< Read Only */ + +typedef __IO u64 vu64; +typedef __IO u32 vu32; +typedef __IO u16 vu16; +typedef __IO u8 vu8; + +typedef __I u64 vuc64; /*!< Read Only */ +typedef __I u32 vuc32; /*!< Read Only */ +typedef __I u16 vuc16; /*!< Read Only */ +typedef __I u8 vuc8; /*!< Read Only */ + + +typedef enum {DISABLE = 0, ENABLE = !DISABLE} EventStatus, ControlStatus; + +#if !defined(bool) && !defined(__cplusplus) // user may already included or CPP +typedef enum {FALSE = 0, TRUE = !FALSE} bool; +#define false FALSE +#define true TRUE +#else +#define FALSE 0 +#define TRUE 1 +#endif + +typedef enum {RESET = 0, SET = !RESET} FlagStatus; + +typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus; + +/** + * @} + */ + +#if defined (__CC_ARM) + #define __ALIGN4 __align(4) +#elif defined (__ICCARM__) + #define __ALIGN4 _Pragma("data_alignment = 4") +#elif defined (__GNUC__) + #define __ALIGN4 __attribute__((aligned(4))) +#endif + +#if defined (__GNUC__) + #define __PACKED_H + #define __PACKED_F __attribute__ ((packed)) +#elif defined (__ICCARM__) || (__CC_ARM) + #define __PACKED_H __packed + #define __PACKED_F +#endif + +#if defined (__CC_ARM) +#pragma anon_unions +#endif + + +#define U8_MAX ((u8)255) +#define S8_MAX ((s8)127) +#define S8_MIN ((s8)-128) +#define U16_MAX ((u16)65535u) +#define S16_MAX ((s16)32767) +#define S16_MIN ((s16)-32768) +#define U32_MAX ((u32)4294967295uL) +#define S32_MAX ((s32)2147483647) +#define S32_MIN ((s32)-2147483648) + + +/** + * @brief Exported constants and macro + */ +#define IS_CONTROL_STATUS(STATUS) ((STATUS == DISABLE) || (STATUS == ENABLE)) + +#define wb(addr, value) (*((u8 volatile *) (addr)) = value) +#define rb(addr) (*((u8 volatile *) (addr))) +#define whw(addr, value) (*((u16 volatile *) (addr)) = value) +#define rhw(addr) (*((u16 volatile *) (addr))) +#define ww(addr, value) (*((u32 volatile *) (addr)) = value) +#define rw(addr) (*((u32 volatile *) (addr))) + + +#define ResetBit_BB(Addr, BitNumber) (rw(Addr) &= ~(1UL << BitNumber)) +#define SetBit_BB(Addr, BitNumber) (rw(Addr) |= (1UL << BitNumber)) +#define GetBit_BB(Addr, BitNumber) ((rw(Addr) >> BitNumber) & 1UL) +#define WriteBit_BB(Addr, BitNumber, Value) (Addr = ((Addr & ~((u32)1 << BitNumber)) | ((u32)Value << BitNumber))) + +#define STRCAT2_(a, b) a##b +#define STRCAT2(a, b) STRCAT2_(a, b) +#define STRCAT3_(a, b, c) a##b##c +#define STRCAT3(a, b, c) STRCAT3_(a, b, c) + +#define IPN_NULL (0) +#define IPN_MCTM0 (0x4002C000) +#define IPN_MCTM1 (0x4002D000) +#define IPN_GPTM0 (0x4006E000) +#define IPN_GPTM1 (0x4006F000) +#define IPN_SCTM0 (0x40034000) +#define IPN_SCTM1 (0x40074000) +#define IPN_SCTM2 (0x40035000) +#define IPN_SCTM3 (0x40075000) +#define IPN_PWM0 (0x40031000) +#define IPN_PWM1 (0x40071000) +#define IPN_PWM2 (0x40031000) +#define IPN_BFTM0 (0x40076000) +#define IPN_BFTM1 (0x40077000) +#define IPN_CHECK(IP) STRCAT2(IPN_, IP) +#define IS_IPN_BFTM(IP) (IPN_CHECK(IP) == IPN_BFTM0) || (IPN_CHECK(IP) == IPN_BFTM1) +#define IS_IPN_MCTM(IP) (IPN_CHECK(IP) == IPN_MCTM0) || (IPN_CHECK(IP) == IPN_MCTM1) +#define IS_IPN_GPTM(IP) (IPN_CHECK(IP) == IPN_GPTM0) || (IPN_CHECK(IP) == IPN_GPTM1) +#define IS_IPN_SCTM(IP) (IPN_CHECK(IP) == IPN_SCTM0) || (IPN_CHECK(IP) == IPN_SCTM1) || (IPN_CHECK(IP) == IPN_SCTM2) || (IPN_CHECK(IP) == IPN_SCTM3) +#define IS_IPN_PWM(IP) (IPN_CHECK(IP) == IPN_PWM0) || (IPN_CHECK(IP) == IPN_PWM1) || (IPN_CHECK(IP) == IPN_PWM2) +#define IS_IPN_TM(IP) (IS_IPN_MCTM(IP) || IS_IPN_GPTM(IP) || IS_IPN_SCTM(IP) || IS_IPN_PWM(IP)) + + +/** @addtogroup Peripheral_Registers_Structures + * @{ + */ + + +/** + * @brief Universal Synchronous Asynchronous Receiver Transmitter + */ +typedef struct +{ + /* USART0: 0x40000000 */ + /* USART1: 0x40040000 */ + /* UART0: 0x40001000 */ + /* UART2: 0x40002000 */ + /* UART1: 0x40041000 */ + /* UART3: 0x40042000 */ + __IO uint32_t DR; /*!< 0x000 Data Register */ + __IO uint32_t CR; /*!< 0x004 Control Register */ + __IO uint32_t FCR; /*!< 0x008 FIFO Control Register */ + __IO uint32_t IER; /*!< 0x00C Interrupt Enable Register */ + __IO uint32_t SR; /*!< 0x010 Status Register */ + __IO uint32_t TPR; /*!< 0x014 Timing Parameter Register */ + __IO uint32_t ICR; /*!< 0x018 IrDA COntrol Register */ + __IO uint32_t RCR; /*!< 0x01C RS485 Control Register */ + __IO uint32_t SCR; /*!< 0x020 Synchronous Control Register */ + __IO uint32_t DLR; /*!< 0x024 Divisor Latch Register */ + __IO uint32_t DTR; /*!< 0x028 Debug/Test Register */ +} HT_USART_TypeDef; + + +/** + * @brief SPI + */ +typedef struct +{ + /* SPI0: 0x40004000 */ + /* SPI1: 0x40044000 */ + __IO uint32_t CR0; /*!< 0x000 Control Register 0 */ + __IO uint32_t CR1; /*!< 0x004 Control Register 1 */ + __IO uint32_t IER; /*!< 0x008 Interrupt Enable Register */ + __IO uint32_t CPR; /*!< 0x00C Clock Prescaler Register */ + __IO uint32_t DR; /*!< 0x010 Data Register */ + __IO uint32_t SR; /*!< 0x014 Status Register */ + __IO uint32_t FCR; /*!< 0x018 FIFO Control Register */ + __IO uint32_t FSR; /*!< 0x01C FIFO Status Register */ + __IO uint32_t FTOCR; /*!< 0x020 FIFO Time Out Counter Register */ +#if defined(USE_HT32F0006) || defined(USE_HT32F61244_45) + __IO uint32_t MIDICR0; /*!< 0x040 MIDI Control Register 0 */ + __IO uint32_t MIDICR1; /*!< 0x044 MIDI Control Register 1 */ +#endif +} HT_SPI_TypeDef; + + +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F66242) || defined(USE_HT32F66246) +/** + * @brief Analog to Digital Converter + */ +typedef struct +{ + /* ADC0: 0x40010000 */ + /* ADC1: 0x40050000 */ + __IO uint32_t CFGR; /*!< 0x000 ADC Configuration Register (ADC1 only) */ + __IO uint32_t RST; /*!< 0x004 ADC Reset Register */ + __IO uint32_t CONV; /*!< 0x008 ADC Regular Conversion Mode Register */ + __IO uint32_t HCONV; /*!< 0x00C ADC High-priority Conversion Mode Register */ + __IO uint32_t LST[2]; /*!< 0x010 - 0x014 ADC Conversion List Register */ + uint32_t RESERVE0[2]; /*!< 0x018 - 0x01C Reserved */ + __IO uint32_t HLST; /*!< 0x020 ADC High-priority Conversion List Register */ + uint32_t RESERVE1[3]; /*!< 0x024 - 0x02C Reserved */ + #if defined(USE_HT32F65230_40) + __IO uint32_t OFR[12]; /*!< 0x030 - 0x05C ADC Input Offset Register 0-11 */ + uint32_t RESERVE2[4]; /*!< 0x060 - 0x06C Reserved */ + __IO uint32_t STR[12]; /*!< 0x070 - 0x08C ADC Input Sampling Time Register 0-11 */ + uint32_t RESERVE3[4]; /*!< 0x090 - 0x0AC Reserved */ + #endif + #if defined(USE_HT32F65232) + __IO uint32_t OFR[15]; /*!< 0x030 - 0x068 ADC Input Offset Register 0-14 */ + uint32_t RESERVE2[1]; /*!< 0x06C Reserved */ + __IO uint32_t STR[15]; /*!< 0x070 - 0x0A8 ADC Input Sampling Time Register 0-14 */ + uint32_t RESERVE3[1]; /*!< 0x0AC Reserved */ + #endif + #if defined(USE_HT32F66242) + uint32_t RESERVE2[16]; /*!< 0x030 - 0x06C Reserved */ + __IO uint32_t STR[16]; /*!< 0x070 - 0x0AC ADC Input Sampling Time Register 0-15 */ + #endif + #if defined(USE_HT32F66246) + uint32_t RESERVE2[16]; /*!< 0x030 - 0x06C Reserved */ + __IO uint32_t STR[16]; /*!< 0x070 - 0x0AC ADC Input Sampling Time Register 0-15 */ + #endif + __IO uint32_t DR[8]; /*!< 0x0B0 - 0x0CC ADC Regular Conversion Data Register 0-7 */ + uint32_t RESERVE4[8]; /*!< 0x0D0 - 0x0EC Reserved */ + __IO uint32_t HDR[4]; /*!< 0x0F0 - 0x0FC ADC High-priority Conversion Data Register 0-3 */ + __IO uint32_t TCR; /*!< 0x100 ADC Trigger Control Register */ + __IO uint32_t TSR; /*!< 0x104 ADC Trigger Source Register */ + uint32_t RESERVE5[2]; /*!< 0x108 - 0x10C Reserved */ + __IO uint32_t HTCR; /*!< 0x110 ADC High-priority Trigger Control Register */ + __IO uint32_t HTSR; /*!< 0x114 ADC High-priority Trigger Source Register */ + uint32_t RESERVE6[2]; /*!< 0x118 - 0x11C Reserved */ + __IO uint32_t WCR; /*!< 0x120 ADC Watchdog Control Register */ + __IO uint32_t LTR; /*!< 0x124 ADC Watchdog Threshold Register */ + __IO uint32_t UTR; /*!< 0x128 ADC Watchdog Threshold Register */ + uint32_t RESERVE7[1]; /*!< 0x12C Reserved */ + __IO uint32_t IER; /*!< 0x130 ADC Interrupt Enable Register */ + __IO uint32_t IRAW; /*!< 0x134 ADC Interrupt Raw Status Register */ + __IO uint32_t ISR; /*!< 0x138 ADC Interrupt Status Register */ + __IO uint32_t ICLR; /*!< 0x13C ADC Interrupt Clear Register */ + __IO uint32_t PDMAR; /*!< 0x140 ADC PDMA Request Register */ + #if defined(USE_HT32F65230_40) + uint32_t RESERVE8[3]; /*!< 0x144 - 0x14C Reserved */ + __IO uint32_t DIESR; /*!< 0x150 Dual ADC Interrupt Enable/Status Register (ADC1 only) */ + __IO uint32_t DPDMAR; /*!< 0x154 Dual ADC PDMA Request Register (ADC1 only) */ + #endif + #if defined(USE_HT32F66242) + uint32_t RESERVE8[3]; /*!< 0x144 - 0x14C Reserved */ + __IO uint32_t VREFCR; /*!< 0x150 ADC Reference Voltage Control Register */ + uint32_t RESERVE9[3]; /*!< 0x154 - 0x15C Reserved */ + __IO uint32_t HDR4[8]; /*!< 0x160 - 0x17C ADC High-priority Conversion Data Register 4-11 */ + uint32_t RESERVE10[4]; /*!< 0x180 - 0x18C Reserved */ + __IO uint32_t STR16[2]; /*!< 0x190 - 0x194 ADC Input Sampling Time Register 16-17 */ + #endif + #if defined(USE_HT32F66246) + uint32_t RESERVE8[3]; /*!< 0x144 - 0x14C Reserved */ + __IO uint32_t VREFCR; /*!< 0x150 ADC Reference Voltage Control Register */ + uint32_t RESERVE9[3]; /*!< 0x154 - 0x15C Reserved */ + __IO uint32_t HDR4[8]; /*!< 0x160 - 0x17C ADC High-priority Conversion Data Register 4-11 */ + uint32_t RESERVE10[4]; /*!< 0x180 - 0x18C Reserved */ + __IO uint32_t STR16[2]; /*!< 0x190 - 0x194 ADC Input Sampling Time Register 16-17 */ + #endif +} HT_ADC_TypeDef; +#else +/** + * @brief Analog to Digital Converter + */ +typedef struct +{ + /* ADC: 0x40010000 */ + __IO uint32_t CR; /*!< 0x000 ADC Conversion Control Register */ + #if defined(USE_HT32F50020_30) + __IO uint32_t LST[1]; /*!< 0x004 ADC Conversion List Register 0 */ + uint32_t RESERVE0[6]; /*!< 0x008 - 0x01C Reserved */ + #else + __IO uint32_t LST[2]; /*!< 0x004 - 0x008 ADC Conversion List Register 0-1 */ + uint32_t RESERVE0[5]; /*!< 0x00C - 0x01C Reserved */ + #endif + __IO uint32_t STR; /*!< 0x020 ADC Input Sampling Time Register */ + uint32_t RESERVE1[3]; /*!< 0x024 - 0x02C Reserved */ + #if defined(USE_HT32F50020_30) + __IO uint32_t DR[4]; /*!< 0x030 - 0x03C ADC Conversion Data Register 0-3 */ + uint32_t RESERVE2[13]; /*!< 0x040 - 0x070 Reserved */ + #else + __IO uint32_t DR[8]; /*!< 0x030 - 0x04C ADC Conversion Data Register 0-7 */ + uint32_t RESERVE2[8]; /*!< 0x050 - 0x06C Reserved */ + __IO uint32_t TCR; /*!< 0x070 ADC Trigger Control Register */ + #endif + __IO uint32_t TSR; /*!< 0x074 ADC Trigger Source Register */ + #if defined(USE_HT32F50020_30) + __IO uint32_t RESERVE3[2]; /*!< 0x078 - 0x07C Reserved */ + #else + __IO uint32_t WCR; /*!< 0x078 ADC Watchdog Control Register */ + __IO uint32_t WTR; /*!< 0x07C ADC Watchdog Threshold Register */ + #endif + __IO uint32_t IER; /*!< 0x080 ADC Interrupt Enable Register */ + __IO uint32_t IRAW; /*!< 0x084 ADC Interrupt Raw Status Register */ + __IO uint32_t ISR; /*!< 0x088 ADC Interrupt Status Register */ + __IO uint32_t ICLR; /*!< 0x08C ADC Interrupt Clear Register */ + #if defined(USE_HT32F52342_52) || defined(USE_HT32F52243_53) || defined(USE_HT32F5826) || defined(USE_HT32F52344_54) || defined(USE_HT32F0006) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F50343) || defined(USE_HT32F54243_53) || defined(USE_HT32F61244_45) || defined(USE_HT32F67041_51) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) || defined(USE_HT32F52234_44) + __IO uint32_t PDMAR; /*!< 0x090 ADC PDMA Request Register */ + #else + uint32_t RESERVE4; /*!< 0x090 Reserved */ + #endif + #if defined(USE_HT32F52344_54) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F50343) || defined(USE_HT32F54231_41) || defined(USE_HT32F54243_53) || defined(USE_HT32F67041_51) || defined(USE_HT32F50020_30) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) || defined(USE_HT32F52234_44) + uint32_t RESERVE5[3]; /*!< 0x094 - 0x09C Reserved */ + __IO uint32_t VREFCR; /*!< 0x0A0 ADC Reference Voltage Control Register */ + __IO uint32_t VREFVALR; /*!< 0x0A4 ADC Reference Voltage Value Register */ + #endif +} HT_ADC_TypeDef; +#endif + + +/** + * @brief Digital to Analog Converter + */ +typedef struct +{ + /* DACDUAL16: 0x40054000 */ + __IO uint32_t CR; /*!< 0x000 D/A Converter Control Register */ + __IO uint32_t RH; /*!< 0x004 D/A R-channel data register */ + __IO uint32_t LH; /*!< 0x008 D/A L-channel data register */ + __IO uint32_t TG; /*!< 0x00c D/A data trigger Register */ +} HT_DAC_DUAL16_TypeDef; + +/** + * @brief Digital to Analog Converter Channel + */ +typedef struct +{ + __IO uint32_t CR; /*!< 0x000 DAC Channel Control Register */ + uint32_t RESERVE0[2]; /*!< 0x004 - 0x008 Reserved */ + __IO uint32_t DHR; /*!< 0x00C DAC Channel Data Holding Register */ + __IO uint32_t DOR; /*!< 0x010 DAC Channel Data Output Register */ + uint32_t RESERVE1[3]; /*!< 0x014 - 0x01C Reserved */ +} HT_DACCH_TypeDef; + +/** + * @brief Digital to Analog Converter + */ +typedef struct +{ + /* DAC1: 0x40014000 */ + /* DAC0: 0x40054000 */ + __IO uint32_t CFGR; /*!< 0x000 DAC Configuration Register */ + uint32_t RESERVE0[3]; /*!< 0x004 - 0x00C Reserved */ + HT_DACCH_TypeDef DACCH0; /*!< 0x010 DAC channel 0 registers */ + HT_DACCH_TypeDef DACCH1; /*!< 0x030 DAC channel 1 registers */ +} HT_DAC_TypeDef; + +/** + * @brief Comparator + */ +typedef struct +{ + /* CMP0: 0x40058000 */ + /* CMP1: 0x40058100 */ + /* CMP2: 0x40058200 */ + __IO uint32_t CR; /*!< 0x000 Comparator Control Register */ + __IO uint32_t VALR; /*!< 0x004 Comparator Voltage Reference Value Register */ + __IO uint32_t IER; /*!< 0x008 Comparator Interrupt Enable Register */ + __IO uint32_t TFR; /*!< 0x00C Comparator Transition Flag Register */ + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F66242) || defined(USE_HT32F66246) + __IO uint32_t CI; /*!< 0x010 Comparator Input Control Register */ + #endif + #if defined(USE_HT32F65232) || defined(USE_HT32F66242) || defined(USE_HT32F66246) + __IO uint32_t CO; /*!< 0x014 Comparator Output Control Register */ + #endif +} HT_CMP_TypeDef; + + +/** + * @brief Operational Amplifier + */ +typedef struct +{ + /* OPA0: 0x40018000 */ + /* OPA1: 0x40018100 */ + __IO uint32_t CR; /*!< 0x000 Operational Amplifier Control Register */ + #if defined(USE_HT32F65232) + __IO uint32_t VOS; /*!< 0x004 Operational Amplifier Input Offset Register */ + __IO uint32_t DAC; /*!< 0x008 Operational Amplifier Voltage Reference Value Register */ + #endif +} HT_OPA_TypeDef; + +/** + * @brief Programmable Gain Amplifier 0~X + */ +typedef struct +{ + /* PGA0: 0x40018000 */ + /* PGA1: 0x40018008 */ + /* PGA2: 0x40018010 */ + /* PGA3: 0x40018018 */ + __IO uint32_t CR; /*!< 0x000 Programmable Gain Amplifier Control Register */ + __IO uint32_t VOS; /*!< 0x004 Programmable Gain Amplifier Offset Control Register */ +} HT_PGA0_X_TypeDef; + +/** + * @brief Programmable Gain Amplifier + */ +typedef struct +{ + /* PGA: 0x40018000 */ + __IO uint32_t VR; /*!< 0x020 PGA Voltage Follower Control Register */ +} HT_PGA_TypeDef; + +/** + * @brief General Purpose I/O + */ +typedef struct +{ + /* GPIOA: 0x400B0000 */ + /* GPIOB: 0x400B2000 */ + /* GPIOC: 0x400B4000 */ + /* GPIOD: 0x400B6000 */ + /* GPIOE: 0x400B8000 */ + /* GPIOF: 0x400BA000 */ + __IO uint32_t DIRCR; /*!< 0x000 Data Direction Control Register */ + __IO uint32_t INER; /*!< 0x004 Input function enable register */ + __IO uint32_t PUR; /*!< 0x008 Pull-Up Selection Register */ + __IO uint32_t PDR; /*!< 0x00C Pull-Down Selection Register */ + __IO uint32_t ODR; /*!< 0x010 Open Drain Selection Register */ + __IO uint32_t DRVR; /*!< 0x014 Drive Current Selection Register */ + __IO uint32_t LOCKR; /*!< 0x018 Lock Register */ + __IO uint32_t DINR; /*!< 0x01c Data Input Register */ + __IO uint32_t DOUTR; /*!< 0x020 Data Output Register */ + __IO uint32_t SRR; /*!< 0x024 Output Set and Reset Control Register */ + __IO uint32_t RR; /*!< 0x028 Output Reset Control Register */ + #if defined(USE_HT32F50220_30) || defined(USE_HT32F50231_41) || defined(USE_HT32F54231_41) || defined(USE_HT32F54243_53) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) + __IO uint32_t SCER; /*!< 0x02C Sink Current Enhanced Selection Register */ + #endif +} HT_GPIO_TypeDef; + + +/** + * @brief AFIO + */ +typedef struct +{ + /* AFIO: 0x40022000 */ + #if defined(USE_HT32F50020_30) + __IO uint32_t ESSR[1]; /*!< 0x000 EXTI Source Selection Register 0 */ + uint32_t RESERVE0[7]; /*!< 0x004 - 0x01C Reserved */ + #else + __IO uint32_t ESSR[2]; /*!< 0x000 EXTI Source Selection Register 0 ~ 1 */ + uint32_t RESERVE0[6]; /*!< 0x008 - 0x01C Reserved */ + #endif + __IO uint32_t GPACFGR[2]; /*!< 0x020 GPIO Port A Configuration Register 0 ~ 1 */ + __IO uint32_t GPBCFGR[2]; /*!< 0x028 GPIO Port B Configuration Register 0 ~ 1 */ + #if !defined(USE_HT32F52220_30) + __IO uint32_t GPCCFGR[2]; /*!< 0x030 GPIO Port C Configuration Register 0 ~ 1 */ + #endif + #if defined(USE_HT32F52342_52) || defined(USE_HT32F52243_53) || defined(USE_HT32F5826) || defined(USE_HT32F52344_54) || defined(USE_HT32F0006) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F54243_53) || defined(USE_HT32F61244_45) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) + __IO uint32_t GPDCFGR[2]; /*!< 0x038 GPIO Port D Configuration Register 0 ~ 1 */ + #endif + #if defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) + __IO uint32_t GPECFGR[2]; /*!< 0x040 GPIO Port E Configuration Register 0 ~ 1 */ + #endif + #if defined(USE_HT32F0008) || defined(USE_HT32F50020_30) + uint32_t RESERVE1[4]; /*!< 0x038 - 0x044 Reserved */ + __IO uint32_t GPFCFGR[2]; /*!< 0x048 GPIO Port F Configuration Register 0 ~ 1 */ + #endif +} HT_AFIO_TypeDef; + + +/** + * @brief External Interrupt/Event Controller + */ +typedef struct +{ + /* EXTI: 0x40024000 */ + __IO uint32_t CFGR0; /*!< 0x000 EXTI Interrupt 0 Configuration Register */ + __IO uint32_t CFGR1; /*!< 0x004 EXTI Interrupt 1 Configuration Register */ + __IO uint32_t CFGR2; /*!< 0x008 EXTI Interrupt 2 Configuration Register */ + __IO uint32_t CFGR3; /*!< 0x00C EXTI Interrupt 3 Configuration Register */ + __IO uint32_t CFGR4; /*!< 0x010 EXTI Interrupt 4 Configuration Register */ + __IO uint32_t CFGR5; /*!< 0x014 EXTI Interrupt 5 Configuration Register */ + __IO uint32_t CFGR6; /*!< 0x018 EXTI Interrupt 6 Configuration Register */ + __IO uint32_t CFGR7; /*!< 0x01C EXTI Interrupt 7 Configuration Register */ + #if defined(USE_HT32F50020_30) + __IO uint32_t RESERVE0[8]; /*!< 0x020 - 0x3C Reserved */ + #else + __IO uint32_t CFGR8; /*!< 0x020 EXTI Interrupt 8 Configuration Register */ + __IO uint32_t CFGR9; /*!< 0x024 EXTI Interrupt 9 Configuration Register */ + __IO uint32_t CFGR10; /*!< 0x028 EXTI Interrupt 10 Configuration Register */ + __IO uint32_t CFGR11; /*!< 0x02C EXTI Interrupt 11 Configuration Register */ + __IO uint32_t CFGR12; /*!< 0x030 EXTI Interrupt 12 Configuration Register */ + __IO uint32_t CFGR13; /*!< 0x034 EXTI Interrupt 13 Configuration Register */ + __IO uint32_t CFGR14; /*!< 0x038 EXTI Interrupt 14 Configuration Register */ + __IO uint32_t CFGR15; /*!< 0x03C EXTI Interrupt 15 Configuration Register */ + #endif + __IO uint32_t CR; /*!< 0x040 EXTI Interrupt Control Register */ + __IO uint32_t EDGEFLGR; /*!< 0x044 EXTI Interrupt Edge Flag Register */ + __IO uint32_t EDGESR; /*!< 0x048 EXTI Interrupt Edge Status Register */ + __IO uint32_t SSCR; /*!< 0x04C EXTI Interrupt Software Set Command Register */ + __IO uint32_t WAKUPCR; /*!< 0x050 EXTI Interrupt Wakeup Control Register */ + __IO uint32_t WAKUPPOLR; /*!< 0x054 EXTI Interrupt Wakeup Polarity Register */ + __IO uint32_t WAKUPFLG; /*!< 0x058 EXTI Interrupt Wakeup Flag Register */ +} HT_EXTI_TypeDef; + + +/** + * @brief Inter-integrated Circuit Interface + */ +typedef struct +{ + /* I2C2: 0x40008000 */ + /* I2C0: 0x40048000 */ + /* I2C1: 0x40049000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t IER; /*!< 0x004 Interrupt Enable Register */ + __IO uint32_t ADDR; /*!< 0x008 Address Register */ + __IO uint32_t SR; /*!< 0x00C Status Register */ + __IO uint32_t SHPGR; /*!< 0x010 SCL High Period Generation Register */ + __IO uint32_t SLPGR; /*!< 0x014 SCL Low Period Generation Register */ + __IO uint32_t DR; /*!< 0x018 Data Register */ + __IO uint32_t TAR; /*!< 0x01C Target Register */ + __IO uint32_t ADDMR; /*!< 0x020 Address Mask Register */ + __IO uint32_t ADDSR; /*!< 0x024 Address Snoop Register */ + __IO uint32_t TOUT; /*!< 0x028 Timeout Register */ +} HT_I2C_TypeDef; + + +/** + * @brief WATCHDOG + */ +typedef struct +{ + /* WDT: 0x40068000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t MR0; /*!< 0x004 Mode 0 Register */ + __IO uint32_t MR1; /*!< 0x008 Mode 1 Register */ + __IO uint32_t SR; /*!< 0x00C Status Register */ + __IO uint32_t PR; /*!< 0x010 Write Protect Register */ + uint32_t RESERVED0[1]; /*!< 0x014 Reserved */ + __IO uint32_t CSR; /*!< 0x018 Clock Selection Register */ +} HT_WDT_TypeDef; + + +/** + * @brief Real-Time Clock + */ +typedef struct +{ + /* RTC: 0x4006A000 */ + __IO uint32_t CNT; /*!< 0x000 RTC Counter Register */ + __IO uint32_t CMP; /*!< 0x004 RTC Compare Register */ + __IO uint32_t CR; /*!< 0x008 RTC Control Register */ + __IO uint32_t SR; /*!< 0x00C RTC Status Register */ + __IO uint32_t IWEN; /*!< 0x010 RTC Interrupt/Wake-up Enable Register */ +} HT_RTC_TypeDef; + + +/** + * @brief Power Control Unit + */ +typedef struct +{ + /* PWRCU: 0x4006A100 */ + __IO uint32_t SR; /*!< 0x000 Status Register */ + __IO uint32_t CR; /*!< 0x004 Control Register */ + #if !defined(USE_HT32F50220_30) && !defined(USE_HT32F50231_41) && !defined(USE_HT32F65230_40) && !defined(USE_HT32F50343) && !defined(USE_HT32F54231_41) && !defined(USE_HT32F54243_53) && !defined(USE_HT32F50020_30) && !defined(USE_HT32F53231_41) && !defined(USE_HT32F53242_52) && !defined(USE_HT32F50431_41) && !defined(USE_HT32F50442_52) && !defined(USE_HT32F66242) && !defined(USE_HT32F66246) + __IO uint32_t TEST; /*!< 0x008 Test Register */ + #else + uint32_t RESERVE0[1]; /*!< 0x008 Reserved */ + #endif + #if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F52357_67) + __IO uint32_t HSIRCR; /*!< 0x00C HSI Ready Counter Control Register */ + #else + uint32_t RESERVE1[1]; /*!< 0x00C Reserved */ + #endif + __IO uint32_t LVDCSR; /*!< 0x010 Low Voltage/Brown Out Detect Control and Status Register*/ + #if defined(USE_HT32F57342_52) + uint32_t RESERVE2[2]; /*!< 0x014 ~ 0x18 Reserved */ + __IO uint32_t LDOSR ; /*!< 0x01C Power Control LDO Status Register */ + #endif + #if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F52357_67) + uint32_t RESERVE3[59]; /*!< 0x014 ~ 0x0FC Reserved */ + __IO uint32_t BAKREG[10]; /*!< 0x100 ~ 0x124 Backup Register 0 ~ 9 */ + #endif +} HT_PWRCU_TypeDef; + + +/** + * @brief General-Purpose Timer + */ +typedef struct +{ + /* GPTM0: 0x4006E000 */ + /* GPTM1: 0x4006F000 */ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[3]; /*!< 0x014 - 0x01C Reserved */ + __IO uint32_t CH0ICFR; /*!< 0x020 Channel-0 Input Configuration Register */ + __IO uint32_t CH1ICFR; /*!< 0x024 Channel-1 Input Configuration Register */ + __IO uint32_t CH2ICFR; /*!< 0x028 Channel-2 Input Configuration Register */ + __IO uint32_t CH3ICFR; /*!< 0x02C Channel-3 Input Configuration Register */ + uint32_t RESERVED2[4]; /*!< 0x030 - 0x03C Reserved */ + __IO uint32_t CH0OCFR; /*!< 0x040 Channel-0 Output Configuration Register */ + __IO uint32_t CH1OCFR; /*!< 0x044 Channel-1 Output Configuration Register */ + __IO uint32_t CH2OCFR; /*!< 0x048 Channel-2 Output Configuration Register */ + __IO uint32_t CH3OCFR; /*!< 0x04C Channel-3 Output Configuration Register */ + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED3[7]; /*!< 0x058 - 0x070 Reserved */ + __IO uint32_t DICTR; /*!< 0x074 DMA / Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + uint32_t RESERVED4[1]; /*!< 0x08C Reserved */ + __IO uint32_t CH0CCR; /*!< 0x090 Channel 0 Capture/Compare Register */ + __IO uint32_t CH1CCR; /*!< 0x094 Channel 1 Capture/Compare Register */ + __IO uint32_t CH2CCR; /*!< 0x098 Channel 2 Capture/Compare Register */ + __IO uint32_t CH3CCR; /*!< 0x09C Channel 3 Capture/Compare Register */ + __IO uint32_t CH0ACR; /*!< 0x0A0 Channel 0 Asymmetric Compare Register */ + __IO uint32_t CH1ACR; /*!< 0x0A4 Channel 1 Asymmetric Compare Register */ + __IO uint32_t CH2ACR; /*!< 0x0A8 Channel 2 Asymmetric Compare Register */ + __IO uint32_t CH3ACR; /*!< 0x0AC Channel 3 Asymmetric Compare Register */ +} HT_GPTM_TypeDef; + + +/** + * @brief Flash Memory Controller + */ +typedef struct +{ + /* FLASH: 0x40080000 */ + __IO uint32_t TADR; /*!< 0x000 Flash Target Address Register */ + __IO uint32_t WRDR; /*!< 0x004 Flash Write Data Register */ + uint32_t RESERVED0[1]; /*!< 0x008 Reserved */ + __IO uint32_t OCMR; /*!< 0x00C Flash Operation Command Register */ + __IO uint32_t OPCR; /*!< 0x010 Flash Operation Control Register */ + __IO uint32_t OIER; /*!< 0x014 Flash Operation Interrupt Enable Register */ + __IO uint32_t OISR; /*!< 0x018 Flash Operation Interrupt and Status Register */ + uint32_t RESERVED1[1]; /*!< 0x01C Reserved */ + __IO uint32_t PPSR[4]; /*!< 0x020 ~ 0x02C Flash Page Erase/Program Protection Status Register */ + __IO uint32_t CPSR; /*!< 0x030 Flash Security Protection Status Register */ + uint32_t RESERVED2[51]; /*!< 0x034 ~ 0x0FC Reserved */ + __IO uint32_t VMCR; /*!< 0x100 Flash Vector Mapping Control Register */ + uint32_t RESERVED3[31]; /*!< 0x104 ~ 0x17C Reserved */ + __IO uint32_t MDID; /*!< 0x180 Manufacturer and Device ID Register */ + __IO uint32_t PNSR; /*!< 0x184 Flash Page Number Status Register */ + __IO uint32_t PSSR; /*!< 0x188 Flash Page Size Status Register */ + __IO uint32_t DID; /*!< 0x18C Device ID Register */ + uint32_t RESERVED4[28]; /*!< 0x190 ~ 0x1FC Reserved */ + #if defined(USE_HT32F50220_30) || defined(USE_HT32F50231_41) + uint32_t RESERVED5[1]; /*!< 0x200 Reserved */ + #else + __IO uint32_t CFCR; /*!< 0x200 Flash Cache and Pre-fetch Control Register */ + #endif + uint32_t RESERVED6[67]; /*!< 0x204 ~ 0x30C Reserved */ + __IO uint32_t CID[4]; /*!< 0x310 ~ 0x31C Custom ID Register */ +} HT_FLASH_TypeDef; + + +/** + * @brief Clock Control Unit + */ +typedef struct +{ + /* CKCU: 0x40088000 */ + __IO uint32_t GCFGR; /*!< 0x000 Global Clock Configuration Register */ + __IO uint32_t GCCR; /*!< 0x004 Global Clock Control Register */ + __IO uint32_t GCSR; /*!< 0x008 Global Clock Status Register */ + __IO uint32_t GCIR; /*!< 0x00C Global Clock Interrupt Register */ + uint32_t RESERVED0[2]; /*!< 0x010 ~ 0x14 Reserved */ + #if !defined(USE_HT32F50220_30) && !defined(USE_HT32F50231_41) + __IO uint32_t PLLCFGR; /*!< 0x018 PLL Configuration Register */ + __IO uint32_t PLLCR; /*!< 0x01C PLL Control Register */ + #else + uint32_t RESERVED1[2]; /*!< 0x018 ~ 0x1C Reserved */ + #endif + __IO uint32_t AHBCFGR; /*!< 0x020 AHB Configuration Register */ + __IO uint32_t AHBCCR; /*!< 0x024 AHB Clock Control Register */ + #if defined(USE_HT32F0008) + uint32_t RESERVED1[1]; /*!< 0x028 Reserved */ + #else + __IO uint32_t APBCFGR; /*!< 0x028 APB Configuration Register */ + #endif + __IO uint32_t APBCCR0; /*!< 0x02C APB Clock Control Register 0 */ + __IO uint32_t APBCCR1; /*!< 0x030 APB Clock Control Register 1 */ + __IO uint32_t CKST; /*!< 0x034 Clock source status Register */ + #if !defined(USE_HT32F50020_30) + __IO uint32_t APBPCSR0; /*!< 0x038 APB Peripheral Clock Selection Register 0 */ + __IO uint32_t APBPCSR1; /*!< 0x03C APB Peripheral Clock Selection Register 1 */ + #else + uint32_t RESERVED2[2]; /*!< 0x038 ~ 0x3C Reserved */ + #endif + #if !defined(USE_HT32F50020_30) + __IO uint32_t HSICR; /*!< 0x040 HSI Control Register */ + __IO uint32_t HSIATCR; /*!< 0x044 HSI Auto Trimming Counter Register */ + #else + uint32_t RESERVED3[2]; /*!< 0x040 ~ 0x44 Reserved */ + #endif + #if defined(USE_HT32F0008) || defined(USE_HT32F50220_30) || defined(USE_HT32F50231_41) || defined(USE_HT32F0006) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F50343) || defined(USE_HT32F54231_41) || defined(USE_HT32F54243_53) || defined(USE_HT32F61244_45) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) + __IO uint32_t APBPCSR2; /*!< 0x048 APB Peripheral Clock Selection Register 2 */ + uint32_t RESERVED4[173]; /*!< 0x04C ~ 0x2FC Reserved */ + #elif defined(USE_HT32F52234_44) + __IO uint32_t APBPCSR2; /*!< 0x048 APB Peripheral Clock Selection Register 2 */ + __IO uint32_t HSIRDYCR; /*!< 0x04C HSI Ready Counter Register */ + uint32_t RESERVED4[172]; /*!< 0x050 ~ 0x2FC Reserved */ + #else + uint32_t RESERVED4[174]; /*!< 0x048 ~ 0x2FC Reserved */ + #endif + #if !defined(USE_HT32F50020_30) + __IO uint32_t LPCR; /*!< 0x300 Low Power Control Register */ + #else + uint32_t RESERVED5; /*!< 0x300 Reserved */ + #endif + __IO uint32_t MCUDBGCR; /*!< 0x304 MCU Debug Control Register */ +} HT_CKCU_TypeDef; + + +/** + * @brief Reset Control Unit + */ +typedef struct +{ + /* RSTCU: 0x40088100 */ + __IO uint32_t GRSR; /*!< 0x000 Global Reset Status Register */ + __IO uint32_t AHBPRST; /*!< 0x004 AHB Peripheral Reset Register */ + __IO uint32_t APBPRST0; /*!< 0x008 APB Peripheral Reset Register 0 */ + __IO uint32_t APBPRST1; /*!< 0x00C APB Peripheral Reset Register 1 */ +} HT_RSTCU_TypeDef; + + +/** + * @brief Smart Card Interface + */ +typedef struct +{ + /* SCI0: 0x40043000 */ + /* SCI1: 0x4003A000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t CCR; /*!< 0x008 Contact Control Register */ + __IO uint32_t ETU; /*!< 0x00C Elementary Time Unit Register */ + __IO uint32_t GT; /*!< 0x010 Guardtime Register */ + __IO uint32_t WT; /*!< 0x014 Waiting Time Register */ + __IO uint32_t IER; /*!< 0x018 Interrupt Enable Register */ + __IO uint32_t IPR; /*!< 0x01C Interrupt Pending Register */ + __IO uint32_t TXB; /*!< 0x020 Transmit Buffer Register */ + __IO uint32_t RXB; /*!< 0x024 Receive Buffer Register */ + __IO uint32_t PSC; /*!< 0x028 Prescaler Register */ +} HT_SCI_TypeDef; + + +/** + * @brief Basic Function Timer + */ +typedef struct +{ + /* BFTM0: 0x40076000 */ + /* BFTM1: 0x40077000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t CNTR; /*!< 0x008 Counter Value Register */ + __IO uint32_t CMP; /*!< 0x00C Compare Value Register */ +} HT_BFTM_TypeDef; + + +#if 0 +/** + * @brief Motor Control Timer + */ +typedef struct +{ + /* MCTM0: 0x4002C000 */ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[3]; /*!< 0x014 - 0x01C Reserved */ + __IO uint32_t CH0ICFR; /*!< 0x020 Channel-0 Input Configuration Register */ + __IO uint32_t CH1ICFR; /*!< 0x024 Channel-1 Input Configuration Register */ + __IO uint32_t CH2ICFR; /*!< 0x028 Channel-2 Input Configuration Register */ + __IO uint32_t CH3ICFR; /*!< 0x02C Channel-3 Input Configuration Register */ + uint32_t RESERVED2[4]; /*!< 0x030 - 0x03C Reserved */ + __IO uint32_t CH0OCFR; /*!< 0x040 Channel-0 Output Configuration Register */ + __IO uint32_t CH1OCFR; /*!< 0x044 Channel-1 Output Configuration Register */ + __IO uint32_t CH2OCFR; /*!< 0x048 Channel-2 Output Configuration Register */ + __IO uint32_t CH3OCFR; /*!< 0x04C Channel-3 Output Configuration Register */ + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED3[5]; /*!< 0x058 - 0x068 Reserved */ + __IO uint32_t CHBRKCFR; /*!< 0x06C Channel Break Configuration Register */ + __IO uint32_t CHBRKCTR; /*!< 0x070 Channel Break Control Register */ + __IO uint32_t DICTR; /*!< 0x074 DMA / Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + __IO uint32_t REPR; /*!< 0x08C Repetition Register */ + __IO uint32_t CH0CCR; /*!< 0x090 Channel 0 Capture/Compare Register */ + __IO uint32_t CH1CCR; /*!< 0x094 Channel 1 Capture/Compare Register */ + __IO uint32_t CH2CCR; /*!< 0x098 Channel 2 Capture/Compare Register */ + __IO uint32_t CH3CCR; /*!< 0x09C Channel 3 Capture/Compare Register */ + __IO uint32_t CH0ACR; /*!< 0x0A0 Channel 0 Asymmetric Compare Register */ + __IO uint32_t CH1ACR; /*!< 0x0A4 Channel 1 Asymmetric Compare Register */ + __IO uint32_t CH2ACR; /*!< 0x0A8 Channel 2 Asymmetric Compare Register */ + __IO uint32_t CH3ACR; /*!< 0x0AC Channel 3 Asymmetric Compare Register */ +} HT_MCTM_TypeDef; +#endif + + +/** + * @brief Timer + */ +typedef struct +{ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[3]; /*!< 0x014 - 0x01C Reserved */ + __IO uint32_t CH0ICFR; /*!< 0x020 Channel-0 Input Configuration Register */ + __IO uint32_t CH1ICFR; /*!< 0x024 Channel-1 Input Configuration Register */ + __IO uint32_t CH2ICFR; /*!< 0x028 Channel-2 Input Configuration Register */ + __IO uint32_t CH3ICFR; /*!< 0x02C Channel-3 Input Configuration Register */ + uint32_t RESERVED2[4]; /*!< 0x030 - 0x03C Reserved */ + __IO uint32_t CH0OCFR; /*!< 0x040 Channel-0 Output Configuration Register */ + __IO uint32_t CH1OCFR; /*!< 0x044 Channel-1 Output Configuration Register */ + __IO uint32_t CH2OCFR; /*!< 0x048 Channel-2 Output Configuration Register */ + __IO uint32_t CH3OCFR; /*!< 0x04C Channel-3 Output Configuration Register */ + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED3[5]; /*!< 0x058 - 0x068 Reserved */ + __IO uint32_t CHBRKCFR; /*!< 0x06C Channel Break Configuration Register */ + __IO uint32_t CHBRKCTR; /*!< 0x070 Channel Break Control Register */ + __IO uint32_t DICTR; /*!< 0x074 DMA / Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + __IO uint32_t REPR; /*!< 0x08C Repetition Register */ + __IO uint32_t CH0CCR; /*!< 0x090 Channel 0 Capture/Compare Register */ + __IO uint32_t CH1CCR; /*!< 0x094 Channel 1 Capture/Compare Register */ + __IO uint32_t CH2CCR; /*!< 0x098 Channel 2 Capture/Compare Register */ + __IO uint32_t CH3CCR; /*!< 0x09C Channel 3 Capture/Compare Register */ + __IO uint32_t CH0ACR; /*!< 0x0A0 Channel 0 Asymmetric Compare Register */ + __IO uint32_t CH1ACR; /*!< 0x0A4 Channel 1 Asymmetric Compare Register */ + __IO uint32_t CH2ACR; /*!< 0x0A8 Channel 2 Asymmetric Compare Register */ + __IO uint32_t CH3ACR; /*!< 0x0AC Channel 3 Asymmetric Compare Register */ + #if defined(USE_HT32F50343) + uint32_t RESERVED4[20]; /*!< 0x0B0 - 0x0FC Reserved */ + __IO uint32_t CH4OCFR; /*!< 0x100 Channel-4 Output Configuration Register */ + __IO uint32_t CH5OCFR; /*!< 0x104 Channel-5 Output Configuration Register */ + __IO uint32_t CH6OCFR; /*!< 0x108 Channel-6 Output Configuration Register */ + __IO uint32_t CH7OCFR; /*!< 0x10C Channel-7 Output Configuration Register */ + __IO uint32_t CH4CR; /*!< 0x110 Channel 4 Compare Register */ + __IO uint32_t CH5CR; /*!< 0x114 Channel 5 Compare Register */ + __IO uint32_t CH6CR; /*!< 0x118 Channel 6 Compare Register */ + __IO uint32_t CH7CR; /*!< 0x11C Channel 7 Compare Register */ + #endif +} HT_TM_TypeDef; + + +/** + * @brief Peripheral Direct Memory Access Channel + */ +typedef struct +{ + __IO uint32_t CR; /*!< 0x000 PDMA Channel Control Register */ + __IO uint32_t SADR; /*!< 0x004 PDMA Channel Source Address Register */ + __IO uint32_t DADR; /*!< 0x008 PDMA Channel Destination Address Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t TSR; /*!< 0x010 PDMA Channel Transfer Size Register */ + __IO uint32_t CTSR; /*!< 0x014 PDMA Channel Current Transfer Size Register */ +} HT_PDMACH_TypeDef; + + +/** + * @brief Peripheral Direct Memory Access Global + */ +typedef struct +{ + /* PDMA: 0x40090000 */ + HT_PDMACH_TypeDef PDMACH0; /*!< 0x000 PDMA channel 0 registers */ + HT_PDMACH_TypeDef PDMACH1; /*!< 0x018 PDMA channel 1 registers */ + HT_PDMACH_TypeDef PDMACH2; /*!< 0x030 PDMA channel 2 registers */ + HT_PDMACH_TypeDef PDMACH3; /*!< 0x048 PDMA channel 3 registers */ + HT_PDMACH_TypeDef PDMACH4; /*!< 0x060 PDMA channel 4 registers */ + HT_PDMACH_TypeDef PDMACH5; /*!< 0x078 PDMA channel 5 registers */ + uint32_t RESERVED0[36];/*!< 0x090 - 0x11C Reserved */ + __IO uint32_t ISR; /*!< 0x120 PDMA Interrupt Status Register */ + uint32_t RESERVED1[1]; /*!< 0x124 Reserved */ + __IO uint32_t ISCR; /*!< 0x128 PDMA Interrupt Status Clear Register */ + uint32_t RESERVED2[1]; /*!< 0x12C Reserved */ + __IO uint32_t IER; /*!< 0x130 PDMA Interrupt Enable Register */ +} HT_PDMA_TypeDef; + + +/** + * @brief Universal Serial Bus Global + */ +typedef struct +{ + /* USB: 0x400A8000 */ + __IO uint32_t CSR; /*!< 0x000 USB Control and Status Register */ + __IO uint32_t IER; /*!< 0x004 USB Interrupt Enable Register */ + __IO uint32_t ISR; /*!< 0x008 USB Interrupt Status Register */ + __IO uint32_t FCR; /*!< 0x00C USB Frame Count Register */ + __IO uint32_t DEVAR; /*!< 0x010 USB Device Address Register */ + __IO uint32_t EP0CSR; /*!< 0x014 USB Endpoint 0 Control and Status Register */ + __IO uint32_t EP0IER; /*!< 0x018 USB Endpoint 0 Interrupt Enable Register */ + __IO uint32_t EP0ISR; /*!< 0x01C USB Endpoint 0 Interrupt Status Register */ + __IO uint32_t EP0TCR; /*!< 0x020 USB Endpoint 0 Transfer Count Register */ + __IO uint32_t EP0CFGR; /*!< 0x024 USB Endpoint 0 Configuration Register */ + __IO uint32_t EP1CSR; /*!< 0x028 USB Endpoint 1 Control and Status Register */ + __IO uint32_t EP1IER; /*!< 0x02C USB Endpoint 1 Interrupt Enable Register */ + __IO uint32_t EP1ISR; /*!< 0x030 USB Endpoint 1 Interrupt Status Register */ + __IO uint32_t EP1TCR; /*!< 0x034 USB Endpoint 1 Transfer Count Register */ + __IO uint32_t EP1CFGR; /*!< 0x038 USB Endpoint 1 Configuration Register */ + __IO uint32_t EP2CSR; /*!< 0x03C USB Endpoint 2 Control and Status Register */ + __IO uint32_t EP2IER; /*!< 0x040 USB Endpoint 2 Interrupt Enable Register */ + __IO uint32_t EP2ISR; /*!< 0x044 USB Endpoint 2 Interrupt Status Register */ + __IO uint32_t EP2TCR; /*!< 0x048 USB Endpoint 2 Transfer Count Register */ + __IO uint32_t EP2CFGR; /*!< 0x04C USB Endpoint 2 Configuration Register */ + __IO uint32_t EP3CSR; /*!< 0x050 USB Endpoint 3 Control and Status Register */ + __IO uint32_t EP3IER; /*!< 0x054 USB Endpoint 3 Interrupt Enable Register */ + __IO uint32_t EP3ISR; /*!< 0x058 USB Endpoint 3 Interrupt Status Register */ + __IO uint32_t EP3TCR; /*!< 0x05C USB Endpoint 3 Transfer Count Register */ + __IO uint32_t EP3CFGR; /*!< 0x060 USB Endpoint 3 Configuration Register */ + __IO uint32_t EP4CSR; /*!< 0x064 USB Endpoint 4 Control and Status Register */ + __IO uint32_t EP4IER; /*!< 0x068 USB Endpoint 4 Interrupt Enable Register */ + __IO uint32_t EP4ISR; /*!< 0x06C USB Endpoint 4 Interrupt Status Register */ + __IO uint32_t EP4TCR; /*!< 0x070 USB Endpoint 4 Transfer Count Register */ + __IO uint32_t EP4CFGR; /*!< 0x074 USB Endpoint 4 Configuration Register */ + __IO uint32_t EP5CSR; /*!< 0x078 USB Endpoint 5 Control and Status Register */ + __IO uint32_t EP5IER; /*!< 0x07C USB Endpoint 5 Interrupt Enable Register */ + __IO uint32_t EP5ISR; /*!< 0x080 USB Endpoint 5 Interrupt Status Register */ + __IO uint32_t EP5TCR; /*!< 0x084 USB Endpoint 5 Transfer Count Register */ + __IO uint32_t EP5CFGR; /*!< 0x088 USB Endpoint 5 Configuration Register */ + __IO uint32_t EP6CSR; /*!< 0x08C USB Endpoint 6 Control and Status Register */ + __IO uint32_t EP6IER; /*!< 0x090 USB Endpoint 6 Interrupt Enable Register */ + __IO uint32_t EP6ISR; /*!< 0x094 USB Endpoint 6 Interrupt Status Register */ + __IO uint32_t EP6TCR; /*!< 0x098 USB Endpoint 6 Transfer Count Register */ + __IO uint32_t EP6CFGR; /*!< 0x09C USB Endpoint 6 Configuration Register */ + __IO uint32_t EP7CSR; /*!< 0x0A0 USB Endpoint 7 Control and Status Register */ + __IO uint32_t EP7IER; /*!< 0x0A4 USB Endpoint 7 Interrupt Enable Register */ + __IO uint32_t EP7ISR; /*!< 0x0A8 USB Endpoint 7 Interrupt Status Register */ + __IO uint32_t EP7TCR; /*!< 0x0AC USB Endpoint 7 Transfer Count Register */ + __IO uint32_t EP7CFGR; /*!< 0x0B0 USB Endpoint 7 Configuration Register */ + #if defined(USE_HT32F61141) + __IO uint32_t EP8CSR; /*!< 0x0B4 USB Endpoint 8 Control and Status Register */ + __IO uint32_t EP8IER; /*!< 0x0B8 USB Endpoint 8 Interrupt Enable Register */ + __IO uint32_t EP8ISR; /*!< 0x0BC USB Endpoint 8 Interrupt Status Register */ + __IO uint32_t EP8TCR; /*!< 0x0C0 USB Endpoint 8 Transfer Count Register */ + __IO uint32_t EP8CFGR; /*!< 0x0C4 USB Endpoint 8 Configuration Register */ + __IO uint32_t EP9CSR; /*!< 0x0C8 USB Endpoint 9 Control and Status Register */ + __IO uint32_t EP9IER; /*!< 0x0CC USB Endpoint 9 Interrupt Enable Register */ + __IO uint32_t EP9ISR; /*!< 0x0D0 USB Endpoint 9 Interrupt Status Register */ + __IO uint32_t EP9TCR; /*!< 0x0D4 USB Endpoint 9 Transfer Count Register */ + __IO uint32_t EP9CFGR; /*!< 0x0D8 USB Endpoint 9 Configuration Register */ + #endif +} HT_USB_TypeDef; + + +/** + * @brief Universal Serial Bus Endpoint + */ +typedef struct +{ + /* USB Endpoint0: 0x400A8014 */ + /* USB Endpoint1: 0x400A8028 */ + /* USB Endpoint2: 0x400A803C */ + /* USB Endpoint3: 0x400A8050 */ + /* USB Endpoint4: 0x400A8064 */ + /* USB Endpoint5: 0x400A8078 */ + /* USB Endpoint6: 0x400A808C */ + /* USB Endpoint7: 0x400A80A0 */ + /* USB Endpoint8: 0x400A80B4 */ + /* USB Endpoint9: 0x400A80C8 */ + __IO uint32_t CSR; /*!< 0x000 USB Endpoint n Control and Status Register */ + __IO uint32_t IER; /*!< 0x004 USB Endpoint n Interrupt Enable Register */ + __IO uint32_t ISR; /*!< 0x008 USB Endpoint n Interrupt Status Register */ + __IO uint32_t TCR; /*!< 0x00C USB Endpoint n Transfer Count Register */ + __IO uint32_t CFGR; /*!< 0x010 USB Endpoint n Configuration Register */ +} HT_USBEP_TypeDef; + + +/** + * @brief External Bus Interface + */ +typedef struct +{ + /* EBI: 0x40098000 */ + __IO uint32_t CR; /*!< 0x000 EBI Control Register */ + uint32_t RESERVED0[1]; /*!< 0x004 Reserved */ + __IO uint32_t SR; /*!< 0x008 EBI Status Register */ + uint32_t RESERVED1[1]; /*!< 0x00C Reserved */ + __IO uint32_t ATR; /*!< 0x010 EBI Address Timing Register */ + __IO uint32_t RTR; /*!< 0x014 EBI Read Timing Register */ + __IO uint32_t WTR; /*!< 0x018 EBI Write Timing Register */ + __IO uint32_t PR; /*!< 0x01C EBI Parity Register */ +} HT_EBI_TypeDef; + + +/** + * @brief Cyclic Redundancy Check + */ +typedef struct +{ + /* CRC: 0x4008A000 */ + __IO uint32_t CR; /*!< 0x000 CRC Control Register */ + __IO uint32_t SDR; /*!< 0x004 CRC Seed Register */ + __IO uint32_t CSR; /*!< 0x008 CRC Checksum Register */ + __IO uint32_t DR; /*!< 0x00C CRC Data Register */ +} HT_CRC_TypeDef; + + +/** + * @brief Integrated Interchip Sound + */ +typedef struct +{ + /* I2S: 0x40026000 */ + __IO uint32_t CR; /*!< 0x000 I2S Control Register */ + __IO uint32_t IER; /*!< 0x004 I2S Interrupt Enable Register */ + __IO uint32_t CDR; /*!< 0x008 I2S Clock Divider Register */ + __IO uint32_t TXDR; /*!< 0x00C I2S TX Data Register */ + __IO uint32_t RXDR; /*!< 0x010 I2S RX Data Register */ + __IO uint32_t FCR; /*!< 0x014 I2S FIFO Control Register */ + __IO uint32_t SR; /*!< 0x018 I2S Status Register */ + __IO uint32_t RCNTR; /*!< 0x01C I2S Rate Counter Register */ +} HT_I2S_TypeDef; + + +/** + * @brief PWM Timer + */ +typedef struct +{ + /* PWM0: 0x40031000 */ + /* PWM2: 0x40032000 */ + /* PWM1: 0x40071000 */ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[11]; /*!< 0x014 - 0x03C Reserved */ + __IO uint32_t CH0OCFR; /*!< 0x040 Channel-0 Output Configuration Register */ + __IO uint32_t CH1OCFR; /*!< 0x044 Channel-1 Output Configuration Register */ + __IO uint32_t CH2OCFR; /*!< 0x048 Channel-2 Output Configuration Register */ + __IO uint32_t CH3OCFR; /*!< 0x04C Channel-3 Output Configuration Register */ + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED2[7]; /*!< 0x058 - 0x070 Reserved */ + __IO uint32_t DICTR; /*!< 0x074 DMA / Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + uint32_t RESERVED3[1]; /*!< 0x08C Reserved */ + __IO uint32_t CH0CR; /*!< 0x090 Channel 0 Compare Register */ + __IO uint32_t CH1CR; /*!< 0x094 Channel 1 Compare Register */ + __IO uint32_t CH2CR; /*!< 0x098 Channel 2 Compare Register */ + __IO uint32_t CH3CR; /*!< 0x09C Channel 3 Compare Register */ + __IO uint32_t CH0ACR; /*!< 0x0A0 Channel 0 Asymmetric Compare Register */ + __IO uint32_t CH1ACR; /*!< 0x0A4 Channel 1 Asymmetric Compare Register */ + __IO uint32_t CH2ACR; /*!< 0x0A8 Channel 2 Asymmetric Compare Register */ + __IO uint32_t CH3ACR; /*!< 0x0AC Channel 3 Asymmetric Compare Register */ + #if defined(USE_HT32F50343) + uint32_t RESERVED4[20]; /*!< 0x0B0 - 0x0FC Reserved */ + __IO uint32_t CH4OCFR; /*!< 0x100 Channel-4 Output Configuration Register */ + __IO uint32_t CH5OCFR; /*!< 0x104 Channel-5 Output Configuration Register */ + __IO uint32_t CH6OCFR; /*!< 0x108 Channel-6 Output Configuration Register */ + __IO uint32_t CH7OCFR; /*!< 0x10C Channel-7 Output Configuration Register */ + __IO uint32_t CH4CR; /*!< 0x110 Channel 4 Compare Register */ + __IO uint32_t CH5CR; /*!< 0x114 Channel 5 Compare Register */ + __IO uint32_t CH6CR; /*!< 0x118 Channel 6 Compare Register */ + __IO uint32_t CH7CR; /*!< 0x11C Channel 7 Compare Register */ + #endif +} HT_PWM_TypeDef; + + +/** + * @brief Single Channel Timer + */ +typedef struct +{ + /* SCTM0: 0x40034000 */ + /* SCTM1: 0x40074000 */ + /* SCTM2: 0x40035000 */ + /* SCTM3: 0x40075000 */ + __IO uint32_t CNTCFR; /*!< 0x000 Counter Configuration Register */ + __IO uint32_t MDCFR; /*!< 0x004 Mode Configuration Register */ + __IO uint32_t TRCFR; /*!< 0x008 Trigger Configuration Register */ + uint32_t RESERVED0[1]; /*!< 0x00C Reserved */ + __IO uint32_t CTR; /*!< 0x010 Control Register */ + uint32_t RESERVED1[3]; /*!< 0x014 - 0x01C Reserved */ + __IO uint32_t CH0ICFR; /*!< 0x020 Channel 0 Input Configuration Register */ + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F66242) || defined(USE_HT32F66246) + __IO uint32_t CH1ICFR; /*!< 0x024 Channel 1 Input Configuration Register */ + uint32_t RESERVED2[6]; /*!< 0x028 - 0x03C Reserved */ + #else + uint32_t RESERVED2[7]; /*!< 0x024 - 0x03C Reserved */ + #endif + __IO uint32_t CHOCFR; /*!< 0x040 Channel Output Configuration Register */ + #if defined(USE_HT32F50020_30) + __IO uint32_t CH1OCFR; /*!< 0x044 Channel 1 Output Configuration Register */ + uint32_t RESERVED3[2]; /*!< 0x048 - 0x04C Reserved */ + #else + uint32_t RESERVED3[3]; /*!< 0x044 - 0x04C Reserved */ + #endif + __IO uint32_t CHCTR; /*!< 0x050 Channel Control Register */ + __IO uint32_t CHPOLR; /*!< 0x054 Channel Polarity Configuration Register */ + uint32_t RESERVED4[7]; /*!< 0x058 - 0x070 Reserved */ + __IO uint32_t DICTR; /*!< 0x074 Interrupt Control Register */ + __IO uint32_t EVGR; /*!< 0x078 Event Generator Register */ + __IO uint32_t INTSR; /*!< 0x07C Interrupt Status Register */ + __IO uint32_t CNTR; /*!< 0x080 Counter Register */ + __IO uint32_t PSCR; /*!< 0x084 Prescaler Register */ + __IO uint32_t CRR; /*!< 0x088 Counter Reload Register */ + uint32_t RESERVED5[1]; /*!< 0x08C Reserved */ + __IO uint32_t CH0CCR; /*!< 0x090 Channel 0 Capture/Compare Register */ + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F50020_30) || defined(USE_HT32F66242) || defined(USE_HT32F66246) + __IO uint32_t CH1CCR; /*!< 0x094 Channel 1 Capture Register */ + #endif +} HT_SCTM_TypeDef; + + +/** + * @brief Divider + */ +typedef struct +{ + /* DIV: 0x400CA000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t DDR; /*!< 0x004 Dividend register */ + __IO uint32_t DSR; /*!< 0x008 Divisor Register */ + __IO uint32_t QTR; /*!< 0x00C Quotient Register */ + __IO uint32_t RMR; /*!< 0x010 Remainder Register */ +} HT_DIV_TypeDef; + + +/** + * @brief Advanced Encryption Standard + */ +typedef struct +{ + /* AES: 0x400C8000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t PDMAR; /*!< 0x008 PDMA Register */ + __IO uint32_t ISR; /*!< 0x00C Interrupt Status Register */ + __IO uint32_t IER; /*!< 0x010 Interrupt Enable Register */ + __IO uint32_t DINR; /*!< 0x014 Data Input Register */ + __IO uint32_t DOUTR; /*!< 0x018 Data Output Register */ + #if defined(USE_HT32F52357_67) + __IO uint32_t KEYR[8]; /*!< 0x01C - 0x038 Key Register 0~7 */ + #else + __IO uint32_t KEYR[4]; /*!< 0x01C - 0x028 Key Register 0~3 */ + uint32_t RESERVED0[4]; /*!< 0x02C - 0x038 Reserved */ + #endif + __IO uint32_t IVR[4]; /*!< 0x03C - 0x048 Initial Vector Register 0~3 */ +} HT_AES_TypeDef; + + +/** + * @brief MIDI + */ +typedef struct +{ + /* MIDI: 0x40060000 */ + __IO uint32_t CHAN; /*!< 0x000 MIDI Channel Number Select */ + __IO uint32_t FREQ; /*!< 0x004 MIDI Frequency Number */ + __IO uint32_t VOL; /*!< 0x008 MIDI Volume Control */ + __IO uint32_t ST_ADDR; /*!< 0x00C MIDI Start Address */ + __IO uint32_t RE_NUM; /*!< 0x010 MIDI Repeat Number */ + __IO uint32_t END_ADDR; /*!< 0x014 MIDI End Address */ + __IO uint32_t IER; /*!< 0x018 MIDI Interrupt/DMA Enable Register */ + __IO uint32_t SR; /*!< 0x01C MIDI Status Register */ + __IO uint32_t MCU_CH0; /*!< 0x020 MIDI MCU Channel 0 data */ + __IO uint32_t MCU_CH1; /*!< 0x024 MIDI MCU Channel 1 data */ + __IO uint32_t MCU_CH2; /*!< 0x028 MIDI MCU Channel 2 data */ + __IO uint32_t MCU_CH3; /*!< 0x02C MIDI MCU Channel 3 data */ + __IO uint32_t MIDIL; /*!< 0x030 MIDI Engine Waveform of Left Channel */ + __IO uint32_t MIDIR; /*!< 0x034 MIDI Engine Waveform of Right Channel */ + __IO uint32_t SPI_DATA; /*!< 0x038 MIDI SPI Flash data read */ + __IO uint32_t SPI_ADDR; /*!< 0x03C MIDI SPI Flash address read */ + __IO uint32_t CTRL; /*!< 0x040 MIDI Control Register */ +} HT_MIDI_TypeDef; + + +/** + * @brief LCD + */ +typedef struct +{ + /* LCD: 0x4001A000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t FCR; /*!< 0x004 Frame Control Register */ + __IO uint32_t IER; /*!< 0x008 Interrupt Enable Register */ + __IO uint32_t SR; /*!< 0x00C Status Register */ + __IO uint32_t CLR; /*!< 0x010 Clear Register */ + uint32_t RESERVED[3]; /*!< 0x014 - 0x020 Reserved */ + __IO uint32_t RAM[16]; /*!< 0x020 - 0x05C Display Memory */ +} HT_LCD_TypeDef; + + +/** + * @brief Serial SLED Interface + */ +typedef struct +{ + /* SLED0: 0x4000E000 */ + /* SLED1: 0x4004E000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t CDR; /*!< 0x008 Clock Divider Register */ + __IO uint32_t TCR; /*!< 0x00C Timne Code Register */ + union { + __IO uint8_t DR_8BIT; /*!< 0x010 Data Register, 8-bit access, duplicate 4 times into 32-bit */ + __IO uint16_t DR_16BIT; /*!< 0x010 Data Register, 16-bit access, duplicate 2 times into 32-bit */ + __IO uint32_t DR_32BIT; /*!< 0x010 Data Register */ + }; + __IO uint32_t FCR; /*!< 0x014 FIFO Control Register */ +} HT_SLED_TypeDef; + + +/** + * @brief Touch Key Module + */ +typedef struct +{ + __IO uint32_t CR; /*!< 0x000 Touch Key Module Control Register */ + __IO uint32_t KCFGR; /*!< 0x004 Touch Key Module Key Configuration Register */ + __IO uint32_t SR; /*!< 0x008 Touch Key Module Status Register */ + __IO uint32_t ROCPR; /*!< 0x00C Touch Key Module Reference OSC Capacitor Register */ + __IO uint32_t K3CPR; /*!< 0x010 Touch Key Module Key 3 Capacitor Register */ + __IO uint32_t K2CPR; /*!< 0x014 Touch Key Module Key 2 Capacitor Register */ + __IO uint32_t K1CPR; /*!< 0x018 Touch Key Module Key 1 Capacitor Register */ + __IO uint32_t K0CPR; /*!< 0x01C Touch Key Module Key 0 Capacitor Register */ + __IO uint32_t CFCNTR; /*!< 0x020 Touch Key Module C/F Counter Register */ + __IO uint32_t K3CNTR; /*!< 0x024 Touch Key Module Key 3 Counter Register */ + __IO uint32_t K2CNTR; /*!< 0x028 Touch Key Module Key 2 Counter Register */ + __IO uint32_t K1CNTR; /*!< 0x02C Touch Key Module Key 1 Counter Register */ + __IO uint32_t K0CNTR; /*!< 0x030 Touch Key Module Key 0 Counter Register */ + __IO uint32_t K3THR; /*!< 0x034 Touch Key Module Key 3 Threshold Register */ + __IO uint32_t K2THR; /*!< 0x038 Touch Key Module Key 2 Threshold Register */ + __IO uint32_t K1THR; /*!< 0x03C Touch Key Module Key 1 Threshold Register */ + __IO uint32_t K0THR; /*!< 0x040 Touch Key Module Key 0 Threshold Register */ + uint32_t RESERVED0[47]; /*!< 0x044 - 0x0FC Reserved */ +} HT_TKM_TypeDef; + + +/** + * @brief Touch Key + */ +typedef struct +{ + /* TKEY: 0x4001A000 */ + __IO uint32_t TKCR; /*!< 0x000 Touch Key Control Register */ + __IO uint32_t TKCNTR; /*!< 0x004 Touch Key Counter Register */ + __IO uint32_t TKTSCRR; /*!< 0x008 Touch Key Time Slot Counter Reload Register */ + __IO uint32_t TKIER; /*!< 0x00C Touch Key Interrupt Enable Register */ + __IO uint32_t TKSR; /*!< 0x010 Touch Key Status Register */ + uint32_t RESERVED0[59]; /*!< 0x014 - 0x0FC Reserved */ + HT_TKM_TypeDef TKM0; /*!< 0x100 Touch Key Module 0 registers */ + HT_TKM_TypeDef TKM1; /*!< 0x200 Touch Key Module 1 registers */ + HT_TKM_TypeDef TKM2; /*!< 0x300 Touch Key Module 2 registers */ + HT_TKM_TypeDef TKM3; /*!< 0x400 Touch Key Module 3 registers */ + HT_TKM_TypeDef TKM4; /*!< 0x500 Touch Key Module 4 registers */ + HT_TKM_TypeDef TKM5; /*!< 0x600 Touch Key Module 5 registers */ +} HT_TKEY_TypeDef; + + +/** + * @brief LED Controller + */ +typedef struct +{ + /* LEDC: 0x4005A000 */ + __IO uint32_t CR; /*!< 0x000 LED Control Register */ + __IO uint32_t CER; /*!< 0x004 LED COM Enable Register */ + __IO uint32_t PCR; /*!< 0x008 LED Polarity Control Register */ + __IO uint32_t IER; /*!< 0x00C LED Interrupt Enable Register */ + __IO uint32_t SR; /*!< 0x010 LED Status Register */ + __IO uint32_t DTCR; /*!< 0x014 LED Dead Time Control Register */ + #if defined(USE_HT32F54231_41) || defined(USE_HT32F50020_30) || defined(USE_HT32F53231_41) || defined(USE_HT32F53242_52) || defined(USE_HT32F50431_41) || defined(USE_HT32F50442_52) + __IO uint32_t DR[8]; /*!< 0x018 - 0x034 LED Data Register */ + #endif + #if defined(USE_HT32F54243_53) + __IO uint32_t DR[12]; /*!< 0x018 - 0x044 LED Data Register */ + #endif +} HT_LEDC_TypeDef; + + +/** + * @brief Controller Area Network Interface + */ +typedef struct +{ + __IO uint32_t CREQ; /*!< 0x000 CAN Interface Command Request Register */ + __IO uint32_t CMASK; /*!< 0x004 CAN Interface Command Mask Register */ + __IO uint32_t MASK0; /*!< 0x008 CAN Interface Mask Register 0 */ + __IO uint32_t MASK1; /*!< 0x00C CAN Interface Mask Register 1 */ + __IO uint32_t ARB0; /*!< 0x010 CAN Interface Arbitration Register 0 */ + __IO uint32_t ARB1; /*!< 0x014 CAN Interface Arbitration Register 1 */ + __IO uint32_t MCR; /*!< 0x018 CAN Interface Message Control Register */ + __IO uint32_t DA0R; /*!< 0x01C CAN Interface Data A 0 Register */ + __IO uint32_t DA1R; /*!< 0x020 CAN Interface Data A 1 Register */ + __IO uint32_t DB0R; /*!< 0x024 CAN Interface Data B 0 Register */ + __IO uint32_t DB1R; /*!< 0x028 CAN Interface Data B 1 Register */ +} HT_CANIF_TypeDef; + +/** + * @brief Controller Area Network Global + */ +typedef struct +{ + /* CAN: 0x4000C000 */ + __IO uint32_t CR; /*!< 0x000 Control Register */ + __IO uint32_t SR; /*!< 0x004 Status Register */ + __IO uint32_t ECR; /*!< 0x008 Error Counter Register */ + __IO uint32_t BTR; /*!< 0x00C Bit Timing Register */ + __IO uint32_t IR; /*!< 0x010 Interrupt Register */ + __IO uint32_t TR; /*!< 0x014 Test Register */ + __IO uint32_t BRPER; /*!< 0x018 BRP Extension Register */ + uint32_t RESERVED0[1]; /*!< 0x01C Reserved */ + HT_CANIF_TypeDef IF0; /*!< 0x020 - 0x048 CAN Interface 0 registers */ + uint32_t RESERVED1[13];/*!< 0x04C - 0x07C Reserved */ + HT_CANIF_TypeDef IF1; /*!< 0x080 - 0x0A8 CAN Interface 1 registers */ + uint32_t RESERVED2[21];/*!< 0x0AC - 0x0FC Reserved */ + __IO uint32_t TRR0; /*!< 0x100 Transmission Request Register 0 */ + __IO uint32_t TRR1; /*!< 0x104 Transmission Request Register 1 */ + uint32_t RESERVED3[6]; /*!< 0x108 - 0x11C Reserved */ + __IO uint32_t NDR0; /*!< 0x120 New Data Register 0 */ + __IO uint32_t NDR1; /*!< 0x124 New Data Register 1 */ + uint32_t RESERVED4[6]; /*!< 0x128 - 0x13C Reserved */ + __IO uint32_t IPR0; /*!< 0x140 Interrupt Pending Register 0 */ + __IO uint32_t IPR1; /*!< 0x144 Interrupt Pending Register 1 */ + uint32_t RESERVED5[6]; /*!< 0x148 - 0x15C Reserved */ + __IO uint32_t MVR0; /*!< 0x160 Message Valid Register 0 */ + __IO uint32_t MVR1; /*!< 0x164 Message Valid Register 1 */ +} HT_CAN_TypeDef; + +/** + * @brief Coordinate Rotation Digital Computer + */ +typedef struct +{ + /* CORDIC: 0x400DC000 */ + __IO uint32_t CSR; /*!< 0x000 Control/Satus Register */ + __IO uint32_t WDATA; /*!< 0x004 Argument Register */ + __IO uint32_t RDATA; /*!< 0x008 Result Register */ +} HT_CORDIC_TypeDef; + +/** + * @brief Proportional Integral Derivative controller + */ +typedef struct +{ + /* PID: 0x400EC000 */ + __IO uint32_t CR0; /*!< 0x000 Control Register 0 */ + __IO uint32_t UI_INPUT; /*!< 0x004 */ + __IO uint32_t ERR_n; /*!< 0x008 */ + __IO uint32_t PID_OUT; /*!< 0x00C */ + __IO uint32_t SPD1ERR1; /*!< 0x010 */ + __IO uint32_t SPD1KP; /*!< 0x014 */ + __IO uint32_t SPD1KI; /*!< 0x018 */ + __IO uint32_t SPD1KD; /*!< 0x01C */ + __IO uint32_t SPD1UI1; /*!< 0x020 */ + __IO uint32_t SPD1UI_MAX; /*!< 0x024 */ + __IO uint32_t SPD1UI_MIN; /*!< 0x028 */ + __IO uint32_t SPD1_PIDOUT_LIM; /*!< 0x02C */ + __IO uint32_t IQ1ERR1; /*!< 0x030 */ + __IO uint32_t IQ1KP; /*!< 0x034 */ + __IO uint32_t IQ1KI; /*!< 0x038 */ + __IO uint32_t IQ1KD; /*!< 0x03C */ + __IO uint32_t IQ1UI1; /*!< 0x040 */ + __IO uint32_t IQ1UI_MAX; /*!< 0x044 */ + __IO uint32_t IQ1UI_MIN; /*!< 0x048 */ + __IO uint32_t IQ1_PIDOUT_LIM; /*!< 0x04C */ + __IO uint32_t ID1ERR1; /*!< 0x050 */ + __IO uint32_t ID1KP; /*!< 0x054 */ + __IO uint32_t ID1KI; /*!< 0x058 */ + __IO uint32_t ID1KD; /*!< 0x05C */ + __IO uint32_t ID1UI1; /*!< 0x060 */ + __IO uint32_t ID1UI_MAX; /*!< 0x064 */ + __IO uint32_t ID1UI_MIN; /*!< 0x068 */ + __IO uint32_t ID1_PIDOUT_LIM; /*!< 0x06C */ + __IO uint32_t FWNK1ERR1; /*!< 0x070 */ + __IO uint32_t FWNK1KP; /*!< 0x074 */ + __IO uint32_t FWNK1KI; /*!< 0x078 */ + __IO uint32_t FWNK1KD; /*!< 0x07C */ + __IO uint32_t FWNK1UI1; /*!< 0x080 */ + __IO uint32_t FWNK1UI_MAX; /*!< 0x084 */ + __IO uint32_t FWNK1UI_MIN; /*!< 0x088 */ + __IO uint32_t FWNK1_PIDOUT_LIM;/*!< 0x08C */ + __IO uint32_t PLL1ERR1; /*!< 0x090 */ + __IO uint32_t PLL1KP; /*!< 0x094 */ + __IO uint32_t PLL1KI; /*!< 0x098 */ + __IO uint32_t PLL1KD; /*!< 0x09C */ + __IO uint32_t PLL1UI1; /*!< 0x0A0 */ + __IO uint32_t PLL1UI_MAX; /*!< 0x0A4 */ + __IO uint32_t PLL1UI_MIN; /*!< 0x0A8 */ + __IO uint32_t PLL1_PIDOUT_LIM; /*!< 0x0AC */ + __IO uint32_t USR1ERR1; /*!< 0x0B0 */ + __IO uint32_t USR1KP; /*!< 0x0B4 */ + __IO uint32_t USR1KI; /*!< 0x0B8 */ + __IO uint32_t USR1KD; /*!< 0x0BC */ + __IO uint32_t USR1UI1; /*!< 0x0C0 */ + __IO uint32_t USR1UI_MAX; /*!< 0x0C4 */ + __IO uint32_t USR1UI_MIN; /*!< 0x0C8 */ + __IO uint32_t USR1_PIDOUT_LIM; /*!< 0x0CC */ +} HT_PID_TypeDef; +/** + * @} + */ + +/** + * @brief RF + */ +typedef struct +{ + /* RF: 0x400D0000 */ + __IO uint8_t TRXADR0; /*!< 0x000 TX/RX ADDRESS 5BYTES(LSB) */ + __IO uint8_t TRXADR1; /*!< 0x001 TX/RX ADDRESS 5BYTES */ + __IO uint8_t TRXADR2; /*!< 0x002 TX/RX ADDRESS 5BYTES */ + __IO uint8_t TRXADR3; /*!< 0x003 TX/RX ADDRESS 5BYTES */ + __IO uint8_t TRXADR4; /*!< 0x004 TX/RX ADDRESS 5BYTES(MSB) */ + __IO uint8_t RXP1ADR0; /*!< 0x005 RX PIPE1 ADDRESS 5BYTES(LSB) */ + __IO uint8_t RXP1ADR1; /*!< 0x006 RX PIPE1 ADDRESS 5BYTES */ + __IO uint8_t RXP1ADR2; /*!< 0x007 RX PIPE1 ADDRESS 5BYTES */ + __IO uint8_t RXP1ADR3; /*!< 0x008 RX PIPE1 ADDRESS 5BYTES */ + __IO uint8_t RXP1ADR4; /*!< 0x009 RX PIPE1 ADDRESS 5BYTES(MSB) */ + __IO uint8_t RXP2ADR0; /*!< 0x00A RX PIPE2 ADDRESS 5BYTES(LSB) */ + __IO uint8_t RXP3ADR0; /*!< 0x00B RX PIPE3 ADDRESS 5BYTES(LSB) */ + __IO uint8_t RXP4ADR0; /*!< 0x00C RX PIPE4 ADDRESS 5BYTES(LSB) */ + __IO uint8_t RXP5ADR0; /*!< 0x00D RX PIPE5 ADDRESS 5BYTES(LSB) */ + uint8_t RESERVED0[2]; /*!< 0x00E - 0x00F Reserved */ + __IO uint8_t TXFIFO; /*!< 0x010 TX FIFO WRITE ONLY */ + uint8_t RESERVED1[3]; /*!< 0x011 - 0x013 Reserved */ + __IO uint8_t RXFIFO; /*!< 0x014 RX FIFO READ ONLY */ + uint8_t RESERVED2[3]; /*!< 0x015 - 0x017 Reserved */ + __IO uint8_t FWREND; /*!< 0x018 FIFO Read/Write End */ + __IO uint8_t FLUSHFF; /*!< 0x019 FLUSH TX/RX FIFO */ + __IO uint8_t TXFFSEL; /*!< 0x01A Write TX FIFO Select ACK Payload or NACK Payload */ + __IO uint8_t PIPESEL; /*!< 0x01B Write TX FIFO for PIPE ACK Payload */ + __IO uint8_t RFC1; /*!< 0x01C RF Control Register 1 */ + __IO uint8_t RFC2; /*!< 0x01D RF Control Register 2 */ + __IO uint8_t RFC3; /*!< 0x01E RF Control Register 3 */ + uint8_t RESERVED3[1]; /*!< 0x01F Reserved */ + __IO uint8_t CFG1; /*!< 0x020 Configuration Control Register 1 */ + __IO uint8_t RC1; /*!< 0x021 Reset/Clock Control Register 1 */ + __IO uint8_t RC2; /*!< 0x022 Reset/Clock Control Register 2 */ + __IO uint8_t MASK; /*!< 0x023 Mask Control Register */ + __IO uint8_t IRQ1; /*!< 0x024 Interrupt Control Register 1 */ + __IO uint8_t STATUS; /*!< 0x025 FIFO Status Control Register */ + __IO uint8_t IO1; /*!< 0x026 IO Control Register 1 */ + __IO uint8_t IO2; /*!< 0x027 IO Control Register 2 */ + __IO uint8_t IO3; /*!< 0x028 IO Control Register 3 */ + __IO uint8_t PKT1; /*!< 0x029 Packet Control Register 1 */ + __IO uint8_t PKT2; /*!< 0x02A Packet Control Register 2 */ + __IO uint8_t PKT3; /*!< 0x02B Packet Control Register 3 */ + __IO uint8_t PKT4; /*!< 0x02C Packet Control Register 4 */ + __IO uint8_t PKT5; /*!< 0x02D Packet Control Register 5 */ + __IO uint8_t MOD1; /*!< 0x02E Modulator Control Register 1 */ + __IO uint8_t MOD2; /*!< 0x02F Modulator Control Register 2 */ + __IO uint8_t DM1; /*!< 0x030 De-modulator Control Register 1 */ + __IO uint8_t DM2; /*!< 0x031 De-modulator Control Register 2 */ + __IO uint8_t RT1; /*!< 0x032 PTX Retransmission Control Register 1 */ + __IO uint8_t RT2; /*!< 0x033 PTX Retransmission Control Register 2 */ + __IO uint8_t CE; /*!< 0x034 Chip Enable Control Register */ + __IO uint8_t CP21; /*!< 0x035 CP Control Register 21 */ + __IO uint8_t CP22; /*!< 0x036 CP Control Register 22 */ + __IO uint8_t CP31; /*!< 0x037 CP Control Register 31 */ + __IO uint8_t CP2R; /*!< 0x038 CP Control Register 2 for Read */ + __IO uint8_t CP3R; /*!< 0x039 CP Control Register 3 for Read */ + __IO uint8_t CP2RX; /*!< 0x03A CP Control Register 2 for RX */ + __IO uint8_t CP3RX; /*!< 0x03B CP Control Register 3 for RX */ + __IO uint8_t PDB; /*!< 0x03C RF Power Down Bar Enable Control Register */ + __IO uint8_t RF1; /*!< 0x03D RF RX control Register 1 */ + uint8_t RESERVED4[2]; /*!< 0x03E - 0x03F Reserved */ + __IO uint8_t OM; /*!< 0x040 Operation Mode Control Register */ + __IO uint8_t CFO1; /*!< 0x041 Carrier Frequency Offset Control Register 1 */ + __IO uint8_t SX1; /*!< 0x042 Fractional-N Synthesizer Control Register 1 */ + __IO uint8_t SX2; /*!< 0x043 Fractional-N Synthesizer Control Register 2 */ + __IO uint8_t SX3; /*!< 0x044 Fractional-N Synthesizer Control Register 3 */ + __IO uint8_t SX4; /*!< 0x045 Fractional-N Synthesizer Control Register 4 */ + __IO uint8_t STA1; /*!< 0x046 Status Control Register 1 */ + __IO uint8_t RSSI1; /*!< 0x047 RSSI Control Register 1 */ + __IO uint8_t RSSI2; /*!< 0x048 RSSI Control Register 2 */ + __IO uint8_t RSSI3; /*!< 0x049 RSSI Control Register 3 */ + __IO uint8_t DPL1; /*!< 0x04A Dynamic Payload Length Control Register 1 */ + __IO uint8_t DPL2; /*!< 0x04B Dynamic Payload Length Control Register 2 */ + __IO uint8_t RXPW0; /*!< 0x04C RX Payload Length Control Register 0 */ + __IO uint8_t RXPW1; /*!< 0x04D RX Payload Length Control Register 1 */ + __IO uint8_t RXPW2; /*!< 0x04E RX Payload Length Control Register 2 */ + __IO uint8_t RXPW3; /*!< 0x04F RX Payload Length Control Register 3 */ + __IO uint8_t RXPW4; /*!< 0x050 RX Payload Length Control Register 4 */ + __IO uint8_t RXPW5; /*!< 0x051 RX Payload Length Control Register 5 */ + __IO uint8_t ENAA; /*!< 0x052 Enable Auto-ACK Control Register */ + __IO uint8_t PEN; /*!< 0x053 Pipe Enable Control Register */ + __IO uint8_t XO1; /*!< 0x054 XO Control Register 1 */ + __IO uint8_t XO2; /*!< 0x055 XO Control Register 2 */ + __IO uint8_t TXP1; /*!< 0x056 TX Power Control Register 1 */ + __IO uint8_t DM3; /*!< 0x057 De-modulator Control Register 3 */ + __IO uint8_t AGC1; /*!< 0x058 AGC Control Register 1 */ + __IO uint8_t AGC2; /*!< 0x059 AGC Control Register 2 */ + __IO uint8_t AGC3; /*!< 0x05A AGC Control Register 3 */ + __IO uint8_t AGC4; /*!< 0x05B AGC Control Register 4 */ + __IO uint8_t FCF1; /*!< 0x05C Filter Coefficient Control Register 1 */ + __IO uint8_t FCF2; /*!< 0x05D Filter Coefficient Control Register 2 */ + __IO uint8_t FCF3; /*!< 0x05E Filter Coefficient Control Register 3 */ + __IO uint8_t FCF4; /*!< 0x05F Filter Coefficient Control Register 4 */ + __IO uint8_t RXG; /*!< 0x060 RX Gain Control Register */ + __IO uint8_t CP1; /*!< 0x061 CP Control Register 1 */ + __IO uint8_t CP2; /*!< 0x062 CP Control Register 2 */ + __IO uint8_t CP3; /*!< 0x063 CP Control Register 3 */ + __IO uint8_t OD1; /*!< 0x064 MMD and OD Control Register 1 */ + __IO uint8_t OD2; /*!< 0x065 MMD and OD Control Register 2 */ + __IO uint8_t VC1; /*!< 0x066 VCO Control Register 1 */ + __IO uint8_t VC2; /*!< 0x067 VCO Control Register 2 */ + __IO uint8_t VC3; /*!< 0x068 VCO Control Register 3 */ + __IO uint8_t RX1; /*!< 0x069 RX Control Register 1 */ + __IO uint8_t RX2; /*!< 0x06A RX Control Register 2 */ + __IO uint8_t RX3; /*!< 0x06B RX Control Register 3 */ + __IO uint8_t RX4; /*!< 0x06C RX Control Register 4 */ + __IO uint8_t RX5; /*!< 0x06D RX Control Register 5 */ + __IO uint8_t TX1; /*!< 0x06E TX Control Register 1 */ + __IO uint8_t TX2; /*!< 0x06F TX Control Register 2 */ + __IO uint8_t TX3; /*!< 0x070 TX Control Register 3 */ + __IO uint8_t CA1; /*!< 0x071 VCO DFC Calibration Control Register 1 */ + __IO uint8_t CA2; /*!< 0x072 VCO DFC Calibration Control Register 2 */ + __IO uint8_t CA3; /*!< 0x073 VCO DFC Calibration Control Register 3 */ + __IO uint8_t LD1; /*!< 0x074 LDO Control Register 1 */ + __IO uint8_t LD2; /*!< 0x075 LDO Control Register 2 */ + __IO uint8_t LD3; /*!< 0x076 LDO Control Register 3 */ + __IO uint8_t RTM1; /*!< 0x077 RF Test Mode Control Register 1 */ + uint8_t RESERVED5[8]; /*!< 0x078 - 0x07F Reserved */ + __IO uint8_t TEST1; /*!< 0x080 Test Control Register 1 */ + __IO uint8_t TEST2; /*!< 0x081 Test Control Register 2 */ + __IO uint8_t TEST3; /*!< 0x082 Test Control Register 3 */ + __IO uint8_t TEST4; /*!< 0x083 Test Control Register 4 */ + __IO uint8_t TEST5; /*!< 0x084 Test Control Register 5 */ + __IO uint8_t TEST6; /*!< 0x085 Test Control Register 6 */ + __IO uint8_t TEST7; /*!< 0x086 Test Control Register 7 */ +} HT_RF_TypeDef; +/** + * @} + */ + +/** @addtogroup Peripheral_Memory_Map + * @{ + */ + +#define HT_SRAM_BASE (0x20000000UL) + +#define HT_PERIPH_BASE (0x40000000UL) + +#define HT_APBPERIPH_BASE (HT_PERIPH_BASE) /* 0x40000000 */ +#define HT_AHBPERIPH_BASE (HT_PERIPH_BASE + 0x80000) /* 0x40080000 */ + +/* APB */ +#define HT_USART0_BASE (HT_APBPERIPH_BASE + 0x0000) /* 0x40000000 */ +#define HT_UART0_BASE (HT_APBPERIPH_BASE + 0x1000) /* 0x40001000 */ +#define HT_UART2_BASE (HT_APBPERIPH_BASE + 0x2000) /* 0x40002000 */ +#define HT_SPI0_BASE (HT_APBPERIPH_BASE + 0x4000) /* 0x40004000 */ +#define HT_I2C2_BASE (HT_APBPERIPH_BASE + 0x8000) /* 0x40008000 */ +#define HT_CAN0_BASE (HT_APBPERIPH_BASE + 0xC000) /* 0x4000C000 */ +#define HT_SLED0_BASE (HT_APBPERIPH_BASE + 0xE000) /* 0x4000E000 */ +#define HT_ADC0_BASE (HT_APBPERIPH_BASE + 0x10000) /* 0x40010000 */ +#define HT_DAC1_BASE (HT_APBPERIPH_BASE + 0x14000) /* 0x40014000 */ +#define HT_OPA0_BASE (HT_APBPERIPH_BASE + 0x18000) /* 0x40018000 */ +#define HT_PGA0_BASE (HT_APBPERIPH_BASE + 0x18000) /* 0x40018000 */ +#define HT_PGA1_BASE (HT_APBPERIPH_BASE + 0x18008) /* 0x40018008 */ +#define HT_PGA2_BASE (HT_APBPERIPH_BASE + 0x18010) /* 0x40018010 */ +#define HT_PGA3_BASE (HT_APBPERIPH_BASE + 0x18018) /* 0x40018018 */ +#define HT_PGA_BASE (HT_APBPERIPH_BASE + 0x18020) /* 0x40018020 */ +#define HT_OPA1_BASE (HT_APBPERIPH_BASE + 0x18100) /* 0x40018100 */ +#define HT_LCD_BASE (HT_APBPERIPH_BASE + 0x1A000) /* 0x4001A000 */ +#define HT_TKEY_BASE (HT_APBPERIPH_BASE + 0x1A000) /* 0x4001A000 */ +#define HT_AFIO_BASE (HT_APBPERIPH_BASE + 0x22000) /* 0x40022000 */ +#define HT_EXTI_BASE (HT_APBPERIPH_BASE + 0x24000) /* 0x40024000 */ +#define HT_I2S_BASE (HT_APBPERIPH_BASE + 0x26000) /* 0x40026000 */ +#define HT_MCTM0_BASE (HT_APBPERIPH_BASE + 0x2C000) /* 0x4002C000 */ +#define HT_PWM0_BASE (HT_APBPERIPH_BASE + 0x31000) /* 0x40031000 */ +#define HT_SCTM0_BASE (HT_APBPERIPH_BASE + 0x34000) /* 0x40034000 */ +#define HT_PWM2_BASE (HT_APBPERIPH_BASE + 0x32000) /* 0x40031000 */ +#define HT_SCTM2_BASE (HT_APBPERIPH_BASE + 0x35000) /* 0x40035000 */ +#define HT_SCI1_BASE (HT_APBPERIPH_BASE + 0x3A000) /* 0x4003A000 */ +#define HT_USART1_BASE (HT_APBPERIPH_BASE + 0x40000) /* 0x40040000 */ +#define HT_UART1_BASE (HT_APBPERIPH_BASE + 0x41000) /* 0x40041000 */ +#define HT_UART3_BASE (HT_APBPERIPH_BASE + 0x42000) /* 0x40042000 */ +#define HT_SCI0_BASE (HT_APBPERIPH_BASE + 0x43000) /* 0x40043000 */ +#define HT_SPI1_BASE (HT_APBPERIPH_BASE + 0x44000) /* 0x40044000 */ +#define HT_I2C0_BASE (HT_APBPERIPH_BASE + 0x48000) /* 0x40048000 */ +#define HT_I2C1_BASE (HT_APBPERIPH_BASE + 0x49000) /* 0x40049000 */ +#define HT_SLED1_BASE (HT_APBPERIPH_BASE + 0x4E000) /* 0x4004E000 */ +#define HT_ADC1_BASE (HT_APBPERIPH_BASE + 0x50000) /* 0x40050000 */ +#define HT_DACDUAL16_BASE (HT_APBPERIPH_BASE + 0x54000) /* 0x40054000 */ +#define HT_DAC0_BASE (HT_APBPERIPH_BASE + 0x54000) /* 0x40054000 */ +#define HT_CMP0_BASE (HT_APBPERIPH_BASE + 0x58000) /* 0x40058000 */ +#define HT_CMP1_BASE (HT_APBPERIPH_BASE + 0x58100) /* 0x40058100 */ +#define HT_CMP2_BASE (HT_APBPERIPH_BASE + 0x58200) /* 0x40058200 */ +#define HT_LEDC_BASE (HT_APBPERIPH_BASE + 0x5A000) /* 0x4005A000 */ +#define HT_MIDI_BASE (HT_APBPERIPH_BASE + 0x60000) /* 0x40060000 */ +#define HT_WDT_BASE (HT_APBPERIPH_BASE + 0x68000) /* 0x40068000 */ +#define HT_RTC_BASE (HT_APBPERIPH_BASE + 0x6A000) /* 0x4006A000 */ +#define HT_PWRCU_BASE (HT_APBPERIPH_BASE + 0x6A100) /* 0x4006A100 */ +#define HT_GPTM0_BASE (HT_APBPERIPH_BASE + 0x6E000) /* 0x4006E000 */ +#define HT_GPTM1_BASE (HT_APBPERIPH_BASE + 0x6F000) /* 0x4006F000 */ +#define HT_PWM1_BASE (HT_APBPERIPH_BASE + 0x71000) /* 0x40071000 */ +#define HT_SCTM1_BASE (HT_APBPERIPH_BASE + 0x74000) /* 0x40074000 */ +#define HT_SCTM3_BASE (HT_APBPERIPH_BASE + 0x75000) /* 0x40075000 */ +#define HT_BFTM0_BASE (HT_APBPERIPH_BASE + 0x76000) /* 0x40076000 */ +#define HT_BFTM1_BASE (HT_APBPERIPH_BASE + 0x77000) /* 0x40077000 */ + +/* AHB */ +#define HT_FLASH_BASE (HT_AHBPERIPH_BASE + 0x0000) /* 0x40080000 */ +#define HT_CKCU_BASE (HT_AHBPERIPH_BASE + 0x8000) /* 0x40088000 */ +#define HT_RSTCU_BASE (HT_AHBPERIPH_BASE + 0x8100) /* 0x40088100 */ +#define HT_CRC_BASE (HT_AHBPERIPH_BASE + 0xA000) /* 0x4008A000 */ +#define HT_PDMA_BASE (HT_AHBPERIPH_BASE + 0x10000) /* 0x40090000 */ +#define HT_EBI_BASE (HT_AHBPERIPH_BASE + 0x18000) /* 0x40098000 */ +#define HT_USB_BASE (HT_AHBPERIPH_BASE + 0x28000) /* 0x400A8000 */ +#define HT_USB_EP0_BASE (HT_USB_BASE + 0x0014) /* 0x400A8014 */ +#define HT_USB_EP1_BASE (HT_USB_BASE + 0x0028) /* 0x400A8028 */ +#define HT_USB_EP2_BASE (HT_USB_BASE + 0x003C) /* 0x400A803C */ +#define HT_USB_EP3_BASE (HT_USB_BASE + 0x0050) /* 0x400A8050 */ +#define HT_USB_EP4_BASE (HT_USB_BASE + 0x0064) /* 0x400A8064 */ +#define HT_USB_EP5_BASE (HT_USB_BASE + 0x0078) /* 0x400A8078 */ +#define HT_USB_EP6_BASE (HT_USB_BASE + 0x008C) /* 0x400A808C */ +#define HT_USB_EP7_BASE (HT_USB_BASE + 0x00A0) /* 0x400A80A0 */ +#define HT_USB_EP8_BASE (HT_USB_BASE + 0x00B4) /* 0x400A80B4 */ +#define HT_USB_EP9_BASE (HT_USB_BASE + 0x00C8) /* 0x400A80C8 */ +#define HT_USB_SRAM_BASE (HT_AHBPERIPH_BASE + 0x2A000) /* 0x400AA000 */ +#define HT_GPIOA_BASE (HT_AHBPERIPH_BASE + 0x30000) /* 0x400B0000 */ +#define HT_GPIOB_BASE (HT_AHBPERIPH_BASE + 0x32000) /* 0x400B2000 */ +#define HT_GPIOC_BASE (HT_AHBPERIPH_BASE + 0x34000) /* 0x400B4000 */ +#define HT_GPIOD_BASE (HT_AHBPERIPH_BASE + 0x36000) /* 0x400B6000 */ +#define HT_GPIOE_BASE (HT_AHBPERIPH_BASE + 0x38000) /* 0x400B8000 */ +#define HT_GPIOF_BASE (HT_AHBPERIPH_BASE + 0x3A000) /* 0x400BA000 */ +#define HT_AES_BASE (HT_AHBPERIPH_BASE + 0x48000) /* 0x400C8000 */ +#define HT_DIV_BASE (HT_AHBPERIPH_BASE + 0x4A000) /* 0x400CA000 */ +#define HT_RF_BASE (HT_AHBPERIPH_BASE + 0x50000) /* 0x400D0000 */ +#define HT_CORDIC_BASE (HT_AHBPERIPH_BASE + 0x5C000) /* 0x400DC000 */ +#define HT_PID_BASE (HT_AHBPERIPH_BASE + 0x5E000) /* 0x400DE000 */ +#define HT_QSPI_BASE (HT_AHBPERIPH_BASE + 0x60000) /* 0x400E0000 */ + +/** + * @} + */ + +/* Peripheral declaration */ +#define HT_FLASH ((HT_FLASH_TypeDef *) HT_FLASH_BASE) +#define HT_CKCU ((HT_CKCU_TypeDef *) HT_CKCU_BASE) +#define HT_PWRCU ((HT_PWRCU_TypeDef *) HT_PWRCU_BASE) +#define HT_RSTCU ((HT_RSTCU_TypeDef *) HT_RSTCU_BASE) +#define HT_AFIO ((HT_AFIO_TypeDef *) HT_AFIO_BASE) +#define HT_EXTI ((HT_EXTI_TypeDef *) HT_EXTI_BASE) +#define HT_GPIOA ((HT_GPIO_TypeDef *) HT_GPIOA_BASE) +#define HT_GPIOB ((HT_GPIO_TypeDef *) HT_GPIOB_BASE) +#define HT_BFTM0 ((HT_BFTM_TypeDef *) HT_BFTM0_BASE) +#define HT_WDT ((HT_WDT_TypeDef *) HT_WDT_BASE) +#define HT_UART0 ((HT_USART_TypeDef *) HT_UART0_BASE) +#define HT_SPI0 ((HT_SPI_TypeDef *) HT_SPI0_BASE) +#define HT_I2C0 ((HT_I2C_TypeDef *) HT_I2C0_BASE) + +#if !defined(USE_HT32F50020_30) && !defined(USE_HT32F52234_44) +#define HT_GPTM0 ((HT_TM_TypeDef *) HT_GPTM0_BASE) +#endif + +#if !defined(USE_HT32F0008) && !defined(USE_HT32F61141) +#define HT_ADC0 ((HT_ADC_TypeDef *) HT_ADC0_BASE) +#endif + +#if !defined(USE_HT32F0008) && !defined(USE_HT32F50220_30) && !defined(USE_HT32F50231_41) && !defined(USE_HT32F57331_41) && !defined(USE_HT32F53231_41) && !defined(USE_HT32F53242_52) && !defined(USE_HT32F50431_41) && !defined(USE_HT32F50442_52) +#define HT_SCTM0 ((HT_TM_TypeDef *) HT_SCTM0_BASE) +#define HT_SCTM1 ((HT_TM_TypeDef *) HT_SCTM1_BASE) +#endif + +#if defined(USE_HT32F52231_41) || defined(USE_HT32F52331_41) || defined(USE_HT32F52243_53) || defined(USE_HT32F0006) || defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F54243_53) || defined(USE_HT32F50020_30) || defined(USE_HT32F67041_51) || defined(USE_HT32F66242) || defined(USE_HT32F66246) +#define HT_SCTM2 ((HT_TM_TypeDef *) HT_SCTM2_BASE) +#endif + +#if defined(USE_HT32F52231_41) || defined(USE_HT32F52331_41) || defined(USE_HT32F52243_53) || defined(USE_HT32F0006) || defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F54243_53) || defined(USE_HT32F67041_51) || defined(USE_HT32F66242) || defined(USE_HT32F66246) +#define HT_SCTM3 ((HT_TM_TypeDef *) HT_SCTM3_BASE) +#endif + +#if !defined(USE_HT32F50220_30) && !defined(USE_HT32F52344_54) && !defined(USE_HT32F50343) && !defined(USE_HT32F61141) && !defined(USE_HT32F61244_45) && !defined(USE_HT32F50020_30) && !defined(USE_HT32F67041_51) +#define HT_USART0 ((HT_USART_TypeDef *) HT_USART0_BASE) +#endif + +#if defined(USE_HT32F52331_41) || defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F61141) +#define HT_SCI0 ((HT_SCI_TypeDef *) HT_SCI0_BASE) +#endif + +#if defined(USE_HT32F52331_41) || defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F0008) || defined(USE_HT32F52344_54) || defined(USE_HT32F0006) || defined(USE_HT32F52357_67) || defined(USE_HT32F57342_52) || defined(USE_HT32F57331_41) || defined(USE_HT32F50343) || defined(USE_HT32F61141) +#define HT_USB ((HT_USB_TypeDef *) HT_USB_BASE) +#define HT_USBEP0 ((HT_USBEP_TypeDef *) HT_USB_EP0_BASE) +#define HT_USBEP1 ((HT_USBEP_TypeDef *) HT_USB_EP1_BASE) +#define HT_USBEP2 ((HT_USBEP_TypeDef *) HT_USB_EP2_BASE) +#define HT_USBEP3 ((HT_USBEP_TypeDef *) HT_USB_EP3_BASE) +#define HT_USBEP4 ((HT_USBEP_TypeDef *) HT_USB_EP4_BASE) +#define HT_USBEP5 ((HT_USBEP_TypeDef *) HT_USB_EP5_BASE) +#define HT_USBEP6 ((HT_USBEP_TypeDef *) HT_USB_EP6_BASE) +#define HT_USBEP7 ((HT_USBEP_TypeDef *) HT_USB_EP7_BASE) +#endif + +#if defined(USE_HT32F52231_41) || defined(USE_HT32F52331_41) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#endif + +#if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_GPTM1 ((HT_TM_TypeDef *) HT_GPTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_SCI1 ((HT_SCI_TypeDef *) HT_SCI1_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#endif + +#if defined(USE_HT32F52243_53) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_UART2 ((HT_USART_TypeDef *) HT_UART2_BASE) +#define HT_UART3 ((HT_USART_TypeDef *) HT_UART3_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_I2C2 ((HT_I2C_TypeDef *) HT_I2C2_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#endif + +#if defined(USE_HT32F0008) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_AES ((HT_AES_TypeDef *) HT_AES_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOF ((HT_GPIO_TypeDef *) HT_GPIOF_BASE) +#endif + +#if defined(USE_HT32F50220_30) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#endif + +#if defined(USE_HT32F50231_41) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#endif + +#if defined(USE_HT32F52344_54) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#endif + +#if defined(USE_HT32F0006) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_QSPI ((HT_SPI_TypeDef *) HT_QSPI_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_DACDUAL16 ((HT_DAC_DUAL16_TypeDef *) HT_DACDUAL16_BASE) +#define HT_MIDI ((HT_MIDI_TypeDef *) HT_MIDI_BASE) +#endif + +#if defined(USE_HT32F52357_67) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_DAC0 ((HT_DAC_TypeDef *) HT_DAC0_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_SCI1 ((HT_SCI_TypeDef *) HT_SCI1_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_UART2 ((HT_USART_TypeDef *) HT_UART2_BASE) +#define HT_UART3 ((HT_USART_TypeDef *) HT_UART3_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_QSPI ((HT_SPI_TypeDef *) HT_QSPI_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_AES ((HT_AES_TypeDef *) HT_AES_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_GPIOE ((HT_GPIO_TypeDef *) HT_GPIOE_BASE) +#endif + +#if defined(USE_HT32F57342_52) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_DAC0 ((HT_DAC_TypeDef *) HT_DAC0_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_SCI1 ((HT_SCI_TypeDef *) HT_SCI1_BASE) +#define HT_I2S ((HT_I2S_TypeDef *) HT_I2S_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_AES ((HT_AES_TypeDef *) HT_AES_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_GPIOE ((HT_GPIO_TypeDef *) HT_GPIOE_BASE) +#define HT_LCD ((HT_LCD_TypeDef *) HT_LCD_BASE) +#endif + +#if defined(USE_HT32F57331_41) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_LCD ((HT_LCD_TypeDef *) HT_LCD_BASE) +#endif + +#if defined(USE_HT32F65230_40) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_ADC1 ((HT_ADC_TypeDef *) HT_ADC1_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_CMP2 ((HT_CMP_TypeDef *) HT_CMP2_BASE) +#define HT_OPA0 ((HT_OPA_TypeDef *) HT_OPA0_BASE) +#define HT_OPA1 ((HT_OPA_TypeDef *) HT_OPA1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#endif + +#if defined(USE_HT32F65232) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_OPA0 ((HT_OPA_TypeDef *) HT_OPA0_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#endif + +#if defined(USE_HT32F50343) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_PWM2 ((HT_TM_TypeDef *) HT_PWM2_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_SLED0 ((HT_SLED_TypeDef *) HT_SLED0_BASE) +#define HT_SLED1 ((HT_SLED_TypeDef *) HT_SLED1_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#endif + +#if defined(USE_HT32F54231_41) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_TKEY ((HT_TKEY_TypeDef *) HT_TKEY_BASE) +#define HT_LEDC ((HT_LEDC_TypeDef *) HT_LEDC_BASE) +#endif + +#if defined(USE_HT32F54243_53) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_UART2 ((HT_USART_TypeDef *) HT_UART2_BASE) +#define HT_UART3 ((HT_USART_TypeDef *) HT_UART3_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_I2C2 ((HT_I2C_TypeDef *) HT_I2C2_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_TKEY ((HT_TKEY_TypeDef *) HT_TKEY_BASE) +#define HT_LEDC ((HT_LEDC_TypeDef *) HT_LEDC_BASE) +#endif + +#if defined(USE_HT32F61141) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SCI1 ((HT_SCI_TypeDef *) HT_SCI1_BASE) +#define HT_USBEP8 ((HT_USBEP_TypeDef *) HT_USB_EP8_BASE) +#define HT_USBEP9 ((HT_USBEP_TypeDef *) HT_USB_EP9_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#endif + +#if defined(USE_HT32F61244_45) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_LSTM0 ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#define HT_QSPI ((HT_SPI_TypeDef *) HT_QSPI_BASE) +#define HT_DACDUAL16 ((HT_DAC_DUAL16_TypeDef *) HT_DACDUAL16_BASE) +#define HT_MIDI ((HT_MIDI_TypeDef *) HT_MIDI_BASE) + +#define HT_RTC HT_LSTM0 +#endif + +#if defined(USE_HT32F50020_30) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOF ((HT_GPIO_TypeDef *) HT_GPIOF_BASE) +#define HT_LEDC ((HT_LEDC_TypeDef *) HT_LEDC_BASE) +#endif + +#if defined(USE_HT32F67041_51) +#define HT_AES ((HT_AES_TypeDef *) HT_AES_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_RF ((HT_RF_TypeDef *) HT_RF_BASE) +#endif + +#if defined(USE_HT32F50442_52) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_LEDC ((HT_LEDC_TypeDef *) HT_LEDC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#endif + +#if defined(USE_HT32F50431_41) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_LEDC ((HT_LEDC_TypeDef *) HT_LEDC_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#endif + +#if defined(USE_HT32F53242_52) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_PWM1 ((HT_TM_TypeDef *) HT_PWM1_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_EBI ((HT_EBI_TypeDef *) HT_EBI_BASE) +#define HT_USART1 ((HT_USART_TypeDef *) HT_USART1_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_LEDC ((HT_LEDC_TypeDef *) HT_LEDC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_CAN0 ((HT_CAN_TypeDef *) HT_CAN0_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#endif + +#if defined(USE_HT32F53231_41) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_UART1 ((HT_USART_TypeDef *) HT_UART1_BASE) +#define HT_SPI1 ((HT_SPI_TypeDef *) HT_SPI1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_LEDC ((HT_LEDC_TypeDef *) HT_LEDC_BASE) +#define HT_CAN0 ((HT_CAN_TypeDef *) HT_CAN0_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_GPIOD ((HT_GPIO_TypeDef *) HT_GPIOD_BASE) +#endif + +#if defined(USE_HT32F66242) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_PGA0 ((HT_PGA0_X_TypeDef *) HT_PGA0_BASE) +#define HT_PGA1 ((HT_PGA0_X_TypeDef *) HT_PGA1_BASE) +#define HT_PGA2 ((HT_PGA0_X_TypeDef *) HT_PGA2_BASE) +#define HT_PGA3 ((HT_PGA0_X_TypeDef *) HT_PGA3_BASE) +#define HT_PGA ((HT_PGA_TypeDef *) HT_PGA_BASE) +#define HT_PID ((HT_LCD_TypeDef *) HT_LCD_BASE) +#define HT_CORDIC ((HT_CORDIC_TypeDef *) HT_CORDIC_BASE) +#define HT_LSTM0 ((HT_RTC_TypeDef *) HT_RTC_BASE) + +#define HT_RTC HT_LSTM0 +#endif + +#if defined(USE_HT32F66246) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_CMP0 ((HT_CMP_TypeDef *) HT_CMP0_BASE) +#define HT_CMP1 ((HT_CMP_TypeDef *) HT_CMP1_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_MCTM0 ((HT_TM_TypeDef *) HT_MCTM0_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#define HT_CAN0 ((HT_CAN_TypeDef *) HT_CAN0_BASE) +#define HT_PGA0 ((HT_PGA0_X_TypeDef *) HT_PGA0_BASE) +#define HT_PGA1 ((HT_PGA0_X_TypeDef *) HT_PGA1_BASE) +#define HT_PGA2 ((HT_PGA0_X_TypeDef *) HT_PGA2_BASE) +#define HT_PGA3 ((HT_PGA0_X_TypeDef *) HT_PGA3_BASE) +#define HT_PGA ((HT_PGA_TypeDef *) HT_PGA_BASE) +#define HT_PID ((HT_LCD_TypeDef *) HT_LCD_BASE) +#define HT_CORDIC ((HT_CORDIC_TypeDef *) HT_CORDIC_BASE) +#define HT_LSTM0 ((HT_RTC_TypeDef *) HT_RTC_BASE) + +#define HT_RTC HT_LSTM0 +#endif + +#if defined(USE_HT32F52234_44) +#define HT_PDMA ((HT_PDMA_TypeDef *) HT_PDMA_BASE) +#define HT_BFTM1 ((HT_BFTM_TypeDef *) HT_BFTM1_BASE) +#define HT_PWM0 ((HT_TM_TypeDef *) HT_PWM0_BASE) +#define HT_DAC0 ((HT_DAC_TypeDef *) HT_DAC0_BASE) +#define HT_DAC1 ((HT_DAC_TypeDef *) HT_DAC1_BASE) +#define HT_I2C1 ((HT_I2C_TypeDef *) HT_I2C1_BASE) +#define HT_I2C2 ((HT_I2C_TypeDef *) HT_I2C2_BASE) +#define HT_RTC ((HT_RTC_TypeDef *) HT_RTC_BASE) +#define HT_CRC ((HT_CRC_TypeDef *) HT_CRC_BASE) +#define HT_DIV ((HT_DIV_TypeDef *) HT_DIV_BASE) +#define HT_GPIOC ((HT_GPIO_TypeDef *) HT_GPIOC_BASE) +#endif + +#if defined USE_HT32_DRIVER + #include "ht32f5xxxx_lib.h" +#endif + +/** + * @brief Adjust the value of High Speed External oscillator (HSE) + Tip: To avoid from modifying every time for different HSE, please define + the "HSE_VALUE=n000000" ("n" represents n MHz) in your own toolchain compiler preprocessor, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + */ +#if !defined HSE_VALUE + #if defined(USE_HT32F50220_30) || defined(USE_HT32F50231_41) + /* Available HSE_VALUE: 4 MHz ~ 20 MHz */ + #define HSE_VALUE 20000000UL /*!< Value of the External oscillator in Hz */ + #elif defined(USE_HT32F50020_30) + /* Available HSE_VALUE: 4 MHz ~ 16 MHz */ + #define HSE_VALUE 16000000UL /*!< Value of the External oscillator in Hz */ + #elif defined(USE_HT32F0006) + /* Available HSE_VALUE: 4 MHz ~ 16 MHz */ + #define HSE_VALUE 12000000UL /*!< Value of the External oscillator in Hz */ + #elif defined(USE_HT32F61244_45) + /* Available HSE_VALUE: 4 MHz ~ 16 MHz */ + #define HSE_VALUE 12000000UL /*!< Value of the External oscillator in Hz */ + #elif defined(USE_HT32F67041_51) + /* Available HSE_VALUE: 16 MHz */ + #define HSE_VALUE 16000000UL /*!< Value of the External oscillator in Hz */ + #else + /* Available HSE_VALUE: 4 MHz ~ 16 MHz */ + #define HSE_VALUE 8000000UL /*!< Value of the External oscillator in Hz */ + #endif +#endif + +/** + * @brief Define for backward compatibility + */ +#define HT_ADC HT_ADC0 +#define ADC ADC0 +#define ADC_IRQn ADC0_IRQn + +#define HT_DAC HT_DAC0 +#define AFIO_FUN_DAC AFIO_FUN_DAC0 +#define CKCU_PCLK_DAC CKCU_PCLK_DAC0 + +#if defined(USE_HT32F52357_67) + #define UART0_IRQn UART0_UART2_IRQn + #define UART2_IRQn UART0_UART2_IRQn + #define UART1_IRQn UART1_UART3_IRQn + #define UART3_IRQn UART1_UART3_IRQn +#endif + +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) + // Alias + #define GPTM0_IRQn GPTM0_G_IRQn + #define GPTM0_IRQHandler GPTM0_G_IRQHandler + #define MCTM0_IRQn MCTM0_UP_IRQn + #define MCTM0_IRQHandler MCTM0_G_IRQHandler + #define MCTM1_IRQn MCTM1_UP_IRQn + #define MCTM1_IRQHandler MCTM1_G_IRQHandler +#endif + +#define AFIO_ESS_Enum u32 + +#if 0 // Set as 1 for backward compatibility +#if defined(USE_HT32F50020_30) +#define EXTI8_IRQn EXTI0_1_IRQn +#define EXTI9_IRQn EXTI0_1_IRQn +#define EXTI10_IRQn EXTI2_3_IRQn +#define EXTI11_IRQn EXTI2_3_IRQn +#define EXTI12_IRQn EXTI4_7_IRQn +#define EXTI13_IRQn EXTI4_7_IRQn +#define EXTI14_IRQn EXTI4_7_IRQn +#define EXTI15_IRQn EXTI4_7_IRQn + +#define EXTI_CHANNEL_8 EXTI_CHANNEL_0 +#define EXTI_CHANNEL_9 EXTI_CHANNEL_1 +#define EXTI_CHANNEL_10 EXTI_CHANNEL_2 +#define EXTI_CHANNEL_11 EXTI_CHANNEL_3 +#define EXTI_CHANNEL_12 EXTI_CHANNEL_4 +#define EXTI_CHANNEL_13 EXTI_CHANNEL_5 +#define EXTI_CHANNEL_14 EXTI_CHANNEL_6 +#define EXTI_CHANNEL_15 EXTI_CHANNEL_7 +#endif +#endif + +#if (LIBCFG_SPI_NO_MULTI_MASTER) +#define SPI_SELOutputCmd(...) +#endif + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f0006.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f0006.h new file mode 100644 index 0000000000..388963ffe1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f0006.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f0006.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F0006 Device + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F0006_H +#define __SYSTEM_HT32F0006_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F0006_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F0006_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5826.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5826.h new file mode 100644 index 0000000000..a1f54a57ca --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5826.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5826.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5826_H +#define __SYSTEM_HT32F5826_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_01.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_01.h new file mode 100644 index 0000000000..bf83db5162 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_01.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_01.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_01_H +#define __SYSTEM_HT32F5XXXX_01_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_02.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_02.h new file mode 100644 index 0000000000..cffecbeac6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_02.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_02.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_02_H +#define __SYSTEM_HT32F5XXXX_02_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_03.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_03.h new file mode 100644 index 0000000000..35c215726d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_03.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_03.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_03_H +#define __SYSTEM_HT32F5XXXX_03_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_04.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_04.h new file mode 100644 index 0000000000..7ddd2dc9d9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_04.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_04.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_04_H +#define __SYSTEM_HT32F5XXXX_04_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_05.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_05.h new file mode 100644 index 0000000000..c0ead9e7d5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_05.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_05.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_05_H +#define __SYSTEM_HT32F5XXXX_05_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_06.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_06.h new file mode 100644 index 0000000000..e8600c85bb --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_06.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_06.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_06_H +#define __SYSTEM_HT32F5XXXX_06_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_07.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_07.h new file mode 100644 index 0000000000..30a451c6c1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_07.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_07.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_07_H +#define __SYSTEM_HT32F5XXXX_07_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_08.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_08.h new file mode 100644 index 0000000000..5f982d45b9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_08.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_08.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_08_H +#define __SYSTEM_HT32F5XXXX_08_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_09.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_09.h new file mode 100644 index 0000000000..85528c095c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_09.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_09.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_09_H +#define __SYSTEM_HT32F5XXXX_09_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_10.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_10.h new file mode 100644 index 0000000000..8ae7e67c9e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_10.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_10.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_10_H +#define __SYSTEM_HT32F5XXXX_10_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_11.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_11.h new file mode 100644 index 0000000000..c9a7e04c33 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_11.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_11.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_11_H +#define __SYSTEM_HT32F5XXXX_11_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_12.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_12.h new file mode 100644 index 0000000000..0f4983569e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_12.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_12.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_12_H +#define __SYSTEM_HT32F5XXXX_12_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_13.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_13.h new file mode 100644 index 0000000000..8176285eea --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_13.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_13.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_13_H +#define __SYSTEM_HT32F5XXXX_13_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_14.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_14.h new file mode 100644 index 0000000000..042adba38d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_14.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_14.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_14_H +#define __SYSTEM_HT32F5XXXX_14_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_15.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_15.h new file mode 100644 index 0000000000..f6d6fc1787 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_15.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_15.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_15_H +#define __SYSTEM_HT32F5XXXX_15_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_16.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_16.h new file mode 100644 index 0000000000..ca845b0ea3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_16.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_16.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_16_H +#define __SYSTEM_HT32F5XXXX_16_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_17.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_17.h new file mode 100644 index 0000000000..ecf72bd705 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_17.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_17.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 1725 $ + * @date $Date:: 2017-08-24 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_17_H +#define __SYSTEM_HT32F5XXXX_17_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_18.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_18.h new file mode 100644 index 0000000000..73ba94f18a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Include/system_ht32f5xxxx_18.h @@ -0,0 +1,74 @@ +/**************************************************************************//** + * @file system_ht32f5xxxx_18.h + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 7408 $ + * @date $Date:: 2023-12-14 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for use with Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system + * @{ + */ + + +#ifndef __SYSTEM_HT32F5XXXX_18_H +#define __SYSTEM_HT32F5XXXX_18_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_System_Exported_types + * @{ + */ +extern __IO uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + * @} + */ + + +/** @addtogroup HT32F5xxxx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_hf5032.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_hf5032.s new file mode 100644 index 0000000000..a86606d966 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_hf5032.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 7 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0006.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0006.s new file mode 100644 index 0000000000..e0b5ba76e2 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0006.s @@ -0,0 +1,304 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_07.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +USE_HT32_CHIP_SET EQU 10 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00061355 +;_HT32FWID EQU 0x00061356 +;_HT32FWID EQU 0x00061357 + +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT32F61355_56_57 EQU 17 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0008.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0008.s new file mode 100644 index 0000000000..db72cb363f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f0008.s @@ -0,0 +1,403 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_03.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +USE_HT32_CHIP_SET EQU 6 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052142 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00052357 +;_HT32FWID EQU 0x00052367 +;_HT32FWID EQU 0x0003200F + +HT32F0008 EQU 6 +HT32F52142 EQU 6 +HT32F52344_54 EQU 9 +HT32F52357_67 EQU 11 +HT50F3200T EQU 11 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD AES_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD QSPI_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52357_67) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_UART2_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_UART3_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD SCI_IRQHandler ; 27, 43, 0xAC, + ELSE + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART0_UART2_IRQHandler [WEAK] + EXPORT UART1_UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART0_UART2_IRQHandler +UART1_UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50020_30.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50020_30.s new file mode 100644 index 0000000000..45853e20f1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50020_30.s @@ -0,0 +1,235 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +USE_HT32_CHIP_SET EQU 25 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050020 +;_HT32FWID EQU 0x00050030 +;_HT32FWID EQU 0x00061630 +;_HT32FWID EQU 0x00061030 + +HT32F50020_30 EQU 25 +HT32F61630 EQU 25 +HT32F61030 EQU 25 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-2048:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-2048:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_7_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD _RESERVED ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_7_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_7_IRQHandler +ADC_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +BFTM0_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50220_30.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50220_30.s new file mode 100644 index 0000000000..a86606d966 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50220_30.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 7 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50231_41.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50231_41.s new file mode 100644 index 0000000000..8e68952909 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50231_41.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 8 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50343.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50343.s new file mode 100644 index 0000000000..1a58d66e73 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50343.s @@ -0,0 +1,298 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_06.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50343 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <15=> HT32F50343 +USE_HT32_CHIP_SET EQU 15 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050343 + +HT32F50343 EQU 15 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-12288:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-12288:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD PWM2_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SLED0_IRQHandler ; 27, 43, 0x0AC, + DCD SLED1_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT PWM2_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SLED0_IRQHandler [WEAK] + EXPORT SLED1_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +PWM2_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SLED0_IRQHandler +SLED1_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50431_41.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50431_41.s new file mode 100644 index 0000000000..be3f3ca0f7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50431_41.s @@ -0,0 +1,264 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_14.s +; Version : $Rev:: 6793 $ +; Date : $Date:: 2023-03-14 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50442, HT32F50452 +; HT32F50431, HT32F50441 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <26=> HT32F50442/52 +;// <30=> HT32F50431/41 +USE_HT32_CHIP_SET EQU 30 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050442 +;_HT32FWID EQU 0x00050452 +;_HT32FWID EQU 0x00050431 +;_HT32FWID EQU 0x00050441 + +HT32F50442_52 EQU 26 +HT32F50431_41 EQU 30 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50442_52.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50442_52.s new file mode 100644 index 0000000000..214cdf9e32 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f50442_52.s @@ -0,0 +1,264 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_14.s +; Version : $Rev:: 6793 $ +; Date : $Date:: 2023-03-14 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50442, HT32F50452 +; HT32F50431, HT32F50441 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <26=> HT32F50442/52 +;// <30=> HT32F50431/41 +USE_HT32_CHIP_SET EQU 26 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050442 +;_HT32FWID EQU 0x00050452 +;_HT32FWID EQU 0x00050431 +;_HT32FWID EQU 0x00050441 + +HT32F50442_52 EQU 26 +HT32F50431_41 EQU 30 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52142.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52142.s new file mode 100644 index 0000000000..db72cb363f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52142.s @@ -0,0 +1,403 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_03.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +USE_HT32_CHIP_SET EQU 6 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052142 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00052357 +;_HT32FWID EQU 0x00052367 +;_HT32FWID EQU 0x0003200F + +HT32F0008 EQU 6 +HT32F52142 EQU 6 +HT32F52344_54 EQU 9 +HT32F52357_67 EQU 11 +HT50F3200T EQU 11 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD AES_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD QSPI_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52357_67) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_UART2_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_UART3_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD SCI_IRQHandler ; 27, 43, 0xAC, + ELSE + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART0_UART2_IRQHandler [WEAK] + EXPORT UART1_UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART0_UART2_IRQHandler +UART1_UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52220_30.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52220_30.s new file mode 100644 index 0000000000..ae562b2a89 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52220_30.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 1 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52231_41.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52231_41.s new file mode 100644 index 0000000000..c653285b1f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52231_41.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 2 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52234_44.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52234_44.s new file mode 100644 index 0000000000..9f80e3bd0e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52234_44.s @@ -0,0 +1,239 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_17.s +; Version : $Rev:: 7027 $ +; Date : $Date:: 2023-07-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52234, HT32F52244 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <33=> HT32F52234/44 +USE_HT32_CHIP_SET EQU 33 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052234 +;_HT32FWID EQU 0x00052244 + +HT32F52234_44 EQU 33 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD DAC0_1_IRQHandler ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD I2C2_IRQHandler ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT DAC0_1_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +DAC0_1_IRQHandler +ADC_IRQHandler +I2C2_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52243_53.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52243_53.s new file mode 100644 index 0000000000..e9b3a2c194 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52243_53.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 5 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52331_41.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52331_41.s new file mode 100644 index 0000000000..8cd61fd13a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52331_41.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 3 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52342_52.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52342_52.s new file mode 100644 index 0000000000..2285fed9c8 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52342_52.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 4 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52344_54.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52344_54.s new file mode 100644 index 0000000000..e745eaa803 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52344_54.s @@ -0,0 +1,403 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_03.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +USE_HT32_CHIP_SET EQU 9 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052142 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00052357 +;_HT32FWID EQU 0x00052367 +;_HT32FWID EQU 0x0003200F + +HT32F0008 EQU 6 +HT32F52142 EQU 6 +HT32F52344_54 EQU 9 +HT32F52357_67 EQU 11 +HT50F3200T EQU 11 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD AES_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD QSPI_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52357_67) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_UART2_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_UART3_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD SCI_IRQHandler ; 27, 43, 0xAC, + ELSE + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART0_UART2_IRQHandler [WEAK] + EXPORT UART1_UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART0_UART2_IRQHandler +UART1_UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52357_67.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52357_67.s new file mode 100644 index 0000000000..4533138d12 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f52357_67.s @@ -0,0 +1,403 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_03.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +USE_HT32_CHIP_SET EQU 11 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052142 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00052357 +;_HT32FWID EQU 0x00052367 +;_HT32FWID EQU 0x0003200F + +HT32F0008 EQU 6 +HT32F52142 EQU 6 +HT32F52344_54 EQU 9 +HT32F52357_67 EQU 11 +HT50F3200T EQU 11 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD AES_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD QSPI_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52357_67) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_UART2_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_UART3_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD SCI_IRQHandler ; 27, 43, 0xAC, + ELSE + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART0_UART2_IRQHandler [WEAK] + EXPORT UART1_UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART0_UART2_IRQHandler +UART1_UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53231_41.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53231_41.s new file mode 100644 index 0000000000..e1bc80febe --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53231_41.s @@ -0,0 +1,266 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_15.s +; Version : $Rev:: 6874 $ +; Date : $Date:: 2023-05-03 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F53242, HT32F53252 +; HT32F53231, HT32F53241 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <28=> HT32F53242/52 +;// <29=> HT32F53231/41 +USE_HT32_CHIP_SET EQU 29 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00053242 +;_HT32FWID EQU 0x00053252 +;_HT32FWID EQU 0x00053231 +;_HT32FWID EQU 0x00053241 + +HT32F53242_52 EQU 28 +HT32F53231_41 EQU 29 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD CAN0_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT CAN0_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +CAN0_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53242_52.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53242_52.s new file mode 100644 index 0000000000..f4dbd9cf62 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f53242_52.s @@ -0,0 +1,266 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_15.s +; Version : $Rev:: 6874 $ +; Date : $Date:: 2023-05-03 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F53242, HT32F53252 +; HT32F53231, HT32F53241 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <28=> HT32F53242/52 +;// <29=> HT32F53231/41 +USE_HT32_CHIP_SET EQU 28 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00053242 +;_HT32FWID EQU 0x00053252 +;_HT32FWID EQU 0x00053231 +;_HT32FWID EQU 0x00053241 + +HT32F53242_52 EQU 28 +HT32F53231_41 EQU 29 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD CAN0_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT CAN0_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +CAN0_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54231_41.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54231_41.s new file mode 100644 index 0000000000..5db17956e7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54231_41.s @@ -0,0 +1,343 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_09.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F54231, HT32F54241 +; HT32F54243, HT32F54253 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <19=> HT32F54231/41 +;// <20=> HT32F54243/53 +USE_HT32_CHIP_SET EQU 19 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00054231 +;_HT32FWID EQU 0x00054241 +;_HT32FWID EQU 0x00054243 +;_HT32FWID EQU 0x00054253 + +HT32F54231_41 EQU 19 +HT32F54243_53 EQU 20 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD TKEY_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F54243_53) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT TKEY_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +I2C2_IRQHandler +MCTM0_IRQHandler +TKEY_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54243_53.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54243_53.s new file mode 100644 index 0000000000..657d0d6523 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f54243_53.s @@ -0,0 +1,343 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_09.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F54231, HT32F54241 +; HT32F54243, HT32F54253 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <19=> HT32F54231/41 +;// <20=> HT32F54243/53 +USE_HT32_CHIP_SET EQU 20 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00054231 +;_HT32FWID EQU 0x00054241 +;_HT32FWID EQU 0x00054243 +;_HT32FWID EQU 0x00054253 + +HT32F54231_41 EQU 19 +HT32F54243_53 EQU 20 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD TKEY_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F54243_53) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT TKEY_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +I2C2_IRQHandler +MCTM0_IRQHandler +TKEY_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57331_41.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57331_41.s new file mode 100644 index 0000000000..cbaf7f3ee1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57331_41.s @@ -0,0 +1,350 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 13 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57342_52.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57342_52.s new file mode 100644 index 0000000000..b1d916864c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f57342_52.s @@ -0,0 +1,350 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 14 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5826.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5826.s new file mode 100644 index 0000000000..eba919c13e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5826.s @@ -0,0 +1,311 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5826.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F5826 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F5826 +USE_HT32_CHIP_SET EQU 1 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00005826 + +HT32F5826 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD COMP_IRQHandler ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5828.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5828.s new file mode 100644 index 0000000000..b1d916864c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5828.s @@ -0,0 +1,350 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 14 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59041.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59041.s new file mode 100644 index 0000000000..8e68952909 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59041.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 8 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59046.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59046.s new file mode 100644 index 0000000000..8e68952909 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59046.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 8 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59741.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59741.s new file mode 100644 index 0000000000..cbaf7f3ee1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59741.s @@ -0,0 +1,350 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 13 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59746.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59746.s new file mode 100644 index 0000000000..cbaf7f3ee1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f59746.s @@ -0,0 +1,350 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 13 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_01.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_01.s new file mode 100644 index 0000000000..b11048b5e0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_01.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_02.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_02.s new file mode 100644 index 0000000000..de2009c868 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_02.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_03.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_03.s new file mode 100644 index 0000000000..1ff2f77f4b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_03.s @@ -0,0 +1,403 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_03.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052142 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00052357 +;_HT32FWID EQU 0x00052367 +;_HT32FWID EQU 0x0003200F + +HT32F0008 EQU 6 +HT32F52142 EQU 6 +HT32F52344_54 EQU 9 +HT32F52357_67 EQU 11 +HT50F3200T EQU 11 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD AES_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD QSPI_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52357_67) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_UART2_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_UART3_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD SCI_IRQHandler ; 27, 43, 0xAC, + ELSE + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART0_UART2_IRQHandler [WEAK] + EXPORT UART1_UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART0_UART2_IRQHandler +UART1_UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_05.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_05.s new file mode 100644 index 0000000000..842644ceee --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_05.s @@ -0,0 +1,350 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_06.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_06.s new file mode 100644 index 0000000000..bf17a58ce7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_06.s @@ -0,0 +1,298 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_06.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50343 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <15=> HT32F50343 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050343 + +HT32F50343 EQU 15 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-12288:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-12288:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD PWM2_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SLED0_IRQHandler ; 27, 43, 0x0AC, + DCD SLED1_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT PWM2_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SLED0_IRQHandler [WEAK] + EXPORT SLED1_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +PWM2_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SLED0_IRQHandler +SLED1_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_07.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_07.s new file mode 100644 index 0000000000..10f210c5a2 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_07.s @@ -0,0 +1,304 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_07.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00061355 +;_HT32FWID EQU 0x00061356 +;_HT32FWID EQU 0x00061357 + +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT32F61355_56_57 EQU 17 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_08.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_08.s new file mode 100644 index 0000000000..24cf68758d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_08.s @@ -0,0 +1,278 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_08.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; MXTX6306 +; HT50F3200S + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> MXTX6306 +;// <12=> HT50F3200S +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00065230 +;_HT32FWID EQU 0x00065240 +;_HT32FWID EQU 0x00065232 +;_HT32FWID EQU 0x00006306 +;_HT32FWID EQU 0x0003200F + +HT32F65230_40 EQU 12 +HT32F65232 EQU 18 +MXTX6306 EQU 12 +HT50F3200S EQU 12 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_9_IRQHandler ; 06, 22, 0x058, + DCD EXTI10_15_IRQHandler ; 07, 23, 0x05C, + DCD ADC0_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD ADC1_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD CMP2_IRQHandler ; 20, 36, 0x090, + ELSE + DCD _RESERVED ; 20, 36, 0x090, + ENDIF + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_9_IRQHandler [WEAK] + EXPORT EXTI10_15_IRQHandler [WEAK] + EXPORT ADC0_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT CMP2_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_9_IRQHandler +EXTI10_15_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +CMP2_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_09.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_09.s new file mode 100644 index 0000000000..089c851eb1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_09.s @@ -0,0 +1,343 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_09.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F54231, HT32F54241 +; HT32F54243, HT32F54253 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <19=> HT32F54231/41 +;// <20=> HT32F54243/53 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00054231 +;_HT32FWID EQU 0x00054241 +;_HT32FWID EQU 0x00054243 +;_HT32FWID EQU 0x00054253 + +HT32F54231_41 EQU 19 +HT32F54243_53 EQU 20 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD TKEY_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F54243_53) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT TKEY_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +I2C2_IRQHandler +MCTM0_IRQHandler +TKEY_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_10.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_10.s new file mode 100644 index 0000000000..57fb44e314 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_10.s @@ -0,0 +1,235 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_10.s +; Version : $Rev:: 5783 $ +; Date : $Date:: 2022-03-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F61244, HT32F61245 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <24=> HT32F61244/45 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00061244 +;_HT32FWID EQU 0x00061245 + +HT32F61244_45 EQU 24 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_11.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_11.s new file mode 100644 index 0000000000..784096cf66 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_11.s @@ -0,0 +1,245 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_11.s +; Version : $Rev:: 5991 $ +; Date : $Date:: 2022-06-23 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F67041, HT32F67051 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <22=> HT32F67041/51 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00067041 +;_HT32FWID EQU 0x00067051 + +HT32F67041_51 EQU 22 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD AES_IRQHandler ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD RF_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT RF_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +AES_IRQHandler +RF_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_12.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_12.s new file mode 100644 index 0000000000..45e5c70109 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_12.s @@ -0,0 +1,278 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_12.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F61141 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <23=> HT32F61141 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00061141 + +HT32F61141 EQU 23 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD _RESERVED ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +USB_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_13.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_13.s new file mode 100644 index 0000000000..f03c345a43 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_13.s @@ -0,0 +1,235 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050020 +;_HT32FWID EQU 0x00050030 +;_HT32FWID EQU 0x00061630 +;_HT32FWID EQU 0x00061030 + +HT32F50020_30 EQU 25 +HT32F61630 EQU 25 +HT32F61030 EQU 25 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-2048:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-2048:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_7_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD _RESERVED ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_7_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_7_IRQHandler +ADC_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +BFTM0_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_14.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_14.s new file mode 100644 index 0000000000..a76b5da417 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_14.s @@ -0,0 +1,264 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_14.s +; Version : $Rev:: 6793 $ +; Date : $Date:: 2023-03-14 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50442, HT32F50452 +; HT32F50431, HT32F50441 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <26=> HT32F50442/52 +;// <30=> HT32F50431/41 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050442 +;_HT32FWID EQU 0x00050452 +;_HT32FWID EQU 0x00050431 +;_HT32FWID EQU 0x00050441 + +HT32F50442_52 EQU 26 +HT32F50431_41 EQU 30 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_15.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_15.s new file mode 100644 index 0000000000..e261fa6021 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_15.s @@ -0,0 +1,266 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_15.s +; Version : $Rev:: 6874 $ +; Date : $Date:: 2023-05-03 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F53242, HT32F53252 +; HT32F53231, HT32F53241 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <28=> HT32F53242/52 +;// <29=> HT32F53231/41 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00053242 +;_HT32FWID EQU 0x00053252 +;_HT32FWID EQU 0x00053231 +;_HT32FWID EQU 0x00053241 + +HT32F53242_52 EQU 28 +HT32F53231_41 EQU 29 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD CAN0_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT CAN0_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +CAN0_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_16.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_16.s new file mode 100644 index 0000000000..23328ec7c4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_16.s @@ -0,0 +1,275 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_16.s +; Version : $Rev:: 7092 $ +; Date : $Date:: 2023-08-02 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F66242 +; HT32F66246 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + + + + + + + +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +;_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00066246 + +HT32F66246 EQU 31 +HT32F66242 EQU 33 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + + IF (USE_HT32_CHIP=0) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66246) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66242) +_HT32FWID EQU 0x00066242 + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F66246) + DCD CAN0_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD CORDIC_IRQHandler ; 09, 25, 0x064, + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + DCD PID_IRQHandler ; 20, 36, 0x090, + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT CAN0_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT CORDIC_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT PID_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +CAN0_IRQHandler +ADC_IRQHandler +CORDIC_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +PID_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_17.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_17.s new file mode 100644 index 0000000000..0829021a82 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f5xxxx_17.s @@ -0,0 +1,239 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_17.s +; Version : $Rev:: 7027 $ +; Date : $Date:: 2023-07-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52234, HT32F52244 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <33=> HT32F52234/44 +USE_HT32_CHIP_SET EQU 0 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052234 +;_HT32FWID EQU 0x00052244 + +HT32F52234_44 EQU 33 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD DAC0_1_IRQHandler ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD I2C2_IRQHandler ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT DAC0_1_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +DAC0_1_IRQHandler +ADC_IRQHandler +I2C2_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61030.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61030.s new file mode 100644 index 0000000000..45853e20f1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61030.s @@ -0,0 +1,235 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +USE_HT32_CHIP_SET EQU 25 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050020 +;_HT32FWID EQU 0x00050030 +;_HT32FWID EQU 0x00061630 +;_HT32FWID EQU 0x00061030 + +HT32F50020_30 EQU 25 +HT32F61630 EQU 25 +HT32F61030 EQU 25 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-2048:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-2048:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_7_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD _RESERVED ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_7_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_7_IRQHandler +ADC_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +BFTM0_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61041.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61041.s new file mode 100644 index 0000000000..8e68952909 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61041.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 8 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61141.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61141.s new file mode 100644 index 0000000000..e01651cc14 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61141.s @@ -0,0 +1,278 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_12.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F61141 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <23=> HT32F61141 +USE_HT32_CHIP_SET EQU 23 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00061141 + +HT32F61141 EQU 23 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD _RESERVED ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +USB_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61244_45.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61244_45.s new file mode 100644 index 0000000000..5477d2e255 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61244_45.s @@ -0,0 +1,235 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_10.s +; Version : $Rev:: 5783 $ +; Date : $Date:: 2022-03-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F61244, HT32F61245 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <24=> HT32F61244/45 +USE_HT32_CHIP_SET EQU 24 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00061244 +;_HT32FWID EQU 0x00061245 + +HT32F61244_45 EQU 24 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61352.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61352.s new file mode 100644 index 0000000000..e0b5ba76e2 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61352.s @@ -0,0 +1,304 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_07.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +USE_HT32_CHIP_SET EQU 10 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00061355 +;_HT32FWID EQU 0x00061356 +;_HT32FWID EQU 0x00061357 + +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT32F61355_56_57 EQU 17 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61355_56_57.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61355_56_57.s new file mode 100644 index 0000000000..418bcfd86f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61355_56_57.s @@ -0,0 +1,304 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_07.s +; Version : $Rev:: 5740 $ +; Date : $Date:: 2022-02-17 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +USE_HT32_CHIP_SET EQU 17 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00061355 +;_HT32FWID EQU 0x00061356 +;_HT32FWID EQU 0x00061357 + +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT32F61355_56_57 EQU 17 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61630.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61630.s new file mode 100644 index 0000000000..45853e20f1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61630.s @@ -0,0 +1,235 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +USE_HT32_CHIP_SET EQU 25 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050020 +;_HT32FWID EQU 0x00050030 +;_HT32FWID EQU 0x00061630 +;_HT32FWID EQU 0x00061030 + +HT32F50020_30 EQU 25 +HT32F61630 EQU 25 +HT32F61030 EQU 25 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-2048:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-2048:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_7_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD _RESERVED ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_7_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT LEDC_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_7_IRQHandler +ADC_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +BFTM0_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61641.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61641.s new file mode 100644 index 0000000000..8e68952909 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f61641.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 8 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62030.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62030.s new file mode 100644 index 0000000000..ae562b2a89 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62030.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 1 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62040.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62040.s new file mode 100644 index 0000000000..c653285b1f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62040.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 2 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62050.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62050.s new file mode 100644 index 0000000000..e9b3a2c194 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f62050.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 5 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65230_40.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65230_40.s new file mode 100644 index 0000000000..b986536809 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65230_40.s @@ -0,0 +1,278 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_08.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; MXTX6306 +; HT50F3200S + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> MXTX6306 +;// <12=> HT50F3200S +USE_HT32_CHIP_SET EQU 12 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00065230 +;_HT32FWID EQU 0x00065240 +;_HT32FWID EQU 0x00065232 +;_HT32FWID EQU 0x00006306 +;_HT32FWID EQU 0x0003200F + +HT32F65230_40 EQU 12 +HT32F65232 EQU 18 +MXTX6306 EQU 12 +HT50F3200S EQU 12 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_9_IRQHandler ; 06, 22, 0x058, + DCD EXTI10_15_IRQHandler ; 07, 23, 0x05C, + DCD ADC0_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD ADC1_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD CMP2_IRQHandler ; 20, 36, 0x090, + ELSE + DCD _RESERVED ; 20, 36, 0x090, + ENDIF + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_9_IRQHandler [WEAK] + EXPORT EXTI10_15_IRQHandler [WEAK] + EXPORT ADC0_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT CMP2_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_9_IRQHandler +EXTI10_15_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +CMP2_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65232.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65232.s new file mode 100644 index 0000000000..0ec4ece850 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f65232.s @@ -0,0 +1,278 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_08.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; MXTX6306 +; HT50F3200S + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> MXTX6306 +;// <12=> HT50F3200S +USE_HT32_CHIP_SET EQU 18 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00065230 +;_HT32FWID EQU 0x00065240 +;_HT32FWID EQU 0x00065232 +;_HT32FWID EQU 0x00006306 +;_HT32FWID EQU 0x0003200F + +HT32F65230_40 EQU 12 +HT32F65232 EQU 18 +MXTX6306 EQU 12 +HT50F3200S EQU 12 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_9_IRQHandler ; 06, 22, 0x058, + DCD EXTI10_15_IRQHandler ; 07, 23, 0x05C, + DCD ADC0_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD ADC1_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD CMP2_IRQHandler ; 20, 36, 0x090, + ELSE + DCD _RESERVED ; 20, 36, 0x090, + ENDIF + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_9_IRQHandler [WEAK] + EXPORT EXTI10_15_IRQHandler [WEAK] + EXPORT ADC0_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT CMP2_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_9_IRQHandler +EXTI10_15_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +CMP2_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66242.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66242.s new file mode 100644 index 0000000000..d2f753c115 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66242.s @@ -0,0 +1,275 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_16.s +; Version : $Rev:: 7092 $ +; Date : $Date:: 2023-08-02 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F66242 +; HT32F66246 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + + + + + + + +USE_HT32_CHIP_SET EQU 33 ; Notice that the project's Asm Define has the higher priority. + +;_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00066246 + +HT32F66246 EQU 31 +HT32F66242 EQU 33 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + + IF (USE_HT32_CHIP=0) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66246) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66242) +_HT32FWID EQU 0x00066242 + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F66246) + DCD CAN0_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD CORDIC_IRQHandler ; 09, 25, 0x064, + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + DCD PID_IRQHandler ; 20, 36, 0x090, + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT CAN0_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT CORDIC_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT PID_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +CAN0_IRQHandler +ADC_IRQHandler +CORDIC_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +PID_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66246.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66246.s new file mode 100644 index 0000000000..9a02335cc6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f66246.s @@ -0,0 +1,275 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_16.s +; Version : $Rev:: 7092 $ +; Date : $Date:: 2023-08-02 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F66242 +; HT32F66246 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + + + + + + + +USE_HT32_CHIP_SET EQU 31 ; Notice that the project's Asm Define has the higher priority. + +;_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00066246 + +HT32F66246 EQU 31 +HT32F66242 EQU 33 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + + IF (USE_HT32_CHIP=0) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66246) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66242) +_HT32FWID EQU 0x00066242 + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F66246) + DCD CAN0_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD CORDIC_IRQHandler ; 09, 25, 0x064, + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + DCD PID_IRQHandler ; 20, 36, 0x090, + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT CAN0_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT CORDIC_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT PID_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +CAN0_IRQHandler +ADC_IRQHandler +CORDIC_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +PID_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67041_51.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67041_51.s new file mode 100644 index 0000000000..13c68a18ec --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67041_51.s @@ -0,0 +1,245 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_11.s +; Version : $Rev:: 5991 $ +; Date : $Date:: 2022-06-23 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F67041, HT32F67051 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <22=> HT32F67041/51 +USE_HT32_CHIP_SET EQU 22 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00067041 +;_HT32FWID EQU 0x00067051 + +HT32F67041_51 EQU 22 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD AES_IRQHandler ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD RF_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT RF_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +AES_IRQHandler +RF_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67232.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67232.s new file mode 100644 index 0000000000..ae562b2a89 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67232.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 1 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67233.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67233.s new file mode 100644 index 0000000000..ae562b2a89 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67233.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 1 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67741.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67741.s new file mode 100644 index 0000000000..c653285b1f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67741.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 2 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67742.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67742.s new file mode 100644 index 0000000000..cbaf7f3ee1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht32f67742.s @@ -0,0 +1,350 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 13 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT LCD_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32002.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32002.s new file mode 100644 index 0000000000..a86606d966 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32002.s @@ -0,0 +1,327 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 7 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-4096:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-4096:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32003.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32003.s new file mode 100644 index 0000000000..2285fed9c8 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f32003.s @@ -0,0 +1,482 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 4 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM1_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT MIDI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200s.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200s.s new file mode 100644 index 0000000000..b986536809 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200s.s @@ -0,0 +1,278 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_08.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; MXTX6306 +; HT50F3200S + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> MXTX6306 +;// <12=> HT50F3200S +USE_HT32_CHIP_SET EQU 12 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00065230 +;_HT32FWID EQU 0x00065240 +;_HT32FWID EQU 0x00065232 +;_HT32FWID EQU 0x00006306 +;_HT32FWID EQU 0x0003200F + +HT32F65230_40 EQU 12 +HT32F65232 EQU 18 +MXTX6306 EQU 12 +HT50F3200S EQU 12 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_9_IRQHandler ; 06, 22, 0x058, + DCD EXTI10_15_IRQHandler ; 07, 23, 0x05C, + DCD ADC0_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD ADC1_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD CMP2_IRQHandler ; 20, 36, 0x090, + ELSE + DCD _RESERVED ; 20, 36, 0x090, + ENDIF + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_9_IRQHandler [WEAK] + EXPORT EXTI10_15_IRQHandler [WEAK] + EXPORT ADC0_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT CMP2_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_9_IRQHandler +EXTI10_15_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +CMP2_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200t.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200t.s new file mode 100644 index 0000000000..4533138d12 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_ht50f3200t.s @@ -0,0 +1,403 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_03.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +USE_HT32_CHIP_SET EQU 11 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052142 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00052357 +;_HT32FWID EQU 0x00052367 +;_HT32FWID EQU 0x0003200F + +HT32F0008 EQU 6 +HT32F52142 EQU 6 +HT32F52344_54 EQU 9 +HT32F52357_67 EQU 11 +HT50F3200T EQU 11 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-16384:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-16384:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD AES_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD QSPI_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52357_67) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_UART2_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_UART3_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD SCI_IRQHandler ; 27, 43, 0xAC, + ELSE + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +BootProcess PROC + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_15_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT COMP_DAC_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT MCTM0_IRQHandler [WEAK] + EXPORT GPTM0_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT QSPI_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART0_UART2_IRQHandler [WEAK] + EXPORT UART1_UART3_IRQHandler [WEAK] + EXPORT SCI_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT AES_IRQHandler [WEAK] + EXPORT USB_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_5_IRQHandler [WEAK] + +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART0_UART2_IRQHandler +UART1_UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_mxtx6306.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_mxtx6306.s new file mode 100644 index 0000000000..b986536809 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/ARM/startup_mxtx6306.s @@ -0,0 +1,278 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_08.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; MXTX6306 +; HT50F3200S + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// Select HT32 Device for the assembly setting. +;// Notice that the project's Asm Define has the higher priority. +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> MXTX6306 +;// <12=> HT50F3200S +USE_HT32_CHIP_SET EQU 12 ; Notice that the project's Asm Define has the higher priority. + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00065230 +;_HT32FWID EQU 0x00065240 +;_HT32FWID EQU 0x00065232 +;_HT32FWID EQU 0x00006306 +;_HT32FWID EQU 0x0003200F + +HT32F65230_40 EQU 12 +HT32F65232 EQU 18 +MXTX6306 EQU 12 +HT50F3200S EQU 12 + + IF USE_HT32_CHIP_SET=0 + ; Use project's Asm Define setting (default) + ELSE + IF :DEF:USE_HT32_CHIP + ; Use project's Asm Define setting (higher priority than the "USE_HT32_CHIP_SET") + ELSE + ; Use "USE_HT32_CHIP_SET" in the "startup_ht32xxxxx_xx.s" file +USE_HT32_CHIP EQU USE_HT32_CHIP_SET + ENDIF + ENDIF + +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <0-8192:8> +Stack_Size EQU 512 + + AREA STACK, NOINIT, READWRITE, ALIGN = 3 +__HT_check_sp +Stack_Mem SPACE Stack_Size +__initial_sp + +;// Heap Size (in Bytes) <0-8192:8> +Heap_Size EQU 0 + + AREA HEAP, NOINIT, READWRITE, ALIGN = 3 +__HT_check_heap +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + AREA RESET, CODE, READONLY + EXPORT __Vectors +_RESERVED EQU 0xFFFFFFFF +__Vectors + DCD __initial_sp ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_9_IRQHandler ; 06, 22, 0x058, + DCD EXTI10_15_IRQHandler ; 07, 23, 0x05C, + DCD ADC0_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD ADC1_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD CMP2_IRQHandler ; 20, 36, 0x090, + ELSE + DCD _RESERVED ; 20, 36, 0x090, + ENDIF + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP + +HardFault_Handler PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP + +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP + +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP + +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + EXPORT LVD_BOD_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT EVWUP_IRQHandler [WEAK] + EXPORT EXTI0_1_IRQHandler [WEAK] + EXPORT EXTI2_3_IRQHandler [WEAK] + EXPORT EXTI4_9_IRQHandler [WEAK] + EXPORT EXTI10_15_IRQHandler [WEAK] + EXPORT ADC0_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT MCTM0_BRK_IRQHandler [WEAK] + EXPORT MCTM0_UP_IRQHandler [WEAK] + EXPORT MCTM0_TR_UP2_IRQHandler [WEAK] + EXPORT MCTM0_CC_IRQHandler [WEAK] + EXPORT GPTM0_G_IRQHandler [WEAK] + EXPORT GPTM0_VCLK_IRQHandler [WEAK] + EXPORT BFTM0_IRQHandler [WEAK] + EXPORT BFTM1_IRQHandler [WEAK] + EXPORT CMP0_IRQHandler [WEAK] + EXPORT CMP1_IRQHandler [WEAK] + EXPORT CMP2_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT USART0_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT PDMA_CH0_1_IRQHandler [WEAK] + EXPORT PDMA_CH2_3_IRQHandler [WEAK] + EXPORT PDMA_CH4_5_IRQHandler [WEAK] + EXPORT SCTM0_IRQHandler [WEAK] + EXPORT SCTM1_IRQHandler [WEAK] + EXPORT SCTM2_IRQHandler [WEAK] + EXPORT SCTM3_IRQHandler [WEAK] +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_9_IRQHandler +EXTI10_15_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +CMP2_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __HT_check_heap + EXPORT __HT_check_sp + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_01.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_01.s new file mode 100644 index 0000000000..13adc8cdcc --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_01.s @@ -0,0 +1,461 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00052220 + .equ _HT32FWID, 0x00052230 + .equ _HT32FWID, 0x00052231 + .equ _HT32FWID, 0x00052241 + .equ _HT32FWID, 0x00052331 + .equ _HT32FWID, 0x00052341 + .equ _HT32FWID, 0x00052342 + .equ _HT32FWID, 0x00052352 + .equ _HT32FWID, 0x00052243 + .equ _HT32FWID, 0x00052253 + .equ _HT32FWID, 0x00000008 + .equ _HT32FWID, 0x00052344 + .equ _HT32FWID, 0x00052354 + .equ _HT32FWID, 0x00000006 + .equ _HT32FWID, 0x00061352 + .equ _HT32FWID, 0x00032003 + .equ _HT32FWID, 0x00062030 + .equ _HT32FWID, 0x00062040 + .equ _HT32FWID, 0x00062050 + .equ _HT32FWID, 0x00067741 + .equ _HT32FWID, 0x00067232 + .equ _HT32FWID, 0x00067233 +*/ + + .equ HT32F52220_30, 1 + .equ HT32F52231_41, 2 + .equ HT32F52331_41, 3 + .equ HT32F52342_52, 4 + .equ HT32F52243_53, 5 + .equ HT32F0008, 6 + .equ HT32F52344_54, 9 + .equ HT32F0006, 10 + .equ HT32F61352, 10 + .equ HT50F32003, 4 + .equ HT32F62030, 1 + .equ HT32F62040, 2 + .equ HT32F62050, 5 + .equ HT32F67741, 2 + .equ HT32F67232, 1 + .equ HT32F67233, 1 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .if (USE_HT32_CHIP==HT32F52220_30) + .long _RESERVED /* 01, 17, 0x044, */ + .else + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .endif + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52344_54) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 08, 24, 0x060, */ + .else + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) + .long GPTM1_IRQHandler /* 11, 27, 0x06C, */ + .else + .long _RESERVED /* 11, 27, 0x06C, */ + .endif + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .else + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F52231_41) || (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52243_53) || (USE_HT32_CHIP==HT32F0006) + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .if (USE_HT32_CHIP==HT32F52220_30) + .long _RESERVED /* 18, 34, 0x088, */ + .else + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .endif + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 22, 38, 0x098, */ + .else + .if (USE_HT32_CHIP==HT32F0006) + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .else + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .endif + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52243_53) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 26, 42, 0x0A8, */ + .else + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52342_52) + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long UART2_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0006) + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 27, 43, 0xAC, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F0006) + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long UART3_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long AES_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long _RESERVED /* 29, 45, 0x0B4, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52243_53) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM1_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ I2C2_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART2_IRQHandler + IRQ UART3_IRQHandler + IRQ SCI_IRQHandler + IRQ MIDI_IRQHandler + IRQ I2S_IRQHandler + IRQ AES_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_02.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_02.s new file mode 100644 index 0000000000..1521f84226 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_02.s @@ -0,0 +1,324 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050220 + .equ _HT32FWID, 0x00050230 + .equ _HT32FWID, 0x00050231 + .equ _HT32FWID, 0x00050241 + .equ _HT32FWID, 0x00032002 + .equ _HT32FWID, 0x00059041 + .equ _HT32FWID, 0x000F5032 + .equ _HT32FWID, 0x00061641 + .equ _HT32FWID, 0x00059046 + .equ _HT32FWID, 0x00061041 +*/ + + .equ HT32F50220_30, 7 + .equ HT32F50231_41, 8 + .equ HT50F32002, 7 + .equ HT32F59041, 8 + .equ HF5032, 7 + .equ HT32F61641, 8 + .equ HT32F59046, 8 + .equ HT32F61041, 8 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 18, 34, 0x088, */ + .else + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .endif + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_03.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_03.s new file mode 100644 index 0000000000..1f2906d760 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_03.s @@ -0,0 +1,386 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_03.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00000008 + .equ _HT32FWID, 0x00052142 + .equ _HT32FWID, 0x00052344 + .equ _HT32FWID, 0x00052354 + .equ _HT32FWID, 0x00052357 + .equ _HT32FWID, 0x00052367 + .equ _HT32FWID, 0x0003200F +*/ + + .equ HT32F0008, 6 + .equ HT32F52142, 6 + .equ HT32F52344_54, 9 + .equ HT32F52357_67, 11 + .equ HT50F3200T, 11 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long COMP_DAC_IRQHandler /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 08, 24, 0x060, */ + .else + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long AES_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long QSPI_IRQHandler /* 11, 27, 0x06C, */ + .else + .long _RESERVED /* 11, 27, 0x06C, */ + .endif + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .else + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52357_67) + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 22, 38, 0x098, */ + .else + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .long UART0_UART2_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_UART3_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .else + .long _RESERVED /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long AES_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ COMP_DAC_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART0_UART2_IRQHandler + IRQ UART1_UART3_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ AES_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_05.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_05.s new file mode 100644 index 0000000000..1618d4b1c0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_05.s @@ -0,0 +1,338 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00057331 + .equ _HT32FWID, 0x00057341 + .equ _HT32FWID, 0x00057342 + .equ _HT32FWID, 0x00057352 + .equ _HT32FWID, 0x00059741 + .equ _HT32FWID, 0x00005828 + .equ _HT32FWID, 0x00067742 + .equ _HT32FWID, 0x00059746 +*/ + + .equ HT32F57331_41, 13 + .equ HT32F57342_52, 14 + .equ HT32F59741, 13 + .equ HT32F5828, 14 + .equ HT32F67742, 13 + .equ HT32F59746, 13 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long COMP_DAC_IRQHandler /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long AES_IRQHandler /* 09, 25, 0x064, */ + .endif + .long _RESERVED /* 10, 26, 0x068, */ + .long LCD_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 30, 46, 0x0B8, */ + .long _RESERVED /* 31, 47, 0x0BC, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ COMP_DAC_IRQHandler + IRQ ADC_IRQHandler + IRQ AES_IRQHandler + IRQ LCD_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_06.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_06.s new file mode 100644 index 0000000000..f7788dc217 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_06.s @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_06.s +; Version : $Rev:: 4141 $ +; Date : $Date:: 2019-07-24 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50343 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <15=> HT32F50343 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050343 +*/ + + .equ HT32F50343, 15 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long PWM2_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SLED0_IRQHandler /* 27, 43, 0x0AC, */ + .long SLED1_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ PWM2_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SLED0_IRQHandler + IRQ SLED1_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_07.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_07.s new file mode 100644 index 0000000000..2ecf758757 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_07.s @@ -0,0 +1,296 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_07.s +; Version : $Rev:: 5157 $ +; Date : $Date:: 2021-01-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00000006 + .equ _HT32FWID, 0x00061352 + .equ _HT32FWID, 0x00061355 + .equ _HT32FWID, 0x00061356 + .equ _HT32FWID, 0x00061357 +*/ + + .equ HT32F0006, 10 + .equ HT32F61352, 10 + .equ HT32F61355_56_57, 17 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ MIDI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_08.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_08.s new file mode 100644 index 0000000000..3c0ee31039 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_08.s @@ -0,0 +1,258 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_08.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; HT50F3200S +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> HT50F3200S +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00065230 + .equ _HT32FWID, 0x00065240 + .equ _HT32FWID, 0x00065232 + .equ _HT32FWID, 0x0003200F +*/ + + .equ HT32F65230_40, 12 + .equ HT32F65232, 18 + .equ HT50F3200S, 12 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_9_IRQHandler /* 06, 22, 0x058, */ + .long EXTI10_15_IRQHandler /* 07, 23, 0x05C, */ + .long ADC0_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F65230_40) + .long ADC1_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .long MCTM0_BRK_IRQHandler /* 10, 26, 0x068, */ + .long MCTM0_UP_IRQHandler /* 11, 27, 0x06C, */ + .long MCTM0_TR_UP2_IRQHandler /* 12, 28, 0x070, */ + .long MCTM0_CC_IRQHandler /* 13, 29, 0x074, */ + .long GPTM0_G_IRQHandler /* 14, 30, 0x078, */ + .long GPTM0_VCLK_IRQHandler /* 15, 31, 0x07C, */ + .long BFTM0_IRQHandler /* 16, 32, 0x080, */ + .long BFTM1_IRQHandler /* 17, 33, 0x084, */ + .long CMP0_IRQHandler /* 18, 34, 0x088, */ + .long CMP1_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F65230_40) + .long CMP2_IRQHandler /* 20, 36, 0x090, */ + .else + .long _RESERVED /* 20, 36, 0x090, */ + .endif + .long I2C0_IRQHandler /* 21, 37, 0x094, */ + .long SPI0_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long UART0_IRQHandler /* 24, 40, 0x0A0, */ + .long PDMA_CH0_1_IRQHandler /* 25, 41, 0x0A4, */ + .long PDMA_CH2_3_IRQHandler /* 26, 42, 0x0A8, */ + .long PDMA_CH4_5_IRQHandler /* 27, 43, 0x0AC, */ + .long SCTM0_IRQHandler /* 28, 44, 0x0B0, */ + .long SCTM1_IRQHandler /* 29, 45, 0x0B4, */ + .long SCTM2_IRQHandler /* 30, 46, 0x0B8, */ + .long SCTM3_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_9_IRQHandler + IRQ EXTI10_15_IRQHandler + IRQ ADC0_IRQHandler + IRQ ADC1_IRQHandler + IRQ MCTM0_BRK_IRQHandler + IRQ MCTM0_UP_IRQHandler + IRQ MCTM0_TR_UP2_IRQHandler + IRQ MCTM0_CC_IRQHandler + IRQ GPTM0_G_IRQHandler + IRQ GPTM0_VCLK_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ CMP0_IRQHandler + IRQ CMP1_IRQHandler + IRQ CMP2_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_3_IRQHandler + IRQ PDMA_CH4_5_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_09.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_09.s new file mode 100644 index 0000000000..f30b6881fb --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_09.s @@ -0,0 +1,329 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_09.s +; Version : $Rev:: 6206 $ +; Date : $Date:: 2022-10-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F54231, HT32F54241 +; HT32F54243, HT32F54253 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <19=> HT32F54231/41 +;// <20=> HT32F54243/53 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00054231 + .equ _HT32FWID, 0x00054241 + .equ _HT32FWID, 0x00054243 + .equ _HT32FWID, 0x00054253 +*/ + + .equ HT32F54231_41, 19 + .equ HT32F54243_53, 20 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .endif + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long TKEY_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long UART2_IRQHandler /* 27, 43, 0x0AC, */ + .long UART3_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .if (USE_HT32_CHIP==HT32F54243_53) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ I2C2_IRQHandler + IRQ MCTM0_IRQHandler + IRQ TKEY_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART2_IRQHandler + IRQ UART3_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_10.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_10.s new file mode 100644 index 0000000000..c2fb7bd028 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_10.s @@ -0,0 +1,230 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_10.s +; Version : $Rev:: 6601 $ +; Date : $Date:: 2022-12-27 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F61244, HT32F61245 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <24=> HT32F61244/45 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00061244 + .equ _HT32FWID, 0x00061245 +*/ + + .equ HT32F61244_45, 24 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ QSPI_IRQHandler + IRQ UART0_IRQHandler + IRQ MIDI_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_11.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_11.s new file mode 100644 index 0000000000..465d0db99d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_11.s @@ -0,0 +1,235 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_11.s +; Version : $Rev:: 6206 $ +; Date : $Date:: 2022-10-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F67041, HT32F67051 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <22=> HT32F67041/51 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00067041 + .equ _HT32FWID, 0x00067051 +*/ + + .equ HT32F67041_51, 22 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long AES_IRQHandler /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long RF_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ AES_IRQHandler + IRQ RF_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_12.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_12.s new file mode 100644 index 0000000000..0e1001014c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_12.s @@ -0,0 +1,278 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_12.s +; Version : $Rev:: 6206 $ +; Date : $Date:: 2022-10-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F61141 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <23=> HT32F61141 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00061141 +*/ + + .equ HT32F61141, 23 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long _RESERVED /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSL R1, R1, #4 + LSR R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ USB_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_13.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_13.s new file mode 100644 index 0000000000..649b402684 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_13.s @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050020 + .equ _HT32FWID, 0x00050030 + .equ _HT32FWID, 0x00061630 + .equ _HT32FWID, 0x00061030 +*/ + + .equ HT32F50020_30, 25 + .equ HT32F61630, 25 + .equ HT32F61030, 25 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_7_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long _RESERVED /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long _RESERVED /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_7_IRQHandler + IRQ ADC_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ BFTM0_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ LEDC_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_14.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_14.s new file mode 100644 index 0000000000..335d485622 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_14.s @@ -0,0 +1,254 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_14.s +; Version : $Rev:: 6793 $ +; Date : $Date:: 2023-03-14 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50442, HT32F50452 +; HT32F50431, HT32F50441 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <26=> HT32F50442/52 +;// <30=> HT32F50431/41 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050442 + .equ _HT32FWID, 0x00050452 + .equ _HT32FWID, 0x00050431 + .equ _HT32FWID, 0x00050441 +*/ + + .equ HT32F50442_52, 26 + .equ HT32F50431_41, 30 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .else + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_15.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_15.s new file mode 100644 index 0000000000..304bfbd803 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_15.s @@ -0,0 +1,255 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_15.s +; Version : $Rev:: 6902 $ +; Date : $Date:: 2023-05-08 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F53242, HT32F53252 +; HT32F53231, HT32F53241 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <28=> HT32F53242/52 +;// <29=> HT32F53231/41 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00053242 + .equ _HT32FWID, 0x00053252 + .equ _HT32FWID, 0x00053231 + .equ _HT32FWID, 0x00053241 +*/ + + .equ HT32F53242_52, 28 + .equ HT32F53231_41, 29 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .else + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long CAN0_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ CAN0_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_16.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_16.s new file mode 100644 index 0000000000..01f644a0a3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_16.s @@ -0,0 +1,259 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_16.s +; Version : $Rev:: 7094 $ +; Date : $Date:: 2023-08-02 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F66242 +; HT32F66246 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* + + + + +*/ + .equ USE_HT32_CHIP_SET, 0 + +/* + .equ _HT32FWID, 0xFFFFFFFF + .equ _HT32FWID, 0x00066246 +*/ + + .equ HT32F66246, 31 + .equ HT32F66242, 33 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .if USE_HT32_CHIP == 0 + .equ _HT32FWID, 0x00066246 + .endif + .if USE_HT32_CHIP == HT32F66246 + .equ _HT32FWID, 0x00066246 + .endif + .if USE_HT32_CHIP == HT32F66242 + .equ _HT32FWID, 0x00066242 + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F66246) + .long CAN0_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long CORDIC_IRQHandler /* 09, 25, 0x064, */ + .long MCTM0_BRK_IRQHandler /* 10, 26, 0x068, */ + .long MCTM0_UP_IRQHandler /* 11, 27, 0x06C, */ + .long MCTM0_TR_UP2_IRQHandler /* 12, 28, 0x070, */ + .long MCTM0_CC_IRQHandler /* 13, 29, 0x074, */ + .long GPTM0_G_IRQHandler /* 14, 30, 0x078, */ + .long GPTM0_VCLK_IRQHandler /* 15, 31, 0x07C, */ + .long BFTM0_IRQHandler /* 16, 32, 0x080, */ + .long BFTM1_IRQHandler /* 17, 33, 0x084, */ + .long CMP0_IRQHandler /* 18, 34, 0x088, */ + .long CMP1_IRQHandler /* 19, 35, 0x08C, */ + .long PID_IRQHandler /* 20, 36, 0x090, */ + .long I2C0_IRQHandler /* 21, 37, 0x094, */ + .long SPI0_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long UART0_IRQHandler /* 24, 40, 0x0A0, */ + .long PDMA_CH0_1_IRQHandler /* 25, 41, 0x0A4, */ + .long PDMA_CH2_3_IRQHandler /* 26, 42, 0x0A8, */ + .long PDMA_CH4_5_IRQHandler /* 27, 43, 0x0AC, */ + .long SCTM0_IRQHandler /* 28, 44, 0x0B0, */ + .long SCTM1_IRQHandler /* 29, 45, 0x0B4, */ + .long SCTM2_IRQHandler /* 30, 46, 0x0B8, */ + .long SCTM3_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ CAN0_IRQHandler + IRQ ADC_IRQHandler + IRQ CORDIC_IRQHandler + IRQ MCTM0_BRK_IRQHandler + IRQ MCTM0_UP_IRQHandler + IRQ MCTM0_TR_UP2_IRQHandler + IRQ MCTM0_CC_IRQHandler + IRQ GPTM0_G_IRQHandler + IRQ GPTM0_VCLK_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ CMP0_IRQHandler + IRQ CMP1_IRQHandler + IRQ PID_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_3_IRQHandler + IRQ PDMA_CH4_5_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_17.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_17.s new file mode 100644 index 0000000000..47dac68db7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/CodeSourcery/startup_ht32f5xxxx_cs3_17.s @@ -0,0 +1,233 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_cs3_17.s +; Version : $Rev:: 7030 $ +; Date : $Date:: 2023-07-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F52234, HT32F52244 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <33=> HT32F52234/44 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00052234 + .equ _HT32FWID, 0x00052244 +*/ + + .equ HT32F52234_44, 33 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __cs3_stack_mem + .globl __cs3_stack + .globl __cs3_stack_size + .globl __HT_check_sp +__HT_check_sp: +__cs3_stack_mem: + .if Stack_Size + .space Stack_Size + .endif +__cs3_stack: + .size __cs3_stack_mem, . - __cs3_stack_mem + .set __cs3_stack_size, . - __cs3_stack_mem + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __cs3_heap_start + .globl __cs3_heap_end + .globl __HT_check_heap +__HT_check_heap: +__cs3_heap_start: + .if Heap_Size + .space Heap_Size + .endif +__cs3_heap_end: + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section ".cs3.interrupt_vector" + .globl __cs3_interrupt_vector_cortex_m + .type __cs3_interrupt_vector_cortex_m, %object +__cs3_interrupt_vector_cortex_m: + .long __cs3_stack /* ---, 00, 0x000, Top address of Stack */ + .long __cs3_reset /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long DAC0_1_IRQHandler /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long _RESERVED /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .cs3.reset,"x",%progbits + .thumb_func + .globl __cs3_reset_cortex_m + .type __cs3_reset_cortex_m, %function +__cs3_reset_cortex_m: + .fnstart + LDR R0, =SystemInit + BLX R0 + LDR R0, =_start + BX R0 + .thumb_func + .pool + .cantunwind + .fnend + .size __cs3_reset_cortex_m,.-__cs3_reset_cortex_m + + .section ".text" + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ DAC0_1_IRQHandler + IRQ ADC_IRQHandler + IRQ I2C2_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_01.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_01.s new file mode 100644 index 0000000000..6ef935fb93 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_01.s @@ -0,0 +1,519 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00052220 + .equ _HT32FWID, 0x00052230 + .equ _HT32FWID, 0x00052231 + .equ _HT32FWID, 0x00052241 + .equ _HT32FWID, 0x00052331 + .equ _HT32FWID, 0x00052341 + .equ _HT32FWID, 0x00052342 + .equ _HT32FWID, 0x00052352 + .equ _HT32FWID, 0x00052243 + .equ _HT32FWID, 0x00052253 + .equ _HT32FWID, 0x00000008 + .equ _HT32FWID, 0x00052344 + .equ _HT32FWID, 0x00052354 + .equ _HT32FWID, 0x00000006 + .equ _HT32FWID, 0x00061352 + .equ _HT32FWID, 0x00032003 + .equ _HT32FWID, 0x00062030 + .equ _HT32FWID, 0x00062040 + .equ _HT32FWID, 0x00062050 + .equ _HT32FWID, 0x00067741 + .equ _HT32FWID, 0x00067232 + .equ _HT32FWID, 0x00067233 +*/ + + .equ HT32F52220_30, 1 + .equ HT32F52231_41, 2 + .equ HT32F52331_41, 3 + .equ HT32F52342_52, 4 + .equ HT32F52243_53, 5 + .equ HT32F0008, 6 + .equ HT32F52344_54, 9 + .equ HT32F0006, 10 + .equ HT32F61352, 10 + .equ HT50F32003, 4 + .equ HT32F62030, 1 + .equ HT32F62040, 2 + .equ HT32F62050, 5 + .equ HT32F67741, 2 + .equ HT32F67232, 1 + .equ HT32F67233, 1 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .if (USE_HT32_CHIP==HT32F52220_30) + .long _RESERVED /* 01, 17, 0x044, */ + .else + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .endif + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52344_54) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 08, 24, 0x060, */ + .else + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) + .long GPTM1_IRQHandler /* 11, 27, 0x06C, */ + .else + .long _RESERVED /* 11, 27, 0x06C, */ + .endif + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .else + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F52231_41) || (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52243_53) || (USE_HT32_CHIP==HT32F0006) + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .if (USE_HT32_CHIP==HT32F52220_30) + .long _RESERVED /* 18, 34, 0x088, */ + .else + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .endif + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 22, 38, 0x098, */ + .else + .if (USE_HT32_CHIP==HT32F0006) + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .else + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .endif + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52243_53) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 26, 42, 0x0A8, */ + .else + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52342_52) + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long UART2_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0006) + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 27, 43, 0xAC, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F0006) + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long UART3_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long AES_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long _RESERVED /* 29, 45, 0x0B4, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52243_53) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM1_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ I2C2_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART2_IRQHandler + IRQ UART3_IRQHandler + IRQ SCI_IRQHandler + IRQ MIDI_IRQHandler + IRQ I2S_IRQHandler + IRQ AES_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_02.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_02.s new file mode 100644 index 0000000000..784c9cef99 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_02.s @@ -0,0 +1,382 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050220 + .equ _HT32FWID, 0x00050230 + .equ _HT32FWID, 0x00050231 + .equ _HT32FWID, 0x00050241 + .equ _HT32FWID, 0x00032002 + .equ _HT32FWID, 0x00059041 + .equ _HT32FWID, 0x000F5032 + .equ _HT32FWID, 0x00061641 + .equ _HT32FWID, 0x00059046 + .equ _HT32FWID, 0x00061041 +*/ + + .equ HT32F50220_30, 7 + .equ HT32F50231_41, 8 + .equ HT50F32002, 7 + .equ HT32F59041, 8 + .equ HF5032, 7 + .equ HT32F61641, 8 + .equ HT32F59046, 8 + .equ HT32F61041, 8 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 18, 34, 0x088, */ + .else + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .endif + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_03.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_03.s new file mode 100644 index 0000000000..e00f3d2618 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_03.s @@ -0,0 +1,444 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_03.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00000008 + .equ _HT32FWID, 0x00052142 + .equ _HT32FWID, 0x00052344 + .equ _HT32FWID, 0x00052354 + .equ _HT32FWID, 0x00052357 + .equ _HT32FWID, 0x00052367 + .equ _HT32FWID, 0x0003200F +*/ + + .equ HT32F0008, 6 + .equ HT32F52142, 6 + .equ HT32F52344_54, 9 + .equ HT32F52357_67, 11 + .equ HT50F3200T, 11 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long COMP_DAC_IRQHandler /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 08, 24, 0x060, */ + .else + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long AES_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long QSPI_IRQHandler /* 11, 27, 0x06C, */ + .else + .long _RESERVED /* 11, 27, 0x06C, */ + .endif + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .else + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52357_67) + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 22, 38, 0x098, */ + .else + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .long UART0_UART2_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_UART3_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .else + .long _RESERVED /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long AES_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ COMP_DAC_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART0_UART2_IRQHandler + IRQ UART1_UART3_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ AES_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_05.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_05.s new file mode 100644 index 0000000000..5aba9e9f48 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_05.s @@ -0,0 +1,396 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00057331 + .equ _HT32FWID, 0x00057341 + .equ _HT32FWID, 0x00057342 + .equ _HT32FWID, 0x00057352 + .equ _HT32FWID, 0x00059741 + .equ _HT32FWID, 0x00005828 + .equ _HT32FWID, 0x00067742 + .equ _HT32FWID, 0x00059746 +*/ + + .equ HT32F57331_41, 13 + .equ HT32F57342_52, 14 + .equ HT32F59741, 13 + .equ HT32F5828, 14 + .equ HT32F67742, 13 + .equ HT32F59746, 13 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long COMP_DAC_IRQHandler /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long AES_IRQHandler /* 09, 25, 0x064, */ + .endif + .long _RESERVED /* 10, 26, 0x068, */ + .long LCD_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 30, 46, 0x0B8, */ + .long _RESERVED /* 31, 47, 0x0BC, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ COMP_DAC_IRQHandler + IRQ ADC_IRQHandler + IRQ AES_IRQHandler + IRQ LCD_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_06.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_06.s new file mode 100644 index 0000000000..8d21e6d900 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_06.s @@ -0,0 +1,347 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_06.s +; Version : $Rev:: 4143 $ +; Date : $Date:: 2019-07-24 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50343 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <15=> HT32F50343 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050343 +*/ + + .equ HT32F50343, 15 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long PWM2_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SLED0_IRQHandler /* 27, 43, 0x0AC, */ + .long SLED1_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ PWM2_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SLED0_IRQHandler + IRQ SLED1_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_07.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_07.s new file mode 100644 index 0000000000..f6702bded7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_07.s @@ -0,0 +1,355 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_07.s +; Version : $Rev:: 5157 $ +; Date : $Date:: 2021-01-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00000006 + .equ _HT32FWID, 0x00061352 + .equ _HT32FWID, 0x00061355 + .equ _HT32FWID, 0x00061356 + .equ _HT32FWID, 0x00061357 +*/ + + .equ HT32F0006, 10 + .equ HT32F61352, 10 + .equ HT32F61355_56_57, 17 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ MIDI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_08.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_08.s new file mode 100644 index 0000000000..eef814945f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_08.s @@ -0,0 +1,315 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_08.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; HT50F3200S +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> HT50F3200S +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00065230 + .equ _HT32FWID, 0x00065240 + .equ _HT32FWID, 0x00065232 + .equ _HT32FWID, 0x0003200F +*/ + + .equ HT32F65230_40, 12 + .equ HT32F65232, 18 + .equ HT50F3200S, 12 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_9_IRQHandler /* 06, 22, 0x058, */ + .long EXTI10_15_IRQHandler /* 07, 23, 0x05C, */ + .long ADC0_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F65230_40) + .long ADC1_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .long MCTM0_BRK_IRQHandler /* 10, 26, 0x068, */ + .long MCTM0_UP_IRQHandler /* 11, 27, 0x06C, */ + .long MCTM0_TR_UP2_IRQHandler /* 12, 28, 0x070, */ + .long MCTM0_CC_IRQHandler /* 13, 29, 0x074, */ + .long GPTM0_G_IRQHandler /* 14, 30, 0x078, */ + .long GPTM0_VCLK_IRQHandler /* 15, 31, 0x07C, */ + .long BFTM0_IRQHandler /* 16, 32, 0x080, */ + .long BFTM1_IRQHandler /* 17, 33, 0x084, */ + .long CMP0_IRQHandler /* 18, 34, 0x088, */ + .long CMP1_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F65230_40) + .long CMP2_IRQHandler /* 20, 36, 0x090, */ + .else + .long _RESERVED /* 20, 36, 0x090, */ + .endif + .long I2C0_IRQHandler /* 21, 37, 0x094, */ + .long SPI0_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long UART0_IRQHandler /* 24, 40, 0x0A0, */ + .long PDMA_CH0_1_IRQHandler /* 25, 41, 0x0A4, */ + .long PDMA_CH2_3_IRQHandler /* 26, 42, 0x0A8, */ + .long PDMA_CH4_5_IRQHandler /* 27, 43, 0x0AC, */ + .long SCTM0_IRQHandler /* 28, 44, 0x0B0, */ + .long SCTM1_IRQHandler /* 29, 45, 0x0B4, */ + .long SCTM2_IRQHandler /* 30, 46, 0x0B8, */ + .long SCTM3_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_9_IRQHandler + IRQ EXTI10_15_IRQHandler + IRQ ADC0_IRQHandler + IRQ ADC1_IRQHandler + IRQ MCTM0_BRK_IRQHandler + IRQ MCTM0_UP_IRQHandler + IRQ MCTM0_TR_UP2_IRQHandler + IRQ MCTM0_CC_IRQHandler + IRQ GPTM0_G_IRQHandler + IRQ GPTM0_VCLK_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ CMP0_IRQHandler + IRQ CMP1_IRQHandler + IRQ CMP2_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_3_IRQHandler + IRQ PDMA_CH4_5_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_09.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_09.s new file mode 100644 index 0000000000..1a2be14682 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_09.s @@ -0,0 +1,387 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_09.s +; Version : $Rev:: 5410 $ +; Date : $Date:: 2021-06-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F54231, HT32F54241 +; HT32F54243, HT32F54253 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <19=> HT32F54231/41 +;// <20=> HT32F54243/53 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00054231 + .equ _HT32FWID, 0x00054241 + .equ _HT32FWID, 0x00054243 + .equ _HT32FWID, 0x00054253 +*/ + + .equ HT32F54231_41, 19 + .equ HT32F54243_53, 20 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .endif + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long TKEY_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long UART2_IRQHandler /* 27, 43, 0x0AC, */ + .long UART3_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .if (USE_HT32_CHIP==HT32F54243_53) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ I2C2_IRQHandler + IRQ MCTM0_IRQHandler + IRQ TKEY_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART2_IRQHandler + IRQ UART3_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_10.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_10.s new file mode 100644 index 0000000000..d6688b4441 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_10.s @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_10.s +; Version : $Rev:: 6601 $ +; Date : $Date:: 2022-12-27 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F61244, HT32F61245 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <24=> HT32F61244/45 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00061244 + .equ _HT32FWID, 0x00061245 +*/ + + .equ HT32F61244_45, 24 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ QSPI_IRQHandler + IRQ UART0_IRQHandler + IRQ MIDI_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_11.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_11.s new file mode 100644 index 0000000000..f5b5d9585e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_11.s @@ -0,0 +1,294 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_11.s +; Version : $Rev:: 6206 $ +; Date : $Date:: 2022-10-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F67041, HT32F67051 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <22=> HT32F67041/51 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00067041 + .equ _HT32FWID, 0x00067051 +*/ + + .equ HT32F67041_51, 22 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long AES_IRQHandler /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long RF_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ AES_IRQHandler + IRQ RF_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_12.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_12.s new file mode 100644 index 0000000000..91be324717 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_12.s @@ -0,0 +1,336 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_12.s +; Version : $Rev:: 5572 $ +; Date : $Date:: 2021-08-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F61141 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <23=> HT32F61141 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00061141 +*/ + + .equ HT32F61141, 23 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long _RESERVED /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ USB_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_13.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_13.s new file mode 100644 index 0000000000..1d5b8a33b1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_13.s @@ -0,0 +1,292 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050020 + .equ _HT32FWID, 0x00050030 + .equ _HT32FWID, 0x00061630 + .equ _HT32FWID, 0x00061030 +*/ + + .equ HT32F50020_30, 25 + .equ HT32F61630, 25 + .equ HT32F61030, 25 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_7_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long _RESERVED /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long _RESERVED /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_7_IRQHandler + IRQ ADC_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ BFTM0_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ LEDC_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_14.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_14.s new file mode 100644 index 0000000000..9a02b727d9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_14.s @@ -0,0 +1,312 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_14.s +; Version : $Rev:: 6838 $ +; Date : $Date:: 2023-04-06 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50442, HT32F50452 +; HT32F50431, HT32F50441 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <26=> HT32F50442/52 +;// <30=> HT32F50431/41 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050442 + .equ _HT32FWID, 0x00050452 + .equ _HT32FWID, 0x00050431 + .equ _HT32FWID, 0x00050441 +*/ + + .equ HT32F50442_52, 26 + .equ HT32F50431_41, 30 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .else + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_15.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_15.s new file mode 100644 index 0000000000..685f83659e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_15.s @@ -0,0 +1,313 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_15.s +; Version : $Rev:: 6902 $ +; Date : $Date:: 2023-05-08 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F53242, HT32F53252 +; HT32F53231, HT32F53241 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <28=> HT32F53242/52 +;// <29=> HT32F53231/41 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00053242 + .equ _HT32FWID, 0x00053252 + .equ _HT32FWID, 0x00053231 + .equ _HT32FWID, 0x00053241 +*/ + + .equ HT32F53242_52, 28 + .equ HT32F53231_41, 29 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .else + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long CAN0_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ CAN0_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_16.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_16.s new file mode 100644 index 0000000000..8cb1f85b48 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_16.s @@ -0,0 +1,317 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_16.s +; Version : $Rev:: 7094 $ +; Date : $Date:: 2023-08-02 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F66242 +; HT32F66246 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* + + + + +*/ + .equ USE_HT32_CHIP_SET, 0 + +/* + .equ _HT32FWID, 0xFFFFFFFF + .equ _HT32FWID, 0x00066246 +*/ + + .equ HT32F66246, 31 + .equ HT32F66242, 33 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .if USE_HT32_CHIP == 0 + .equ _HT32FWID, 0x00066246 + .endif + .if USE_HT32_CHIP == HT32F66246 + .equ _HT32FWID, 0x00066246 + .endif + .if USE_HT32_CHIP == HT32F66242 + .equ _HT32FWID, 0x00066242 + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F66246) + .long CAN0_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long CORDIC_IRQHandler /* 09, 25, 0x064, */ + .long MCTM0_BRK_IRQHandler /* 10, 26, 0x068, */ + .long MCTM0_UP_IRQHandler /* 11, 27, 0x06C, */ + .long MCTM0_TR_UP2_IRQHandler /* 12, 28, 0x070, */ + .long MCTM0_CC_IRQHandler /* 13, 29, 0x074, */ + .long GPTM0_G_IRQHandler /* 14, 30, 0x078, */ + .long GPTM0_VCLK_IRQHandler /* 15, 31, 0x07C, */ + .long BFTM0_IRQHandler /* 16, 32, 0x080, */ + .long BFTM1_IRQHandler /* 17, 33, 0x084, */ + .long CMP0_IRQHandler /* 18, 34, 0x088, */ + .long CMP1_IRQHandler /* 19, 35, 0x08C, */ + .long PID_IRQHandler /* 20, 36, 0x090, */ + .long I2C0_IRQHandler /* 21, 37, 0x094, */ + .long SPI0_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long UART0_IRQHandler /* 24, 40, 0x0A0, */ + .long PDMA_CH0_1_IRQHandler /* 25, 41, 0x0A4, */ + .long PDMA_CH2_3_IRQHandler /* 26, 42, 0x0A8, */ + .long PDMA_CH4_5_IRQHandler /* 27, 43, 0x0AC, */ + .long SCTM0_IRQHandler /* 28, 44, 0x0B0, */ + .long SCTM1_IRQHandler /* 29, 45, 0x0B4, */ + .long SCTM2_IRQHandler /* 30, 46, 0x0B8, */ + .long SCTM3_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ CAN0_IRQHandler + IRQ ADC_IRQHandler + IRQ CORDIC_IRQHandler + IRQ MCTM0_BRK_IRQHandler + IRQ MCTM0_UP_IRQHandler + IRQ MCTM0_TR_UP2_IRQHandler + IRQ MCTM0_CC_IRQHandler + IRQ GPTM0_G_IRQHandler + IRQ GPTM0_VCLK_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ CMP0_IRQHandler + IRQ CMP1_IRQHandler + IRQ PID_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_3_IRQHandler + IRQ PDMA_CH4_5_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_17.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_17.s new file mode 100644 index 0000000000..f19b45b36f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/GCC/startup_ht32f5xxxx_gcc_17.s @@ -0,0 +1,291 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_gcc_17.s +; Version : $Rev:: 7030 $ +; Date : $Date:: 2023-07-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F52234, HT32F52244 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <33=> HT32F52234/44 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00052234 + .equ _HT32FWID, 0x00052244 +*/ + + .equ HT32F52234_44, 33 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .syntax unified + .cpu cortex-m0plus + .fpu softvfp + .thumb + +/* start address for the initialization values of the .data section. defined in linker script */ +.word _sidata + +/* start address for the .data section. defined in linker script */ +.word _sdata + +/* end address for the .data section. defined in linker script */ +.word _edata + +/* start address for the .bss section. defined in linker script */ +.word _sbss + +/* end address for the .bss section. defined in linker script */ +.word _ebss + + +/* +; Amount of memory (in bytes) allocated for Stack and Heap +; Tailor those values to your application needs +;// Stack Size (in Bytes, must 8 byte aligned) <:8> +*/ + .equ Stack_Size, 512 + .section ".stack", "w" + .align 3 + .globl __StackTop + .globl __StackLimit + .globl __HT_check_sp +__HT_check_sp: +__StackLimit: + .if Stack_Size + .space Stack_Size + .endif + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + +/* +;// Heap Size (in Bytes) <:8> +*/ + .equ Heap_Size, 0 + .section ".heap", "w" + .align 3 + .globl __HeapBase + .globl _end + .globl __HeapLimit + .globl __HT_check_heap +__HT_check_heap: +__HeapBase: +_end: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .section .isr_vector,"a",%progbits + .global __interrupt_vector_cortex_m + .type __interrupt_vector_cortex_m, %object +__interrupt_vector_cortex_m: + .long __StackTop /* ---, 00, 0x000, Top address of Stack */ + .long Reset_Handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long DAC0_1_IRQHandler /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long _RESERVED /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + .size __interrupt_vector_cortex_m, . - __interrupt_vector_cortex_m + + + .thumb + + +/* Reset Handler */ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + LDR R0, =__StackTop /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + + /* Copy the data segment initializers from flash to SRAM */ + MOVS R1, #0 + B LoopCopyDataInit + +CopyDataInit: + LDR R3, =_sidata + LDR R3, [R3, R1] + STR R3, [R0, R1] + ADDS R1, R1, #4 + +LoopCopyDataInit: + LDR R0, =_sdata + LDR R3, =_edata + ADDS R2, R0, R1 + CMP R2, R3 + BCC CopyDataInit + LDR R2, =_sbss + B LoopFillZerobss + +/* Zero fill the bss segment. */ +FillZerobss: + MOVS R3, #0 + STR R3, [R2] + ADDS R2, R2, #4 + +LoopFillZerobss: + LDR R3, =_ebss + CMP R2, R3 + BCC FillZerobss + + /* Call static constructors */ + BL __libc_init_array + + /* Call the application's entry point.*/ + BL main + +LoopForever: + B LoopForever + + .thumb_func + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ DAC0_1_IRQHandler + IRQ ADC_IRQHandler + IRQ I2C2_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_01.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_01.s new file mode 100644 index 0000000000..1fc4bed7a6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_01.s @@ -0,0 +1,430 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052220 +;_HT32FWID EQU 0x00052230 +;_HT32FWID EQU 0x00052231 +;_HT32FWID EQU 0x00052241 +;_HT32FWID EQU 0x00052331 +;_HT32FWID EQU 0x00052341 +;_HT32FWID EQU 0x00052342 +;_HT32FWID EQU 0x00052352 +;_HT32FWID EQU 0x00052243 +;_HT32FWID EQU 0x00052253 +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00032003 +;_HT32FWID EQU 0x00062030 +;_HT32FWID EQU 0x00062040 +;_HT32FWID EQU 0x00062050 +;_HT32FWID EQU 0x00067741 +;_HT32FWID EQU 0x00067232 +;_HT32FWID EQU 0x00067233 + +HT32F52220_30 EQU 1 +HT32F52231_41 EQU 2 +HT32F52331_41 EQU 3 +HT32F52342_52 EQU 4 +HT32F52243_53 EQU 5 +HT32F0008 EQU 6 +HT32F52344_54 EQU 9 +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT50F32003 EQU 4 +HT32F62030 EQU 1 +HT32F62040 EQU 2 +HT32F62050 EQU 5 +HT32F67741 EQU 2 +HT32F67232 EQU 1 +HT32F67233 EQU 1 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 01, 17, 0x044, + ELSE + DCD RTC_IRQHandler ; 01, 17, 0x044, + ENDIF + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) + DCD GPTM1_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F52231_41) || (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0006) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F52220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + IF (USE_HT32_CHIP=HT32F0006) + DCD QSPI_IRQHandler ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + IF (USE_HT32_CHIP=HT32F52220_30) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F0006) + DCD _RESERVED ; 26, 42, 0x0A8, + ELSE + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0006) + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0006) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52331_41) || (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD USB_IRQHandler ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52243_53) + DCD _RESERVED ; 29, 45, 0x0B4, + ENDIF + IF (USE_HT32_CHIP=HT32F52342_52) || (USE_HT32_CHIP=HT32F52243_53) || (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) || (USE_HT32_CHIP=HT32F0006) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK COMP_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK MCTM0_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK GPTM1_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK SCTM3_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK PWM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK I2C2_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK QSPI_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK USART1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK UART2_IRQHandler + PUBWEAK UART3_IRQHandler + PUBWEAK SCI_IRQHandler + PUBWEAK MIDI_IRQHandler + PUBWEAK I2S_IRQHandler + PUBWEAK AES_IRQHandler + PUBWEAK USB_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM1_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +SCI_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_02.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_02.s new file mode 100644 index 0000000000..90e0090688 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_02.s @@ -0,0 +1,275 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050220 +;_HT32FWID EQU 0x00050230 +;_HT32FWID EQU 0x00050231 +;_HT32FWID EQU 0x00050241 +;_HT32FWID EQU 0x00032002 +;_HT32FWID EQU 0x00059041 +;_HT32FWID EQU 0x000F5032 +;_HT32FWID EQU 0x00061641 +;_HT32FWID EQU 0x00059046 +;_HT32FWID EQU 0x00061041 + +HT32F50220_30 EQU 7 +HT32F50231_41 EQU 8 +HT50F32002 EQU 7 +HT32F59041 EQU 8 +HF5032 EQU 7 +HT32F61641 EQU 8 +HT32F59046 EQU 8 +HT32F61041 EQU 8 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 18, 34, 0x088, + ELSE + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + ENDIF + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + IF (USE_HT32_CHIP=HT32F50220_30) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK MCTM0_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK PWM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_03.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_03.s new file mode 100644 index 0000000000..d33333bd3a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_03.s @@ -0,0 +1,351 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_03.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000008 +;_HT32FWID EQU 0x00052142 +;_HT32FWID EQU 0x00052344 +;_HT32FWID EQU 0x00052354 +;_HT32FWID EQU 0x00052357 +;_HT32FWID EQU 0x00052367 +;_HT32FWID EQU 0x0003200F + +HT32F0008 EQU 6 +HT32F52142 EQU 6 +HT32F52344_54 EQU 9 +HT32F52357_67 EQU 11 +HT50F3200T EQU 11 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 08, 24, 0x060, + ELSE + DCD ADC_IRQHandler ; 08, 24, 0x060, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD AES_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 10, 26, 0x068, + ELSE + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD QSPI_IRQHandler ; 11, 27, 0x06C, + ELSE + DCD _RESERVED ; 11, 27, 0x06C, + ENDIF + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ELSE + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52357_67) + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F0008) || (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 20, 36, 0x090, + ELSE + DCD I2C1_IRQHandler ; 20, 36, 0x090, + ENDIF + DCD SPI0_IRQHandler ; 21, 37, 0x094, + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 22, 38, 0x098, + ELSE + DCD SPI1_IRQHandler ; 22, 38, 0x098, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 23, 39, 0x09C, + ELSE + DCD USART0_IRQHandler ; 23, 39, 0x09C, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + DCD UART0_UART2_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_UART3_IRQHandler ; 26, 42, 0x0A8, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD SCI_IRQHandler ; 27, 43, 0xAC, + ELSE + DCD _RESERVED ; 27, 43, 0xAC, + ENDIF + IF (USE_HT32_CHIP=HT32F0008) + DCD AES_IRQHandler ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52344_54) + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F52357_67) + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK COMP_IRQHandler + PUBWEAK COMP_DAC_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK MCTM0_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK PWM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK QSPI_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK USART1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK UART0_UART2_IRQHandler + PUBWEAK UART1_UART3_IRQHandler + PUBWEAK SCI_IRQHandler + PUBWEAK I2S_IRQHandler + PUBWEAK AES_IRQHandler + PUBWEAK USB_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART0_UART2_IRQHandler +UART1_UART3_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +AES_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_05.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_05.s new file mode 100644 index 0000000000..2d5a99264b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_05.s @@ -0,0 +1,298 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00057331 +;_HT32FWID EQU 0x00057341 +;_HT32FWID EQU 0x00057342 +;_HT32FWID EQU 0x00057352 +;_HT32FWID EQU 0x00059741 +;_HT32FWID EQU 0x00005828 +;_HT32FWID EQU 0x00067742 +;_HT32FWID EQU 0x00059746 + +HT32F57331_41 EQU 13 +HT32F57342_52 EQU 14 +HT32F59741 EQU 13 +HT32F5828 EQU 14 +HT32F67742 EQU 13 +HT32F59746 EQU 13 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD COMP_DAC_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD AES_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD _RESERVED ; 10, 26, 0x068, + DCD LCD_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + ENDIF + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F57331_41) + DCD _RESERVED ; 30, 46, 0x0B8, + DCD _RESERVED ; 31, 47, 0x0BC, + ENDIF + IF (USE_HT32_CHIP=HT32F57342_52) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK COMP_DAC_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK AES_IRQHandler + PUBWEAK LCD_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK PWM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK USART1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK SCI_IRQHandler + PUBWEAK I2S_IRQHandler + PUBWEAK USB_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_DAC_IRQHandler +ADC_IRQHandler +AES_IRQHandler +LCD_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_06.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_06.s new file mode 100644 index 0000000000..fc26530cff --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_06.s @@ -0,0 +1,245 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_06.s +; Version : $Rev:: 4123 $ +; Date : $Date:: 2019-07-23 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50343 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <15=> HT32F50343 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050343 + +HT32F50343 EQU 15 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD PWM2_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD PWM1_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SLED0_IRQHandler ; 27, 43, 0x0AC, + DCD SLED1_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK PWM2_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK PWM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK SLED0_IRQHandler + PUBWEAK SLED1_IRQHandler + PUBWEAK USB_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +PWM2_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SLED0_IRQHandler +SLED1_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_07.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_07.s new file mode 100644 index 0000000000..dd22e9e2ed --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_07.s @@ -0,0 +1,252 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_07.s +; Version : $Rev:: 5157 $ +; Date : $Date:: 2021-01-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00000006 +;_HT32FWID EQU 0x00061352 +;_HT32FWID EQU 0x00061355 +;_HT32FWID EQU 0x00061356 +;_HT32FWID EQU 0x00061357 + +HT32F0006 EQU 10 +HT32F61352 EQU 10 +HT32F61355_56_57 EQU 17 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD I2S_IRQHandler ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK SCTM3_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK QSPI_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK MIDI_IRQHandler + PUBWEAK I2S_IRQHandler + PUBWEAK USB_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +I2S_IRQHandler +USB_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_08.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_08.s new file mode 100644 index 0000000000..c1c8add3fb --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_08.s @@ -0,0 +1,224 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_08.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; HT50F3200S + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> HT50F3200S +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00065230 +;_HT32FWID EQU 0x00065240 +;_HT32FWID EQU 0x00065232 +;_HT32FWID EQU 0x0003200F + +HT32F65230_40 EQU 12 +HT32F65232 EQU 18 +HT50F3200S EQU 12 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_9_IRQHandler ; 06, 22, 0x058, + DCD EXTI10_15_IRQHandler ; 07, 23, 0x05C, + DCD ADC0_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD ADC1_IRQHandler ; 09, 25, 0x064, + ELSE + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + IF (USE_HT32_CHIP=HT32F65230_40) + DCD CMP2_IRQHandler ; 20, 36, 0x090, + ELSE + DCD _RESERVED ; 20, 36, 0x090, + ENDIF + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_9_IRQHandler + PUBWEAK EXTI10_15_IRQHandler + PUBWEAK ADC0_IRQHandler + PUBWEAK ADC1_IRQHandler + PUBWEAK MCTM0_BRK_IRQHandler + PUBWEAK MCTM0_UP_IRQHandler + PUBWEAK MCTM0_TR_UP2_IRQHandler + PUBWEAK MCTM0_CC_IRQHandler + PUBWEAK GPTM0_G_IRQHandler + PUBWEAK GPTM0_VCLK_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK CMP0_IRQHandler + PUBWEAK CMP1_IRQHandler + PUBWEAK CMP2_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_3_IRQHandler + PUBWEAK PDMA_CH4_5_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK SCTM3_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_9_IRQHandler +EXTI10_15_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +CMP2_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_09.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_09.s new file mode 100644 index 0000000000..508fb39eaa --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_09.s @@ -0,0 +1,291 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_09.s +; Version : $Rev:: 5410 $ +; Date : $Date:: 2021-06-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F54231, HT32F54241 +; HT32F54243, HT32F54253 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <19=> HT32F54231/41 +;// <20=> HT32F54243/53 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00054231 +;_HT32FWID EQU 0x00054241 +;_HT32FWID EQU 0x00054243 +;_HT32FWID EQU 0x00054253 + +HT32F54231_41 EQU 19 +HT32F54243_53 EQU 20 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 09, 25, 0x064, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD I2C2_IRQHandler ; 09, 25, 0x064, + ENDIF + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD TKEY_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + IF (USE_HT32_CHIP=HT32F54231_41) + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + ENDIF + IF (USE_HT32_CHIP=HT32F54243_53) + DCD UART2_IRQHandler ; 27, 43, 0x0AC, + DCD UART3_IRQHandler ; 28, 44, 0x0B0, + ENDIF + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + IF (USE_HT32_CHIP=HT32F54243_53) + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + ENDIF + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK COMP_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK I2C2_IRQHandler + PUBWEAK MCTM0_IRQHandler + PUBWEAK TKEY_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK SCTM3_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK USART1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK UART2_IRQHandler + PUBWEAK UART3_IRQHandler + PUBWEAK LEDC_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +I2C2_IRQHandler +MCTM0_IRQHandler +TKEY_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_10.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_10.s new file mode 100644 index 0000000000..a8289bc68e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_10.s @@ -0,0 +1,184 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_10.s +; Version : $Rev:: 5780 $ +; Date : $Date:: 2022-03-28 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F61244, HT32F61245 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <24=> HT32F61244/45 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00061244 +;_HT32FWID EQU 0x00061245 + +HT32F61244_45 EQU 24 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD QSPI_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD MIDI_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK QSPI_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK MIDI_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +QSPI_IRQHandler +UART0_IRQHandler +MIDI_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_11.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_11.s new file mode 100644 index 0000000000..e49a6d5643 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_11.s @@ -0,0 +1,194 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_11.s +; Version : $Rev:: 5991 $ +; Date : $Date:: 2022-06-23 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F67041, HT32F67051 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <22=> HT32F67041/51 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00067041 +;_HT32FWID EQU 0x00067051 + +HT32F67041_51 EQU 22 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD AES_IRQHandler ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD RF_IRQHandler ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD SCTM3_IRQHandler ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK AES_IRQHandler + PUBWEAK RF_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK SCTM3_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +ADC_IRQHandler +AES_IRQHandler +RF_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_12.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_12.s new file mode 100644 index 0000000000..90ff940648 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_12.s @@ -0,0 +1,226 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_12.s +; Version : $Rev:: 5572 $ +; Date : $Date:: 2021-08-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F61141 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <23=> HT32F61141 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00061141 + +HT32F61141 EQU 23 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD _RESERVED ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD _RESERVED ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD SCI_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD USB_IRQHandler ; 29, 45, 0x0B4, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + +BootProcess + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1 LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2 DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3 LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4 LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK SCI_IRQHandler + PUBWEAK USB_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +GPTM0_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +SCI_IRQHandler +USB_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_13.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_13.s new file mode 100644 index 0000000000..b573c7b115 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_13.s @@ -0,0 +1,184 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050020 +;_HT32FWID EQU 0x00050030 +;_HT32FWID EQU 0x00061630 +;_HT32FWID EQU 0x00061030 + +HT32F50020_30 EQU 25 +HT32F61630 EQU 25 +HT32F61030 EQU 25 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_7_IRQHandler ; 06, 22, 0x058, + DCD _RESERVED ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD SCTM2_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD _RESERVED ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD _RESERVED ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD _RESERVED ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_7_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK LEDC_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_7_IRQHandler +ADC_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +BFTM0_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_14.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_14.s new file mode 100644 index 0000000000..ffd489d97a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_14.s @@ -0,0 +1,213 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_14.s +; Version : $Rev:: 6834 $ +; Date : $Date:: 2023-03-31 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F50442, HT32F50452 +; HT32F50431, HT32F50441 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <26=> HT32F50442/52 +;// <30=> HT32F50431/41 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00050442 +;_HT32FWID EQU 0x00050452 +;_HT32FWID EQU 0x00050431 +;_HT32FWID EQU 0x00050441 + +HT32F50442_52 EQU 26 +HT32F50431_41 EQU 30 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F50442_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK COMP_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK MCTM0_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK PWM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK USART1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK LEDC_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_15.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_15.s new file mode 100644 index 0000000000..cf8b05ac9b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_15.s @@ -0,0 +1,215 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_15.s +; Version : $Rev:: 6902 $ +; Date : $Date:: 2023-05-08 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F53242, HT32F53252 +; HT32F53231, HT32F53241 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <28=> HT32F53242_52 +;// <29=> HT32F53231_41 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00053242 +;_HT32FWID EQU 0x00053252 +;_HT32FWID EQU 0x00053231 +;_HT32FWID EQU 0x00053241 + +HT32F53242_52 EQU 28 +HT32F53231_41 EQU 29 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD COMP_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD _RESERVED ; 09, 25, 0x064, + DCD MCTM0_IRQHandler ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD GPTM0_IRQHandler ; 12, 28, 0x070, + DCD _RESERVED ; 13, 29, 0x074, + DCD _RESERVED ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD PWM1_IRQHandler ; 16, 32, 0x080, + ELSE + DCD _RESERVED ; 16, 32, 0x080, + ENDIF + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD SPI1_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + IF (USE_HT32_CHIP=HT32F53242_52) + DCD USART1_IRQHandler ; 24, 40, 0x0A0, + ELSE + DCD _RESERVED ; 24, 40, 0x0A0, + ENDIF + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD UART1_IRQHandler ; 26, 42, 0x0A8, + DCD CAN0_IRQHandler ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD LEDC_IRQHandler ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK COMP_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK MCTM0_IRQHandler + PUBWEAK GPTM0_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK PWM1_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK USART1_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK CAN0_IRQHandler + PUBWEAK LEDC_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +COMP_IRQHandler +ADC_IRQHandler +MCTM0_IRQHandler +GPTM0_IRQHandler +PWM0_IRQHandler +PWM1_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +USART0_IRQHandler +USART1_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +CAN0_IRQHandler +LEDC_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_16.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_16.s new file mode 100644 index 0000000000..753e6eb165 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_16.s @@ -0,0 +1,224 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_16.s +; Version : $Rev:: 7212 $ +; Date : $Date:: 2023-09-11 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F66242 +; HT32F66246 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + + + + + +USE_HT32_CHIP_SET EQU 0 + +;_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00066246 + +HT32F66246 EQU 31 +HT32F66242 EQU 33 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + IF (USE_HT32_CHIP=0) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66246) +_HT32FWID EQU 0x00066246 + ENDIF + IF (USE_HT32_CHIP=HT32F66242) +_HT32FWID EQU 0x00066242 + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + IF (USE_HT32_CHIP=HT32F66246) + DCD CAN0_IRQHandler ; 07, 23, 0x05C, + ELSE + DCD _RESERVED ; 07, 23, 0x05C, + ENDIF + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD CORDIC_IRQHandler ; 09, 25, 0x064, + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + DCD PID_IRQHandler ; 20, 36, 0x090, + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK CAN0_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK CORDIC_IRQHandler + PUBWEAK MCTM0_BRK_IRQHandler + PUBWEAK MCTM0_UP_IRQHandler + PUBWEAK MCTM0_TR_UP2_IRQHandler + PUBWEAK MCTM0_CC_IRQHandler + PUBWEAK GPTM0_G_IRQHandler + PUBWEAK GPTM0_VCLK_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK CMP0_IRQHandler + PUBWEAK CMP1_IRQHandler + PUBWEAK PID_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_3_IRQHandler + PUBWEAK PDMA_CH4_5_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK SCTM3_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +CAN0_IRQHandler +ADC_IRQHandler +CORDIC_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +PID_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_17.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_17.s new file mode 100644 index 0000000000..bfabd93ba9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f5xxxx_iar_17.s @@ -0,0 +1,188 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_iar_17.s +; Version : $Rev:: 7212 $ +; Date : $Date:: 2023-09-11 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F52234, HT32F52244 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <33=> HT32F52234/44 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00052234 +;_HT32FWID EQU 0x00052244 + +HT32F52234_44 EQU 33 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_15_IRQHandler ; 06, 22, 0x058, + DCD DAC0_1_IRQHandler ; 07, 23, 0x05C, + DCD ADC_IRQHandler ; 08, 24, 0x060, + DCD I2C2_IRQHandler ; 09, 25, 0x064, + DCD _RESERVED ; 10, 26, 0x068, + DCD _RESERVED ; 11, 27, 0x06C, + DCD _RESERVED ; 12, 28, 0x070, + DCD SCTM0_IRQHandler ; 13, 29, 0x074, + DCD SCTM1_IRQHandler ; 14, 30, 0x078, + DCD PWM0_IRQHandler ; 15, 31, 0x07C, + DCD _RESERVED ; 16, 32, 0x080, + DCD BFTM0_IRQHandler ; 17, 33, 0x084, + DCD BFTM1_IRQHandler ; 18, 34, 0x088, + DCD I2C0_IRQHandler ; 19, 35, 0x08C, + DCD I2C1_IRQHandler ; 20, 36, 0x090, + DCD SPI0_IRQHandler ; 21, 37, 0x094, + DCD _RESERVED ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD _RESERVED ; 24, 40, 0x0A0, + DCD UART0_IRQHandler ; 25, 41, 0x0A4, + DCD _RESERVED ; 26, 42, 0x0A8, + DCD _RESERVED ; 27, 43, 0x0AC, + DCD _RESERVED ; 28, 44, 0x0B0, + DCD _RESERVED ; 29, 45, 0x0B4, + DCD PDMA_CH0_1_IRQHandler ; 30, 46, 0x0B8, + DCD PDMA_CH2_5_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_15_IRQHandler + PUBWEAK DAC0_1_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK I2C2_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK PWM0_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_5_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_15_IRQHandler +DAC0_1_IRQHandler +ADC_IRQHandler +I2C2_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +PWM0_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_5_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f65230_40_iar.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f65230_40_iar.s new file mode 100644 index 0000000000..695ea54ce5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/IAR/startup_ht32f65230_40_iar.s @@ -0,0 +1,209 @@ +;/*---------------------------------------------------------------------------------------------------------*/ +;/* Holtek Semiconductor Inc. */ +;/* */ +;/* Copyright (C) Holtek Semiconductor Inc. */ +;/* All rights reserved. */ +;/* */ +;/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f65230_40_iar.s +; Version : $Rev:: 6877 $ +; Date : $Date:: 2023-05-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +; Supported Device +; ======================================== +; HT32F65230 +; HT32F65240 + +;/* <<< Use Configuration Wizard in Context Menu >>> */ + +;// HT32 Device +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +USE_HT32_CHIP_SET EQU 0 + +_HT32FWID EQU 0xFFFFFFFF +;_HT32FWID EQU 0x00065230 +;_HT32FWID EQU 0x00065240 + +HT32F65230_40 EQU 12 + + IF USE_HT32_CHIP_SET=0 + ELSE + #undef USE_HT32_CHIP + #define USE_HT32_CHIP USE_HT32_CHIP_SET + ENDIF + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;******************************************************************************* + DATA +_RESERVED EQU 0xFFFFFFFF +__vector_table + DCD sfe(CSTACK) ; ---, 00, 0x000, Top address of Stack + DCD Reset_Handler ; ---, 01, 0x004, Reset Handler + DCD NMI_Handler ; -14, 02, 0x008, NMI Handler + DCD HardFault_Handler ; -13, 03, 0x00C, Hard Fault Handler + DCD _RESERVED ; ---, 04, 0x010, Reserved + DCD _RESERVED ; ---, 05, 0x014, Reserved + DCD _RESERVED ; ---, 06, 0x018, Reserved + DCD _RESERVED ; ---, 07, 0x01C, Reserved + DCD _HT32FWID ; ---, 08, 0x020, Reserved + DCD _RESERVED ; ---, 09, 0x024, Reserved + DCD _RESERVED ; ---, 10, 0x028, Reserved + DCD SVC_Handler ; -05, 11, 0x02C, SVC Handler + DCD _RESERVED ; ---, 12, 0x030, Reserved + DCD _RESERVED ; ---, 13, 0x034, Reserved + DCD PendSV_Handler ; -02, 14, 0x038, PendSV Handler + DCD SysTick_Handler ; -01, 15, 0x03C, SysTick Handler + + ; External Interrupt Handler + DCD LVD_BOD_IRQHandler ; 00, 16, 0x040, + DCD RTC_IRQHandler ; 01, 17, 0x044, + DCD FLASH_IRQHandler ; 02, 18, 0x048, + DCD EVWUP_IRQHandler ; 03, 19, 0x04C, + DCD EXTI0_1_IRQHandler ; 04, 20, 0x050, + DCD EXTI2_3_IRQHandler ; 05, 21, 0x054, + DCD EXTI4_9_IRQHandler ; 06, 22, 0x058, + DCD EXTI10_15_IRQHandler ; 07, 23, 0x05C, + DCD ADC0_IRQHandler ; 08, 24, 0x060, + DCD ADC1_IRQHandler ; 09, 25, 0x064, + DCD MCTM0_BRK_IRQHandler ; 10, 26, 0x068, + DCD MCTM0_UP_IRQHandler ; 11, 27, 0x06C, + DCD MCTM0_TR_UP2_IRQHandler ; 12, 28, 0x070, + DCD MCTM0_CC_IRQHandler ; 13, 29, 0x074, + DCD GPTM0_G_IRQHandler ; 14, 30, 0x078, + DCD GPTM0_VCLK_IRQHandler ; 15, 31, 0x07C, + DCD BFTM0_IRQHandler ; 16, 32, 0x080, + DCD BFTM1_IRQHandler ; 17, 33, 0x084, + DCD CMP0_IRQHandler ; 18, 34, 0x088, + DCD CMP1_IRQHandler ; 19, 35, 0x08C, + DCD CMP2_IRQHandler ; 20, 36, 0x090, + DCD I2C0_IRQHandler ; 21, 37, 0x094, + DCD SPI0_IRQHandler ; 22, 38, 0x098, + DCD USART0_IRQHandler ; 23, 39, 0x09C, + DCD UART0_IRQHandler ; 24, 40, 0x0A0, + DCD PDMA_CH0_1_IRQHandler ; 25, 41, 0x0A4, + DCD PDMA_CH2_3_IRQHandler ; 26, 42, 0x0A8, + DCD PDMA_CH4_5_IRQHandler ; 27, 43, 0x0AC, + DCD SCTM0_IRQHandler ; 28, 44, 0x0B0, + DCD SCTM1_IRQHandler ; 29, 45, 0x0B4, + DCD SCTM2_IRQHandler ; 30, 46, 0x0B8, + DCD SCTM3_IRQHandler ; 31, 47, 0x0BC, + + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B . + + PUBWEAK HardFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +HardFault_Handler + B . + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B . + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B . + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B . + + + PUBWEAK LVD_BOD_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK FLASH_IRQHandler + PUBWEAK EVWUP_IRQHandler + PUBWEAK EXTI0_1_IRQHandler + PUBWEAK EXTI2_3_IRQHandler + PUBWEAK EXTI4_9_IRQHandler + PUBWEAK EXTI10_15_IRQHandler + PUBWEAK ADC0_IRQHandler + PUBWEAK ADC1_IRQHandler + PUBWEAK MCTM0_BRK_IRQHandler + PUBWEAK MCTM0_UP_IRQHandler + PUBWEAK MCTM0_TR_UP2_IRQHandler + PUBWEAK MCTM0_CC_IRQHandler + PUBWEAK GPTM0_G_IRQHandler + PUBWEAK GPTM0_VCLK_IRQHandler + PUBWEAK BFTM0_IRQHandler + PUBWEAK BFTM1_IRQHandler + PUBWEAK CMP0_IRQHandler + PUBWEAK CMP1_IRQHandler + PUBWEAK CMP2_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK USART0_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK PDMA_CH0_1_IRQHandler + PUBWEAK PDMA_CH2_3_IRQHandler + PUBWEAK PDMA_CH4_5_IRQHandler + PUBWEAK SCTM0_IRQHandler + PUBWEAK SCTM1_IRQHandler + PUBWEAK SCTM2_IRQHandler + PUBWEAK SCTM3_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) +LVD_BOD_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +EVWUP_IRQHandler +EXTI0_1_IRQHandler +EXTI2_3_IRQHandler +EXTI4_9_IRQHandler +EXTI10_15_IRQHandler +ADC0_IRQHandler +ADC1_IRQHandler +MCTM0_BRK_IRQHandler +MCTM0_UP_IRQHandler +MCTM0_TR_UP2_IRQHandler +MCTM0_CC_IRQHandler +GPTM0_G_IRQHandler +GPTM0_VCLK_IRQHandler +BFTM0_IRQHandler +BFTM1_IRQHandler +CMP0_IRQHandler +CMP1_IRQHandler +CMP2_IRQHandler +I2C0_IRQHandler +SPI0_IRQHandler +USART0_IRQHandler +UART0_IRQHandler +PDMA_CH0_1_IRQHandler +PDMA_CH2_3_IRQHandler +PDMA_CH4_5_IRQHandler +SCTM0_IRQHandler +SCTM1_IRQHandler +SCTM2_IRQHandler +SCTM3_IRQHandler + B . + + END diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/SEGGER_THUMB_Startup.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/SEGGER_THUMB_Startup.s new file mode 100644 index 0000000000..63a379c804 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/SEGGER_THUMB_Startup.s @@ -0,0 +1,435 @@ +// ********************************************************************** +// * SEGGER Microcontroller GmbH * +// * The Embedded Experts * +// ********************************************************************** +// * * +// * (c) 2014 - 2018 SEGGER Microcontroller GmbH * +// * (c) 2001 - 2018 Rowley Associates Limited * +// * * +// * www.segger.com Support: support@segger.com * +// * * +// ********************************************************************** +// * * +// * All rights reserved. * +// * * +// * Redistribution and use in source and binary forms, with or * +// * without modification, are permitted provided that the following * +// * conditions are met: * +// * * +// * - Redistributions of source code must retain the above copyright * +// * notice, this list of conditions and the following disclaimer. * +// * * +// * - Neither the name of SEGGER Microcontroller GmbH * +// * nor the names of its contributors may be used to endorse or * +// * promote products derived from this software without specific * +// * prior written permission. * +// * * +// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +// * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +// * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +// * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +// * DISCLAIMED. * +// * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR * +// * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +// * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +// * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +// * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +// * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +// * DAMAGE. * +// * * +// ********************************************************************** +// Preprocessor Definitions +// ------------------------ +// +// FULL_LIBRARY +// +// If defined then +// - argc, argv are setup by the debug_getargs. +// - the exit symbol is defined and executes on return from main. +// - the exit symbol calls destructors, atexit functions and then debug_exit. +// +// If not defined then +// - argc and argv are zero. +// - the exit symbol is defined, executes on return from main and loops +// + + .syntax unified + + .section .segger.init.__SEGGER_init_lzss, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_lzss +.thumb_func +__SEGGER_init_lzss: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source stream + adds r4, r4, #8 +2: + ldrb r2, [r1] + adds r1, r1, #1 + tst r2, r2 + beq 9f @ 0 -> end of table + cmp r2, #0x80 + bcc 1f @ +ve -> literal run +// +// -ve -> copy run +// +// r0 = pointer to output stream +// r1 = pointer to input stream +// r2 = run length +// r3 = copy byte +// r4 = pointer to initialization table +// +3: + subs r2, r2, #0x80 // convert to run length + beq 10f + ldrb r3, [r1] // r3 = first byte of distance + adds r1, r1, #1 + cmp r3, #0x80 + bcc 5f // r3 < 128, short run + subs r3, r3, #0x80 // Adjust to recover true run length high byte + lsls r3, r3, #8 // Prepare to fuse + ldrb r5, [r1] // extract run length low byte + adds r1, r1, #1 + adds r3, r3, r5 // construct run length +5: + subs r5, r0, r3 // source of where to copy from +4: + ldrb r3, [r5] // source byte of run + strb r3, [r0] // store to destination + adds r5, r5, #1 + adds r0, r0, #1 + subs r2, r2, #1 + bne 4b + b 2b +// +// +ve -> literal run +// +// r0 = pointer to output stream +// r1 = pointer to input stream +// r2 = run length +// r3 = copy byte +// r4 = pointer to initialization table +// +1: + ldrb r3, [r1] // source byte of run + adds r1, r1, #1 + strb r3, [r0] // store to destination + adds r0, r0, #1 + subs r2, r2, #1 + bne 1b + b 2b +9: + bx lr +10: + b 10b + + .section .segger.init.__SEGGER_init_zero, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_zero +.thumb_func +__SEGGER_init_zero: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ size + adds r4, r4, #8 + tst r1, r1 + beq 2f + movs r2, #0 +1: + strb r2, [r0] + adds r0, r0, #1 + subs r1, r1, #1 + bne 1b +2: + bx lr + + .section .segger.init.__SEGGER_init_copy, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_copy +.thumb_func +__SEGGER_init_copy: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source + ldr r2, [r4, #8] @ size + adds r4, r4, #12 + tst r2, r2 + beq 2f +1: + ldrb r3, [r1] + strb r3, [r0] + adds r0, r0, #1 + adds r1, r1, #1 + subs r2, r2, #1 + bne 1b +2: + bx lr + + .section .segger.init.__SEGGER_init_pack, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_pack +.thumb_func +__SEGGER_init_pack: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source stream + adds r4, r4, #8 +1: + ldrb r2, [r1] + adds r1, r1, #1 + cmp r2, #0x80 + beq 4f + bcc 3f + ldrb r3, [r1] @ byte to replicate + adds r1, r1, #1 + negs r2, r2 + adds r2, r2, #255 + adds r2, r2, #1 +2: + strb r3, [r0] + adds r0, r0, #1 + subs r2, r2, #1 + bpl 2b + b 1b + +3: @ 1+n literal bytes + ldrb r3, [r1] + strb r3, [r0] + adds r0, r0, #1 + adds r1, r1, #1 + subs r2, r2, #1 + bpl 3b + b 1b +4: + bx lr + + .section .segger.init.__SEGGER_init_zpak, "ax" + .code 16 + .balign 2 + .global __SEGGER_init_zpak +.thumb_func +__SEGGER_init_zpak: + ldr r0, [r4] @ destination + ldr r1, [r4, #4] @ source stream + ldr r2, [r4, #8] @ size + adds r4, r4, #12 @ skip table entries +1: + ldrb r3, [r1] @ get control byte from source stream + adds r1, r1, #1 + movs r6, #8 +2: + movs r5, #0 @ prepare zero filler + lsrs r3, r3, #1 @ get byte control flag + bcs 3f @ carry set -> zero filler + ldrb r5, [r1] @ get literal byte from source stream + adds r1, r1, #1 +3: + strb r5, [r0] @ store initialization byte + adds r0, r0, #1 + subs r2, r2, #1 @ size -= 1 + beq 4f @ exit when destination filled + subs r6, r6, #1 @ decrement bit count + bne 2b @ still within this control byte + b 1b @ get next control byte +4: + bx lr + +#ifndef APP_ENTRY_POINT +#define APP_ENTRY_POINT main +#endif + +#ifndef ARGSSPACE +#define ARGSSPACE 128 +#endif + + .global _start + .extern APP_ENTRY_POINT + .global exit + .weak exit + +#ifdef INITIALIZE_USER_SECTIONS + .extern InitializeUserMemorySections +#endif + + .section .init, "ax" + .code 16 + .align 1 + .thumb_func + +_start: + ldr r0, = __stack_end__ + mov sp, r0 + ldr r4, =__SEGGER_init_table__ +1: + ldr r0, [r4] + adds r4, r4, #4 + tst r0, r0 + beq 2f + blx r0 + b 1b +2: + + /* Initialize the heap */ + ldr r0, = __heap_start__ + ldr r1, = __heap_end__ + subs r1, r1, r0 + cmp r1, #8 + blt 1f + movs r2, #0 + str r2, [r0] + adds r0, r0, #4 + str r1, [r0] +1: + +#ifdef INITIALIZE_USER_SECTIONS + ldr r2, =InitializeUserMemorySections + blx r2 +#endif + + /* Call constructors */ + ldr r0, =__ctors_start__ + ldr r1, =__ctors_end__ +ctor_loop: + cmp r0, r1 + beq ctor_end + ldr r2, [r0] + adds r0, #4 + push {r0-r1} + blx r2 + pop {r0-r1} + b ctor_loop +ctor_end: + + /* Setup initial call frame */ + movs r0, #0 + mov lr, r0 + mov r12, sp + + .type start, function +start: + /* Jump to application entry point */ +#ifdef FULL_LIBRARY + movs r0, #ARGSSPACE + ldr r1, =args + ldr r2, =debug_getargs + blx r2 + ldr r1, =args +#else + movs r0, #0 + movs r1, #0 +#endif + ldr r2, =APP_ENTRY_POINT + blx r2 + + .thumb_func +exit: +#ifdef FULL_LIBRARY + mov r5, r0 // save the exit parameter/return result + + /* Call destructors */ + ldr r0, =__dtors_start__ + ldr r1, =__dtors_end__ +dtor_loop: + cmp r0, r1 + beq dtor_end + ldr r2, [r0] + add r0, #4 + push {r0-r1} + blx r2 + pop {r0-r1} + b dtor_loop +dtor_end: + + /* Call atexit functions */ + ldr r2, =_execute_at_exit_fns + blx r2 + + /* Call debug_exit with return result/exit parameter */ + mov r0, r5 + ldr r2, =debug_exit + blx r2 +#endif + + /* Returned from application entry point, loop forever. */ +exit_loop: + b exit_loop + + // default C/C++ library helpers + +.macro HELPER helper_name + .section .text.\helper_name, "ax", %progbits + .global \helper_name + .align 1 + .weak \helper_name +\helper_name: + .thumb_func +.endm + +.macro JUMPTO name +#if defined(__thumb__) && !defined(__thumb2__) + mov r12, r0 + ldr r0, =\name + push {r0} + mov r0, r12 + pop {pc} +#else + b \name +#endif +.endm + +HELPER __aeabi_read_tp + ldr r0, =__tbss_start__-8 + bx lr +HELPER abort + b . +HELPER __assert + b . +HELPER __aeabi_assert + b . +HELPER __sync_synchronize + bx lr +HELPER __getchar + JUMPTO debug_getchar +HELPER __putchar + JUMPTO debug_putchar +HELPER __open + JUMPTO debug_fopen +HELPER __close + JUMPTO debug_fclose +HELPER __write + mov r3, r0 + mov r0, r1 + movs r1, #1 + JUMPTO debug_fwrite +HELPER __read + mov r3, r0 + mov r0, r1 + movs r1, #1 + JUMPTO debug_fread +HELPER __seek + push {r4, lr} + mov r4, r0 + bl debug_fseek + cmp r0, #0 + bne 1f + mov r0, r4 + bl debug_ftell + pop {r4, pc} +1: + ldr r0, =-1 + pop {r4, pc} + // char __user_locale_name_buffer[]; + .section .bss.__user_locale_name_buffer, "aw", %nobits + .global __user_locale_name_buffer + .weak __user_locale_name_buffer + __user_locale_name_buffer: + .word 0x0 + +#ifdef FULL_LIBRARY + .bss +args: + .space ARGSSPACE +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_01.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_01.s new file mode 100644 index 0000000000..a667619b58 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_01.s @@ -0,0 +1,426 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_01.s +; Version : $Rev:: 6953 $ +; Date : $Date:: 2023-05-30 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F52220, HT32F52230 +; HT32F52231, HT32F52241 +; HT32F52331, HT32F52341 +; HT32F52342, HT32F52352 +; HT32F52243, HT32F52253 +; HT32F0008 +; HT32F52344, HT32F52354 +; HT32F0006 +; HT32F61352 +; HT50F32003 +; HT32F62030, HT32F62040, HT32F62050 +; HT32F67741 +; HT32F67232 +; HT32F67233 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <1=> HT32F52220/30 +;// <2=> HT32F52231/41 +;// <3=> HT32F52331/41 +;// <4=> HT32F52342/52 +;// <5=> HT32F52243/53 +;// <6=> HT32F0008 +;// <9=> HT32F52344/54 +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <4=> HT50F32003 +;// <2=> HT32F67741 +;// <1=> HT32F67232 +;// <1=> HT32F67233 +;// <1=> HT32F62030 +;// <2=> HT32F62040 +;// <5=> HT32F62050 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00052220 + .equ _HT32FWID, 0x00052230 + .equ _HT32FWID, 0x00052231 + .equ _HT32FWID, 0x00052241 + .equ _HT32FWID, 0x00052331 + .equ _HT32FWID, 0x00052341 + .equ _HT32FWID, 0x00052342 + .equ _HT32FWID, 0x00052352 + .equ _HT32FWID, 0x00052243 + .equ _HT32FWID, 0x00052253 + .equ _HT32FWID, 0x00000008 + .equ _HT32FWID, 0x00052344 + .equ _HT32FWID, 0x00052354 + .equ _HT32FWID, 0x00000006 + .equ _HT32FWID, 0x00061352 + .equ _HT32FWID, 0x00032003 + .equ _HT32FWID, 0x00062030 + .equ _HT32FWID, 0x00062040 + .equ _HT32FWID, 0x00062050 + .equ _HT32FWID, 0x00067741 + .equ _HT32FWID, 0x00067232 + .equ _HT32FWID, 0x00067233 +*/ + + .equ HT32F52220_30, 1 + .equ HT32F52231_41, 2 + .equ HT32F52331_41, 3 + .equ HT32F52342_52, 4 + .equ HT32F52243_53, 5 + .equ HT32F0008, 6 + .equ HT32F52344_54, 9 + .equ HT32F0006, 10 + .equ HT32F61352, 10 + .equ HT50F32003, 4 + .equ HT32F62030, 1 + .equ HT32F62040, 2 + .equ HT32F62050, 5 + .equ HT32F67741, 2 + .equ HT32F67232, 1 + .equ HT32F67233, 1 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .if (USE_HT32_CHIP==HT32F52220_30) + .long _RESERVED /* 01, 17, 0x044, */ + .else + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .endif + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52344_54) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 08, 24, 0x060, */ + .else + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) + .long GPTM1_IRQHandler /* 11, 27, 0x06C, */ + .else + .long _RESERVED /* 11, 27, 0x06C, */ + .endif + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .else + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F52231_41) || (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52243_53) || (USE_HT32_CHIP==HT32F0006) + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .if (USE_HT32_CHIP==HT32F52220_30) + .long _RESERVED /* 18, 34, 0x088, */ + .else + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .endif + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 22, 38, 0x098, */ + .else + .if (USE_HT32_CHIP==HT32F0006) + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .else + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .endif + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52243_53) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .if (USE_HT32_CHIP==HT32F52220_30) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F0006) + .long _RESERVED /* 26, 42, 0x0A8, */ + .else + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52342_52) + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long UART2_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0006) + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 27, 43, 0xAC, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F0006) + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long UART3_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long AES_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52331_41) || (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .endif + .if (USE_HT32_CHIP==HT32F52243_53) + .long _RESERVED /* 29, 45, 0x0B4, */ + .endif + .if (USE_HT32_CHIP==HT32F52342_52) || (USE_HT32_CHIP==HT32F52243_53) || (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) || (USE_HT32_CHIP==HT32F0006) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM1_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ I2C2_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART2_IRQHandler + IRQ UART3_IRQHandler + IRQ SCI_IRQHandler + IRQ MIDI_IRQHandler + IRQ I2S_IRQHandler + IRQ AES_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_02.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_02.s new file mode 100644 index 0000000000..5b5110f922 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_02.s @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_02.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50220, HT32F50230 +; HT32F50231, HT32F50241 +; HT50F32002 +; HT32F59041 +; HF5032 +; HT32F61641 +; HT32F59046 +; HT32F61041 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <7=> HT32F50220/30 +;// <8=> HT32F50231/41 +;// <7=> HT50F32002 +;// <8=> HT32F59041 +;// <7=> HF5032 +;// <8=> HT32F61641 +;// <8=> HT32F59046 +;// <8=> HT32F61041 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050220 + .equ _HT32FWID, 0x00050230 + .equ _HT32FWID, 0x00050231 + .equ _HT32FWID, 0x00050241 + .equ _HT32FWID, 0x00032002 + .equ _HT32FWID, 0x00059041 + .equ _HT32FWID, 0x000F5032 + .equ _HT32FWID, 0x00061641 + .equ _HT32FWID, 0x00059046 + .equ _HT32FWID, 0x00061041 +*/ + + .equ HT32F50220_30, 7 + .equ HT32F50231_41, 8 + .equ HT50F32002, 7 + .equ HT32F59041, 8 + .equ HF5032, 7 + .equ HT32F61641, 8 + .equ HT32F59046, 8 + .equ HT32F61041, 8 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 18, 34, 0x088, */ + .else + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .endif + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .if (USE_HT32_CHIP==HT32F50220_30) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_03.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_03.s new file mode 100644 index 0000000000..e004b72345 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_03.s @@ -0,0 +1,351 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_03.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F0008 +; HT32F52142 +; HT32F52344, HT32F52354 +; HT32F52357, HT32F52367 +; HT50F3200T +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <6=> HT32F0008 +;// <6=> HT32F52142 +;// <9=> HT32F52344/54 +;// <11=> HT32F52357/67 +;// <11=> HT50F3200T +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00000008 + .equ _HT32FWID, 0x00052142 + .equ _HT32FWID, 0x00052344 + .equ _HT32FWID, 0x00052354 + .equ _HT32FWID, 0x00052357 + .equ _HT32FWID, 0x00052367 + .equ _HT32FWID, 0x0003200F +*/ + + .equ HT32F0008, 6 + .equ HT32F52142, 6 + .equ HT32F52344_54, 9 + .equ HT32F52357_67, 11 + .equ HT50F3200T, 11 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long COMP_DAC_IRQHandler /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 08, 24, 0x060, */ + .else + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long AES_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 10, 26, 0x068, */ + .else + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long QSPI_IRQHandler /* 11, 27, 0x06C, */ + .else + .long _RESERVED /* 11, 27, 0x06C, */ + .endif + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .else + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52357_67) + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F0008) || (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 20, 36, 0x090, */ + .else + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .endif + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 22, 38, 0x098, */ + .else + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 23, 39, 0x09C, */ + .else + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .long UART0_UART2_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_UART3_IRQHandler /* 26, 42, 0x0A8, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .else + .long _RESERVED /* 27, 43, 0x0AC, */ + .endif + .if (USE_HT32_CHIP==HT32F0008) + .long AES_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52344_54) + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F52357_67) + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ COMP_DAC_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART0_UART2_IRQHandler + IRQ UART1_UART3_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ AES_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_05.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_05.s new file mode 100644 index 0000000000..25447b9b1f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_05.s @@ -0,0 +1,303 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_05.s +; Version : $Rev:: 6993 $ +; Date : $Date:: 2023-06-26 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F57331, HT32F57341 +; HT32F57342, HT32F57352 +; HT32F59741 +; HT32F5828 +; HT32F67742 +; HT32F59746 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <13=> HT32F57331/41 +;// <14=> HT32F57342/52 +;// <13=> HT32F59741 +;// <14=> HT32F5828 +;// <13=> HT32F67742 +;// <13=> HT32F59746 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00057331 + .equ _HT32FWID, 0x00057341 + .equ _HT32FWID, 0x00057342 + .equ _HT32FWID, 0x00057352 + .equ _HT32FWID, 0x00059741 + .equ _HT32FWID, 0x00005828 + .equ _HT32FWID, 0x00067742 + .equ _HT32FWID, 0x00059746 +*/ + + .equ HT32F57331_41, 13 + .equ HT32F57342_52, 14 + .equ HT32F59741, 13 + .equ HT32F5828, 14 + .equ HT32F67742, 13 + .equ HT32F59746, 13 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long COMP_DAC_IRQHandler /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long AES_IRQHandler /* 09, 25, 0x064, */ + .endif + .long _RESERVED /* 10, 26, 0x068, */ + .long LCD_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .endif + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .if (USE_HT32_CHIP==HT32F57331_41) + .long _RESERVED /* 30, 46, 0x0B8, */ + .long _RESERVED /* 31, 47, 0x0BC, */ + .endif + .if (USE_HT32_CHIP==HT32F57342_52) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ COMP_DAC_IRQHandler + IRQ ADC_IRQHandler + IRQ AES_IRQHandler + IRQ LCD_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_06.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_06.s new file mode 100644 index 0000000000..00dc85d233 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_06.s @@ -0,0 +1,254 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_06.s +; Version : $Rev:: 4142 $ +; Date : $Date:: 2019-07-24 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50343 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <15=> HT32F50343 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050343 +*/ + + .equ HT32F50343, 15 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long PWM2_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SLED0_IRQHandler /* 27, 43, 0x0AC, */ + .long SLED1_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ PWM2_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SLED0_IRQHandler + IRQ SLED1_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_07.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_07.s new file mode 100644 index 0000000000..4f71e6a029 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_07.s @@ -0,0 +1,262 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_07.s +; Version : $Rev:: 5157 $ +; Date : $Date:: 2021-01-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F0006 +; HT32F61352 +; HT32F61355, HT32F61356, HT32F61357 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <10=> HT32F0006 +;// <10=> HT32F61352 +;// <17=> HT32F61355/56/57 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00000006 + .equ _HT32FWID, 0x00061352 + .equ _HT32FWID, 0x00061355 + .equ _HT32FWID, 0x00061356 + .equ _HT32FWID, 0x00061357 +*/ + + .equ HT32F0006, 10 + .equ HT32F61352, 10 + .equ HT32F61355_56_57, 17 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .long I2S_IRQHandler /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ QSPI_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ MIDI_IRQHandler + IRQ I2S_IRQHandler + IRQ USB_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_08.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_08.s new file mode 100644 index 0000000000..afbbdcd115 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_08.s @@ -0,0 +1,222 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_08.s +; Version : $Rev:: 6887 $ +; Date : $Date:: 2023-05-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F65230, HT32F65240 +; HT32F65232 +; HT50F3200S +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <12=> HT32F65230_40 +;// <18=> HT32F65232 +;// <12=> HT50F3200S +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00065230 + .equ _HT32FWID, 0x00065240 + .equ _HT32FWID, 0x00065232 + .equ _HT32FWID, 0x0003200F +*/ + + .equ HT32F65230_40, 12 + .equ HT32F65232, 18 + .equ HT50F3200S, 12 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_9_IRQHandler /* 06, 22, 0x058, */ + .long EXTI10_15_IRQHandler /* 07, 23, 0x05C, */ + .long ADC0_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F65230_40) + .long ADC1_IRQHandler /* 09, 25, 0x064, */ + .else + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .long MCTM0_BRK_IRQHandler /* 10, 26, 0x068, */ + .long MCTM0_UP_IRQHandler /* 11, 27, 0x06C, */ + .long MCTM0_TR_UP2_IRQHandler /* 12, 28, 0x070, */ + .long MCTM0_CC_IRQHandler /* 13, 29, 0x074, */ + .long GPTM0_G_IRQHandler /* 14, 30, 0x078, */ + .long GPTM0_VCLK_IRQHandler /* 15, 31, 0x07C, */ + .long BFTM0_IRQHandler /* 16, 32, 0x080, */ + .long BFTM1_IRQHandler /* 17, 33, 0x084, */ + .long CMP0_IRQHandler /* 18, 34, 0x088, */ + .long CMP1_IRQHandler /* 19, 35, 0x08C, */ + .if (USE_HT32_CHIP==HT32F65230_40) + .long CMP2_IRQHandler /* 20, 36, 0x090, */ + .else + .long _RESERVED /* 20, 36, 0x090, */ + .endif + .long I2C0_IRQHandler /* 21, 37, 0x094, */ + .long SPI0_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long UART0_IRQHandler /* 24, 40, 0x0A0, */ + .long PDMA_CH0_1_IRQHandler /* 25, 41, 0x0A4, */ + .long PDMA_CH2_3_IRQHandler /* 26, 42, 0x0A8, */ + .long PDMA_CH4_5_IRQHandler /* 27, 43, 0x0AC, */ + .long SCTM0_IRQHandler /* 28, 44, 0x0B0, */ + .long SCTM1_IRQHandler /* 29, 45, 0x0B4, */ + .long SCTM2_IRQHandler /* 30, 46, 0x0B8, */ + .long SCTM3_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_9_IRQHandler + IRQ EXTI10_15_IRQHandler + IRQ ADC0_IRQHandler + IRQ ADC1_IRQHandler + IRQ MCTM0_BRK_IRQHandler + IRQ MCTM0_UP_IRQHandler + IRQ MCTM0_TR_UP2_IRQHandler + IRQ MCTM0_CC_IRQHandler + IRQ GPTM0_G_IRQHandler + IRQ GPTM0_VCLK_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ CMP0_IRQHandler + IRQ CMP1_IRQHandler + IRQ CMP2_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_3_IRQHandler + IRQ PDMA_CH4_5_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_09.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_09.s new file mode 100644 index 0000000000..cd8e491fce --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_09.s @@ -0,0 +1,294 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_09.s +; Version : $Rev:: 5410 $ +; Date : $Date:: 2021-06-04 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F54231, HT32F54241 +; HT32F54243, HT32F54253 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <19=> HT32F54231/41 +;// <20=> HT32F54243/53 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00054231 + .equ _HT32FWID, 0x00054241 + .equ _HT32FWID, 0x00054243 + .equ _HT32FWID, 0x00054253 +*/ + + .equ HT32F54231_41, 19 + .equ HT32F54243_53, 20 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 09, 25, 0x064, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .endif + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long TKEY_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .if (USE_HT32_CHIP==HT32F54231_41) + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .endif + .if (USE_HT32_CHIP==HT32F54243_53) + .long UART2_IRQHandler /* 27, 43, 0x0AC, */ + .long UART3_IRQHandler /* 28, 44, 0x0B0, */ + .endif + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .if (USE_HT32_CHIP==HT32F54243_53) + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + .endif + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ I2C2_IRQHandler + IRQ MCTM0_IRQHandler + IRQ TKEY_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ UART2_IRQHandler + IRQ UART3_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_10.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_10.s new file mode 100644 index 0000000000..d9253dcbca --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_10.s @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_10.s +; Version : $Rev:: 6601 $ +; Date : $Date:: 2022-12-27 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F61244, HT32F61245 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <24=> HT32F61244/45 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00061244 + .equ _HT32FWID, 0x00061245 +*/ + + .equ HT32F61244_45, 24 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long QSPI_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long MIDI_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ QSPI_IRQHandler + IRQ UART0_IRQHandler + IRQ MIDI_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_11.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_11.s new file mode 100644 index 0000000000..176c685784 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_11.s @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_11.s +; Version : $Rev:: 6206 $ +; Date : $Date:: 2022-10-05 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F67041, HT32F67051 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <22=> HT32F67041/51 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00067041 + .equ _HT32FWID, 0x00067051 +*/ + + .equ HT32F67041_51, 22 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long AES_IRQHandler /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long RF_IRQHandler /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long SCTM3_IRQHandler /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ ADC_IRQHandler + IRQ AES_IRQHandler + IRQ RF_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_12.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_12.s new file mode 100644 index 0000000000..b1dc8ca860 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_12.s @@ -0,0 +1,243 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_12.s +; Version : $Rev:: 5572 $ +; Date : $Date:: 2021-08-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F61141 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <23=> HT32F61141 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00061141 +*/ + + .equ HT32F61141, 23 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long _RESERVED /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long _RESERVED /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long SCI_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long USB_IRQHandler /* 29, 45, 0x0B4, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =BootProcess + BLX R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .thumb_func +BootProcess: + LDR R0, =0x40080300 + LDR R1,[R0, #0x10] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x14] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x18] + CMP R1, #0 + BNE BP1 + LDR R1,[R0, #0x1C] + CMP R1, #0 + BEQ BP2 +BP1: + LDR R0, =0x40080180 + LDR R1,[R0, #0xC] + LSLS R1, R1, #4 + LSRS R1, R1, #20 + CMP R1, #0 + BEQ BP3 + CMP R1, #5 + BEQ BP3 + CMP R1, #6 + BEQ BP3 +BP2: + DSB + LDR R0, =0x20000000 + LDR R1, =0x05fa0004 + STR R1, [R0] + LDR R1, =0xe000ed00 + LDR R0, =0x05fa0004 + STR R0, [R1, #0xC] + DSB + B . +BP3: + LDR R0, =0x20000000 + LDR R1, [R0] + LDR R0, =0x05fa0004 + CMP R0, R1 + BEQ BP4 + BX LR +BP4: + LDR R0, =0x40088100 + LDR R1, =0x00000001 + STR R1, [R0] + LDR R0, =0x20000000 + LDR R1, =0x0 + STR R1, [R0] + BX LR + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ GPTM0_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ SCI_IRQHandler + IRQ USB_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_13.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_13.s new file mode 100644 index 0000000000..8c3a524ef1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_13.s @@ -0,0 +1,197 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_13.s +; Version : $Rev:: 7119 $ +; Date : $Date:: 2023-08-15 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50020, HT32F50030 +; HT32F61630 +; HT32F61030 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <25=> HT32F50020/30 +;// <25=> HT32F61630 +;// <25=> HT32F61030 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050020 + .equ _HT32FWID, 0x00050030 + .equ _HT32FWID, 0x00061630 + .equ _HT32FWID, 0x00061030 +*/ + + .equ HT32F50020_30, 25 + .equ HT32F61630, 25 + .equ HT32F61030, 25 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_7_IRQHandler /* 06, 22, 0x058, */ + .long _RESERVED /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long _RESERVED /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long SCTM2_IRQHandler /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long _RESERVED /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long _RESERVED /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long _RESERVED /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_7_IRQHandler + IRQ ADC_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ BFTM0_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ LEDC_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_14.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_14.s new file mode 100644 index 0000000000..530eb0949f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_14.s @@ -0,0 +1,216 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_14.s +; Version : $Rev:: 6793 $ +; Date : $Date:: 2023-03-14 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F50442, HT32F50452 +; HT32F50431, HT32F50441 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <26=> HT32F50442/52 +;// <30=> HT32F50431/41 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00050442 + .equ _HT32FWID, 0x00050452 + .equ _HT32FWID, 0x00050431 + .equ _HT32FWID, 0x00050441 +*/ + + .equ HT32F50442_52, 26 + .equ HT32F50431_41, 30 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .else + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F50442_52) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_15.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_15.s new file mode 100644 index 0000000000..732e674b45 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_15.s @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_15.s +; Version : $Rev:: 6902 $ +; Date : $Date:: 2023-05-08 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F53242, HT32F53252 +; HT32F53231, HT32F53241 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <28=> HT32F53242/52 +;// <29=> HT32F53231/41 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00053242 + .equ _HT32FWID, 0x00053252 + .equ _HT32FWID, 0x00053231 + .equ _HT32FWID, 0x00053241 +*/ + + .equ HT32F53242_52, 28 + .equ HT32F53231_41, 29 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long COMP_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long _RESERVED /* 09, 25, 0x064, */ + .long MCTM0_IRQHandler /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long GPTM0_IRQHandler /* 12, 28, 0x070, */ + .long _RESERVED /* 13, 29, 0x074, */ + .long _RESERVED /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long PWM1_IRQHandler /* 16, 32, 0x080, */ + .else + .long _RESERVED /* 16, 32, 0x080, */ + .endif + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long SPI1_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .if (USE_HT32_CHIP==HT32F53242_52) + .long USART1_IRQHandler /* 24, 40, 0x0A0, */ + .else + .long _RESERVED /* 24, 40, 0x0A0, */ + .endif + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long UART1_IRQHandler /* 26, 42, 0x0A8, */ + .long CAN0_IRQHandler /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long LEDC_IRQHandler /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ COMP_IRQHandler + IRQ ADC_IRQHandler + IRQ MCTM0_IRQHandler + IRQ GPTM0_IRQHandler + IRQ PWM0_IRQHandler + IRQ PWM1_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ SPI1_IRQHandler + IRQ USART0_IRQHandler + IRQ USART1_IRQHandler + IRQ UART0_IRQHandler + IRQ UART1_IRQHandler + IRQ CAN0_IRQHandler + IRQ LEDC_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_16.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_16.s new file mode 100644 index 0000000000..81260f6c78 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_16.s @@ -0,0 +1,221 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_16.s +; Version : $Rev:: 7094 $ +; Date : $Date:: 2023-08-02 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F66242 +; HT32F66246 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* + + + + +*/ + .equ USE_HT32_CHIP_SET, 0 + +/* + .equ _HT32FWID, 0xFFFFFFFF + .equ _HT32FWID, 0x00066246 +*/ + + .equ HT32F66246, 31 + .equ HT32F66242, 33 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .if USE_HT32_CHIP == 0 + .equ _HT32FWID, 0x00066246 + .endif + .if USE_HT32_CHIP == HT32F66246 + .equ _HT32FWID, 0x00066246 + .endif + .if USE_HT32_CHIP == HT32F66242 + .equ _HT32FWID, 0x00066242 + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .if (USE_HT32_CHIP==HT32F66246) + .long CAN0_IRQHandler /* 07, 23, 0x05C, */ + .else + .long _RESERVED /* 07, 23, 0x05C, */ + .endif + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long CORDIC_IRQHandler /* 09, 25, 0x064, */ + .long MCTM0_BRK_IRQHandler /* 10, 26, 0x068, */ + .long MCTM0_UP_IRQHandler /* 11, 27, 0x06C, */ + .long MCTM0_TR_UP2_IRQHandler /* 12, 28, 0x070, */ + .long MCTM0_CC_IRQHandler /* 13, 29, 0x074, */ + .long GPTM0_G_IRQHandler /* 14, 30, 0x078, */ + .long GPTM0_VCLK_IRQHandler /* 15, 31, 0x07C, */ + .long BFTM0_IRQHandler /* 16, 32, 0x080, */ + .long BFTM1_IRQHandler /* 17, 33, 0x084, */ + .long CMP0_IRQHandler /* 18, 34, 0x088, */ + .long CMP1_IRQHandler /* 19, 35, 0x08C, */ + .long PID_IRQHandler /* 20, 36, 0x090, */ + .long I2C0_IRQHandler /* 21, 37, 0x094, */ + .long SPI0_IRQHandler /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long UART0_IRQHandler /* 24, 40, 0x0A0, */ + .long PDMA_CH0_1_IRQHandler /* 25, 41, 0x0A4, */ + .long PDMA_CH2_3_IRQHandler /* 26, 42, 0x0A8, */ + .long PDMA_CH4_5_IRQHandler /* 27, 43, 0x0AC, */ + .long SCTM0_IRQHandler /* 28, 44, 0x0B0, */ + .long SCTM1_IRQHandler /* 29, 45, 0x0B4, */ + .long SCTM2_IRQHandler /* 30, 46, 0x0B8, */ + .long SCTM3_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ CAN0_IRQHandler + IRQ ADC_IRQHandler + IRQ CORDIC_IRQHandler + IRQ MCTM0_BRK_IRQHandler + IRQ MCTM0_UP_IRQHandler + IRQ MCTM0_TR_UP2_IRQHandler + IRQ MCTM0_CC_IRQHandler + IRQ GPTM0_G_IRQHandler + IRQ GPTM0_VCLK_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ CMP0_IRQHandler + IRQ CMP1_IRQHandler + IRQ PID_IRQHandler + IRQ I2C0_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_3_IRQHandler + IRQ PDMA_CH4_5_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ SCTM2_IRQHandler + IRQ SCTM3_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_17.s b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_17.s new file mode 100644 index 0000000000..d5be1f4cd5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/emStudio/startup_ht32f5xxxx_es_17.s @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------------------------------------*/ +/* Holtek Semiconductor Inc. */ +/* */ +/* Copyright (C) Holtek Semiconductor Inc. */ +/* All rights reserved. */ +/* */ +/*----------------------------------------------------------------------------------------------------------- +; File Name : startup_ht32f5xxxx_es_17.s +; Version : $Rev:: 7030 $ +; Date : $Date:: 2023-07-18 #$ +; Description : Startup code. +;-----------------------------------------------------------------------------------------------------------*/ + +/* +; Supported Device +; ======================================== +; HT32F52234, HT32F52244 +*/ + +;/* <<< Use Configuration Wizard in Context Menu >>> */ +/* +;// HT32 Device +;// <0=> By Project Asm Define +;// <33=> HT32F52234/44 +*/ + .equ USE_HT32_CHIP_SET, 0 + + .equ _HT32FWID, 0xFFFFFFFF +/* + .equ _HT32FWID, 0x00052234 + .equ _HT32FWID, 0x00052244 +*/ + + .equ HT32F52234_44, 33 + + .if USE_HT32_CHIP_SET == 0 + .else + .equ USE_HT32_CHIP, USE_HT32_CHIP_SET + .endif + + .equ _RESERVED, 0xFFFFFFFF +/* +;******************************************************************************* +; Fill-up the Vector Table entries with the exceptions ISR address +;********************************************************************************/ + .syntax unified + .global reset_handler + .global Reset_Handler + .equ Reset_Handler, reset_handler + + .section .vectors, "ax" + .section .vectors, "ax" + .code 16 + .balign 2 + .global _vectors +_vectors: + .long __stack_end__ /* ---, 00, 0x000, Top address of Stack */ + .long reset_handler /* ---, 01, 0x004, Reset Handler */ + .long NMI_Handler /* -14, 02, 0x008, NMI Handler */ + .long HardFault_Handler /* -13, 03, 0x00C, Hard Fault Handler */ + .long _RESERVED /* ---, 04, 0x010, Reserved */ + .long _RESERVED /* ---, 05, 0x014, Reserved */ + .long _RESERVED /* ---, 06, 0x018, Reserved */ + .long _RESERVED /* ---, 07, 0x01C, Reserved */ + .long _HT32FWID /* ---, 08, 0x020, Reserved */ + .long _RESERVED /* ---, 09, 0x024, Reserved */ + .long _RESERVED /* ---, 10, 0x028, Reserved */ + .long SVC_Handler /* -05, 11, 0x02C, SVC Handler */ + .long _RESERVED /* ---, 12, 0x030, Reserved */ + .long _RESERVED /* ---, 13, 0x034, Reserved */ + .long PendSV_Handler /* -02, 14, 0x038, PendSV Handler */ + .long SysTick_Handler /* -01, 15, 0x03C, SysTick Handler */ + + /* External Interrupt Handler */ + .long LVD_BOD_IRQHandler /* 00, 16, 0x040, */ + .long RTC_IRQHandler /* 01, 17, 0x044, */ + .long FLASH_IRQHandler /* 02, 18, 0x048, */ + .long EVWUP_IRQHandler /* 03, 19, 0x04C, */ + .long EXTI0_1_IRQHandler /* 04, 20, 0x050, */ + .long EXTI2_3_IRQHandler /* 05, 21, 0x054, */ + .long EXTI4_15_IRQHandler /* 06, 22, 0x058, */ + .long DAC0_1_IRQHandler /* 07, 23, 0x05C, */ + .long ADC_IRQHandler /* 08, 24, 0x060, */ + .long I2C2_IRQHandler /* 09, 25, 0x064, */ + .long _RESERVED /* 10, 26, 0x068, */ + .long _RESERVED /* 11, 27, 0x06C, */ + .long _RESERVED /* 12, 28, 0x070, */ + .long SCTM0_IRQHandler /* 13, 29, 0x074, */ + .long SCTM1_IRQHandler /* 14, 30, 0x078, */ + .long PWM0_IRQHandler /* 15, 31, 0x07C, */ + .long _RESERVED /* 16, 32, 0x080, */ + .long BFTM0_IRQHandler /* 17, 33, 0x084, */ + .long BFTM1_IRQHandler /* 18, 34, 0x088, */ + .long I2C0_IRQHandler /* 19, 35, 0x08C, */ + .long I2C1_IRQHandler /* 20, 36, 0x090, */ + .long SPI0_IRQHandler /* 21, 37, 0x094, */ + .long _RESERVED /* 22, 38, 0x098, */ + .long USART0_IRQHandler /* 23, 39, 0x09C, */ + .long _RESERVED /* 24, 40, 0x0A0, */ + .long UART0_IRQHandler /* 25, 41, 0x0A4, */ + .long _RESERVED /* 26, 42, 0x0A8, */ + .long _RESERVED /* 27, 43, 0x0AC, */ + .long _RESERVED /* 28, 44, 0x0B0, */ + .long _RESERVED /* 29, 45, 0x0B4, */ + .long PDMA_CH0_1_IRQHandler /* 30, 46, 0x0B8, */ + .long PDMA_CH2_5_IRQHandler /* 31, 47, 0x0BC, */ + + + + .thumb + + +/* Reset Handler */ + + .section .text.reset_handler + .weak reset_handler + .type reset_handler, %function +reset_handler: + LDR R0, =__stack_end__ /* set stack pointer */ + MOV SP, R0 + LDR R0, =SystemInit + BLX R0 + BL _start + .size Reset_Handler, .-Reset_Handler + +/* Exception Handlers */ + + .weak NMI_Handler + .type NMI_Handler, %function +NMI_Handler: + B . + .size NMI_Handler, . - NMI_Handler + + .weak HardFault_Handler + .type HardFault_Handler, %function +HardFault_Handler: + B . + .size HardFault_Handler, . - HardFault_Handler + + .weak SVC_Handler + .type SVC_Handler, %function +SVC_Handler: + B . + .size SVC_Handler, . - SVC_Handler + + .weak PendSV_Handler + .type PendSV_Handler, %function +PendSV_Handler: + B . + .size PendSV_Handler, . - PendSV_Handler + + .weak SysTick_Handler + .type SysTick_Handler, %function +SysTick_Handler: + B . + .size SysTick_Handler, . - SysTick_Handler + + +/* IRQ Handlers */ + + .globl Default_Handler + .type Default_Handler, %function +Default_Handler: + B . + .size Default_Handler, . - Default_Handler + + .macro IRQ handler + .weak \handler + .set \handler, Default_Handler + .endm + + IRQ LVD_BOD_IRQHandler + IRQ RTC_IRQHandler + IRQ FLASH_IRQHandler + IRQ EVWUP_IRQHandler + IRQ EXTI0_1_IRQHandler + IRQ EXTI2_3_IRQHandler + IRQ EXTI4_15_IRQHandler + IRQ DAC0_1_IRQHandler + IRQ ADC_IRQHandler + IRQ I2C2_IRQHandler + IRQ SCTM0_IRQHandler + IRQ SCTM1_IRQHandler + IRQ PWM0_IRQHandler + IRQ BFTM0_IRQHandler + IRQ BFTM1_IRQHandler + IRQ I2C0_IRQHandler + IRQ I2C1_IRQHandler + IRQ SPI0_IRQHandler + IRQ USART0_IRQHandler + IRQ UART0_IRQHandler + IRQ PDMA_CH0_1_IRQHandler + IRQ PDMA_CH2_5_IRQHandler + + .end diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f0006.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f0006.c new file mode 100644 index 0000000000..aa9578190f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f0006.c @@ -0,0 +1,478 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f0006.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F0006 +// HT32F61352 + +//#define USE_HT32F0006 +//#define USE_HT32F61352 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 24 MHz to 48 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 48 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 24 MHz +// 1 WS: 24 MHz < CK_AHB <= 48 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_NF2_DIV (4) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = ((HSE or HSI) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO (HSI_VALUE * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO (HSE_VALUE * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 48000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 48000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 48000000UL +#define WS0_CLK 24000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + HT_CKCU->LPCR = 1; /* configure Backup domain isolation */ + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllFeedbackClockDiv = ((HT_CKCU->PLLCFGR >> 23) == 0) ? (16) : (HT_CKCU->PLLCFGR >> 23); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = ((HSI_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((HSE_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5826.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5826.c new file mode 100644 index 0000000000..9e59781925 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5826.c @@ -0,0 +1,508 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5826.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F5826 + +//#define USE_HT32F5826 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// Not apply to HT32F52220/30 +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = ((HSE or HSI) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 24 MHz to 48 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 48 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE (Not apply to HT32F52220/30) +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <9=> AUTO +// HT32F52331/41/42/52, HT32F5826 +// 0 WS: 1 kHz <= CK_AHB <= 24 MHz +// 1 WS: 24 MHz < CK_AHB <= 48 MHz +// HT32F52220/30/31/41/43/53 +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable (HT3F52342/52, HT32F5826 Only) +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_NF2_DIV (6) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = ((HSE or HSI) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if !defined(USE_HT32F52220_30) +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO (HSI_VALUE * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO (HSE_VALUE * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 48000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 48000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #ifdef USE_HT32F52220_30 + #error "CK_LSE can not be the source of SystemCoreClock for HT32F52220/30" + #else + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#if defined(USE_HT32F52331_41) || defined(USE_HT32F52342_52) || defined(USE_HT32F5826) + #define CKAHB_MIN 1000UL + #define CKAHB_MAX 48000000UL + #define WS0_CLK 24000000UL +#endif + +#if defined(USE_HT32F52220_30) || defined(USE_HT32F52231_41) || defined(USE_HT32F52243_53) + #define CKAHB_MIN 1000UL + #define CKAHB_MAX 40000000UL + #define WS0_CLK 20000000UL +#endif + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + HT_CKCU->LPCR = 1; /* configure Backup domain isolation */ + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + + while ((HT_PWRCU->CR & 0x00000200) != 0x00000200) /* Backup domain register access test */ + HT_PWRCU->CR = 0x00000200; + while ((HT_PWRCU->CR & 0x00000200) != 0x00000000) + HT_PWRCU->CR = 0x00000000; + HT_CKCU->LPCR = 0; + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if !defined(USE_HT32F52220_30) +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllFeedbackClockDiv = ((HT_CKCU->PLLCFGR >> 23) == 0) ? (16) : (HT_CKCU->PLLCFGR >> 23); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = ((HSI_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((HSE_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + #ifndef USE_HT32F52220_30 + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + #endif + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_01.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_01.c new file mode 100644 index 0000000000..e6f4c361e5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_01.c @@ -0,0 +1,518 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_01.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F52220, HT32F52230 +// HT32F52231, HT32F52241 +// HT32F52331, HT32F52341 +// HT32F52342, HT32F52352 +// HT32F52243, HT32F52253 +// HT50F32003 + +//#define USE_HT32F52220_30 +//#define USE_HT32F52231_41 +//#define USE_HT32F52331_41 +//#define USE_HT32F52342_52 +//#define USE_HT32F52243_53 +//#define USE_HT50F32003 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// Not apply to HT32F52220/30 +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = ((HSE or HSI) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 24 MHz to 48 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 48 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE (Not apply to HT32F52220/30) +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <9=> AUTO +// HT32F52331/41/42/52 +// 0 WS: 1 kHz <= CK_AHB <= 24 MHz +// 1 WS: 24 MHz < CK_AHB <= 48 MHz +// HT32F52220/30/31/41/43/53 +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable (HT3F52342/52 Only) +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_NF2_DIV (6) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = ((HSE or HSI) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if !defined(USE_HT32F52220_30) +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO (HSI_VALUE * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO (HSE_VALUE * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 48000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 48000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #ifdef USE_HT32F52220_30 + #error "CK_LSE can not be the source of SystemCoreClock for HT32F52220/30" + #else + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#if defined(USE_HT32F52331_41) || defined(USE_HT32F52342_52) + #define CKAHB_MIN 1000UL + #define CKAHB_MAX 48000000UL + #define WS0_CLK 24000000UL +#endif + +#if defined(USE_HT32F52220_30) || defined(USE_HT32F52231_41) || defined(USE_HT32F52243_53) + #define CKAHB_MIN 1000UL + #define CKAHB_MAX 40000000UL + #define WS0_CLK 20000000UL +#endif + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + HT_CKCU->LPCR = 1; /* configure Backup domain isolation */ + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + + while ((HT_PWRCU->CR & 0x00000200) != 0x00000200) /* Backup domain register access test */ + HT_PWRCU->CR = 0x00000200; + while ((HT_PWRCU->CR & 0x00000200) != 0x00000000) + HT_PWRCU->CR = 0x00000000; + HT_CKCU->LPCR = 0; + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if !defined(USE_HT32F52220_30) +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#ifdef USE_HT32F52342_52 +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllFeedbackClockDiv = ((HT_CKCU->PLLCFGR >> 23) == 0) ? (16) : (HT_CKCU->PLLCFGR >> 23); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = ((HSI_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((HSE_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + #ifndef USE_HT32F52220_30 + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + #endif + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_02.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_02.c new file mode 100644 index 0000000000..f864735544 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_02.c @@ -0,0 +1,525 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_02.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6953 $ + * @date $Date:: 2023-05-30 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F52220, HT32F52230 +// HT32F52231, HT32F52241 +// HT32F52331, HT32F52341 +// HT32F52342, HT32F52352 +// HT32F52243, HT32F52253 +// HT32F62030, HT32F62040, HT32F62050 +// HT32F67232, HT32F67233 +// HT32F67741, + +//#define USE_HT32F52220_30 +//#define USE_HT32F52231_41 +//#define USE_HT32F52331_41 +//#define USE_HT32F52342_52 +//#define USE_HT32F52243_53 +//#define USE_HT32F62030 +//#define USE_HT32F62040 +//#define USE_HT32F62050 +//#define USE_HT32F67232 +//#define USE_HT32F67233 +//#define USE_HT32F67741 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// Not apply to HT32F52220/30 +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = ((HSE or HSI) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 24 MHz to 48 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 48 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE (Not apply to HT32F52220/30) +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <9=> AUTO +// HT32F52331/41/42/52 +// 0 WS: 1 kHz <= CK_AHB <= 24 MHz +// 1 WS: 24 MHz < CK_AHB <= 48 MHz +// HT32F52220/30/31/41/43/53 +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable (HT3F52342/52 Only) +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_NF2_DIV (5) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = ((HSE or HSI) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if !defined(USE_HT32F52220_30) +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO (HSI_VALUE * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO (HSE_VALUE * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 48000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 48000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #ifdef USE_HT32F52220_30 + #error "CK_LSE can not be the source of SystemCoreClock for HT32F52220/30" + #else + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#if defined(USE_HT32F52331_41) || defined(USE_HT32F52342_52) + #define CKAHB_MIN 1000UL + #define CKAHB_MAX 48000000UL + #define WS0_CLK 24000000UL +#endif + +#if defined(USE_HT32F52220_30) || defined(USE_HT32F52231_41) || defined(USE_HT32F52243_53) + #define CKAHB_MIN 1000UL + #define CKAHB_MAX 40000000UL + #define WS0_CLK 20000000UL +#endif + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + HT_CKCU->LPCR = 1; /* configure Backup domain isolation */ + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + + while ((HT_PWRCU->CR & 0x00000200) != 0x00000200) /* Backup domain register access test */ + HT_PWRCU->CR = 0x00000200; + while ((HT_PWRCU->CR & 0x00000200) != 0x00000000) + HT_PWRCU->CR = 0x00000000; + HT_CKCU->LPCR = 0; + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if !defined(USE_HT32F52220_30) +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#ifdef USE_HT32F52342_52 +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllFeedbackClockDiv = ((HT_CKCU->PLLCFGR >> 23) == 0) ? (16) : (HT_CKCU->PLLCFGR >> 23); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = ((HSI_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((HSE_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + #ifndef USE_HT32F52220_30 + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + #endif + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_03.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_03.c new file mode 100644 index 0000000000..4da04c838a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_03.c @@ -0,0 +1,518 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_03.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 7370 $ + * @date $Date:: 2023-12-06 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F0008 +// HT32F52142 +// HT32F52344, HT32F52354 +// HT32F52357, HT32F52367 +// HT32F65230, HT32F65240 +// HT50F3200T + +//#define USE_HT32F0008 +//#define USE_HT32F52142 +//#define USE_HT32F52344_54 +//#define USE_HT32F52357_67 +//#define USE_HT32F65230_40 +//#define USE_HT50F3200T + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// Enable Waiting LSE Clock Ready +// Default Waiting LSE Clock Ready = ENABLE +// +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable (HT32F52357/67, HT32F65230/40, HT50F3200T Only) +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_WAIT_READY (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #ifndef USE_HT32F65230_40 + ResetBit_BB((u32)(&HT_CKCU->GCCR), 3); /* disable USB PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 9); /* select USB PLL source as HSI */ + #endif + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + #if (LSE_WAIT_READY == 1) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ + #endif +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if defined(USE_HT32F52357_67) || defined(USE_HT32F65230_40) +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_04.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_04.c new file mode 100644 index 0000000000..b709d27c6f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_04.c @@ -0,0 +1,335 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_04.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 7119 $ + * @date $Date:: 2023-08-15 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F50220, HT32F50230 +// HT32F50231, HT32F50241 +// HT50F32002 +// HT32F59041 +// HF5032 +// HT32F61641 +// HT32F59046 +// HT32F61041 + +//#define USE_HT32F50220_30 +//#define USE_HT32F50231_41 +//#define USE_HT50F32002 +//#define USE_HT32F59041 +//#define USE_HF5032 +//#define USE_HT32F61641 +//#define USE_HT32F59046 +//#define USE_HT32F61041 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 2 +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define HCLK_SRC (2) /*!< 0: N/A 1: N/A 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 20000000UL) + #error "CK_HSI clock issue: must be 20 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 20000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 20 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 20000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_CKCU->AHBCFGR = 1; /* set CK_AHB prescaler */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2)) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3)) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_05.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_05.c new file mode 100644 index 0000000000..e0460f199e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_05.c @@ -0,0 +1,497 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_05.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6993 $ + * @date $Date:: 2023-06-26 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F57331, HT32F57341 +// HT32F57342, HT32F57352 +// HT32F59741 +// HT32F5828 +// HT32F67742 +// HT32F59746 + +//#define USE_HT32F57331_41 +//#define USE_HT32F57342_52 +//#define USE_HT32F59741 +//#define USE_HT32F5828 +//#define USE_HT32F67742 +//#define USE_HT32F59746 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 3); /* disable USB PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 9); /* select USB PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_06.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_06.c new file mode 100644 index 0000000000..3be16d5319 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_06.c @@ -0,0 +1,488 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_06.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F50343 + + +//#define USE_HT32F50343 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 3); /* disable USB PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 9); /* select USB PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_07.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_07.c new file mode 100644 index 0000000000..3eb3d41a9c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_07.c @@ -0,0 +1,482 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_07.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F0006 +// HT32F61352 +// HT32F61355 +// HT32F61356 +// HT32F61357 + +//#define USE_HT32F0006 +//#define USE_HT32F61352 +//#define USE_HT32F61355_56_57 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL clock source x NF2 +// PLL feedback clock must be in the range of 24 MHz to 48 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 48 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 24 MHz +// 1 WS: 24 MHz < CK_AHB <= 48 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_NF2_DIV (4) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 9: WS = AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = ((HSE or HSI) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO (HSI_VALUE * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO (HSE_VALUE * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 48000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 48000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 48000000UL +#define WS0_CLK 24000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + HT_CKCU->LPCR = 1; /* configure Backup domain isolation */ + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllFeedbackClockDiv = ((HT_CKCU->PLLCFGR >> 23) == 0) ? (16) : (HT_CKCU->PLLCFGR >> 23); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = ((HSI_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((HSE_VALUE * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_08.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_08.c new file mode 100644 index 0000000000..e20480f1ed --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_08.c @@ -0,0 +1,518 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_08.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6877 $ + * @date $Date:: 2023-05-04 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F65230, HT32F65240 +// HT32F65232 +// MXTX6306 +// HT50F3200S + +//#define USE_HT32F65230_40 +//#define USE_HT32F65232 +//#define USE_MXTX6306 +//#define USE_HT50F3200S + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// HT32F65230/65240, MXTX6306, HT50F3200S Only +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE (HT32F65230/65240, MXTX6306, HT50F3200S Only) +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable (HT32F52357/67, HT32F65230/40, MXTX6306, HT50F3200S Only) +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if defined(USE_HT32F65230_40) +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif +#endif +#if defined(USE_HT32F65232) + #if (LSE_ENABLE == 1) + #error "Dose not support LSE!" + #endif +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if defined(USE_HT32F65230_40) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif + #if defined(USE_HT32F65232) + #error "Dose not support LSE!" + #endif + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if defined(USE_HT32F65230_40) +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable VDD power domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + #if defined(USE_HT32F65230_40) + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + #endif + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_09.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_09.c new file mode 100644 index 0000000000..a7b5f24091 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_09.c @@ -0,0 +1,489 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_09.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F54231, HT32F54241 +// HT32F54243, HT32F54253 + +//#define USE_HT32F54231_41 +//#define USE_HT32F54243_53 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x1 << 11); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 3); /* disable USB PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 9); /* select USB PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_10.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_10.c new file mode 100644 index 0000000000..704ebb5730 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_10.c @@ -0,0 +1,455 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_10.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F61244, HT32F61245 + +//#define USE_HT32F61244_45 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 48 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 48 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 48 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (0) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (4) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 48000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 48000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 48000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + ResetBit_BB((u32)(&HT_CKCU->AHBCCR), 11); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable VDD power domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_11.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_11.c new file mode 100644 index 0000000000..d1b2c20be4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_11.c @@ -0,0 +1,511 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_11.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F67041, HT32F67051 + +//#define USE_HT32F67041_51 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// HSE Output Clock Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// Default HSE output clock divider = 1 +// +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_CLK_DIV (1) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if (HSE_VALUE != 16000000UL) + #error "CK_HSE clock issue: must be 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_HSE definition + */ +#define __CK_HSE (HSE_VALUE >> HSE_CLK_DIV) /*!< Get CK_HSE frequency */ + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_PLL_IN frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_PLL_SRC (HSI_VALUE >> PLL_CLK_SRC_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_PLL_SRC (__CK_HSE >> PLL_CLK_SRC_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define PLL_SRC_MIN 4000000UL + #define PLL_SRC_MAX 16000000UL + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_PLL_IN frequency */ + #if ((__CK_PLL_SRC < PLL_SRC_MIN) || (__CK_PLL_SRC > PLL_SRC_MAX)) + #error "CK_PLL_SRC clock issue: must be in the range!" + #endif + + /* Get CK_VCO frequency */ + #define __CK_VCO (__CK_PLL_SRC * PLL_NF2_DIV) /*!< Get CK_VCO frequency */ + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS __CK_HSE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + ResetBit_BB((u32)(&HT_CKCU->AHBCCR), 11); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + HT_CKCU->GCFGR = (HT_CKCU->GCFGR & ~(3UL << 16)) | (HSE_CLK_DIV << 16); /* set HSE divider */ + + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + u32 HseClockDiv = (HT_CKCU->GCFGR >> 16) & 3UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = ((((HSE_VALUE >> HseClockDiv) >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = (HSE_VALUE >> HseClockDiv) >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_12.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_12.c new file mode 100644 index 0000000000..feca9dca25 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_12.c @@ -0,0 +1,485 @@ +/***************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_12.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6597 $ + * @date $Date:: 2022-12-27 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F61141 + +//#define USE_HT32F61141 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 48 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 48 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 48 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (0) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (6) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 48000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 48000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 48000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable VDD power domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_13.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_13.c new file mode 100644 index 0000000000..c906eb1640 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_13.c @@ -0,0 +1,325 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_13.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 7119 $ + * @date $Date:: 2023-08-15 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F50020, HT32F50030 +// HT32F61630 +// HT32F61030 + +//#define USE_HT32F50020_30 +//#define USE_HT32F61630 +//#define USE_HT32F61030 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 2 +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define HCLK_SRC (2) /*!< 0: N/A 1: N/A 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 16000000UL) + #error "CK_HSI clock issue: must be 16 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 16000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_CKCU->AHBCFGR = 1; /* set CK_AHB prescaler */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2)) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3)) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_14.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_14.c new file mode 100644 index 0000000000..2dc4216f4b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_14.c @@ -0,0 +1,487 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_14.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6790 $ + * @date $Date:: 2023-03-13 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F50442, HT32F50452 +// HT32F50431, HT32F50441 + +//#define USE_HT32F50442_52 +//#define USE_HT32F50431_41 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x1 << 11); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable VDD power domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_15.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_15.c new file mode 100644 index 0000000000..ad84d9825c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_15.c @@ -0,0 +1,487 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_15.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 6777 $ + * @date $Date:: 2023-03-06 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F53242, HT32F53252 +// HT32F53231, HT32F53241 + +//#define USE_HT32F53242_52 +//#define USE_HT32F53231_41 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x1 << 11); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable VDD power domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_16.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_16.c new file mode 100644 index 0000000000..5eb90ab190 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_16.c @@ -0,0 +1,472 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_16.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 7090 $ + * @date $Date:: 2023-08-02 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F66242 +// HT32F66246 + +//#define USE_HT32F66246 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 32 +// <1-32:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 64 MHz to 96 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 8 MHz to 96 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <3=> 3 WS +// <9=> AUTO +// 0 WS: 1 KHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// 3 WS: 60 MHz < CK_AHB <= 80 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (20) /*!< 1~32: DIV1~DIV32 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 3: WS = 3, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 64000000UL + #define VCO_MAX 96000000UL + #define PLL_MIN 8000000UL + #define PLL_MAX 96000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 80000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL +#define WS2_CLK 60000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS2_CLK) && (WAIT_STATE < 3) || \ + (__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x1 << 11); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x1F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS2_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 4UL); /* auto-select wait state */ + #elif (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 31UL) == 0) ? (32) : ((HT_CKCU->PLLCFGR >> 23) & 31UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_17.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_17.c new file mode 100644 index 0000000000..9eb200c400 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_17.c @@ -0,0 +1,488 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_17.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 7027 $ + * @date $Date:: 2023-07-18 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F52234, HT32F52244 + +//#define USE_HT32F52234_44 + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed Internal RC Oscillator (HSI) +// Default HSI = ENABLE +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (0) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable VDD power domain register clock */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x1 << 11); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable VDD power domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_18.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_18.c new file mode 100644 index 0000000000..ba5073e76f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_18.c @@ -0,0 +1,518 @@ +/**************************************************************************//** + * @file library/Device/Holtek/HT32F5xxxx/Source/system_ht32f5xxxx_18.c + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Source File + * for the Holtek HT32F5xxxx Device Series + * @version $Rev:: 7413 $ + * @date $Date:: 2023-12-15 #$ + * + * @note + * Copyright (C) Holtek Semiconductor Inc. All rights reserved. + * + * @par + * ARM Limited (ARM) supplies this software for Cortex-M processor-based + * microcontrollers. This file can be freely distributed within development + * tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +// Supported Device +// ======================================== +// HT32F0008 +// HT32F52142 +// HT32F52344, HT32F52354 +// HT32F52357, HT32F52367 +// HT32F65230, HT32F65240 +// HT50F3200T + +//#define USE_HT32F0008 +//#define USE_HT32F52142 +//#define USE_HT32F52344_54 +//#define USE_HT32F52357_67 +//#define USE_HT32F65230_40 +//#define USE_HT50F3200T + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup HT32F5xxxx_system HT32F5xxxx System + * @{ + */ + + +#include "ht32f5xxxx_01.h" + +/** @addtogroup HT32F5xxxx_System_Private_Defines + * @{ + */ +/* +//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +*/ + +/*--------------------- Clock Configuration ---------------------------------- +// +// Enable High Speed External Crystal Oscillator (HSE) +// Default HSE = DISABLE +// +// Enable Low Speed External Crystal Oscillator (LSE) +// Default LSE = DISABLE +// Enable Waiting LSE Clock Ready +// Default Waiting LSE Clock Ready = ENABLE +// +// +// Enable PLL +// Default PLL = DISABLE +// PLL Out = (((HSE or HSI) / SRC_DIV) x NF2 ) / NO2 +// PLL Clock Source +// <0=> CK_HSE +// <1=> CK_HSI +// Default PLL clock source = CK_HSI +// PLL source clock must be in the range of 4 MHz to 16 MHz +// PLL Clock Source Divider (SRC_DIV) +// <0=> 1 +// <1=> 2 +// PLL input clock = PLL Clock Source / (SRC_DIV) +// PLL Feedback Clock Divider (NF2): 1 ~ 16 +// <1-16:1> +// PLL feedback clock = PLL input clock x NF2 +// PLL feedback clock must be in the range of 24 MHz to 60 MHz +// PLL Output Clock Divider (NO2) +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// PLL output clock = PLL feedback clock / NO2 +// PLL output clock must be in the range of 4 MHz to 60 MHz +// +// +// SystemCoreClock Configuration (CK_AHB) +// SystemCoreClock Source +// <1=> CK_PLL +// <2=> CK_HSE +// <3=> CK_HSI +// <6=> CK_LSE +// <7=> CK_LSI +// Default SystemCoreClock source = CK_HSI +// SystemCoreClock Source Divider +// <0=> 1 +// <1=> 2 +// <2=> 4 +// <3=> 8 +// <4=> 16 +// <5=> 32 +// Default SystemCoreClock source divider = 1 +// +// +// FLASH Configuration +// Wait state +// <0=> 0 WS +// <1=> 1 WS +// <2=> 2 WS +// <9=> AUTO +// 0 WS: 1 kHz <= CK_AHB <= 20 MHz +// 1 WS: 20 MHz < CK_AHB <= 40 MHz +// 2 WS: 40 MHz < CK_AHB <= 60 MHz +// Pre-fetch Buffer Enable +// Default pre-fetch buffer = ENABLE +// Branch cache Enable (HT32F52357/67, HT32F65230/40, HT50F3200T Only) +// Default branch cache = ENABLE +// +*/ + +/* !!! NOTICE !!! + HSI must keep turn on when doing the Flash operation (Erase/Program). +*/ + +/* !!! NOTICE !!! + * How to adjust the value of High Speed External oscillator (HSE)? + The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h". + If your board uses a different HSE speed, please add a new compiler preprocessor + C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE, + or edit the "HSE_VALUE" in the "ht32f5xxxx_conf.h" file. + Take Keil MDK-ARM for instance, to set HSE as 16 MHz: + "Option of Taret -> C/C++ > Preprocessor Symbols" + Define: USE_HT32_DRIVER, USE_HT32Fxxxxx_SK, USE_HT32Fxxxxx_xx, USE_MEM_HT32Fxxxxx, HSE_VALUE=16000000 + ^^ Add "HSE_VALUE" + define as above. +*/ +#define HSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define HSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define LSI_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define LSE_WAIT_READY (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define PLL_CLK_SRC (1) /*!< 0: HSE, 1: HSI */ +#define PLL_CLK_SRC_DIV (1) /*!< 0: DIV1, 1: DIV2 */ +#define PLL_NF2_DIV (15) /*!< 1~16: DIV1~DIV16 */ +#define PLL_NO2_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8 */ +#define HCLK_SRC (1) /*!< 0: PLL, 1: PLL, 2: HSE, 3: HSI 6: LSE, 7: LSI */ +#define HCLK_DIV (0) /*!< 0: DIV1, 1: DIV2, 2: DIV4, 3: DIV8, 4: DIV16, 5: DIV32 */ +#define WAIT_STATE (9) /*!< 0: WS = 0, 1: WS = 1, 2: WS = 2, 9: AUTO */ +#define PRE_FETCH_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define BCACHE_ENABLE (1) /*!< 0: DISABLE, 1: ENABLE */ +#define DEINIT_ENABLE (1) /* Set 0 for reduce code size */ + +/*----------------------------------------------------------------------------------------------------------*/ +/* PLL Out = (((HSE or HSI) / (PLL_CLK_SRC_DIV + 1)) x PLL_NF2) / PLL_NO2 */ +/*----------------------------------------------------------------------------------------------------------*/ + + +/*--------------------- WDT Configuration ---------------------------------- +// +// Enable WDT Configuration +// WDT Prescaler Selection +// <0=> CK_WDT / 1 +// <1=> CK_WDT / 2 +// <2=> CK_WDT / 4 +// <3=> CK_WDT / 8 +// <4=> CK_WDT / 16 +// <5=> CK_WDT / 32 +// <6=> CK_WDT / 64 +// <7=> CK_WDT / 128 +// WDT Reload Value <1-4095:1> +// Enable WDT Reset function +// WDT Sleep Halt mode +// <0=> No halt +// <1=> Halt in DeepSleep1 +// <2=> Halt in Sleep & DeepSleep1 +// +*/ +#define WDT_ENABLE (0) /*!< 0: DISABLE, 1: ENABLE */ +#define WDT_PRESCALER (5) /*!< 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64, 7: 1/128 */ +#define WDT_RELOAD (2000) /*!< 0 ~ 4095, 12 bit */ +#define WDT_RESET_ENABLE (1) /*!< 0: No Reset, 1: Reset when WDT over flow */ +#define WDT_SLEEP_HALT (2) /*!< 0: No halt, 1: Halt in DeepSleep1, 2: Halt in Sleep & DeepSleep1 */ + +/** + * @brief Check HSI frequency + */ +#if (HSI_VALUE != 8000000UL) + #error "CK_HSI clock issue: must be 8 MHz!" +#endif + +/** + * @brief Check HSE frequency + */ +#if ((HSE_VALUE < 4000000UL) || (HSE_VALUE > 16000000UL)) + #error "CK_HSE clock issue: must be in the range of 4 MHz to 16 MHz!" +#endif + +/** + * @brief Check LSI frequency + */ +#if (LSI_VALUE != 32000UL) + #error "CK_LSI clock issue: must be 32 kHz!" +#endif + +/** + * @brief Check LSE frequency + */ +#if (LSE_VALUE != 32768UL) + #error "CK_LSE clock issue: must be 32.768 kHz!" +#endif + +/** + * @brief CK_PLL definition + */ +#if (PLL_ENABLE == 1) + /* Get CK_VCO frequency */ + #if (PLL_CLK_SRC == 1) + #if (HSI_ENABLE == 0) + #error "CK_PLL clock source issue: HSI has not been enabled" + #else + #define __CK_VCO ((HSI_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSI as PLL source */ + #endif + #else + #if (HSE_ENABLE == 0) + #error "CK_PLL clock source issue: HSE has not been enabled!" + #else + #define __CK_VCO ((HSE_VALUE >> PLL_CLK_SRC_DIV) * PLL_NF2_DIV) /*!< Select HSE as PLL source */ + #endif + #endif + + #define VCO_MIN 24000000UL + #define VCO_MAX 60000000UL + #define PLL_MIN 4000000UL + #define PLL_MAX 60000000UL + + /* Check CK_VCO frequency */ + #if ((__CK_VCO < VCO_MIN) || (__CK_VCO > VCO_MAX)) + #error "CK_VCO clock issue: must be in the range!" + #endif + + #define __CK_PLL (__CK_VCO >> PLL_NO2_DIV) /*!< Get CK_PLL frequency */ + + /* Check CK_PLL frequency */ + #if ((__CK_PLL < PLL_MIN) || (__CK_PLL > PLL_MAX)) + #error "CK_PLL clock issue: must be in the range!" + #endif +#endif + +/** + * @brief CK_SYS definition + */ +#if (HCLK_SRC == 1) + #if (PLL_ENABLE == 1) + #define __CK_SYS __CK_PLL /*!< Select PLL as CK_SYS source */ + #else + #error "CK_SYS clock source issue: PLL is not enable!" + #endif +#elif (HCLK_SRC == 2) + #if (HSE_ENABLE == 1) + #define __CK_SYS HSE_VALUE /*!< Select HSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSE is not enable!" + #endif +#elif (HCLK_SRC == 3) + #if (HSI_ENABLE == 1) + #define __CK_SYS HSI_VALUE /*!< Select HSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: HSI is not enable!" + #endif +#elif (HCLK_SRC == 6) + #if (LSE_ENABLE == 1) + #define __CK_SYS LSE_VALUE /*!< Select LSE as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSE is not enable!" + #endif +#elif (HCLK_SRC == 7) + #if (LSI_ENABLE == 1) + #define __CK_SYS LSI_VALUE /*!< Select LSI as CK_SYS source */ + #else + #error "CK_SYS clock source issue: LSI is not enable!" + #endif +#else + #error "CK_SYS clock source issue: No clock source is selected!" +#endif + +/** + * @brief CK_AHB definition + */ +#define __CK_AHB (__CK_SYS >> HCLK_DIV) /*!< Get CK_AHB frequency */ + +#define CKAHB_MIN 1000UL +#define CKAHB_MAX 60000000UL +#define WS0_CLK 20000000UL +#define WS1_CLK 40000000UL + +/* Check CK_AHB frequency */ +#if ((__CK_AHB < CKAHB_MIN) || (__CK_AHB > CKAHB_MAX)) + #error "CK_AHB clock issue: must be in the range!" +#endif + +/* Check FLASH wait-state setting */ +#if ((__CK_AHB > WS1_CLK) && (WAIT_STATE < 2) || \ + (__CK_AHB > WS0_CLK) && (WAIT_STATE < 1)) + #error "FLASH wait state configuration issue!" +#endif +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Variables + * @{ + */ +__IO uint32_t SystemCoreClock = __CK_AHB; /*!< SystemCoreClock = CK_AHB */ +/** + * @} + */ + +/** @addtogroup HT32F5xxxx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * Initializes the system clocks and the embedded Flash. + * @note This function should be used after reset. + * @retval None + */ +void SystemInit(void) +{ +#if (WDT_ENABLE == 1) + HT_CKCU->APBCCR1 |= (0x1 << 4); + HT_WDT->PR = 0x35CA; + HT_WDT->MR0 = 0; + HT_WDT->MR1 = ((HT_WDT->MR1 & 0xFFF) | (WDT_PRESCALER << 12)); + HT_WDT->MR0 = WDT_RELOAD | (WDT_RESET_ENABLE << 13) | (WDT_SLEEP_HALT << 14) | (0x1 << 16); + HT_WDT->CR = 0x5FA00001; +#else + #if (DEINIT_ENABLE == 1) + HT_RSTCU->APBPRST1 = (1 << 4); + #endif +#endif + + SetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* enable Backup domain register clock */ + while (HT_PWRCU->TEST != 0x27); /* wait for Backup domain register ready */ + + #if (DEINIT_ENABLE == 1) + /* De-init the setting */ + HT_CKCU->AHBCCR &= ~(0x3 << 10); /* disable IP who may use PLL as source */ + SetBit_BB((u32)(&HT_CKCU->GCCR), 11); /* enable HSI */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 3)); /* wait for HSI ready */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | 3UL); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != 3UL); /* wait for clock switch complete */ + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 1UL); /* set Wait State as 0 WS */ + HT_CKCU->AHBCFGR = 0; /* set CK_AHB prescaler */ + ResetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* disable PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #ifndef USE_HT32F65230_40 + ResetBit_BB((u32)(&HT_CKCU->GCCR), 3); /* disable USB PLL */ + SetBit_BB((u32)(&HT_CKCU->GCFGR), 9); /* select USB PLL source as HSI */ + #endif + #endif + + /* HSE initiation */ +#if (HSE_ENABLE == 1) + SetBit_BB((u32)(&HT_CKCU->GCCR), 10); /* enable HSE */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 2)){}; /* wait for HSE ready */ +#endif + + /* LSE initiation */ +#if (LSE_ENABLE == 1) + do { + SetBit_BB((u32)(&HT_RTC->CR), 3); /* enable LSE */ + } while (!GetBit_BB((u32)(&HT_RTC->CR), 3)); + #if (LSE_WAIT_READY == 1) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 4)); /* wait for LSE ready */ + #endif +#endif + + ResetBit_BB((u32)(&HT_CKCU->APBCCR1), 6); /* disable Backup domain register clock */ + + /* LSI initiation */ +#if (HCLK_SRC == 7) + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 5)){}; /* wait for LSI ready */ +#endif + + /* PLL initiation */ +#if (PLL_ENABLE == 1) + HT_CKCU->PLLCFGR = ((PLL_NF2_DIV & 0x0F) << 23) | (PLL_NO2_DIV << 21); /* set PLL divider */ + + #if (PLL_CLK_SRC_DIV == 1) + SetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* set PLL clock source divider */ + #else + ResetBit_BB((u32)(&HT_CKCU->PLLCFGR), 28); /* reset PLL clock source divider */ + #endif + + #if (PLL_CLK_SRC == 0) + ResetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSE */ + #else + SetBit_BB((u32)(&HT_CKCU->GCFGR), 8); /* select PLL source as HSI */ + #endif + + SetBit_BB((u32)(&HT_CKCU->GCCR), 9); /* enable PLL */ + while (!GetBit_BB((u32)(&HT_CKCU->GCSR), 1)){}; /* wait for PLL ready */ +#endif + + /* CK_AHB initiation */ +#if (WAIT_STATE == 9) + #if (__CK_AHB > WS1_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 3UL); /* auto-select wait state */ + #elif (__CK_AHB > WS0_CLK) + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | 2UL); /* auto-select wait state */ + #endif +#else + HT_FLASH->CFCR = (((HT_FLASH->CFCR) & ~7UL) | (WAIT_STATE + 1)); /* manual wait state */ +#endif + + HT_CKCU->AHBCFGR = HCLK_DIV; /* set CK_AHB prescaler */ + HT_CKCU->GCCR = ((HT_CKCU->GCCR & ~7UL) | HCLK_SRC); /* select CK_SYS source */ + while ((HT_CKCU->CKST & 7UL) != HCLK_SRC); /* wait for clock switch complete */ + + /* Pre-fetch buffer configuration */ +#if (PRE_FETCH_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 4); /* 0: pre-fetch disable, 1: pre-fetch enable */ +#endif + + /* Branch cache configuration */ +#if defined(USE_HT32F52357_67) || defined(USE_HT32F65230_40) +#if (BCACHE_ENABLE == 0) + ResetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#else + SetBit_BB((u32)(&HT_FLASH->CFCR), 12); /* 0: branch cache disable, 1: branch cache enable */ +#endif +#endif + + /* HSE power down */ +#if ((HSE_ENABLE == 0) && (HCLK_SRC != 2) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 1))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 10); +#endif + + /* HSI power down */ +#if ((HSI_ENABLE == 0) && (HCLK_SRC != 3) && ((PLL_ENABLE == 0) || (PLL_CLK_SRC == 0))) + ResetBit_BB((u32)(&HT_CKCU->GCCR), 11); +#endif +} + +/** + * @brief Update SystemCoreClock + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + u32 SystemCoreClockDiv = HT_CKCU->AHBCFGR & 7UL; + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + u32 PllFeedbackClockDiv = (((HT_CKCU->PLLCFGR >> 23) & 15UL) == 0) ? (16) : ((HT_CKCU->PLLCFGR >> 23) & 15UL); + u32 PllOutputClockDiv = (HT_CKCU->PLLCFGR >> 21) & 3UL; + u32 SystemCoreClockSrc = HT_CKCU->CKST & 7UL; + + /* Get system core clock according to global clock control & configuration registers */ + if (SystemCoreClockSrc == 1) + { + if (GetBit_BB((u32)(&HT_CKCU->PLLCR), 31)) + { + PllFeedbackClockDiv = 1; + PllOutputClockDiv = 0; + } + + if (GetBit_BB((u32)(&HT_CKCU->GCFGR), 8)) + { + SystemCoreClock = (((HSI_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + else + { + SystemCoreClock = (((HSE_VALUE >> PllSourceClockDiv) * PllFeedbackClockDiv) >> PllOutputClockDiv) >> SystemCoreClockDiv; + } + } + else if (SystemCoreClockSrc == 2) + { + SystemCoreClock = HSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 3) + { + SystemCoreClock = HSI_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 6) + { + SystemCoreClock = LSE_VALUE >> SystemCoreClockDiv; + } + else if (SystemCoreClockSrc == 7) + { + SystemCoreClock = LSI_VALUE >> SystemCoreClockDiv; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT Holtek Semiconductor Inc. *****END OF FILE*** */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32.h new file mode 100644 index 0000000000..ccedbb647f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32.h @@ -0,0 +1,35 @@ +/*********************************************************************************************************//** + * @file ht32.h + * @version $Rev:: 1704 $ + * @date $Date:: 2017-08-17 #$ + * @brief The API between application and HT32FXXXX Firmware Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_H +#define __HT32_H + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_01.h" + +#endif /* __HT32_H -----------------------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_cm0plus_misc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_cm0plus_misc.h new file mode 100644 index 0000000000..8919d357bc --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_cm0plus_misc.h @@ -0,0 +1,132 @@ +/*********************************************************************************************************//** + * @file ht32_cm0plus_misc.h + * @version $Rev:: 750 $ + * @date $Date:: 2016-05-31 #$ + * @brief All the function prototypes for the miscellaneous firmware library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_CM0PLUS_MISC_H +#define __HT32_CM0PLUS_MISC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32_Peripheral_Driver + * @{ + */ + +/** @addtogroup MISC + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Exported_Constants MISC exported constants + * @{ + */ + +/* Vector Table Base */ +#define NVIC_VECTTABLE_RAM ((u32)0x20000000) +#define NVIC_VECTTABLE_FLASH ((u32)0x00000000) + +#define IS_NVIC_VECTTABLE(VECTTABLE) ((VECTTABLE == NVIC_VECTTABLE_RAM) || \ + (VECTTABLE == NVIC_VECTTABLE_FLASH)) + +#define IS_NVIC_OFFSET(OFFSET) (OFFSET < 0x0001FFFF) + +/* System Low Power */ +#define NVIC_LOWPOWER_SEVONPEND ((u8)0x10) +#define NVIC_LOWPOWER_SLEEPDEEP ((u8)0x04) +#define NVIC_LOWPOWER_SLEEPONEXIT ((u8)0x02) + +#define IS_NVIC_LOWPOWER(LOWPOWER) ((LOWPOWER == NVIC_LOWPOWER_SEVONPEND) || \ + (LOWPOWER == NVIC_LOWPOWER_SLEEPDEEP) || \ + (LOWPOWER == NVIC_LOWPOWER_SLEEPONEXIT)) + +/* System Handler */ +#define SYSTEMHANDLER_NMI ((u32)0x80000000) +#define SYSTEMHANDLER_PSV ((u32)0x10000000) +#define SYSTEMHANDLER_SYSTICK ((u32)0x04000000) +#define SYSTEMHANDLER_ALL ((u32)0x94000000) + +#define IS_NVIC_SYSTEMHANDLER(HANDLER) ((HANDLER == SYSTEMHANDLER_NMI) || \ + (HANDLER == SYSTEMHANDLER_PSV) || \ + (HANDLER == SYSTEMHANDLER_SYSTICK) ||\ + (HANDLER == SYSTEMHANDLER_ALL)) + +/* SysTick clock source */ +#define SYSTICK_SRC_STCLK ((u32)0xFFFFFFFB) +#define SYSTICK_SRC_FCLK ((u32)0x00000004) + +#define IS_SYSTICK_CLOCK_SOURCE(SOURCE) ((SOURCE == SYSTICK_SRC_STCLK) || \ + (SOURCE == SYSTICK_SRC_FCLK) ) + +/* SysTick counter state */ +#define SYSTICK_COUNTER_DISABLE ((u32)0xFFFFFFFE) +#define SYSTICK_COUNTER_ENABLE ((u32)0x00000001) +#define SYSTICK_COUNTER_CLEAR ((u32)0x00000000) + +#define IS_SYSTICK_COUNTER(COUNTER) ((COUNTER == SYSTICK_COUNTER_DISABLE) || \ + (COUNTER == SYSTICK_COUNTER_ENABLE) || \ + (COUNTER == SYSTICK_COUNTER_CLEAR)) + +#define IS_SYSTICK_RELOAD(RELOAD) ((RELOAD > 0) && (RELOAD <= 0xFFFFFF)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Exported_Functions MISC exported functions + * @{ + */ +void NVIC_SetVectorTable(u32 NVIC_VectTable, u32 NVIC_Offset); +void NVIC_LowPowerConfig(u8 NVIC_LowPowerMode, ControlStatus NewState); +void NVIC_SetPendingSystemHandler(u32 SystemHandler); +void SYSTICK_ClockSourceConfig(u32 SysTick_ClockSource); +void SYSTICK_CounterCmd(u32 SysTick_Counter); +void SYSTICK_IntConfig(ControlStatus NewState); +void SYSTICK_SetReloadValue(u32 SysTick_Reload); +u32 RBIT(u32 in); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_config.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_config.h new file mode 100644 index 0000000000..bd4e561247 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_config.h @@ -0,0 +1,307 @@ +/*********************************************************************************************************//** + * @file ht32_config.h + * @version $Rev:: 7125 $ + * @date $Date:: 2023-08-16 #$ + * @brief Configuration file of HT32. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_CONFIG_H +#define __HT32_CONFIG_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Settings ------------------------------------------------------------------------------------------------*/ +#ifdef USE_HT32F59999_SK + #define USE_HT32F52352_SK +#endif +#ifdef USE_HT32F59999 + #define USE_HT32F52342_52 +#endif +#ifdef USE_MEM_HT32F59999 + #define USE_MEM_HT32F52352 +#endif + +#ifdef USE_HT32F52142_SK + #define USE_HT32F0008_SK +#endif +#ifdef USE_HT32F52142 + #define USE_HT32F0008 +#endif +#ifdef USE_MEM_HT32F52142 + #define USE_MEM_HT32F0008 +#endif + +#ifdef USE_HT32F61352_DVB + #define USE_HT32F0006_DVB +#endif +#ifdef USE_HT32F61352 + #define USE_HT32F0006 +#endif +#ifdef USE_MEM_HT32F61352 + #define USE_MEM_HT32F0006 +#endif +#ifdef USE_HT32F61355_56_57 + #define USE_HT32F0006 +#endif +#ifdef USE_MEM_HT32F61355 + #define USE_MEM_HT32F0006 +#endif +#ifdef USE_MEM_HT32F61356 + #define USE_MEM_HT32F0006 +#endif +#ifdef USE_MEM_HT32F61357 + #define USE_MEM_HT32F0006 +#endif + +#ifdef USE_HT50F32002_SK + #define USE_HT32F50230_SK +#endif +#ifdef USE_HT50F32002 + #define USE_HT32F50220_30 +#endif +#ifdef USE_MEM_HT50F32002 + #define USE_MEM_HT32F50230 +#endif + +#ifdef USE_HT50F32003_SK + #define USE_HT32F52352_SK +#endif +#ifdef USE_HT50F32003 + #define USE_HT32F52342_52 +#endif +#ifdef USE_MEM_HT50F32003 + #define USE_MEM_HT32F52352 +#endif + +#ifdef USE_HT32F59041_SK + #define USE_HT32F50241_SK +#endif +#ifdef USE_HT32F59041 + #define USE_HT32F50231_41 +#endif +#ifdef USE_MEM_HT32F59041 + #define USE_MEM_HT32F50241 +#endif + +#ifdef USE_HT32F59741_SK + #define USE_HT32F57341_SK +#endif +#ifdef USE_HT32F59741 + #define USE_HT32F57331_41 +#endif +#ifdef USE_MEM_HT32F59741 + #define USE_MEM_HT32F57341 +#endif + +#ifdef USE_HT32F67741_SK + #define USE_HT32F52241_SK +#endif +#ifdef USE_HT32F67741 + #define USE_HT32F52231_41 +#endif +#ifdef USE_MEM_HT32F67741 + #define USE_MEM_HT32F52241 +#endif + +#ifdef USE_HF5032_SK + #define USE_HT32F50230_SK +#endif +#ifdef USE_HF5032 + #define USE_HT32F50220_30 +#endif +#ifdef USE_MEM_HF5032 + #define USE_MEM_HT32F50230 +#endif + +#ifdef USE_HT32F65240 + #undef USE_HT32F65230_40 + #define USE_HT32F65230_40 +#elif defined USE_HT32F65230_40 + #undef USE_HT32F65240 + #define USE_HT32F65240 +#endif + +#ifdef USE_HT32F5828_SK + #define USE_HT32F57352_SK +#endif +#ifdef USE_HT32F5828 + #define USE_HT32F57342_52 +#endif +#ifdef USE_MEM_HT32F5828 + #define USE_MEM_HT32F57352 +#endif + +#ifdef USE_MXTX6306_SK + #define USE_HT32F65240_SK +#endif +#ifdef USE_MXTX6306 + #define USE_HT32F65230_40 +#endif +#ifdef USE_MEM_MXTX6306 + #define USE_MEM_HT32F65230 +#endif + +#ifdef USE_HT32F67232_SK + #define USE_HT32F52230_SK +#endif +#ifdef USE_HT32F67232 + #define USE_HT32F52220_30 +#endif +#ifdef USE_MEM_HT32F67232 + #define USE_MEM_HT32F52230 +#endif + +#ifdef USE_HT32F67233 + #define USE_HT32F52220_30 +#endif +#ifdef USE_MEM_HT32F67233 + #define USE_MEM_HT32F52230 +#endif + +#ifdef USE_HT50F3200S_SK + #define USE_HT32F65240_SK +#endif +#ifdef USE_HT50F3200S + #define USE_HT32F65230_40 +#endif +#ifdef USE_MEM_HT50F3200S + #define USE_MEM_HT32F65240 +#endif + +#ifdef USE_HT50F3200T_SK + #define USE_HT32F52367_SK +#endif +#ifdef USE_HT50F3200T + #define USE_HT32F52357_67 +#endif +#ifdef USE_MEM_HT50F3200T + #define USE_MEM_HT32F52367 +#endif + +#ifdef USE_HT32F62030_SK + #define USE_HT32F52230_SK +#endif +#ifdef USE_HT32F62030 + #define USE_HT32F52220_30 +#endif +#ifdef USE_MEM_HT32F62030 + #define USE_MEM_HT32F52230 +#endif + +#ifdef USE_HT32F62040_SK + #define USE_HT32F52241_SK +#endif +#ifdef USE_HT32F62040 + #define USE_HT32F52231_41 +#endif +#ifdef USE_MEM_HT32F62040 + #define USE_MEM_HT32F52241 +#endif + +#ifdef USE_HT32F62050_SK + #define USE_HT32F52253_SK +#endif +#ifdef USE_HT32F62050 + #define USE_HT32F52243_53 +#endif +#ifdef USE_MEM_HT32F62050 + #define USE_MEM_HT32F52253 +#endif + +#ifdef USE_HT32F61630_SK + #define USE_HT32F50030_SK +#endif +#ifdef USE_HT32F61630 + #define USE_HT32F50020_30 +#endif +#ifdef USE_MEM_HT32F61630 + #define USE_MEM_HT32F50030 +#endif + +#ifdef USE_HT32F61641_SK + #define USE_HT32F50241_SK +#endif +#ifdef USE_HT32F61641 + #define USE_HT32F50231_41 +#endif +#ifdef USE_MEM_HT32F61641 + #define USE_MEM_HT32F50241 +#endif + +#ifdef USE_HT32F67742_SK + #define USE_HT32F57341_SK +#endif +#ifdef USE_HT32F67742 + #define USE_HT32F57331_41 +#endif +#ifdef USE_MEM_HT32F67742 + #define USE_MEM_HT32F57341 +#endif + +#ifdef USE_HT32F59046_SK + #define USE_HT32F50241_SK +#endif +#ifdef USE_HT32F59046 + #define USE_HT32F50231_41 +#endif +#ifdef USE_MEM_HT32F59046 + #define USE_MEM_HT32F50241 +#endif + +#ifdef USE_HT32F59746_SK + #define USE_HT32F57341_SK +#endif +#ifdef USE_HT32F59746 + #define USE_HT32F57331_41 +#endif +#ifdef USE_MEM_HT32F59746 + #define USE_MEM_HT32F57341 +#endif + +#ifdef USE_HT32F61030_SK + #define USE_HT32F50030_SK +#endif +#ifdef USE_HT32F61030 + #define USE_HT32F50020_30 +#endif +#ifdef USE_MEM_HT32F61030 + #define USE_MEM_HT32F50030 +#endif + +#ifdef USE_HT32F61041_SK + #define USE_HT32F50241_SK +#endif +#ifdef USE_HT32F61041 + #define USE_HT32F50231_41 +#endif +#ifdef USE_MEM_HT32F61041 + #define USE_MEM_HT32F50241 +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_dependency.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_dependency.h new file mode 100644 index 0000000000..d96ecb9c3c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_dependency.h @@ -0,0 +1,86 @@ +/*********************************************************************************************************//** + * @file ht32_dependency.h + * @version $Rev:: 5863 $ + * @date $Date:: 2022-05-12 #$ + * @brief The header file of dependency check. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +#ifdef __cplusplus + extern "C" { +#endif + + +#if 0 // Version setting example for module + +/* Dependency check ----------------------------------------------------------------------------------------*/ +#define MIN_HT32_FWLIB_VER (0x01000005) //0xmmnnnrrr -> Vm.n.r +#define MIN_HT32_FWLIB_SVN (0x2200) +#include "ht32_dependency.h" // Not exist means the version of HT32 Firmware Library is older than the module required. + +#endif + +#if 0 // Version setting example for module + +/* Dependency check ----------------------------------------------------------------------------------------*/ +#if (__CORTEX_M == 0) +#define MIN_HT32_FWLIB_VER (0x01000024) //0xmmnnnrrr -> Vm.n.r +#define MIN_HT32_FWLIB_SVN (0x5762) +#endif +#if (__CORTEX_M == 3) +#define MIN_HT32_FWLIB_VER (0x01000009) //0xmmnnnrrr -> Vm.n.r +#define MIN_HT32_FWLIB_SVN (0x2556) +#endif +#include "ht32_dependency.h" // Not exist means the version of HT32 Firmware Library is older than the module required. + +#endif + + +#if 0 // Enable for test +#undef HT32_FWLIB_VER +#undef HT32_FWLIB_SVN +#define HT32_FWLIB_VER (0x00000004) +#define HT32_FWLIB_SVN (0x1074) +#endif + + +// Check "ht32fxxxxx_lib.h" for the version of HT32 Firmwar Library +#if (HT32_FWLIB_VER != 999999) +#if HT32_FWLIB_VER < MIN_HT32_FWLIB_VER + #error !!! The version of HT32 Firmware Library is older than the module required. Please update HT32 Firmware Library. +#endif + +#if HT32_FWLIB_SVN < MIN_HT32_FWLIB_SVN + #error !!! The version of HT32 Firmware Library is older than the module required. Please update HT32 Firmware Library. +#endif +#endif + + +// Un-defined for next module of the .C include .C case +#undef MIN_HT32_FWLIB_VER +#undef MIN_HT32_FWLIB_SVN + + +#ifdef __cplusplus +} +#endif + +//#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_div.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_div.h new file mode 100644 index 0000000000..7fa7c168c1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_div.h @@ -0,0 +1,37 @@ +/*********************************************************************************************************//** + * @file ht32_div.h + * @version $Rev:: 220 $ + * @date $Date:: 2016-02-16 #$ + * @brief The header file of division assembly. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_DIV_H +#define __HT32_DIV_H + +/* Exported functions --------------------------------------------------------------------------------------*/ +void DIV32_Init(void); +extern u32 (*UDIV32)(u32, u32); +extern s32 (*SDIV32)(s32, s32); + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_rand.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_rand.h new file mode 100644 index 0000000000..46827ba414 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_rand.h @@ -0,0 +1,43 @@ +/*********************************************************************************************************//** + * @file ht32_rand.h + * @version $Rev:: 957 $ + * @date $Date:: 2016-08-15 #$ + * @brief The header file of random number. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_RAND_H +#define __HT32_RAND_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported functions --------------------------------------------------------------------------------------*/ +void Rand_Init(u32 *uSeed, u32 uCount, u32 a, u32 b); +extern u32 (*Rand_Get)(u32 *, u32); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_desc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_desc.h new file mode 100644 index 0000000000..9605a27597 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_desc.h @@ -0,0 +1,182 @@ +/*********************************************************************************************************//** + * @file ht32_retarget_desc.h + * @version $Rev:: 891 $ + * @date $Date:: 2016-07-14 #$ + * @brief The USB VCP descriptor file of retarget. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_RETARGET_DESC_H +#define __HT32_RETARGET_DESC_H + +/* Exported constants --------------------------------------------------------------------------------------*/ + + /*--------------------------------------------------------------------------------------------------------*/ + /* IAD to associate the two CDC interfaces */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + 8, // bLength 1 Size of this descriptor in bytes + 11, // bDescriptorType 1 Descriptor Type + 11, // bFirstInterface 1 + 2, // bInterfaceCount 1 + 2, // bFunctionClass 1 + 2, // bFunctionSubClass 1 + 0, // bFunctionProtocol 1 + 0x00, // iFunction 1 Index of string descriptor describing this function. + + /*--------------------------------------------------------------------------------------------------------*/ + /* Interface descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_INF, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_04_INF, // bDescriptorType 1 INTERFACE Descriptor Type + 11, // bInterfaceNumber 1 Number of this interface (Zero-based 0) + 0x00, // bAlternateSetting 1 Value used to select alternate setting + 1, // bNumEndpoints 1 Number of endpoints used by this interface + DESC_CLASS_02_CDC_CTRL, // bInterfaceClass 1 Class code (assigned by USB-IF) + 2, // bInterfaceSubClass 1 Subclass code (assigned by USB-IF) + 0, // bInterfaceProtocol 1 Protocol code (assigned by USB) + 0x00, // iInterface 1 Index of string descriptor describing this interface + + /*--------------------------------------------------------------------------------------------------------*/ + /* Header Functional descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 5, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 0, // bDescriptorSubtype 1 header functional descriptor + DESC_H2B(0x0110), // bcdCDC 2 spec release number + + /*--------------------------------------------------------------------------------------------------------*/ + /* Abstract control management Functional */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 4, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 2, // bDescriptorSubtype 1 Abstract Control Management Functional descriptor + 0x02, // bmCapabilities 1 + + /*--------------------------------------------------------------------------------------------------------*/ + /* Union Functional */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 5, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 5, // bDescriptorSubtype 1 Union Functional descriptor + 0x00, // bMasterInterface 1 Communication class interface + 0x01, // bSlaveInterface0 1 Data Class Interface + + /*--------------------------------------------------------------------------------------------------------*/ + /* Call Management Functional */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + 5, // bFunctionLength 1 Size of this descriptor in bytes + 0x24, // bDescriptorType 1 CS_INTERFACE descriptor type + 1, // bDescriptorSubtype 1 Call Management Functional descriptor + 0x00, // bmCapabilities 1 + 0x01, // bDataInterface 1 Interface number of Data + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLengthE 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + (0x80 | RETARGET_CTRL_EPT), // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x03, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(RETARGET_CTRL_LEN),// wMaxPacketSize 2 Maximum packet size + 0x00, // bInterval 1 Interval for polling endpoint + + /*--------------------------------------------------------------------------------------------------------*/ + /* Data class interface descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_INF, // bLength 1 Endpoint Descriptor size + DESC_TYPE_04_INF, // bDescriptorType 1 + 12, // bInterfaceNumber 1 Number of Interface + 0x00, // bAlternateSetting 1 Alternate setting + 2, // bNumEndpoints 1 Two endpoints used + DESC_CLASS_0A_CDC_DATA, // bInterfaceClass 1 + 0, // bInterfaceSubClass 1 + 0, // bInterfaceProtocol 1 + 0x00, // iInterface 1 + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint n Out descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + (0x00 | RETARGET_RX_EPT), // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x02, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(RETARGET_RX_LEN), // wMaxPacketSize 2 Maximum packet size + 0x00, // bInterval 1 Interval for polling endpoint + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint n In Descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + (0x80 | RETARGET_TX_EPT), // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x02, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(RETARGET_TX_LEN), // wMaxPacketSize 2 Maximum packet size + 0x00, // bInterval 1 Interval for polling endpoint + +#endif /* __HT32_RETARGET_DESC_H ---------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_usbdconf.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_usbdconf.h new file mode 100644 index 0000000000..f06a334604 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_retarget_usbdconf.h @@ -0,0 +1,321 @@ +/*********************************************************************************************************//** + * @file ht32_retarget_usbdconf.h + * @version $Rev:: 4447 $ + * @date $Date:: 2019-12-27 #$ + * @brief The USB Device configuration of retarget + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_RETARGET_USBDCONF_H +#define __HT32_RETARGET_USBDCONF_H + +/* Settings ------------------------------------------------------------------------------------------------*/ +#define RETARGET_INF (0) +#define RETARGET_DLEN (0) + +#if (_RETARGET == 1) + + #ifdef RETARGET_IS_USB + + #undef RETARGET_INF + #undef RETARGET_DLEN + #define RETARGET_INF (2) + #define RETARGET_DLEN (8 + DESC_LEN_INF * 2 + 5 + 4 + 5 + 5 + DESC_LEN_EPT * 3) + + #if (_EP1_ENABLE == 0 && _EP2_ENABLE == 0 && _EP3_ENABLE == 0 && _EP4_ENABLE == 0 && \ + _EP5_ENABLE == 0 && _EP6_ENABLE == 0 && _EP7_ENABLE == 0) + #define NON_USB_IN_APP + #undef _UIER + #undef _EP0LEN + #undef _EP0_IER + #define _EP0LEN (64) + #define _EP0_IER (0x212) + #define _UIER (0x011D) + #endif + + #define _UIER_ALL (_UIER | (EP0IE << RETARGET_RX_EPT) | (EP0IE << RETARGET_TX_EPT)) + + #if (RETARGET_RX_EPT == 1 || RETARGET_TX_EPT == 1 || RETARGET_CTRL_EPT == 1) + #if (_EP1_ENABLE == 1) + #define _RERATGET1_ERR + #else + #undef _EP1_ENABLE + #undef _EP1_CFG_EPADR + #undef _EP1_CFG_EPEN_TMP + #undef _EP1_TYPR + #undef _EP1_CFG_EPDIR + #undef _EP1LEN_TMP + #undef _EP1_IER + + #define _EP1_ENABLE (1) + #define _EP1_CFG_EPADR (1) + #define _EP1_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 1) + #define _EP1_TYPR (2) + #define _EP1_CFG_EPDIR (0) + #define _EP1LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP1_IER (0x02) + #define RETARGET_RX_LEN (_EP1LEN) + #elif (RETARGET_TX_EPT == 1) + #define _EP1_TYPR (2) + #define _EP1_CFG_EPDIR (1) + #define _EP1LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP1_IER (0x10) + #define RETARGET_TX_LEN (_EP1LEN) + #elif (RETARGET_CTRL_EPT == 1) + #define _EP1_TYPR (3) + #define _EP1_CFG_EPDIR (1) + #define _EP1LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP1_IER (0x10) + #define RETARGET_CTRL_LEN (_EP1LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 2 || RETARGET_TX_EPT == 2 || RETARGET_CTRL_EPT == 2) + #if (_EP2_ENABLE == 1) + #define _RERATGET2_ERR + #else + #undef _EP2_ENABLE + #undef _EP2_CFG_EPADR + #undef _EP2_CFG_EPEN_TMP + #undef _EP2_TYPR + #undef _EP2_CFG_EPDIR + #undef _EP2LEN_TMP + #undef _EP2_IER + + #define _EP2_ENABLE (1) + #define _EP2_CFG_EPADR (2) + #define _EP2_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 2) + #define _EP2_TYPR (2) + #define _EP2_CFG_EPDIR (0) + #define _EP2LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP2_IER (0x02) + #define RETARGET_RX_LEN (_EP2LEN) + #elif (RETARGET_TX_EPT == 2) + #define _EP2_TYPR (2) + #define _EP2_CFG_EPDIR (1) + #define _EP2LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP2_IER (0x10) + #define RETARGET_TX_LEN (_EP2LEN) + #elif (RETARGET_CTRL_EPT == 2) + #define _EP2_TYPR (3) + #define _EP2_CFG_EPDIR (1) + #define _EP2LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP2_IER (0x10) + #define RETARGET_CTRL_LEN (_EP2LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 3 || RETARGET_TX_EPT == 3 || RETARGET_CTRL_EPT == 3) + #if (_EP3_ENABLE == 1) + #define _RERATGET3_ERR + #else + #undef _EP3_ENABLE + #undef _EP3_CFG_EPADR + #undef _EP3_CFG_EPEN_TMP + #undef _EP3_TYPR + #undef _EP3_CFG_EPDIR + #undef _EP3LEN_TMP + #undef _EP3_IER + + #define _EP3_ENABLE (1) + #define _EP3_CFG_EPADR (3) + #define _EP3_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 3) + #define _EP3_TYPR (2) + #define _EP3_CFG_EPDIR (0) + #define _EP3LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP3_IER (0x02) + #define RETARGET_RX_LEN (_EP3LEN) + #elif (RETARGET_TX_EPT == 3) + #define _EP3_TYPR (2) + #define _EP3_CFG_EPDIR (1) + #define _EP3LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP3_IER (0x10) + #define RETARGET_TX_LEN (_EP3LEN) + #elif (RETARGET_CTRL_EPT == 3) + #define _EP3_TYPR (3) + #define _EP3_CFG_EPDIR (1) + #define _EP3LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP3_IER (0x10) + #define RETARGET_CTRL_LEN (_EP3LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 4 || RETARGET_TX_EPT == 4 || RETARGET_CTRL_EPT == 4) + #if (_EP4_ENABLE == 1) + #define _RERATGET4_ERR + #else + #undef _EP4_ENABLE + #undef _EP4_CFG_EPADR + #undef _EP4_CFG_EPEN_TMP + #undef _EP4_TYPR + #undef _EP4_CFG_EPDIR + #undef _EP4LEN_TMP + #undef _EP4_IER + + #define _EP4_ENABLE (1) + #define _EP4_CFG_EPADR (4) + #define _EP4_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 4) + #define _EP4_TYPR (2) + #define _EP4_CFG_EPDIR (0) + #define _EP4LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP4_IER (0x02) + #define RETARGET_RX_LEN (_EP4LEN) + #elif (RETARGET_TX_EPT == 4) + #define _EP4_TYPR (2) + #define _EP4_CFG_EPDIR (1) + #define _EP4LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP4_IER (0x10) + #define RETARGET_TX_LEN (_EP4LEN) + #elif (RETARGET_CTRL_EPT == 4) + #define _EP4_TYPR (3) + #define _EP4_CFG_EPDIR (1) + #define _EP4LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP4_IER (0x10) + #define RETARGET_CTRL_LEN (_EP4LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 5 || RETARGET_TX_EPT == 5 || RETARGET_CTRL_EPT == 5) + #if (_EP5_ENABLE == 1) + #define _RERATGET5_ERR + #else + #undef _EP5_ENABLE + #undef _EP5_CFG_EPADR + #undef _EP5_CFG_EPEN_TMP + #undef _EP5_TYPR + #undef _EP5_CFG_EPDIR + #undef _EP5LEN_TMP + #undef _EP5_IER + + #define _EP5_ENABLE (1) + #define _EP5_CFG_EPADR (5) + #define _EP5_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 5) + #define _EP5_TYPR (2) + #define _EP5_CFG_EPDIR (0) + #define _EP5LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP5_IER (0x02) + #define RETARGET_RX_LEN (_EP5LEN) + #elif (RETARGET_TX_EPT == 5) + #define _EP5_TYPR (2) + #define _EP5_CFG_EPDIR (1) + #define _EP5LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP5_IER (0x10) + #define RETARGET_TX_LEN (_EP5LEN) + #elif (RETARGET_CTRL_EPT == 5) + #define _EP5_TYPR (3) + #define _EP5_CFG_EPDIR (1) + #define _EP5LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP5_IER (0x10) + #define RETARGET_CTRL_LEN (_EP5LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 6 || RETARGET_TX_EPT == 6 || RETARGET_CTRL_EPT == 6) + #if (_EP6_ENABLE == 1) + #define _RERATGET6_ERR + #else + #undef _EP6_ENABLE + #undef _EP6_CFG_EPADR + #undef _EP6_CFG_EPEN_TMP + #undef _EP6_TYPR + #undef _EP6_CFG_EPDIR + #undef _EP6LEN_TMP + #undef _EP6_IER + + #define _EP6_ENABLE (1) + #define _EP6_CFG_EPADR (6) + #define _EP6_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 6) + #define _EP6_TYPR (2) + #define _EP6_CFG_EPDIR (0) + #define _EP6LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP6_IER (0x02) + #define RETARGET_RX_LEN (_EP6LEN) + #elif (RETARGET_TX_EPT == 6) + #define _EP6_TYPR (2) + #define _EP6_CFG_EPDIR (1) + #define _EP6LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP6_IER (0x10) + #define RETARGET_TX_LEN (_EP6LEN) + #elif (RETARGET_CTRL_EPT == 6) + #define _EP6_TYPR (3) + #define _EP6_CFG_EPDIR (1) + #define _EP6LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP6_IER (0x10) + #define RETARGET_CTRL_LEN (_EP6LEN) + #endif + #endif + #endif + + #if (RETARGET_RX_EPT == 7 || RETARGET_TX_EPT == 7 || RETARGET_CTRL_EPT == 7) + #if (_EP7_ENABLE == 1) + #define _RERATGET7_ERR + #else + #undef _EP7_ENABLE + #undef _EP7_CFG_EPADR + #undef _EP7_CFG_EPEN_TMP + #undef _EP7_TYPR + #undef _EP7_CFG_EPDIR + #undef _EP7LEN_TMP + #undef _EP7_IER + + #define _EP7_ENABLE (1) + #define _EP7_CFG_EPADR (7) + #define _EP7_CFG_EPEN_TMP (1) + #if (RETARGET_RX_EPT == 7) + #define _EP7_TYPR (2) + #define _EP7_CFG_EPDIR (0) + #define _EP7LEN_TMP (RETARGET_RX_EPTLEN) + #define _EP7_IER (0x02) + #define RETARGET_RX_LEN (_EP7LEN) + #elif (RETARGET_TX_EPT == 7) + #define _EP7_TYPR (2) + #define _EP7_CFG_EPDIR (1) + #define _EP7LEN_TMP (RETARGET_TX_EPTLEN) + #define _EP7_IER (0x10) + #define RETARGET_TX_LEN (_EP7LEN) + #elif (RETARGET_CTRL_EPT == 7) + #define _EP7_TYPR (3) + #define _EP7_CFG_EPDIR (1) + #define _EP7LEN_TMP (RETARGET_CTRL_EPTLEN) + #define _EP7_IER (0x10) + #define RETARGET_CTRL_LEN (_EP7LEN) + #endif + #endif + #endif + + #endif /* #ifdef RETARGET_IS_USB */ + +#endif /* #if (_RETARGET == 1) */ + +#endif /* __HT32_RETARGET_USBDCONF_H -----------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_serial.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_serial.h new file mode 100644 index 0000000000..bea9f04ae3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_serial.h @@ -0,0 +1,84 @@ +/*********************************************************************************************************//** + * @file ht32_serial.h + * @version $Rev:: 6444 $ + * @date $Date:: 2022-11-11 #$ + * @brief The header file of the Serial library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_SERIAL_H +#define __HT32_SERIAL_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#ifdef RETARGET_IS_USB +#include "ht32_usbd_core.h" +#endif + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @addtogroup SERIAL + * @brief Serial related functions + * @{ + */ + + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Exported_Functions Serial exported functions + * @{ + */ +void RETARGET_UART_IRQHandler(void); +u32 SERIAL_GetChar(void); +u32 SERIAL_PutChar(u32 ch); +#ifdef RETARGET_IS_USB +void SERIAL_USBDClass_Request(USBDCore_Device_TypeDef *pDev); +void SERIAL_USBDClass_RXHandler(USBD_EPTn_Enum EPTn); +void SERIAL_USBDClass_TXHandler(USBD_EPTn_Enum EPTn); +void SERIAL_USBDInit(void); +void SERIAL_Flush(void); +#else +#define SERIAL_Flush(...) +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_time.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_time.h new file mode 100644 index 0000000000..51aeba2c3e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_time.h @@ -0,0 +1,170 @@ +/*********************************************************************************************************//** + * @file ht32_time.h + * @version $Rev:: 6751 $ + * @date $Date:: 2023-03-02 #$ + * @brief The header file of time function. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_TIME_H +#define __HT32_TIME_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#ifndef HTCFG_TIME_IPSEL +#include "ht32_time_conf.h" +#endif + +/* Settings ------------------------------------------------------------------------------------------------*/ +#ifdef HTCFG_TIME_IPSEL +#if (HTCFG_TIME_IPSEL == 0) +#define HTCFG_TIME_IPN BFTM0 +#endif +#if (HTCFG_TIME_IPSEL == 1) +#define HTCFG_TIME_IPN BFTM1 +#endif +#if (HTCFG_TIME_IPSEL == 2) +#define HTCFG_TIME_IPN SCTM0 +#endif +#if (HTCFG_TIME_IPSEL == 3) +#define HTCFG_TIME_IPN SCTM1 +#endif +#if (HTCFG_TIME_IPSEL == 4) +#define HTCFG_TIME_IPN SCTM2 +#endif +#if (HTCFG_TIME_IPSEL == 5) +#define HTCFG_TIME_IPN SCTM3 +#endif +#if (HTCFG_TIME_IPSEL == 6) +#define HTCFG_TIME_IPN PWM0 +#endif +#if (HTCFG_TIME_IPSEL == 7) +#define HTCFG_TIME_IPN PWM1 +#endif +#if (HTCFG_TIME_IPSEL == 8) +#define HTCFG_TIME_IPN PWM2 +#endif +#if (HTCFG_TIME_IPSEL == 9) +#define HTCFG_TIME_IPN GPTM0 +#endif +#if (HTCFG_TIME_IPSEL == 10) +#define HTCFG_TIME_IPN GPTM1 +#endif +#if (HTCFG_TIME_IPSEL == 11) +#define HTCFG_TIME_IPN MCTM0 +#endif +#endif + +/* Exported constants --------------------------------------------------------------------------------------*/ +#ifndef IS_IPN_BFTM +#undef IPN_MCTM0 +#undef IPN_MCTM1 +#undef IPN_GPTM0 +#undef IPN_GPTM1 + +#define IPN_NULL (0) +#define IPN_MCTM0 (0x4002C000) +#define IPN_MCTM1 (0x4002D000) +#define IPN_GPTM0 (0x4006E000) +#define IPN_GPTM1 (0x4006F000) +#define IPN_SCTM0 (0x40034000) +#define IPN_SCTM1 (0x40074000) +#define IPN_SCTM2 (0x40035000) +#define IPN_SCTM3 (0x40075000) +#define IPN_PWM0 (0x40031000) +#define IPN_PWM1 (0x40071000) +#define IPN_PWM2 (0x40031000) +#define IPN_BFTM0 (0x40076000) +#define IPN_BFTM1 (0x40077000) +#define IPN_CHECK(IP) STRCAT2(IPN_, IP) +#define IS_IPN_BFTM(IP) (IPN_CHECK(IP) == IPN_BFTM0) || (IPN_CHECK(IP) == IPN_BFTM1) +#define IS_IPN_MCTM(IP) (IPN_CHECK(IP) == IPN_MCTM0) || (IPN_CHECK(IP) == IPN_MCTM1) +#define IS_IPN_GPTM(IP) (IPN_CHECK(IP) == IPN_GPTM0) || (IPN_CHECK(IP) == IPN_GPTM1) +#define IS_IPN_SCTM(IP) (IPN_CHECK(IP) == IPN_SCTM0) || (IPN_CHECK(IP) == IPN_SCTM1) || (IPN_CHECK(IP) == IPN_SCTM2) || (IPN_CHECK(IP) == IPN_SCTM3) +#define IS_IPN_PWM(IP) (IPN_CHECK(IP) == IPN_PWM0) || (IPN_CHECK(IP) == IPN_PWM1) || (IPN_CHECK(IP) == IPN_PWM2) +#define IS_IPN_TM(IP) (IS_IPN_MCTM(IP) || IS_IPN_GPTM(IP) || IS_IPN_SCTM(IP) || IS_IPN_PWM(IP)) +#endif + +#define _HTCFG_TIME_PORT STRCAT2(HT_, HTCFG_TIME_IPN) + +#if (HTCFG_TIME_CLKSEL == 0) +#define _HTCFG_TIME_CORECLK (LIBCFG_MAX_SPEED) +#else +#define _HTCFG_TIME_CORECLK (HTCFG_TIME_CLK_MANUAL) +#endif + +#if (LIBCFG_CKCU_NO_APB_PRESCALER == 1) +#undef HTCFG_TIME_PCLK_DIV +#define HTCFG_TIME_PCLK_DIV (0) +#endif + +#define HTCFG_TIME_CLKSRC (_HTCFG_TIME_CORECLK >> HTCFG_TIME_PCLK_DIV) + +#if (IS_IPN_BFTM(HTCFG_TIME_IPN)) +#undef HTCFG_TIME_TICKHZ +#define HTCFG_TIME_TICKHZ HTCFG_TIME_CLKSRC +#endif + +/* Exported macro ------------------------------------------------------------------------------------------*/ +#define TIME_TICKDIFF(start, current) ((current >= start) ? (u32)(current - start) : (u32)(0xFFFFFFFF - start + 1 + current)) + +#if (HTCFG_TIME_TICKHZ < 1000000) +#define TIME_US2TICK(us) (us / (1000000UL / HTCFG_TIME_TICKHZ)) +#define TIME_TICK2US(t) (t * (1000000UL / HTCFG_TIME_TICKHZ)) +#else +#define TIME_US2TICK(us) (us * (HTCFG_TIME_TICKHZ / 1000000UL)) +#define TIME_TICK2US(t) (t / (HTCFG_TIME_TICKHZ / 1000000UL)) +#endif + +#if (HTCFG_TIME_TICKHZ < 1000) +#define TIME_MS2TICK(ms) (ms / (1000UL / HTCFG_TIME_TICKHZ)) +#define TIME_TICK2MS(t) (t * (1000UL / HTCFG_TIME_TICKHZ)) +#else +#define TIME_MS2TICK(ms) (ms * (HTCFG_TIME_TICKHZ / 1000UL)) +#define TIME_TICK2MS(t) (t / (HTCFG_TIME_TICKHZ / 1000UL)) +#endif + +#define TIME_S2TICK(s) (s * (u32)(HTCFG_TIME_TICKHZ)) +#define TIME_TICK2S(t) (t / (HTCFG_TIME_TICKHZ)) + + +#define GET_CNT() (_HTCFG_TIME_PORT->CNTR) + +/* Exported functions --------------------------------------------------------------------------------------*/ +void Time_Init(void); +void Time_Delay(u32 delay); +u32 Time_GetTick(void); + +#if (IS_IPN_BFTM(HTCFG_TIME_IPN)) +// BFTM +#define Time_GetTick GET_CNT +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_undef_IP.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_undef_IP.h new file mode 100644 index 0000000000..fb67ddcd1f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32_undef_IP.h @@ -0,0 +1,200 @@ +/*********************************************************************************************************//** + * @file ht32_undef_IP.h + * @version $Rev:: 7309 $ + * @date $Date:: 2023-10-18 #$ + * @brief Header file for undefined IP. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ + +#ifndef __HT32_UNDEF_IP_H +#define __HT32_UNDEF_IP_H + +#ifdef __cplusplus + extern "C" { +#endif + +#if _AES +#undef _AES +#endif + +#ifdef _ADC +#undef _ADC +#endif + +#ifdef _BFTM +#undef _BFTM +#endif + +#ifdef _CAN +#undef _CAN +#endif + +#ifdef _CKCU +#undef _CKCU +#endif + +#ifdef _CMP +#undef _CMP +#endif + +#ifdef _CRC +#undef _CRC +#endif + +#ifdef _CSIF +#undef _CSIF +#endif + +#ifdef _DAC +#undef _DAC +#endif + +#ifdef _DIV +#undef _DIV +#endif + +#ifdef _EBI +#undef _EBI +#endif + +#ifdef _EXTI +#undef _EXTI +#endif + +#ifdef _FLASH +#undef _FLASH +#endif + +#ifdef _GPIO +#undef _GPIO +#endif + +#ifdef _GPTM +#undef _GPTM +#endif + +#ifdef _I2C +#undef _I2C +#endif + +#ifdef _I2S +#undef _I2S +#endif + +#ifdef _LCD +#undef _LCD +#endif + +#ifdef _LEDC +#undef _LEDC +#endif + +#ifdef _MCTM +#undef _MCTM +#endif + +#ifdef _MIDI +#undef _MIDI +#endif + +#ifdef _OPA +#undef _OPA +#endif + +#ifdef _PDMA +#undef _PDMA +#endif + +#ifdef _PWRCU +#undef _PWRCU +#endif + +#ifdef _PWM +#undef _PWM +#endif + +#ifdef _RSTCU +#undef _RSTCU +#endif + +#ifdef _RTC +#undef _RTC +#endif + +#ifdef _SCI +#undef _SCI +#endif + +#ifdef _SCTM +#undef _SCTM +#endif + +#ifdef _SDIO +#undef _SDIO +#endif + +#ifdef _SLED +#undef _SLED +#endif + +#ifdef _SPI +#undef _SPI +#endif + +#ifdef _TKEY +#undef _TKEY +#endif + +#ifdef _USART +#undef _USART +#endif + +#ifdef _USB +#undef _USB +#endif + +#ifdef _WDT +#undef _WDT +#endif + +#ifdef _MISC +#undef _MISC +#endif + +#ifdef _SERIAL +#undef _SERIAL +#endif + +#ifdef _SWDIV +#undef _SWDIV +#endif + +#ifdef _SWRAND +#undef _SWRAND +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0006_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0006_libcfg.h new file mode 100644 index 0000000000..ca5464f977 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0006_libcfg.h @@ -0,0 +1,73 @@ +/*********************************************************************************************************//** + * @file ht32f0006_libcfg.h + * @version $Rev:: 6657 $ + * @date $Date:: 2023-01-16 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F0006_LIBCFG_H +#define __HT32F0006_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F0006) +#define USE_MEM_HT32F0006 +#endif + +#define LIBCFG_MAX_SPEED (48000000) + +#define LIBCFG_FLASH_PAGESIZE (512) + +#ifdef USE_MEM_HT32F0006 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x0006) +#endif + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DACDUAL16 (1) +#define LIBCFG_DIV (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_I2S (1) +#define LIBCFG_LSE (1) +#define LIBCFG_MIDI (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_QSPI (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_USBD (1) + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_ADC_CH12_15 (1) +#define LIBCFG_AFE0006 (1) +#define LIBCFG_FMC_BRANCHCACHE (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FLASH_2PAGE_PER_WPBIT (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0008_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0008_libcfg.h new file mode 100644 index 0000000000..a53d939bbf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f0008_libcfg.h @@ -0,0 +1,74 @@ +/*********************************************************************************************************//** + * @file ht32f0008_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F0008_LIBCFG_H +#define __HT32F0008_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F0008) +#define USE_MEM_HT32F0008 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F0008 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x0008) +#endif + +#define LIBCFG_PDMA (1) + +#define LIBCFG_BFTM1 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_USBD (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_AES (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOF (1) + +#define LIBCFG_NO_ADC (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) +#define LIBCFG_AFIO_PWM_MODE4 (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_GPIO_DISABLE_DEBUG_PORT (1) +#define LIBCFG_AES_SWAP (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50020_30_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50020_30_libcfg.h new file mode 100644 index 0000000000..44d05bdcc9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50020_30_libcfg.h @@ -0,0 +1,111 @@ +/*********************************************************************************************************//** + * @file ht32f50020_30_libcfg.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __ht32f50020_30_LIBCFG_H +#define __ht32f50020_30_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F50020) && !defined(USE_MEM_HT32F50030) +#define USE_MEM_HT32F50030 +#endif + +#define LIBCFG_MAX_SPEED (16000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F50020 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 16) + #define LIBCFG_RAM_SIZE (1024 * 2) + #define LIBCFG_CHIPNAME (0x50020) +#endif + +#ifdef USE_MEM_HT32F50030 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 31) + #define LIBCFG_RAM_SIZE (1024 * 2) + #define LIBCFG_CHIPNAME (0x50030) +#endif + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOF (1) +#define LIBCFG_LEDC (1) +#define LIBCFG_LSE (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_NO_GPTM0 (1) +#define LIBCFG_NO_USART0 (1) + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_LEVEL_TYPE2 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_ADC_VREFBUF (1) +#define LIBCFG_ADC_NO_DISCON_MODE (1) +#define LIBCFG_ADC_NO_SEQ_4_7 (1) +#define LIBCFG_ADC_NO_WDT (1) +#define LIBCFG_ADC_SW_TRIGGER_ONLY (1) +#define LIBCFG_AFIO_LEDC_MODE3 (1) +#define LIBCFG_AFIO_MODE_0_7 (1) +#define LIBCFG_AFIO_SCTM_MODE4 (1) +#define LIBCFG_AFIO_SYSTEM_MODE1 (1) +#define LIBCFG_BFTM_16BIT_COUNTER (1) +#define LIBCFG_CKCU_NO_APB_PRESCALER (1) +#define LIBCFG_CKCU_NO_AUTO_TRIM (1) +#define LIBCFG_CKCU_NO_LPCR (1) +#define LIBCFG_EXTI_8BIT_DEBOUNCE_COUNTER (1) +#define LIBCFG_EXTI_8CH (1) +#define LIBCFG_EXTI_DEBCNTPRE (1) +#define LIBCFG_GPIO_PR_STRONG_UP (1) +#define LIBCFG_I2C_PRESCALER_2BIT (1) +#define LIBCFG_I2C_TOUT_COUNT_8BIT (1) +#define LIBCFG_I2C_TWO_DEV_ADDR (1) +#define LIBCFG_I2C_NO_10BIT_MODE (1) +#define LIBCFG_I2C_NO_ADDR_MASK (1) +#define LIBCFG_I2C_NO_ARBLOS (1) +#define LIBCFG_LEDC_NO_COM_8_11 (1) +#define LIBCFG_NO_PLL (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_SPI_CLK_PRE_V01 (1) +#define LIBCFG_SPI_DATA_LENGTH_V01 (1) +#define LIBCFG_SPI_FIFO_DEPTH_V01 (1) +#define LIBCFG_SPI_NO_DUAL (1) +#define LIBCFG_SPI_NO_MULTI_MASTER (1) +#define LIBCFG_SPI_TIMEOUT_LENGTH_V01 (1) +#define LIBCFG_TM_CKDIV_8 (1) +#define LIBCFG_TM_PRESCALER_8BIT (1) +#define LIBCFG_TM_SCTM_2CHANNEL (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50220_30_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50220_30_libcfg.h new file mode 100644 index 0000000000..3624e76b7b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50220_30_libcfg.h @@ -0,0 +1,75 @@ +/*********************************************************************************************************//** + * @file ht32f50220_30_libcfg.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F50220_30_LIBCFG_H +#define __HT32F50220_30_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F50220) && !defined(USE_MEM_HT32F50230) +#define USE_MEM_HT32F50230 +#endif + +#define LIBCFG_MAX_SPEED (20000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F50220 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 16) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x50220) +#endif + +#ifdef USE_MEM_HT32F50230 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 31) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x50230) +#endif + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_LSE (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) +#define LIBCFG_DIV (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIO_SINK_CURRENT_ENHANCED (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_NO_PLL (1) +#define LIBCFG_NO_USART0 (1) +#define LIBCFG_FMC_CMD_READY_WAIT (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50231_41_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50231_41_libcfg.h new file mode 100644 index 0000000000..b7e24634f7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50231_41_libcfg.h @@ -0,0 +1,79 @@ +/*********************************************************************************************************//** + * @file ht32f50231_41_libcfg.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F50231_41_LIBCFG_H +#define __HT32F50231_41_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F50231) && !defined(USE_MEM_HT32F50241) +#define USE_MEM_HT32F50241 +#endif + +#define LIBCFG_MAX_SPEED (20000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F50231 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x50231) +#endif + +#ifdef USE_MEM_HT32F50241 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x50241) +#endif + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_LSE (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) +#define LIBCFG_DIV (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIO_SINK_CURRENT_ENHANCED (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CRC (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_NO_PLL (1) +#define LIBCFG_FMC_CMD_READY_WAIT (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50343_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50343_libcfg.h new file mode 100644 index 0000000000..2e13c2bea0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50343_libcfg.h @@ -0,0 +1,87 @@ +/*********************************************************************************************************//** + * @file ht32f50343_libcfg.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F50343_LIBCFG_H +#define __HT32F50343_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F50343) +#define USE_MEM_HT32F50343 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F50343 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 12) + #define LIBCFG_CHIPNAME (0x50343) +#endif + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_LSE (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_NO_USART0 (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_VREG (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) +#define LIBCFG_PWM2 (1) +#define LIBCFG_PWM_8_CHANNEL (1) +#define LIBCFG_SLED0 (1) +#define LIBCFG_SLED1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_USBD (1) + + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50431_41_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50431_41_libcfg.h new file mode 100644 index 0000000000..9c3bb3bb39 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50431_41_libcfg.h @@ -0,0 +1,95 @@ +/*********************************************************************************************************//** + * @file ht32f50431_41_libcfg.h + * @version $Rev:: 7265 $ + * @date $Date:: 2023-10-02 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F50431_41_LIBCFG_H +#define __HT32F50431_41_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F50431) && !defined(USE_MEM_HT32F50441) +#define USE_MEM_HT32F50441 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F50431 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x50431) +#endif + +#ifdef USE_MEM_HT32F50441 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x50441) +#endif + +#define LIBCFG_PDMA (1) +#define LIBCFG_ADC_CH8_11 (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PWM0 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_LEDC (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) + +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) + +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_LEDC_NO_COM_8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_LEVEL_TYPE2 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_USART_LIN (1) +#define LIBCFG_USART_SINGLE_WIRE (1) +#define LIBCFG_GPIO_SINK_CURREMT_ENHANCED (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50442_52_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50442_52_libcfg.h new file mode 100644 index 0000000000..6a3cff8ab6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f50442_52_libcfg.h @@ -0,0 +1,99 @@ +/*********************************************************************************************************//** + * @file ht32f50442_52_libcfg.h + * @version $Rev:: 7265 $ + * @date $Date:: 2023-10-02 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F50442_52_LIBCFG_H +#define __HT32F50442_52_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F50442) && !defined(USE_MEM_HT32F50452) +#define USE_MEM_HT32F50452 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F50442 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x50442) +#endif + +#ifdef USE_MEM_HT32F50452 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x50452) +#endif + +#define LIBCFG_PDMA (1) +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_CMP (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_EBI (1) +#define LIBCFG_LEDC (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) + +#define LIBCFG_USART1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) + +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_LEDC_NO_COM_8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_LEVEL_TYPE2 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_USART_LIN (1) +#define LIBCFG_USART_SINGLE_WIRE (1) +#define LIBCFG_GPIO_SINK_CURREMT_ENHANCED (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52220_30_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52220_30_libcfg.h new file mode 100644 index 0000000000..1804c38460 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52220_30_libcfg.h @@ -0,0 +1,61 @@ +/*********************************************************************************************************//** + * @file ht32f52220_30_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52220_30_LIBCFG_H +#define __HT32F52220_30_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52220) && !defined(USE_MEM_HT32F52230) +#define USE_MEM_HT32F52230 +#endif + +#define LIBCFG_MAX_SPEED (40000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F52220 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 16) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x52220) +#endif + +#ifdef USE_MEM_HT32F52230 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 31) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x52230) +#endif + +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) + +#define LIBCFG_GPIO_DISABLE_DEBUG_PORT (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52231_41_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52231_41_libcfg.h new file mode 100644 index 0000000000..071c8ab1dc --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52231_41_libcfg.h @@ -0,0 +1,76 @@ +/*********************************************************************************************************//** + * @file ht32f52231_41_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52231_41_LIBCFG_H +#define __HT32F52231_41_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52231) && !defined(USE_MEM_HT32F52241) +#define USE_MEM_HT32F52241 +#endif + +#define LIBCFG_MAX_SPEED (40000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F52231 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x52231) +#endif + +#ifdef USE_MEM_HT32F52241 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x52241) +#endif + +#define LIBCFG_ADC_CH8_11 (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_MCTM0 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_CRC (1) + +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIO_DISABLE_DEBUG_PORT (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52234_44_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52234_44_libcfg.h new file mode 100644 index 0000000000..1ac83f1323 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52234_44_libcfg.h @@ -0,0 +1,83 @@ +/*********************************************************************************************************//** + * @file ht32f52234_44_libcfg.h + * @version $Rev:: 7265 $ + * @date $Date:: 2023-10-02 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52234_44_LIBCFG_H +#define __HT32F52234_44_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52234) && !defined(USE_MEM_HT32F52244) +#define USE_MEM_HT32F52244 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F52234 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x52234) +#endif + +#ifdef USE_MEM_HT32F52244 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x52244) +#endif + +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_DEFAULT_08V (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_LSE (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_I2C2 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_NO_GPTM0 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_HSIRDYCR (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_DAC0 (1) +#define LIBCFG_DAC1 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_USART_LIN (1) +#define LIBCFG_USART_SINGLE_WIRE (1) +#define LIBCFG_AFIO_DAC_MODE3 (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52243_53_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52243_53_libcfg.h new file mode 100644 index 0000000000..38f4675048 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52243_53_libcfg.h @@ -0,0 +1,84 @@ +/*********************************************************************************************************//** + * @file ht32f52243_53_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52243_53_LIBCFG_H +#define __HT32F52243_53_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52243) && !defined(USE_MEM_HT32F52253) +#define USE_MEM_HT32F52253 +#endif + +#define LIBCFG_MAX_SPEED (40000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F52243 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x52243) +#endif + +#ifdef USE_MEM_HT32F52253 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x52253) +#endif + +#define LIBCFG_PDMA (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_ADC_CH8_11 (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_MCTM0 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) + +#define LIBCFG_USART1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_UART2 (1) +#define LIBCFG_UART3 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_I2C2 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_GPIO_DISABLE_DEBUG_PORT (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52331_41_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52331_41_libcfg.h new file mode 100644 index 0000000000..63db24b8f4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52331_41_libcfg.h @@ -0,0 +1,78 @@ +/*********************************************************************************************************//** + * @file ht32f52331_41_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52331_41_LIBCFG_H +#define __HT32F52331_41_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52331) && !defined(USE_MEM_HT32F52341) +#define USE_MEM_HT32F52341 +#endif + +#define LIBCFG_MAX_SPEED (48000000) + +#define LIBCFG_FLASH_PAGESIZE (512) + +#ifdef USE_MEM_HT32F52331 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x52331) +#endif + +#ifdef USE_MEM_HT32F52341 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x52341) +#endif + +#define LIBCFG_ADC_CH8_11 (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_MCTM0 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_USBD (1) +#define LIBCFG_CRC (1) + +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIO_DISABLE_DEBUG_PORT (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52342_52_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52342_52_libcfg.h new file mode 100644 index 0000000000..54a148b589 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52342_52_libcfg.h @@ -0,0 +1,91 @@ +/*********************************************************************************************************//** + * @file ht32f52342_52_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52342_52_LIBCFG_H +#define __HT32F52342_52_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52342) && !defined(USE_MEM_HT32F52352) +#define USE_MEM_HT32F52352 +#endif + +#define LIBCFG_MAX_SPEED (48000000) + +#define LIBCFG_FLASH_PAGESIZE (512) + +#ifdef USE_MEM_HT32F52342 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 128) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x52342) +#endif + +#ifdef USE_MEM_HT32F52352 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x52352) +#endif + +#define LIBCFG_PDMA (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_CMP (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_GPTM1 (1) +#define LIBCFG_MCTM0 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SCI1 (1) +#define LIBCFG_USBD (1) +#define LIBCFG_EBI (1) +#define LIBCFG_I2S (1) +#define LIBCFG_CRC (1) + +#define LIBCFG_USART1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) + +#define LIBCFG_BAKREG (1) + +#define LIBCFG_FMC_BRANCHCACHE (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FLASH_2PAGE_PER_WPBIT (1) +#define LIBCFG_GPIO_DISABLE_DEBUG_PORT (1) +#define LIBCFG_RTC_LSI_LOAD_TRIM (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52344_54_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52344_54_libcfg.h new file mode 100644 index 0000000000..452a832483 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52344_54_libcfg.h @@ -0,0 +1,84 @@ +/*********************************************************************************************************//** + * @file ht32f52344_54_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52344_54_LIBCFG_H +#define __HT32F52344_54_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52344) && !defined(USE_MEM_HT32F52354) +#define USE_MEM_HT32F52354 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F52344 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x52344) +#endif + +#ifdef USE_MEM_HT32F52354 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x52354) +#endif + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_CKCU_USB_PLL_96M (1) +#define LIBCFG_CKCU_MCTM_SRC (1) +#define LIBCFG_CMP (1) +#define LIBCFG_CMP_IVREF_CN_IN (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_EBI (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_LSE (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_NO_USART0 (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_USBD (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52357_67_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52357_67_libcfg.h new file mode 100644 index 0000000000..1804f46079 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f52357_67_libcfg.h @@ -0,0 +1,102 @@ +/*********************************************************************************************************//** + * @file ht32f52357_67_libcfg.h + * @version $Rev:: 7167 $ + * @date $Date:: 2023-08-25 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F52357_67_LIBCFG_H +#define __HT32F52357_67_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F52357) && !defined(USE_MEM_HT32F52367) +#define USE_MEM_HT32F52367 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F52357 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 128) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x52357) +#endif + +#ifdef USE_MEM_HT32F52367 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 32) + #define LIBCFG_CHIPNAME (0x52367) +#endif + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_AES (1) +#define LIBCFG_AES_KEYSIZE_256B (1) +#define LIBCFG_BAKREG (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_CMP (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DAC0 (1) +#define LIBCFG_DIV (1) +#define LIBCFG_EBI (1) +#define LIBCFG_FLASH_2PAGE_PER_WPBIT (1) +#define LIBCFG_FMC_BRANCHCACHE (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_GPIOE (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_I2S (1) +#define LIBCFG_LSE (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) +#define LIBCFG_QSPI (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SCI1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_UART2 (1) +#define LIBCFG_UART3 (1) +#define LIBCFG_USART1 (1) +#define LIBCFG_USBD (1) + +#define UART0_IRQHandler UART0_UART2_IRQHandler +#define UART2_IRQHandler UART0_UART2_IRQHandler +#define UART1_IRQHandler UART1_UART3_IRQHandler +#define UART3_IRQHandler UART1_UART3_IRQHandler + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53231_41_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53231_41_libcfg.h new file mode 100644 index 0000000000..43068a9c12 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53231_41_libcfg.h @@ -0,0 +1,96 @@ +/*********************************************************************************************************//** + * @file ht32f53231_41_libcfg.h + * @version $Rev:: 7265 $ + * @date $Date:: 2023-10-02 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F53231_41_LIBCFG_H +#define __HT32F53231_41_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F53231) && !defined(USE_MEM_HT32F53241) +#define USE_MEM_HT32F53241 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F53231 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x53231) +#endif + +#ifdef USE_MEM_HT32F53241 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x53241) +#endif + +#define LIBCFG_PDMA (1) +#define LIBCFG_ADC_CH8_11 (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PWM0 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_LEDC (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_CAN0 (1) + +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) + +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_LEDC_NO_COM_8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_LEVEL_TYPE2 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_USART_LIN (1) +#define LIBCFG_USART_SINGLE_WIRE (1) +#define LIBCFG_GPIO_SINK_CURREMT_ENHANCED (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53242_52_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53242_52_libcfg.h new file mode 100644 index 0000000000..c2493ba610 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f53242_52_libcfg.h @@ -0,0 +1,100 @@ +/*********************************************************************************************************//** + * @file ht32f53242_52_libcfg.h + * @version $Rev:: 7265 $ + * @date $Date:: 2023-10-02 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F53242_52_LIBCFG_H +#define __HT32F53242_52_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F53242) && !defined(USE_MEM_HT32F53252) +#define USE_MEM_HT32F53252 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F53242 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x53242) +#endif + +#ifdef USE_MEM_HT32F53252 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x53252) +#endif + +#define LIBCFG_PDMA (1) +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_CMP (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_EBI (1) +#define LIBCFG_LEDC (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_CAN0 (1) + +#define LIBCFG_USART1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) + +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_LEDC_NO_COM_8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_LEVEL_TYPE2 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_USART_LIN (1) +#define LIBCFG_USART_SINGLE_WIRE (1) +#define LIBCFG_GPIO_SINK_CURREMT_ENHANCED (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54231_41_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54231_41_libcfg.h new file mode 100644 index 0000000000..671765ef1b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54231_41_libcfg.h @@ -0,0 +1,87 @@ +/*********************************************************************************************************//** + * @file ht32f54231_41_libcfg.h + * @version $Rev:: 7184 $ + * @date $Date:: 2023-08-31 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F54231_41_LIBCFG_H +#define __HT32F54231_41_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F54231) && !defined(USE_MEM_HT32F54241) +#define USE_MEM_HT32F52352 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F54231 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x54231) +#endif + +#ifdef USE_MEM_HT32F54241 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x54241) +#endif + +#define LIBCFG_ADC_CH8_9 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_LEVEL_TYPE2 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIO_SINK_CURRENT_ENHANCED (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_LEDC (1) +#define LIBCFG_LEDC_NO_COM_8_11 (1) +#define LIBCFG_LSE (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_TKEY (1) +#define LIBCFG_UART1 (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54243_53_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54243_53_libcfg.h new file mode 100644 index 0000000000..750e4fb377 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f54243_53_libcfg.h @@ -0,0 +1,95 @@ +/*********************************************************************************************************//** + * @file ht32f54243_53_libcfg.h + * @version $Rev:: 6896 $ + * @date $Date:: 2023-05-08 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F54243_53_LIBCFG_H +#define __HT32F54243_53_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F54243) && !defined(USE_MEM_HT32F54253) +#define USE_MEM_HT32F52352 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F54243 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x54243) +#endif + +#ifdef USE_MEM_HT32F54253 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x54253) +#endif + +#define LIBCFG_ADC_CH8_9 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_IVREF_LEVEL_TYPE2 (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CRC (1) +#define LIBCFG_CMP (1) +#define LIBCFG_DIV (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_GPIO_SINK_CURRENT_ENHANCED (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_I2C2 (1) +#define LIBCFG_LEDC (1) +#define LIBCFG_LSE (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_TKEY (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_UART2 (1) +#define LIBCFG_UART3 (1) +#define LIBCFG_USART1 (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57331_41_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57331_41_libcfg.h new file mode 100644 index 0000000000..147fdcc041 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57331_41_libcfg.h @@ -0,0 +1,79 @@ +/*********************************************************************************************************//** + * @file ht32f57331_41_libcfg.h + * @version $Rev:: 6189 $ + * @date $Date:: 2022-09-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F57331_41_LIBCFG_H +#define __HT32F57331_41_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F57331) && !defined(USE_MEM_HT32F57341) +#define USE_MEM_HT32F57341 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F57331 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x57331) +#endif + +#ifdef USE_MEM_HT32F57341 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x57341) +#endif + +#define LIBCFG_ADC_CH8_9 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_LCD_SRC (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_LCD (1) +#define LIBCFG_LSE (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_USBD (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57342_52_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57342_52_libcfg.h new file mode 100644 index 0000000000..c8740e5f8d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f57342_52_libcfg.h @@ -0,0 +1,89 @@ +/*********************************************************************************************************//** + * @file ht32f57342_52_libcfg.h + * @version $Rev:: 7167 $ + * @date $Date:: 2023-08-25 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F57342_52_LIBCFG_H +#define __HT32F57342_52_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F57342) && !defined(USE_MEM_HT32F57352) +#define USE_MEM_HT32F57352 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F57342 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x57342) +#endif + +#ifdef USE_MEM_HT32F57352 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x57352) +#endif + +#define LIBCFG_ADC_CH8_9 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_AES (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_LCD_SRC (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CKCU_USB_PLL (1) +#define LIBCFG_CRC (1) +#define LIBCFG_CMP (1) +#define LIBCFG_DAC0 (1) +#define LIBCFG_DIV (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_GPIOE (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_I2S (1) +#define LIBCFG_LCD (1) +#define LIBCFG_LSE (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_PWM0 (1) +#define LIBCFG_PWM1 (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SCI1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_USBD (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5826_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5826_libcfg.h new file mode 100644 index 0000000000..f2378a22fd --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5826_libcfg.h @@ -0,0 +1,85 @@ +/*********************************************************************************************************//** + * @file ht32f5826_libcfg.h + * @version $Rev:: 7184 $ + * @date $Date:: 2023-08-31 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5826_LIBCFG_H +#define __HT32F5826_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F5826) +#define USE_MEM_HT32F5826 +#endif + +#define LIBCFG_MAX_SPEED (48000000) + +#define LIBCFG_FLASH_PAGESIZE (512) + +#ifdef USE_MEM_HT32F5826 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 255) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x5826) +#endif + +#define LIBCFG_PDMA (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_CMP (1) + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_GPTM1 (1) +#define LIBCFG_MCTM0 (1) + +#define LIBCFG_LSE (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SCI1 (1) +#define LIBCFG_USBD (1) +#define LIBCFG_EBI (1) +#define LIBCFG_I2S (1) +#define LIBCFG_CRC (1) + +#define LIBCFG_USART1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_I2C1 (1) + +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) + +#define LIBCFG_BAKREG (1) + +#define LIBCFG_FMC_BRANCHCACHE (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FLASH_2PAGE_PER_WPBIT (1) +#define LIBCFG_GPIO_DISABLE_DEBUG_PORT (1) +#define LIBCFG_RTC_LSI_LOAD_TRIM (1) +#define LIBCFG_CKCU_AUTO_TRIM_LEGACY (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_adc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_adc.h new file mode 100644 index 0000000000..c50babaa1a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_adc.h @@ -0,0 +1,660 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_adc.h + * @version $Rev:: 7265 $ + * @date $Date:: 2023-10-02 #$ + * @brief The header file of the ADC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __ht32f5XXXX_ADC_H +#define __ht32f5XXXX_ADC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup ADC + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Exported_Constants ADC exported constants + * @{ + */ +#define IS_ADC(x) (x == HT_ADC0) + +#define ONE_SHOT_MODE (0x00000000) +#define CONTINUOUS_MODE (0x00000002) +#if (LIBCFG_ADC_NO_DISCON_MODE) +#define IS_DISCONTINUOUS_MODE(x) (0) +#else +#define DISCONTINUOUS_MODE (0x00000003) +#define IS_DISCONTINUOUS_MODE(x) (x == DISCONTINUOUS_MODE) +#endif + +#define IS_ADC_CONVERSION_MODE(REGULAR_MODE) ((REGULAR_MODE == ONE_SHOT_MODE) || \ + (REGULAR_MODE == CONTINUOUS_MODE) || \ + (IS_DISCONTINUOUS_MODE(REGULAR_MODE))) + +#define ADC_CH_0 (0) +#define ADC_CH_1 (1) +#define ADC_CH_2 (2) +#define ADC_CH_3 (3) +#define ADC_CH_4 (4) +#define ADC_CH_5 (5) +#define ADC_CH_6 (6) +#define ADC_CH_7 (7) + +#define IS_ADC_CHANNEL1(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7)) + +#if (LIBCFG_ADC_CH8_9) +#define ADC_CH_8 (8) +#define ADC_CH_9 (9) +#define IS_ADC_CHANNEL2(CHANNEL) (((CHANNEL) == ADC_CH_8) || ((CHANNEL) == ADC_CH_9)) +#elif (LIBCFG_ADC_CH8_11) +#define ADC_CH_8 (8) +#define ADC_CH_9 (9) +#define ADC_CH_10 (10) +#define ADC_CH_11 (11) +#define IS_ADC_CHANNEL2(CHANNEL) (((CHANNEL) == ADC_CH_8) || ((CHANNEL) == ADC_CH_9) || \ + ((CHANNEL) == ADC_CH_10) || ((CHANNEL) == ADC_CH_11)) +#else +#define IS_ADC_CHANNEL2(CHANNEL) (0) +#endif + +#if (LIBCFG_ADC_CH12_15) +#define ADC_CH_12 (12) +#define ADC_CH_13 (13) +#define ADC_CH_14 (14) +#define ADC_CH_15 (15) +#define IS_ADC_CHANNEL3(CHANNEL) (((CHANNEL) == ADC_CH_12) || ((CHANNEL) == ADC_CH_13) || \ + ((CHANNEL) == ADC_CH_14) || ((CHANNEL) == ADC_CH_15)) +#else +#define IS_ADC_CHANNEL3(CHANNEL) (0) +#endif + +#if defined(USE_HT32F50020_30) +#define ADC_CH_BANDGAP (12) +#define ADC_CH_MVDDA (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_BANDGAP) || ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F50220_30) +#define ADC_CH_GND_VREF (12) +#define ADC_CH_VDD_VREF (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F50231_41) +#define ADC_CH_GND_VREF (12) +#define ADC_CH_VDD_VREF (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F52220_30) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F52231_41) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F52243_53) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F52331_41) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F52342_52) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F52344_54) +#define ADC_CH_IVREF (15) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_MVDDA (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_GND_VREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F52357_67) +#define ADC_CH_VDD_VREF (12) +#define ADC_CH_DAC0_CH1 (13) +#define ADC_CH_DAC0_CH0 (14) +#define ADC_CH_IVREF (15) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_MVDDA (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_VDD_VREF) || \ + ((CH) == ADC_CH_DAC0_CH1) || \ + ((CH) == ADC_CH_DAC0_CH0) || \ + ((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_GND_VREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F57331_41) +#define ADC_CH_VDD_VREF (12) +#define ADC_CH_IVREF (15) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_MVDDA (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_VDD_VREF) || \ + ((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_GND_VREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F57342_52) +#define ADC_CH_VDD_VREF (12) +#define ADC_CH_DAC0_CH1 (13) +#define ADC_CH_DAC0_CH0 (14) +#define ADC_CH_IVREF (15) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_MVDDA (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_VDD_VREF) || \ + ((CH) == ADC_CH_DAC0_CH1) || \ + ((CH) == ADC_CH_DAC0_CH0) || \ + ((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_GND_VREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F0006) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F61244_45) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F50343) +#define ADC_CH_MVDDA (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F5826) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_VDD_VREF (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || ((CH) == ADC_CH_VDD_VREF)) +#endif + +#if defined(USE_HT32F54231_41) +#define ADC_CH_GND_VREF (10) +#define ADC_CH_VDD_VREF (11) +#define ADC_CH_IVREF (12) +#define ADC_CH_MVDDA (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || \ + ((CH) == ADC_CH_VDD_VREF) || \ + ((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F54243_53) +#define ADC_CH_GND_VREF (10) +#define ADC_CH_VDD_VREF (11) +#define ADC_CH_IVREF (12) +#define ADC_CH_MVDDA (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_GND_VREF) || \ + ((CH) == ADC_CH_VDD_VREF) || \ + ((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F67041_51) +#define ADC_CH_IVREF (15) +#define ADC_CH_GND_VREF (16) +#define ADC_CH_MVDDA (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_GND_VREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F52234_44) +#define ADC_CH_DAC0_CH0 (12) +#define ADC_CH_DAC0_CH1 (13) +#define ADC_CH_DAC1_CH0 (14) +#define ADC_CH_DAC1_CH1 (15) +#define ADC_CH_IVREF (16) +#define ADC_CH_MVDDA (17) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_DAC0_CH0) || \ + ((CH) == ADC_CH_DAC0_CH1) || \ + ((CH) == ADC_CH_DAC1_CH0) || \ + ((CH) == ADC_CH_DAC1_CH1) || \ + ((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F53231_41) +#define ADC_CH_IVREF (12) +#define ADC_CH_MVDDA (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F53242_52) +#define ADC_CH_IVREF (12) +#define ADC_CH_MVDDA (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F50431_41) +#define ADC_CH_IVREF (12) +#define ADC_CH_MVDDA (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#if defined(USE_HT32F50442_52) +#define ADC_CH_IVREF (12) +#define ADC_CH_MVDDA (13) +#define IS_ADC_CH_INTERNAL1(CH) (((CH) == ADC_CH_IVREF) || \ + ((CH) == ADC_CH_MVDDA)) +#endif + +#define IS_ADC_CHANNEL(CHANNEL) (IS_ADC_CHANNEL1(CHANNEL) || \ + IS_ADC_CHANNEL2(CHANNEL) || \ + IS_ADC_CHANNEL3(CHANNEL) || \ + IS_ADC_CH_INTERNAL1(CHANNEL)) + +#define IS_ADC_INPUT_CHANNEL(CHANNEL) (IS_ADC_CHANNEL1(CHANNEL) || IS_ADC_CHANNEL2(CHANNEL) || IS_ADC_CHANNEL3(CHANNEL)) + + +#define ADC_TRIG_SOFTWARE (1UL << 0) + +#if (LIBCFG_ADC_SW_TRIGGER_ONLY) +#define IS_ADC_TRIG(REGTRIG) ((REGTRIG) == ADC_TRIG_SOFTWARE) +#else +/* ((ADCTCR[4] << 4) | (ADCTSR[20] << 20)) */ +#if (LIBCFG_CMP) +#define ADC_TRIG_CMP0 ((1UL << 4) | (0UL << 20)) +#define ADC_TRIG_CMP1 ((1UL << 4) | (1UL << 20)) +#endif + +/* ((ADCTCR[3] << 3) | (ADCTSR[23:22] << 22) | (ADCTSR[19] << 19)) */ +#define ADC_TRIG_BFTM0 ((1UL << 3) | (0UL << 22) | (0UL << 19)) +#if (LIBCFG_BFTM1) +#define ADC_TRIG_BFTM1 ((1UL << 3) | (0UL << 22) | (1UL << 19)) +#endif + +/* ((ADCTCR[3] << 3) | (ADCTSR[29:27]) << 27) | (ADCTSR[23:22] << 22) | (ADCTSR[19] << 19)) */ +#if (LIBCFG_PWM0) +#define ADC_TRIG_PWM0_MTO ((1UL << 3) | (0UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH0O ((1UL << 3) | (1UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH1O ((1UL << 3) | (2UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH2O ((1UL << 3) | (3UL << 27) | (1UL << 22) | (0UL << 19)) +#define ADC_TRIG_PWM0_CH3O ((1UL << 3) | (4UL << 27) | (1UL << 22) | (0UL << 19)) +#endif +#if (LIBCFG_PWM1) +#define ADC_TRIG_PWM1_MTO ((1UL << 3) | (0UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH0O ((1UL << 3) | (1UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH1O ((1UL << 3) | (2UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH2O ((1UL << 3) | (3UL << 27) | (1UL << 22) | (1UL << 19)) +#define ADC_TRIG_PWM1_CH3O ((1UL << 3) | (4UL << 27) | (1UL << 22) | (1UL << 19)) +#endif + +/* ((ADCTCR[2] << 2) | (ADCTSR[26:24] << 24) | (ADCTSR[18:16] << 16)) */ +#if (LIBCFG_MCTM0) +#define ADC_TRIG_MCTM0_MTO ((1UL << 2) | (0UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH0O ((1UL << 2) | (1UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH1O ((1UL << 2) | (2UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH2O ((1UL << 2) | (3UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH3O ((1UL << 2) | (4UL << 24) | (0UL << 16)) +#endif + +#if (LIBCFG_NO_GPTM0) +#define IS_ADC_TRIG_GPTM0(x) (0) +#else +#define ADC_TRIG_GPTM0_MTO ((1UL << 2) | (0UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH0O ((1UL << 2) | (1UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH1O ((1UL << 2) | (2UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH2O ((1UL << 2) | (3UL << 24) | (2UL << 16)) +#define ADC_TRIG_GPTM0_CH3O ((1UL << 2) | (4UL << 24) | (2UL << 16)) + +#define IS_ADC_TRIG_GPTM0(x) (((x) == ADC_TRIG_GPTM0_MTO) || \ + ((x) == ADC_TRIG_GPTM0_CH0O) || \ + ((x) == ADC_TRIG_GPTM0_CH1O) || \ + ((x) == ADC_TRIG_GPTM0_CH2O) || \ + ((x) == ADC_TRIG_GPTM0_CH3O)) +#endif + +#if (LIBCFG_GPTM1) +#define ADC_TRIG_GPTM1_MTO ((1UL << 2) | (0UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH0O ((1UL << 2) | (1UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH1O ((1UL << 2) | (2UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH2O ((1UL << 2) | (3UL << 24) | (3UL << 16)) +#define ADC_TRIG_GPTM1_CH3O ((1UL << 2) | (4UL << 24) | (3UL << 16)) +#endif + +/* (ADCTCR[1] << 1) | (ADCTSR[11:8] << 8) */ +#define ADC_TRIG_EXTI_0 ((1UL << 1) | ( 0UL << 8)) +#define ADC_TRIG_EXTI_1 ((1UL << 1) | ( 1UL << 8)) +#define ADC_TRIG_EXTI_2 ((1UL << 1) | ( 2UL << 8)) +#define ADC_TRIG_EXTI_3 ((1UL << 1) | ( 3UL << 8)) +#define ADC_TRIG_EXTI_4 ((1UL << 1) | ( 4UL << 8)) +#define ADC_TRIG_EXTI_5 ((1UL << 1) | ( 5UL << 8)) +#define ADC_TRIG_EXTI_6 ((1UL << 1) | ( 6UL << 8)) +#define ADC_TRIG_EXTI_7 ((1UL << 1) | ( 7UL << 8)) +#define ADC_TRIG_EXTI_8 ((1UL << 1) | ( 8UL << 8)) +#define ADC_TRIG_EXTI_9 ((1UL << 1) | ( 9UL << 8)) +#define ADC_TRIG_EXTI_10 ((1UL << 1) | (10UL << 8)) +#define ADC_TRIG_EXTI_11 ((1UL << 1) | (11UL << 8)) +#define ADC_TRIG_EXTI_12 ((1UL << 1) | (12UL << 8)) +#define ADC_TRIG_EXTI_13 ((1UL << 1) | (13UL << 8)) +#define ADC_TRIG_EXTI_14 ((1UL << 1) | (14UL << 8)) +#define ADC_TRIG_EXTI_15 ((1UL << 1) | (15UL << 8)) + +#define IS_ADC_TRIG(REGTRIG) (IS_ADC_TRIG1(REGTRIG) || \ + IS_ADC_TRIG2(REGTRIG) || \ + IS_ADC_TRIG3(REGTRIG) || \ + IS_ADC_TRIG4(REGTRIG) || \ + IS_ADC_TRIG5(REGTRIG) || \ + IS_ADC_TRIG6(REGTRIG) || \ + IS_ADC_TRIG7(REGTRIG)) + +#define IS_ADC_TRIG1(REGTRIG) (IS_ADC_TRIG_GPTM0(REGTRIG) || \ + ((REGTRIG) == ADC_TRIG_BFTM0) || \ + ((REGTRIG) == ADC_TRIG_EXTI_0) || \ + ((REGTRIG) == ADC_TRIG_EXTI_1) || \ + ((REGTRIG) == ADC_TRIG_EXTI_2) || \ + ((REGTRIG) == ADC_TRIG_EXTI_3) || \ + ((REGTRIG) == ADC_TRIG_EXTI_4) || \ + ((REGTRIG) == ADC_TRIG_EXTI_5) || \ + ((REGTRIG) == ADC_TRIG_EXTI_6) || \ + ((REGTRIG) == ADC_TRIG_EXTI_7) || \ + ((REGTRIG) == ADC_TRIG_EXTI_8) || \ + ((REGTRIG) == ADC_TRIG_EXTI_9) || \ + ((REGTRIG) == ADC_TRIG_EXTI_10) || \ + ((REGTRIG) == ADC_TRIG_EXTI_11) || \ + ((REGTRIG) == ADC_TRIG_EXTI_12) || \ + ((REGTRIG) == ADC_TRIG_EXTI_13) || \ + ((REGTRIG) == ADC_TRIG_EXTI_14) || \ + ((REGTRIG) == ADC_TRIG_EXTI_15) || \ + ((REGTRIG) == ADC_TRIG_SOFTWARE)) + +#if (LIBCFG_BFTM1) +#define IS_ADC_TRIG2(REGTRIG) ((REGTRIG) == ADC_TRIG_BFTM1) +#else +#define IS_ADC_TRIG2(REGTRIG) (0) +#endif + +#if (LIBCFG_MCTM0) +#define IS_ADC_TRIG3(REGTRIG) (((REGTRIG) == ADC_TRIG_MCTM0_MTO) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH0O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH1O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH2O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH3O) || \ + ((REGTRIG) == ADC_TRIG_BFTM1)) +#else +#define IS_ADC_TRIG3(REGTRIG) (0) +#endif + +#if (LIBCFG_GPTM1) +#define IS_ADC_TRIG4(REGTRIG) (((REGTRIG) == ADC_TRIG_GPTM1_MTO) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH0O) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH1O) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH2O) || \ + ((REGTRIG) == ADC_TRIG_GPTM1_CH3O)) +#else +#define IS_ADC_TRIG4(REGTRIG) (0) +#endif + +#if (LIBCFG_PWM0) +#define IS_ADC_TRIG5(REGTRIG) (((REGTRIG) == ADC_TRIG_PWM0_MTO) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH0O) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH1O) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH2O) || \ + ((REGTRIG) == ADC_TRIG_PWM0_CH3O)) +#else +#define IS_ADC_TRIG5(REGTRIG) (0) +#endif + +#if (LIBCFG_PWM1) +#define IS_ADC_TRIG6(REGTRIG) (((REGTRIG) == ADC_TRIG_PWM1_MTO) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH0O) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH1O) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH2O) || \ + ((REGTRIG) == ADC_TRIG_PWM1_CH3O)) +#else +#define IS_ADC_TRIG6(REGTRIG) (0) +#endif + +#if (LIBCFG_CMP) +#define IS_ADC_TRIG7(REGTRIG) (((REGTRIG) == ADC_TRIG_CMP0) || \ + ((REGTRIG) == ADC_TRIG_CMP1)) +#else +#define IS_ADC_TRIG7(REGTRIG) (0) +#endif +#endif + +#define ADC_INT_SINGLE_EOC (0x00000001) +#if (LIBCFG_ADC_NO_DISCON_MODE == 0) +#define ADC_INT_SUB_GROUP_EOC (0x00000002) +#endif +#define ADC_INT_CYCLE_EOC (0x00000004) +#if (LIBCFG_ADC_NO_WDT == 0) +#define ADC_INT_AWD_LOWER (0x00010000) +#define ADC_INT_AWD_UPPER (0x00020000) +#endif +#define ADC_INT_DATA_OVERWRITE (0x01000000) + +#define IS_ADC_INT(INT) ((((INT) & 0xFEFCFFF8) == 0) && ((INT) != 0)) + + +#define ADC_FLAG_SINGLE_EOC (0x00000001) +#if (LIBCFG_ADC_NO_DISCON_MODE == 0) +#define ADC_FLAG_SUB_GROUP_EOC (0x00000002) +#endif +#define ADC_FLAG_CYCLE_EOC (0x00000004) +#if (LIBCFG_ADC_NO_WDT == 0) +#define ADC_FLAG_AWD_LOWER (0x00010000) +#define ADC_FLAG_AWD_UPPER (0x00020000) +#endif +#define ADC_FLAG_DATA_OVERWRITE (0x01000000) + +#define IS_ADC_FLAG(FLAG) ((((FLAG) & 0xFEFCFFF8) == 0) && ((FLAG) != 0)) + + +#define ADC_REGULAR_DATA0 (0) +#define ADC_REGULAR_DATA1 (1) +#define ADC_REGULAR_DATA2 (2) +#define ADC_REGULAR_DATA3 (3) +#if (LIBCFG_ADC_NO_SEQ_4_7 == 0) +#define ADC_REGULAR_DATA4 (4) +#define ADC_REGULAR_DATA5 (5) +#define ADC_REGULAR_DATA6 (6) +#define ADC_REGULAR_DATA7 (7) +#endif + +#if (LIBCFG_ADC_NO_SEQ_4_7) +#define IS_ADC_REGULAR_DATA(DATA) ((DATA) < 4) +#else +#define IS_ADC_REGULAR_DATA(DATA) ((DATA) < 8) +#endif + +#define ADC_AWD_DISABLE (u8)0x00 +#define ADC_AWD_ALL_LOWER (u8)0x05 +#define ADC_AWD_ALL_UPPER (u8)0x06 +#define ADC_AWD_ALL_LOWER_UPPER (u8)0x07 +#define ADC_AWD_SINGLE_LOWER (u8)0x01 +#define ADC_AWD_SINGLE_UPPER (u8)0x02 +#define ADC_AWD_SINGLE_LOWER_UPPER (u8)0x03 + +#define IS_ADC_AWD(AWD) (((AWD) == ADC_AWD_DISABLE) || \ + ((AWD) == ADC_AWD_ALL_LOWER) || \ + ((AWD) == ADC_AWD_ALL_UPPER) || \ + ((AWD) == ADC_AWD_ALL_LOWER_UPPER) || \ + ((AWD) == ADC_AWD_SINGLE_LOWER) || \ + ((AWD) == ADC_AWD_SINGLE_UPPER) || \ + ((AWD) == ADC_AWD_SINGLE_LOWER_UPPER)) + +#define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) < 4096) + +#if (LIBCFG_PDMA) +#define ADC_PDMA_REGULAR_SINGLE (0x00000001) +#define ADC_PDMA_REGULAR_SUBGROUP (0x00000002) +#define ADC_PDMA_REGULAR_CYCLE (0x00000004) + +#define IS_ADC_PDMA(PDMA) (((PDMA) == ADC_PDMA_REGULAR_SINGLE) || \ + ((PDMA) == ADC_PDMA_REGULAR_SUBGROUP) || \ + ((PDMA) == ADC_PDMA_REGULAR_CYCLE)) +#endif + +#define IS_ADC_INPUT_SAMPLING_TIME(TIME) ((TIME) <= 255) + +#define IS_ADC_OFFSET(OFFSET) ((OFFSET) < 4096) + + +#if (LIBCFG_ADC_NO_SEQ_4_7) +#define IS_ADC_REGULAR_RANK(RANK) ((RANK) < 4) +#define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 1) && ((LENGTH) <= 4)) +#else +#define IS_ADC_REGULAR_RANK(RANK) ((RANK) < 8) +#define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 1) && ((LENGTH) <= 8)) +#endif +#define IS_ADC_REGULAR_SUB_LENGTH(SUB_LENGTH) (((SUB_LENGTH) >= 1) && ((SUB_LENGTH) <= 8)) + +#if (LIBCFG_ADC_IVREF) +#if (LIBCFG_ADC_IVREF_LEVEL_TYPE2) +#define ADC_VREF_2V5 (0ul << 4) +#define ADC_VREF_3V0 (1ul << 4) +#define ADC_VREF_4V0 (2ul << 4) +#define ADC_VREF_4V5 (3ul << 4) + +#define IS_ADC_VREF_SEL(SEL) ((SEL == ADC_VREF_2V5) || \ + (SEL == ADC_VREF_3V0) || \ + (SEL == ADC_VREF_4V0) || \ + (SEL == ADC_VREF_4V5)) +#else + #if LIBCFG_ADC_IVREF_DEFAULT_08V + #define ADC_VREF_0V8 (0ul << 4) + #define ADC_VREF_DEFAULT ADC_VREF_0V8 + #else + #define ADC_VREF_1V215 (0ul << 4) + #define ADC_VREF_DEFAULT ADC_VREF_1V215 + #endif +#define ADC_VREF_2V0 (1ul << 4) +#define ADC_VREF_2V5 (2ul << 4) +#define ADC_VREF_2V7 (3ul << 4) + +#define IS_ADC_VREF_SEL(SEL) ((SEL == ADC_VREF_DEFAULT) || \ + (SEL == ADC_VREF_2V0) || \ + (SEL == ADC_VREF_2V5) || \ + (SEL == ADC_VREF_2V7)) +#endif +#endif + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Exported_Functions ADC exported functions + * @{ + */ +void ADC_DeInit(HT_ADC_TypeDef* HT_ADCn); +void ADC_Reset(HT_ADC_TypeDef* HT_ADCn); +void ADC_Cmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); + +void ADC_SamplingTimeConfig(HT_ADC_TypeDef* HT_ADCn, u8 SampleClock); +void ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, ...); +void ADC_RegularGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength); +void ADC_RegularTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x); + +void ADC_SoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); + +u16 ADC_GetConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_REGULAR_DATAn); + +void ADC_IntConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x, ControlStatus NewState); +FlagStatus ADC_GetIntStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x); +void ADC_ClearIntPendingBit(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x); +FlagStatus ADC_GetFlagStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_FLAG_x); + +#if (LIBCFG_ADC_NO_WDT) +#else +void ADC_AWDConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_AWD_x); +void ADC_AWDSingleChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n); +void ADC_AWDThresholdsConfig(HT_ADC_TypeDef* HT_ADCn, u16 UPPER, u16 LOWER); +#endif + +#if (LIBCFG_PDMA) +void ADC_PDMAConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_PDMA_x, ControlStatus NewState); +#endif + +#if (LIBCFG_ADC_IVREF) +void ADC_VREFCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); +void ADC_VREFConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_VREF_x); +#endif + +#if (LIBCFG_ADC_VREFBUF) +void ADC_VREFOutputCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); +#endif + +#if (LIBCFG_ADC_MVDDA) +void ADC_MVDDACmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_aes.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_aes.h new file mode 100644 index 0000000000..ec7db17443 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_aes.h @@ -0,0 +1,209 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_aes.h + * @version $Rev:: 7390 $ + * @date $Date:: 2023-12-12 #$ + * @brief The header file of the ADC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_AES_H +#define __HT32F5XXXX_AES_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup AES + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Types AES exported types + * @{ + */ + +/** + * @brief Definition of AES Init Structure + */ +typedef struct +{ + u16 AES_KeySize; + u16 AES_Dir; + u16 AES_Mode; + u16 AES_Swap; +} AES_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Constants AES exported constants + * @{ + */ + +#define IS_AES(AES) (AES == HT_AES) + +/* Definitions of AES key size */ +#define AES_KEYSIZE_128B ((u32)0x00000000) +#define IS_AES_KEY_SIZE1(SIZE) (SIZE == AES_KEYSIZE_128B) + +#if (LIBCFG_AES_KEYSIZE_256B) +#define AES_KEYSIZE_192B ((u32)0x00000020) +#define AES_KEYSIZE_256B ((u32)0x00000040) +#define IS_AES_KEY_SIZE2(SIZE) ((SIZE == AES_KEYSIZE_192B) || (SIZE == AES_KEYSIZE_256B)) +#else +#define IS_AES_KEY_SIZE2(SIZE) (0) +#endif + +#define IS_AES_KEY_SIZE(SIZE) (IS_AES_KEY_SIZE1(SIZE) || IS_AES_KEY_SIZE2(SIZE)) + +/* Definitions of AES direction */ +typedef enum +{ + AES_DIR_ENCRYPT =0, + AES_DIR_DECRYPT =2 +} AES_DIR_Enum; + +#define IS_AES_DIR(DIR) ((DIR == AES_DIR_ENCRYPT) || (DIR == AES_DIR_DECRYPT)) + +/* Definitions of AES mode */ +#define AES_MODE_ECB ((u32)0x00000000) +#define AES_MODE_CBC ((u32)0x00000004) +#define AES_MODE_CTR ((u32)0x00000008) + +#define IS_AES_MODE(MODE) ((MODE == AES_MODE_ECB) || (MODE == AES_MODE_CBC) || (MODE == AES_MODE_CTR)) + +/* Definitions of AES key start */ +#define AES_KEYSTART_DISABLE ((u32)0x00000000) +#define AES_KEYSTART_ENABLE ((u32)0x00000010) + +#define IS_AES_KEYSTART(KEYSTART) ((KEYSTART == AES_KEYSTART_DISABLE) || (KEYSTART == AES_KEYSTART_ENABLE)) + +/* Definitions of AES swap */ +#define AES_SWAP_DISABLE ((u32)0x00000000) +#define AES_SWAP_ENABLE ((u32)0x00000100) + +#define IS_AES_SWAP(SWAP) ((SWAP == AES_SWAP_DISABLE) || (SWAP == AES_SWAP_ENABLE)) + +/* Definitions of AES flush */ +#define AES_FLUSH_DISABLE ((u32)0x00000000) +#define AES_FLUSH_ENABLE ((u32)0x00000400) + +#define IS_AES_FLUSH(FLUSH) ((FLUSH == AES_FLUSH_DISABLE) || (FLUSH == AES_FLUSH_ENABLE)) + +/* Definitions of AES Enable */ +#define AES_DISABLE ((u32)0x00000000) +#define AES_ENABLE ((u32)0x00000001) + +#define IS_AES_CMD(CMD) ((CMD == AES_DISABLE) || (CMD == AES_ENABLE)) + +/* Definitions of AES status */ +#define AES_SR_IFEMPTY ((u32)0x00000001) +#define AES_SR_IFNFULL ((u32)0x00000002) +#define AES_SR_OFNEMPTY ((u32)0x00000004) +#define AES_SR_OFFULL ((u32)0x00000008) +#define AES_SR_BUSY ((u32)0x00000010) + +#define IS_AES_STATUS(STATUS) ((STATUS == AES_SR_IFEMPTY) || \ + (STATUS == AES_SR_IFNFULL) || \ + (STATUS == AES_SR_OFNEMPTY) || \ + (STATUS == AES_SR_OFFULL) || \ + (STATUS == AES_SR_BUSY)) + +/* Definitions of AES PDMA */ +#define AES_PDMA_IFDMAEN ((u32)0x00000001) +#define AES_PDMA_OFDMAEN ((u32)0x00000002) + +#define IS_AES_PDMA(AES_PDMA) ((AES_PDMA == AES_PDMA_IFDMAEN) || (AES_PDMA == AES_PDMA_OFDMAEN)) + +/* Definitions of AES Interrupt Status */ +#define AES_INTSR_IFINT ((u32)0x00000001) +#define AES_INTSR_OFINT ((u32)0x00000002) + +#define IS_AES_INTSR(AES_INSR) ((AES_INSR == AES_INTSR_IFINT) || (AES_INSR == AES_INTSR_OFINT)) + +/* Definitions of AES interrupt enable */ +#define AES_IER_IFINTEN ((u32)0x00000001) +#define AES_IER_OFINTEN ((u32)0x00000002) + +#define IS_AES_IER(ARS_IER) ((ARS_IER == AES_IER_IFINTEN) || (ARS_IER == AES_IER_OFINTEN)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Functions AES exported functions + * @{ + */ +void AES_ECB_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); +void AES_CBC_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); +void AES_CTR_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); +void AES_SetKeyTable(HT_AES_TypeDef* HT_AESn, u32 *Key, u32 keySize); +ErrStatus _AES_CryptData(HT_AES_TypeDef* HT_AESn, AES_DIR_Enum dir, u32 *iv, u32 length, u32 *inputData, u32 *outputData); +#define AES_ECB_CryptData(a, b, c, d, e) _AES_CryptData(a, b, NULL, c, d, e) +#define AES_CBC_CryptData _AES_CryptData +#define AES_CTR_CryptData(a, b, c, d, e) _AES_CryptData(a, AES_DIR_ENCRYPT, b, c, d, e) +#if 0 +ErrStatus AES_ECB_CryptData(HT_AES_TypeDef* HT_AESn, AES_DIR_Enum mode, u32 length, u32 *inputData, u32 *outputData); +ErrStatus AES_CBC_CryptData(HT_AES_TypeDef* HT_AESn, AES_DIR_Enum mode, u32 *iv, u32 length, u32 *inputData, u32 *outputData); +ErrStatus AES_CTR_CryptData(HT_AES_TypeDef* HT_AESn, u32 *iv, u32 length, u32 *inputData, u32 *outputData); +#endif + +void AES_StartKey(HT_AES_TypeDef* HT_AESn); +void AES_DeInit(HT_AES_TypeDef* HT_AESn); +void AES_FIFOFlush(HT_AES_TypeDef* HT_AESn); +void AES_Cmd(HT_AES_TypeDef* HT_AESn, ControlStatus NewState); +FlagStatus AES_GetStatus(HT_AES_TypeDef* HT_AESn, u32 AES_Status); +void AES_PDMACmd(HT_AES_TypeDef* HT_AESn, u32 AES_PDMA_xFDMAEN, ControlStatus NewState); +FlagStatus AES_GetIntStatus(HT_AES_TypeDef* HT_AESn, u32 AES_INTSR_x); +void AES_IntConfig(HT_AES_TypeDef* HT_AESn, u32 AES_IER_x, ControlStatus NewState); +void AES_SetInputData(HT_AES_TypeDef* HT_AESn, uc32 AES_Data); +u32 AES_GetOutputData(HT_AES_TypeDef* HT_AESn); +void AES_SetVectorTable(HT_AES_TypeDef* HT_AESn, u32 *Vector); +void AESCore_IRQHandler(HT_AES_TypeDef* HT_AESn); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_bftm.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_bftm.h new file mode 100644 index 0000000000..5b6e6c904c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_bftm.h @@ -0,0 +1,111 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_bftm.h + * @version $Rev:: 6393 $ + * @date $Date:: 2022-10-27 #$ + * @brief The header file of the BFTM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_BFTM_H +#define __HT32F5XXXX_BFTM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup BFTM + * @{ + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Types BFTM exported types + * @{ + */ +#if (LIBCFG_BFTM_16BIT_COUNTER) +typedef u16 BFTM_DataTypeDef; +#else +typedef u32 BFTM_DataTypeDef; +#endif +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Constants BFTM exported constants + * @{ + */ +#define IS_BFTM(x) (IS_BFTM0(x) || IS_BFTM1(x)) + +#define IS_BFTM0(x) (x == HT_BFTM0) + +#if (LIBCFG_BFTM1) +#define IS_BFTM1(x) (x == HT_BFTM1) +#else +#define IS_BFTM1(x) (0) +#endif + +#define BFTM_FLAG_MATCH (1UL << 0) +#define BFTM_INT_MATCH (1UL << 0) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Functions BFTM exported functions + * @{ + */ +void BFTM_DeInit(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_EnaCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState); +void BFTM_SetCompare(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCompare); +u32 BFTM_GetCompare(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_SetCounter(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCounter); +u32 BFTM_GetCounter(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_OneShotModeCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState); +void BFTM_IntConfig(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState); +FlagStatus BFTM_GetFlagStatus(HT_BFTM_TypeDef* HT_BFTMn); +void BFTM_ClearFlag(HT_BFTM_TypeDef* HT_BFTMn); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_can.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_can.h new file mode 100644 index 0000000000..a66d141dd7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_can.h @@ -0,0 +1,498 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_can.h + * @version $Rev:: 7188 $ + * @date $Date:: 2023-08-31 #$ + * @brief The header file of the CAN library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_CAN_H +#define __HT32F5XXXX_CAN_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CAN + * @{ + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup CAN_Exported_Types CAN exported types + * @{ + */ + +/** + * @brief CAN message structure + */ +typedef struct +{ + u32 IdType; + u32 FrameType; + u32 Id; + u32 DLC; +} STR_CANMSG_TypeDef; + +/** + * @brief CAN TX message structure + */ +typedef struct +{ + u32 IdType; + u32 FrameType; + u32 Id; + u32 MCR; + u32 DLC; + u32 EOB; + u32 RMTEN; + u32 UMASK; + u32 Data[8]; +} STR_CANMSG_T_TypeDef; + +/** + * @brief CAN RX message structure + */ +typedef struct +{ + u32 IdType; + u32 Id; + u32 u8Xtd; + u32 u8Dir; + u32 MCR; + u32 MASK0; + u32 MASK1; + u32 EOB; + u32 UMASK; + u32 RMTEN; + u32 DIR; /* For receive remote frame. */ + } STR_CANMSG_R_TypeDef; + +/** + * @brief CAN mask message structure + */ +typedef struct +{ + u32 u8Xtd; + u32 u8Dir; + u32 u32Id; + u32 u8IdType; +} STR_CANMASK_TyprDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CAN_Exported_Constants CAN exported constants + * @{ + */ +#define IS_CAN(x) IS_CAN0(x) +#define IS_CAN0(x) (x == HT_CAN0) + +/** + * @brief CAN Test Mode Constant Definitions + */ +#define CAN_NORMAL_MODE 0 +#define CAN_BASIC_MODE 0x04 +#define CAN_SILENT_MODE 0x08 +#define CAN_LBACK_MODE 0x10 +#define CAN_LBS_MODE 0x18 + +/** + * @brief DMessage ID Type Constant Definitions + */ +#define CAN_STD_ID 0 +#define CAN_EXT_ID 1 + +/** + * @brief Message Frame Type Constant Definitions + */ +#define CAN_REMOTE_FRAME 0 +#define CAN_DATA_FRAME 1 + +#define CAN_NBR 1 +#define CAN_VECTOR_NBR 1 +#define DATA_NBR 4 + +/** + * @brief CAN CR Bit Field Definitions + */ +#define CAN_CR_TEST_Pos 7 /*!< CAN_T::CR: TEST Position */ +#define CAN_CR_TEST_Msk (1ul << CAN_CR_TEST_Pos) /*!< CAN_T::CR: TEST Mask */ + +#define CAN_CR_CCE_Pos 6 /*!< CAN_T::CR: CCE Position */ +#define CAN_CR_CCE_Msk (1ul << CAN_CR_CCE_Pos) /*!< CAN_T::CR: CCE Mask */ + +#define CAN_CR_DAR_Pos 5 /*!< CAN_T::CR: DAR Position */ +#define CAN_CR_DAR_Msk (1ul << CAN_CR_DAR_Pos) /*!< CAN_T::CR: DAR Mask */ + +#define CAN_CR_EIE_Pos 3 /*!< CAN_T::CR: EIE Position */ +#define CAN_CR_EIE_Msk (1ul << CAN_CR_EIE_Pos) /*!< CAN_T::CR: EIE Mask */ + +#define CAN_CR_SIE_Pos 2 /*!< CAN_T::CR: SIE Position */ +#define CAN_CR_SIE_Msk (1ul << CAN_CR_SIE_Pos) /*!< CAN_T::CR SIE Mask */ + +#define CAN_CR_IE_Pos 1 /*!< CAN_T::CR: IE Position */ +#define CAN_CR_IE_Msk (1ul << CAN_CR_IE_Pos) /*!< CAN_T::CR: IE Mask */ + +#define CAN_CR_INIT_Pos 0 /*!< CAN_T::CR: INIT Position */ +#define CAN_CR_INIT_Msk (1ul << CAN_CR_INIT_Pos) /*!< CAN_T::CR: INIT Mask */ + +/** + * @brief CAN STATUS Bit Field Definitions + */ +#define CAN_SR_BOFF_Pos 7 /*!< CAN_T::STATUS: BOFF Position */ +#define CAN_SR_BOFF_Msk (1ul << CAN_SR_BOFF_Pos) /*!< CAN_T::STATUS: BOFF Mask */ + +#define CAN_SR_EWARN_Pos 6 /*!< CAN_T::STATUS: EWARN Position */ +#define CAN_SR_EWARN_Msk (1ul << CAN_SR_EWARN_Pos) /*!< CAN_T::STATUS: EWARN Mask */ + +#define CAN_SR_EPASS_Pos 5 /*!< CAN_T::STATUS: EPASS Position */ +#define CAN_SR_EPASS_Msk (1ul << CAN_SR_EPASS_Pos) /*!< CAN_T::STATUS: EPASS Mask */ + +#define CAN_SR_RXOK_Pos 4 /*!< CAN_T::STATUS: RXOK Position */ +#define CAN_SR_RXOK_Msk (1ul << CAN_SR_RXOK_Pos) /*!< CAN_T::STATUS: RXOK Mask */ + +#define CAN_SR_TXOK_Pos 3 /*!< CAN_T::STATUS: TXOK Position */ +#define CAN_SR_TXOK_Msk (1ul << CAN_SR_TXOK_Pos) /*!< CAN_T::STATUS: TXOK Mask */ + +#define CAN_SR_LEC_Pos 0 /*!< CAN_T::STATUS: LEC Position */ +#define CAN_SR_LEC_Msk (0x3ul << CAN_SR_LEC_Pos) /*!< CAN_T::STATUS: LEC Mask */ + +/** + * @brief CAN ECR Bit Field Definitions + */ +#define CAN_ECR_RP_Pos 15 /*!< CAN_T::ECR: RP Position */ +#define CAN_ECR_RP_Msk (1ul << CAN_ECR_RP_Pos) /*!< CAN_T::ECR: RP Mask */ + +#define CAN_ECR_REC_Pos 8 /*!< CAN_T::ECR: REC Position */ +#define CAN_ECR_REC_Msk (0x7Ful << CAN_ECR_REC_Pos) /*!< CAN_T::ECR: REC Mask */ + +#define CAN_ECR_TEC_Pos 0 /*!< CAN_T::ECR: TEC Position */ +#define CAN_ECR_TEC_Msk (0xFFul << CAN_ECR_TEC_Pos) /*!< CAN_T::ECR: TEC Mask */ + +/** + * @brief CAN BTR Bit Field Definitions + */ +#define CAN_BTR_TSEG1_Pos 12 /*!< CAN_T::BTR: TSEG1 Position */ +#define CAN_BTR_TSEG1_Msk (0x7ul << CAN_BTR_TSEG1_Pos) /*!< CAN_T::BTR: TSEG1 Mask */ + +#define CAN_BTR_TSEG0_Pos 8 /*!< CAN_T::BTR: TSEG0 Position */ +#define CAN_BTR_TSEG0_Msk (0xFul << CAN_BTR_TSEG0_Pos) /*!< CAN_T::BTR: TSEG0 Mask */ + +#define CAN_BTR_SJW_Pos 6 /*!< CAN_T::BTR: SJW Position */ +#define CAN_BTR_SJW_Msk (0x3ul << CAN_BTR_SJW_Pos) /*!< CAN_T::BTR: SJW Mask */ + +#define CAN_BTR_BRP_Pos 0 /*!< CAN_T::BTR: BRP Position */ +#define CAN_BTR_BRP_Msk (0x3Ful << CAN_BTR_BRP_Pos) /*!< CAN_T::BTR: BRP Mask */ + +/** + * @brief CAN IR Bit Field Definitions + */ +#define CAN_IR_INTID_Pos 0 /*!< CAN_T::IR: INTID Position */ +#define CAN_IR_INTID_Msk (0xFFFFul << CAN_IR_INTID_Pos) /*!< CAN_T::R: INTID Mask */ + +/** + * @brief CAN TEST Bit Field Definitions + */ +#define CAN_TEST_RX_Pos 7 /*!< CAN_T::TEST: RX Position */ +#define CAN_TEST_RX_Msk (1ul << CAN_TEST_RX_Pos) /*!< CAN_T::TEST: RX Mask */ + +#define CAN_TEST_TX_Pos 5 /*!< CAN_T::TEST: TX Position */ +#define CAN_TEST_TX_Msk (0x3ul << CAN_TEST_TX_Pos) /*!< CAN_T::TEST: TX Mask */ + +#define CAN_TEST_LBACK_Pos 4 /*!< CAN_T::TEST: LBACK Position */ +#define CAN_TEST_LBACK_Msk (1ul << CAN_TEST_LBACK_Pos) /*!< CAN_T::TEST: LBACK Mask */ + +#define CAN_TEST_SILENT_Pos 3 /*!< CAN_T::TEST: Silent Position */ +#define CAN_TEST_SILENT_Msk (1ul << CAN_TEST_SILENT_Pos) /*!< CAN_T::TEST: Silent Mask */ + +#define CAN_TEST_BASIC_Pos 2 /*!< CAN_T::TEST: Basic Position */ +#define CAN_TEST_BASIC_Msk (1ul << CAN_TEST_BASIC_Pos) /*!< CAN_T::TEST: Basic Mask */ + +/** + * @brief CAN BPRE Bit Field Definitions + */ +#define CAN_BRPE_BRPE_Pos 0 /*!< CAN_T::BRPE: BRPE Position */ +#define CAN_BRPE_BRPE_Msk (0xFul << CAN_BRPE_BRPE_Pos) /*!< CAN_T::BRPE: BRPE Mask */ + +/** + * @brief CAN IFn_CREQ Bit Field Definitions + */ +#define CAN_IF_CREQ_BUSY_Pos 15 /*!< CAN_T::IFnCREQ: BUSY Position */ +#define CAN_IF_CREQ_BUSY_Msk (1ul << CAN_IF_CREQ_BUSY_Pos) /*!< CAN_T::IFnCREQ: BUSY Mask */ + +#define CAN_IF_CREQ_MSGNUM_Pos 0 /*!< CAN_T::IFnCREQ: MSGNUM Position */ +#define CAN_IF_CREQ_MSGNUM_Msk (0x3Ful << CAN_IF_CREQ_MSGNUM_Pos) /*!< CAN_T::IFnCREQ: MSGNUM Mask */ + +/** + * @brief CAN IFn_CMASK Bit Field Definitions + */ +#define CAN_IF_CMASK_WRRD_Pos 7 /*!< CAN_T::IFnCMASK: WRRD Position */ +#define CAN_IF_CMASK_WRRD_Msk (1ul << CAN_IF_CMASK_WRRD_Pos) /*!< CAN_T::IFnCMASK: WRRD Mask */ + +#define CAN_IF_CMASK_MASK_Pos 6 /*!< CAN_T::IFnCMASK: MASK Position */ +#define CAN_IF_CMASK_MASK_Msk (1ul << CAN_IF_CMASK_MASK_Pos) /*!< CAN_T::IFnCMASK: MASK Mask */ + +#define CAN_IF_CMASK_ARB_Pos 5 /*!< CAN_T::IFnCMASK: ARB Position */ +#define CAN_IF_CMASK_ARB_Msk (1ul << CAN_IF_CMASK_ARB_Pos) /*!< CAN_T::IFnCMASK: ARB Mask */ + +#define CAN_IF_CMASK_CONTROL_Pos 4 /*!< CAN_T::IFnCMASK: CONTROL Position */ +#define CAN_IF_CMASK_CONTROL_Msk (1ul << CAN_IF_CMASK_CONTROL_Pos) /*!< CAN_T::IFnCMASK: CONTROL Mask */ + +#define CAN_IF_CMASK_CLRINTPND_Pos 3 /*!< CAN_T::IFnCMASK: CLRINTPND Position */ +#define CAN_IF_CMASK_CLRINTPND_Msk (1ul << CAN_IF_CMASK_CLRINTPND_Pos) /*!< CAN_T::IFnCMASK: CLRINTPND Mask */ + +#define CAN_IF_CMASK_TXRQSTNEWDAT_Pos 2 /*!< CAN_T::IFnCMASK: TXRQSTNEWDAT Position */ +#define CAN_IF_CMASK_TXRQSTNEWDAT_Msk (1ul << CAN_IF_CMASK_TXRQSTNEWDAT_Pos) /*!< CAN_T::IFnCMASK: TXRQSTNEWDAT Mask */ + +#define CAN_IF_CMASK_DATAA_Pos 1 /*!< CAN_T::IFnCMASK: DATAA Position */ +#define CAN_IF_CMASK_DATAA_Msk (1ul << CAN_IF_CMASK_DATAA_Pos) /*!< CAN_T::IFnCMASK: DATAA Mask */ + +#define CAN_IF_CMASK_DATAB_Pos 0 /*!< CAN_T::IFnCMASK: DATAB Position */ +#define CAN_IF_CMASK_DATAB_Msk (1ul << CAN_IF_CMASK_DATAB_Pos) /*!< CAN_T::IFnCMASK: DATAB Mask */ + +/** + * @brief CAN IFn_MASK0 Bit Field Definitions + */ +#define CAN_IF_MASK0_MSK_Pos 0 /*!< CAN_T::IFnMASK0: MSK Position */ +#define CAN_IF_MASK0_MSK_Msk (0xFFul << CAN_IF_MASK0_MSK_Pos) /*!< CAN_T::IFnMASK0: MSK Mask */ + +/** + * @brief CAN IFn_MASK1 Bit Field Definitions + */ +#define CAN_IF_MASK1_MXTD_Pos 15 /*!< CAN_T::IFnMASK1: MXTD Position */ +#define CAN_IF_MASK1_MXTD_Msk (1ul << CAN_IF_MASK1_MXTD_Pos) /*!< CAN_T::IFnMASK1: MXTD Mask */ + +#define CAN_IF_MASK1_MDIR_Pos 14 /*!< CAN_T::IFnMASK1: MDIR Position */ +#define CAN_IF_MASK1_MDIR_Msk (1ul << CAN_IF_MASK1_MDIR_Pos) /*!< CAN_T::IFnMASK1: MDIR Mask */ + +#define CAN_IF_MASK1_MSK_Pos 0 /*!< CAN_T::IFnMASK1: MSK Position */ +#define CAN_IF_MASK1_MSK_Msk (0x1FFul << CAN_IF_MASK1_MSK_Pos) /*!< CAN_T::IFnMASK1: MSK Mask */ + +/** + * @brief CAN IFn_ARB0 Bit Field Definitions + */ +#define CAN_IF_ARB0_ID_Pos 0 /*!< CAN_T::IFnARB0: ID Position */ +#define CAN_IF_ARB0_ID_Msk (0xFFFFul << CAN_IF_ARB0_ID_Pos) /*!< CAN_T::IFnARB0: ID Mask */ + +/** + * @brief CAN IFn_ARB1 Bit Field Definitions + */ +#define CAN_IF_ARB1_MSGVAL_Pos 15 /*!< CAN_T::IFnARB1: MSGVAL Position */ +#define CAN_IF_ARB1_MSGVAL_Msk (1ul << CAN_IF_ARB1_MSGVAL_Pos) /*!< CAN_T::IFnARB1: MSGVAL Mask */ + +#define CAN_IF_ARB1_XTD_Pos 14 /*!< CAN_T::IFnARB1: XTD Position */ +#define CAN_IF_ARB1_XTD_Msk (1ul << CAN_IF_ARB1_XTD_Pos) /*!< CAN_T::IFnARB1: XTD Mask */ + +#define CAN_IF_ARB1_DIR_Pos 13 /*!< CAN_T::IFnARB1: DIR Position */ +#define CAN_IF_ARB1_DIR_Msk (1ul << CAN_IF_ARB1_DIR_Pos) /*!< CAN_T::IFnARB1: DIR Mask */ + +#define CAN_IF_ARB1_ID_Pos 0 /*!< CAN_T::IFnARB1: ID Position */ +#define CAN_IF_ARB1_ID_Msk (0x1FFFul << CAN_IF_ARB1_ID_Pos) /*!< CAN_T::IFnARB1: ID Mask */ + +/** + * @brief CAN IFn_MCR Bit Field Definitions + */ +#define CAN_IF_MCR_NEWDAT_Pos 15 /*!< CAN_T::IFnMCON: NEWDAT Position */ +#define CAN_IF_MCR_NEWDAT_Msk (1ul << CAN_IF_MCR_NEWDAT_Pos) /*!< CAN_T::IFnMCON: NEWDAT Mask */ + +#define CAN_IF_MCR_MSGLST_Pos 14 /*!< CAN_T::IFnMCON: MSGLST Position */ +#define CAN_IF_MCR_MSGLST_Msk (1ul << CAN_IF_MCR_MSGLST_Pos) /*!< CAN_T::IFnMCON: MSGLST Mask */ + +#define CAN_IF_MCR_INTPND_Pos 13 /*!< CAN_T::IFnMCON: INTPND Position */ +#define CAN_IF_MCR_INTPND_Msk (1ul << CAN_IF_MCR_INTPND_Pos) /*!< CAN_T::IFnMCON: INTPND Mask */ + +#define CAN_IF_MCR_UMASK_Pos 12 /*!< CAN_T::IFnMCON: UMASK Position */ +#define CAN_IF_MCR_UMASK_Msk (1ul << CAN_IF_MCR_UMASK_Pos) /*!< CAN_T::IFnMCON: UMASK Mask */ + +#define CAN_IF_MCR_TXIE_Pos 11 /*!< CAN_T::IFnMCON: TXIE Position */ +#define CAN_IF_MCR_TXIE_Msk (1ul << CAN_IF_MCR_TXIE_Pos) /*!< CAN_T::IFnMCON: TXIE Mask */ + +#define CAN_IF_MCR_RXIE_Pos 10 /*!< CAN_T::IFnMCON: RXIE Position */ +#define CAN_IF_MCR_RXIE_Msk (1ul << CAN_IF_MCR_RXIE_Pos) /*!< CAN_T::IFnMCON: RXIE Mask */ + +#define CAN_IF_MCR_RMTEN_Pos 9 /*!< CAN_T::IFnMCON: RMTEN Position */ +#define CAN_IF_MCR_RMTEN_Msk (1ul << CAN_IF_MCR_RMTEN_Pos) /*!< CAN_T::IFnMCON: RMTEN Mask */ + +#define CAN_IF_MCR_TXRQST_Pos 8 /*!< CAN_T::IFnMCON: TXRQST Position */ +#define CAN_IF_MCR_TXRQST_Msk (1ul << CAN_IF_MCR_TXRQST_Pos) /*!< CAN_T::IFnMCON: TXRQST Mask */ + +#define CAN_IF_MCR_EOB_Pos 7 /*!< CAN_T::IFnMCON: EOB Position */ +#define CAN_IF_MCR_EOB_Msk (1ul << CAN_IF_MCR_EOB_Pos) /*!< CAN_T::IFnMCON: EOB Mask */ + +#define CAN_IF_MCR_DLC_Pos 0 /*!< CAN_T::IFnMCON: DLC Position */ +#define CAN_IF_MCR_DLC_Msk (0xFul << CAN_IF_MCR_DLC_Pos) /*!< CAN_T::IFnMCON: DLC Mask */ + +/** + * @brief CAN IFn_DATA_A0 Bit Field Definitions + */ +#define CAN_IF_DAT_A0_DATA1_Pos 8 /*!< CAN_T::IFnDATAA0: DATA1 Position */ +#define CAN_IF_DAT_A0_DATA1_Msk (0xFFul << CAN_IF_DAT_A0_DATA1_Pos) /*!< CAN_T::IFnDATAA0: DATA1 Mask */ + +#define CAN_IF_DAT_A0_DATA0_Pos 0 /*!< CAN_T::IFnDATAA0: DATA0 Position */ +#define CAN_IF_DAT_A0_DATA0_Msk (0xFFul << CAN_IF_DAT_A0_DATA0_Pos) /*!< CAN_T::IFnDATAA0: DATA0 Mask */ + +/** + * @brief CAN IFn_DATA_A1 Bit Field Definitions + */ +#define CAN_IF_DAT_A1_DATA3_Pos 8 /*!< CAN_T::IFnDATAA1: DATA3 Position */ +#define CAN_IF_DAT_A1_DATA3_Msk (0xFFul << CAN_IF_DAT_A1_DATA3_Pos) /*!< CAN_T::IFnDATAA1: DATA3 Mask */ + +#define CAN_IF_DAT_A1_DATA2_Pos 0 /*!< CAN_T::IFnDATAA1: DATA2 Position */ +#define CAN_IF_DAT_A1_DATA2_Msk (0xFFul << CAN_IF_DAT_A1_DATA2_Pos) /*!< CAN_T::IFnDATAA1: DATA2 Mask */ + +/** + * @brief CAN IFn_DATA_B0 Bit Field Definitions + */ +#define CAN_IF_DAT_B0_DATA5_Pos 8 /*!< CAN_T::IFnDATAB0: DATA5 Position */ +#define CAN_IF_DAT_B0_DATA5_Msk (0xFFul << CAN_IF_DAT_B0_DATA5_Pos) /*!< CAN_T::IFnDATAB0: DATA5 Mask */ + +#define CAN_IF_DAT_B0_DATA4_Pos 0 /*!< CAN_T::IFnDATAB0: DATA4 Position */ +#define CAN_IF_DAT_B0_DATA4_Msk (0xFFul << CAN_IF_DAT_B0_DATA4_Pos) /*!< CAN_T::IFnDATAB0: DATA4 Mask */ + +/** + * @brief CAN IFn_DATA_B1 Bit Field Definitions + */ +#define CAN_IF_DAT_B1_DATA7_Pos 8 /*!< CAN_T::IFnDATAB1: DATA7 Position */ +#define CAN_IF_DAT_B1_DATA7_Msk (0xFFul << CAN_IF_DAT_B1_DATA7_Pos) /*!< CAN_T::IFnDATAB1: DATA7 Mask */ + +#define CAN_IF_DAT_B1_DATA6_Pos 0 /*!< CAN_T::IFnDATAB1: DATA6 Position */ +#define CAN_IF_DAT_B1_DATA6_Msk (0xFFul << CAN_IF_DAT_B1_DATA6_Pos) /*!< CAN_T::IFnDATAB1: DATA6 Mask */ + +/** + * @brief CAN IFn_TXRQST0 Bit Field Definitions + */ +#define CAN_IF_TXRQST0_TXRQST_Pos 0 /*!< CAN_T::IFnTXRQST0: TXRQST Position */ +#define CAN_IF_TXRQST0_TXRQST_Msk (0xFFFFul << CAN_IF_TXRQST0_TXRQST_Pos) /*!< CAN_T::IFnTXRQST0: TXRQST Mask */ + +/** + * @brief CAN IFn_TXRQST1 Bit Field Definitions + */ +#define CAN_IF_TXRQST1_TXRQST_Pos 0 /*!< CAN_T::IFnTXRQST1: TXRQST Position */ +#define CAN_IF_TXRQST1_TXRQST_Msk (0xFFFFul << CAN_IF_TXRQST1_TXRQST_Pos) /*!< CAN_T::IFnTXRQST1: TXRQST Mask */ + +/** + * @brief CAN IFn_NDAT0 Bit Field Definitions + */ +#define CAN_IF_NDAT0_NEWDATA_Pos 0 /*!< CAN_T::IFnNDAT0: NEWDATA Position */ +#define CAN_IF_NDAT0_NEWDATA_Msk (0xFFFFul << CAN_IF_NDAT0_NEWDATA_Pos) /*!< CAN_T::IFnNDAT0: NEWDATA Mask */ + +/** + * @brief CAN IFn_NDAT1 Bit Field Definitions + */ +#define CAN_IF_NDAT1_NEWDATA_Pos 0 /*!< CAN_T::IFnNDAT1: NEWDATA Position */ +#define CAN_IF_NDAT1_NEWDATA_Msk (0xFFFFul << CAN_IF_NDAT1_NEWDATA_Pos) /*!< CAN_T::IFnNDAT1: NEWDATA Mask */ + +/** + * @brief CAN IFn_IPND0 Bit Field Definitions + */ +#define CAN_IF_IPND0_INTPND_Pos 0 /*!< CAN_T::IFnIPND0: INTPND Position */ +#define CAN_IF_IPND0_INTPND_Msk (0xFFFFul << CAN_IF_IPND0_INTPND_Pos) /*!< CAN_T::IFnIPND0: INTPND Mask */ + +/** + * @brief CAN IFn_IPND1 Bit Field Definitions + */ +#define CAN_IF_IPND1_INTPND_Pos 0 /*!< CAN_T::IFnIPND1: INTPND Position */ +#define CAN_IF_IPND1_INTPND_Msk (0xFFFFul << CAN_IF_IPND1_INTPND_Pos) /*!< CAN_T::IFnIPND1: INTPND Mask */ + +/** + * @brief CAN IFn_MVLD0 Bit Field Definitions + */ +#define CAN_IF_MVLD0_MSGVAL_Pos 0 /*!< CAN_T::IFnMVLD0: MSGVAL Position */ +#define CAN_IF_MVLD0_MSGVAL_Msk (0xFFFFul << CAN_IF_MVLD0_MSGVAL_Pos) /*!< CAN_T::IFnMVLD0: MSGVAL Mask */ + +/** + * @brief CAN IFn_MVLD1 Bit Field Definitions + */ +#define CAN_IF_MVLD1_MSGVAL_Pos 0 /*!< CAN_T::IFnMVLD1: MSGVAL Position */ +#define CAN_IF_MVLD1_MSGVAL_Msk (0xFFFFul << CAN_IF_MVLD1_MSGVAL_Pos) /*!< CAN_T::IFnMVLD1: MSGVAL Mask */ + +/** + * @brief CAN WUEN Bit Field Definitions + */ +#define CAN_WUEN_WAKUP_EN_Pos 0 /*!< CAN_T::WUEN: WAKUP_EN Position */ +#define CAN_WUEN_WAKUP_EN_Msk (1ul << CAN_WUEN_WAKUP_EN_Pos) /*!< CAN_T::WUEN: WAKUP_EN Mask */ + +/** + * @brief CAN WUSTATUS Bit Field Definitions + */ +#define CAN_WUSTATUS_WAKUP_STS_Pos 0 /*!< CAN_T::WUSTATUS: WAKUP_STS Position */ +#define CAN_WUSTATUS_WAKUP_STS_Msk (1ul << CAN_WUSTATUS_WAKUP_STS_Pos) /*!< CAN_T::WUSTATUS: WAKUP_STS Mask */ +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CAN_Exported_Functions CAN exported functions + * @{ + */ +void CAN_DeInit(HT_CAN_TypeDef* CANx); +u32 CAN_SetBaudRate(HT_CAN_TypeDef *CANx, u32 u32BaudRate); +void CAN_Close(HT_CAN_TypeDef *CANx); +u32 CAN_Open(HT_CAN_TypeDef *CANx, u32 u32BaudRate, u32 u32Mode); +void CAN_CLR_INT_PENDING_BIT(HT_CAN_TypeDef *CANx, u32 u32MsgNum); +void CAN_EnableInt(HT_CAN_TypeDef *CANx, u32 u32Mask); +void CAN_DisableInt(HT_CAN_TypeDef *CANx, u32 u32Mask); +s32 CAN_Transmit(HT_CAN_TypeDef *CANx, u32 u32MsgNum , STR_CANMSG_T_TypeDef* pCanMsg); +s32 CAN_Receive(HT_CAN_TypeDef *CANx, u32 u32MsgNum , STR_CANMSG_T_TypeDef* pCanMsg); +s32 CAN_SetRxMsg(HT_CAN_TypeDef *CANx, u32 u32MsgNum , STR_CANMSG_R_TypeDef* pCanMsg); +s32 CAN_SetTxMsg(HT_CAN_TypeDef *CANx, u32 u32MsgNum , STR_CANMSG_T_TypeDef* pCanMsg); +s32 CAN_TriggerTxMsg(HT_CAN_TypeDef *CANx, u32 u32MsgNum); +void CAN_EnterInitMode(HT_CAN_TypeDef *CANx); +void CAN_LeaveInitMode(HT_CAN_TypeDef *CANx); +void CAN_WaitMsg(HT_CAN_TypeDef *CANx); +u32 CAN_GetCANBitRate(HT_CAN_TypeDef *CANx); +void CAN_EnterTestMode(HT_CAN_TypeDef *CANx, u32 u8TestMask); +void CAN_LeaveTestMode(HT_CAN_TypeDef *CANx); +u32 CAN_IsNewDataReceived(HT_CAN_TypeDef *CANx, u32 u8MsgObj); +s32 CAN_BasicSendMsg(HT_CAN_TypeDef *CANx, STR_CANMSG_T_TypeDef* pCanMsg); +s32 CAN_BasicReceiveMsg(HT_CAN_TypeDef *CANx, STR_CANMSG_T_TypeDef* pCanMsg); +s32 CAN_SetRxMsgObj(HT_CAN_TypeDef *CANx, u32 MsgObj, STR_CANMSG_R_TypeDef* pCanMsg); +s32 CAN_ReadMsgObj(HT_CAN_TypeDef *CANx, u32 u8MsgObj, u32 u8Release, STR_CANMSG_T_TypeDef* pCanMsg); +s32 CAN_MsgObjMaskConfig(HT_CAN_TypeDef *tCAN, u32 u8MsgObj, STR_CANMSG_R_TypeDef* MaskMsg); +s32 CAN_SetMultiRxMsg(HT_CAN_TypeDef *CANx, u32 u32MsgNum , u32 u32MsgCount, STR_CANMSG_R_TypeDef* pCanMsg); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ckcu.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ckcu.h new file mode 100644 index 0000000000..531078537b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ckcu.h @@ -0,0 +1,936 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_ckcu.h + * @version $Rev:: 7108 $ + * @date $Date:: 2023-08-09 #$ + * @brief The header file of the Clock Control Unit library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_CKCU_H +#define __HT32F5XXXX_CKCU_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CKCU + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Exported_Types CKCU exported types + * @{ + */ + +#if (!LIBCFG_CKCU_NO_APB_PRESCALER) +/** + * @brief Enumeration of APB peripheral prescaler. + */ +typedef enum +{ + CKCU_APBCLKPRE_DIV1 = 0, + CKCU_APBCLKPRE_DIV2, + CKCU_APBCLKPRE_DIV4, + CKCU_APBCLKPRE_DIV8, + CKCU_APBCLKPRE_DIV16, + CKCU_APBCLKPRE_DIV32 +} CKCU_APBCLKPRE_TypeDef; +#endif + +/** + * @brief Enumeration of CK_REF prescaler. + */ +typedef enum +{ + CKCU_CKREFPRE_DIV2 = 0, + CKCU_CKREFPRE_DIV4, + CKCU_CKREFPRE_DIV6, + CKCU_CKREFPRE_DIV8, + CKCU_CKREFPRE_DIV10, + CKCU_CKREFPRE_DIV12, + CKCU_CKREFPRE_DIV14, + CKCU_CKREFPRE_DIV16, + CKCU_CKREFPRE_DIV18, + CKCU_CKREFPRE_DIV20, + CKCU_CKREFPRE_DIV22, + CKCU_CKREFPRE_DIV24, + CKCU_CKREFPRE_DIV26, + CKCU_CKREFPRE_DIV28, + CKCU_CKREFPRE_DIV30, + CKCU_CKREFPRE_DIV32, + CKCU_CKREFPRE_DIV34, + CKCU_CKREFPRE_DIV36, + CKCU_CKREFPRE_DIV38, + CKCU_CKREFPRE_DIV40, + CKCU_CKREFPRE_DIV42, + CKCU_CKREFPRE_DIV44, + CKCU_CKREFPRE_DIV46, + CKCU_CKREFPRE_DIV48, + CKCU_CKREFPRE_DIV50, + CKCU_CKREFPRE_DIV52, + CKCU_CKREFPRE_DIV54, + CKCU_CKREFPRE_DIV56, + CKCU_CKREFPRE_DIV58, + CKCU_CKREFPRE_DIV60, + CKCU_CKREFPRE_DIV62, + CKCU_CKREFPRE_DIV64 +} CKCU_CKREFPRE_TypeDef; + +#if (!LIBCFG_NO_PLL) +/** + * @brief Enumeration of PLL clock source. + */ +typedef enum +{ + CKCU_PLLSRC_HSE = 0, + CKCU_PLLSRC_HSI +} CKCU_PLLSRC_TypeDef; + +#define IS_PLL_CLKSRC(SRC) ((SRC == CKCU_PLLSRC_HSE) || \ + (SRC == CKCU_PLLSRC_HSI)) +#endif + +#if (LIBCFG_CKCU_USB_PLL) +/** + * @brief Enumeration of CK_USB clock source. + */ +typedef enum +{ + CKCU_CKPLL = 0, + CKCU_CKUSBPLL +} CKCU_USBSRC_TypeDef; +#endif + +#if (LIBCFG_CKCU_LCD_SRC) +/** + * @brief Enumeration of CK_LCD clock source. + */ +typedef enum +{ + CKCU_LCDSRC_LSI = 0, + #if (LIBCFG_LSE) + CKCU_LCDSRC_LSE, + #endif + CKCU_LCDSRC_HSI, + CKCU_LCDSRC_HSE +} CKCU_LCDSRC_TypeDef; +#endif + +#if (LIBCFG_CKCU_MCTM_SRC) +/** + * @brief Enumeration of MCTM clock source. + */ +typedef enum +{ + CKCU_MCTMSRC_AHB = 0, + CKCU_MCTMSRC_USBPLL +} CKCU_MCTMSRC_TypeDef; + +#define IS_MCTM_SRC(SRC) ((SRC == CKCU_MCTMSRC_AHB) || \ + (SRC == CKCU_MCTMSRC_USBPLL)) +#endif + + +#if (((LIBCFG_LSE) || (LIBCFG_USBD) || (LIBCFG_CKCU_REFCLK_EXT_PIN)) && (!LIBCFG_CKCU_NO_AUTO_TRIM)) +/** + * @brief Enumeration of HSI auto-trim clock source. + */ +typedef enum +{ + #if (LIBCFG_LSE) + CKCU_ATC_LSE = 0, + #endif + #if (LIBCFG_USBD) + CKCU_ATC_USB = 1, + #endif + #if (LIBCFG_CKCU_REFCLK_EXT_PIN) + CKCU_ATC_CKIN = 2, + #endif +} CKCU_ATC_TypeDef; +#endif + +#if (LIBCFG_CKCU_ATM_V01) +/** + * @brief Enumeration of ATC search algorithm. + */ +typedef enum +{ + CKCU_ATC_BINARY_SEARCH = 0, + CKCU_ATC_LINEAR_SEARCH = 8 +} CKCU_ATCSearchAlgorithm_TypeDef; + +/** + * @brief Enumeration of ATC frequency tolerance. + */ +typedef enum +{ + CKCU_ATC_DOUBLE_PRECISION = 0, + CKCU_ATC_SINGLE_PRECISION = 4 +} CKCU_ATCFrqTolerance_TypeDef; +#endif + +/** + * @brief Enumeration of CK_AHB prescaler. + */ +typedef enum +{ + CKCU_SYSCLK_DIV1 = 0, + CKCU_SYSCLK_DIV2, + CKCU_SYSCLK_DIV4, + CKCU_SYSCLK_DIV8, + CKCU_SYSCLK_DIV16, + CKCU_SYSCLK_DIV32 +} CKCU_SYSCLKDIV_TypeDef; + +/** + * @brief Enumeration of CK_ADC prescaler. + */ +typedef enum +{ + #if (LIBCFG_CKCU_NO_ADCPRE_DIV1) + #else + CKCU_ADCPRE_DIV1 = 0, + #endif + CKCU_ADCPRE_DIV2 = 1, + CKCU_ADCPRE_DIV4, + CKCU_ADCPRE_DIV8, + CKCU_ADCPRE_DIV16, + CKCU_ADCPRE_DIV32, + CKCU_ADCPRE_DIV64, + CKCU_ADCPRE_DIV3 +} CKCU_ADCPRE_TypeDef; + +/** + * @brief Enumeration of CK_ADCn. + */ +typedef enum +{ + CKCU_ADCPRE_ADC0 = 16, + #if (LIBCFG_ADC1) + CKCU_ADCPRE_ADC1 = 20, + #endif +} CKCU_ADCPRE_ADCn_TypeDef; + +#if (LIBCFG_LCD) +/** + * @brief Enumeration of CK_LCD prescaler. + */ +typedef enum +{ + CKCU_LCDPRE_DIV1 = 0, + CKCU_LCDPRE_DIV2, + CKCU_LCDPRE_DIV4, + CKCU_LCDPRE_DIV8, + CKCU_LCDPRE_DIV16, +} CKCU_LCDPRE_TypeDef; +#endif + +#if (LIBCFG_MIDI) +/** + * @brief Enumeration of CK_MIDI prescaler. + */ +typedef enum +{ + CKCU_MIDIPRE_DIV16 = 0, + CKCU_MIDIPRE_DIV13, + CKCU_MIDIPRE_DIV11, + CKCU_MIDIPRE_DIV9, + CKCU_MIDIPRE_DIV8, +} CKCU_MIDIPRE_TypeDef; +#endif + +/** + * @brief Enumeration of System clock source. + */ +typedef enum +{ +#if (!LIBCFG_NO_PLL) + CKCU_SW_PLL = 1, +#endif + CKCU_SW_HSE = 2, + CKCU_SW_HSI = 3, + #if (LIBCFG_LSE) + CKCU_SW_LSE = 6, + #endif + CKCU_SW_LSI = 7 +} CKCU_SW_TypeDef; + +/** + * @brief Enumeration of CKOUT clock source. + */ +typedef enum +{ + CKCU_CKOUTSRC_REFCK = 0, + CKCU_CKOUTSRC_HCLK_DIV16 = 1, + CKCU_CKOUTSRC_SYSCK_DIV16 = 2, + CKCU_CKOUTSRC_HSECK_DIV16 = 3, + CKCU_CKOUTSRC_HSICK_DIV16 = 4, + #if (LIBCFG_LSE) + CKCU_CKOUTSRC_LSECK = 5, + #endif + CKCU_CKOUTSRC_LSICK = 6 +} CKCU_CKOUTSRC_TypeDef; + +#if (!LIBCFG_NO_PLL) +/** + * @brief Enumeration of PLL clock source status. + */ +typedef enum +{ + CKCU_PLLST_SYSCK = 1, + #if (LIBCFG_USBD) + CKCU_PLLST_USB = 4, + #endif + CKCU_PLLST_REFCK = 8 +} CKCU_PLLST_TypeDef; +#endif + +/** + * @brief Enumeration of HSI clock source status. + */ +typedef enum +{ + CKCU_HSIST_SYSCK = 1, +#if (!LIBCFG_NO_PLL) + CKCU_HSIST_PLL = 2, +#endif + CKCU_HSIST_CKM = 4 +} CKCU_HSIST_TypeDef; + +/** + * @brief Enumeration of HSE clock source status. + */ +typedef enum +{ + CKCU_HSEST_SYSCK = 1, +#if (!LIBCFG_NO_PLL) + CKCU_HSEST_PLL +#endif +} CKCU_HSEST_TypeDef; + +/** + * @brief Definition of CKOUT Init Structure. + */ +typedef struct +{ + CKCU_CKOUTSRC_TypeDef CKOUTSRC; +} CKCU_CKOUTInitTypeDef; + +#if (!LIBCFG_NO_PLL) +/** + * @brief Definition of PLL Init Structure. + */ +typedef struct +{ + u32 CFG; + CKCU_PLLSRC_TypeDef ClockSource; + ControlStatus BYPASSCmd; +} CKCU_PLLInitTypeDef; +#endif + +/** + * @brief Definition of structure for clock frequency. + */ +typedef struct +{ +#if (!LIBCFG_NO_PLL) + u32 PLL_Freq; +#endif + u32 SYSCK_Freq; + u32 HCLK_Freq; +#if (HT32_LIB_ENABLE_GET_CK_ADC) +#if (!LIBCFG_NO_ADC) + u32 ADC0_Freq; +#endif +#if (LIBCFG_ADC1) + u32 ADC1_Freq; +#endif +#endif +} CKCU_ClocksTypeDef; + +#if (LIBCFG_CKCU_ATM_V01) +/** + * @brief Definition of ATC Init Structure. + */ +typedef struct +{ + CKCU_ATCSearchAlgorithm_TypeDef SearchAlgorithm; + CKCU_ATCFrqTolerance_TypeDef FrqTolerance; +} CKCU_ATCInitTypeDef; +#endif + +/** + * @brief Definition of initial structure of peripheral clock control. + */ +typedef union +{ + struct + { + /* Definitions of AHB clock control */ + unsigned long FMC :1; // Bit 0 + unsigned long :1; // Bit 1 + unsigned long SRAM :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long PDMA :1; // Bit 4 + unsigned long BM :1; // Bit 5 + unsigned long APB :1; // Bit 6 + unsigned long :1; // Bit 7 + + unsigned long :1; // Bit 8 + unsigned long :1; // Bit 9 + unsigned long USBD :1; // Bit 10 + unsigned long CKREF :1; // Bit 11 + unsigned long EBI :1; // Bit 12 + unsigned long CRC :1; // Bit 13 + unsigned long :1; // Bit 14 + unsigned long AES :1; // Bit 15 + + unsigned long PA :1; // Bit 16 + unsigned long PB :1; // Bit 17 + unsigned long PC :1; // Bit 18 + unsigned long PD :1; // Bit 19 + unsigned long PE :1; // Bit 20 + unsigned long PF :1; // Bit 21 + unsigned long :1; // Bit 22 + unsigned long :1; // Bit 23 + + unsigned long DIV :1; // Bit 24 + unsigned long QSPI :1; // Bit 25 + unsigned long RF :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long :1; // Bit 28 + unsigned long :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB0 clock control */ + unsigned long I2C0 :1; // Bit 0 + unsigned long I2C1 :1; // Bit 1 + unsigned long I2C2 :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long SPI0 :1; // Bit 4 + unsigned long SPI1 :1; // Bit 5 + unsigned long :1; // Bit 6 + unsigned long :1; // Bit 7 + + unsigned long USART0 :1; // Bit 8 + unsigned long USART1 :1; // Bit 9 + unsigned long UART0 :1; // Bit 10 + unsigned long UART1 :1; // Bit 11 + unsigned long UART2 :1; // Bit 12 + unsigned long UART3 :1; // Bit 13 + unsigned long AFIO :1; // Bit 14 + unsigned long EXTI :1; // Bit 15 + + unsigned long :1; // Bit 16 + unsigned long :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 + unsigned long SLED0 :1; // Bit 22 + unsigned long SLED1 :1; // Bit 23 + + unsigned long SCI0 :1; // Bit 24 + unsigned long I2S :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long SCI1 :1; // Bit 27 + unsigned long MIDI :1; // Bit 28 + unsigned long LEDC :1; // Bit 29 + unsigned long CAN0 :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB1 clock control */ + unsigned long MCTM0 :1; // Bit 0 + unsigned long :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long WDT :1; // Bit 4 + unsigned long :1; // Bit 5 + unsigned long BKP :1; // Bit 6 + unsigned long DAC1 :1; // Bit 7 + + unsigned long GPTM0 :1; // Bit 8 + unsigned long GPTM1 :1; // Bit 9 + unsigned long :1; // Bit 10 + unsigned long :1; // Bit 11 + unsigned long PWM0 :1; // Bit 12 + unsigned long PWM1 :1; // Bit 13 + unsigned long PWM2 :1; // Bit 14 + unsigned long :1; // Bit 15 + + unsigned long BFTM0 :1; // Bit 16 + unsigned long BFTM1 :1; // Bit 17 + unsigned long TKEY :1; // Bit 18 + unsigned long LCDR :1; // Bit 19 + unsigned long LCDC :1; // Bit 20 + unsigned long DAC0 :1; // Bit 21 + unsigned long CMP :1; // Bit 22 + unsigned long OPA :1; // Bit 23 + + unsigned long ADC0 :1; // Bit 24 + unsigned long ADC1 :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long SCTM0 :1; // Bit 28 + unsigned long SCTM1 :1; // Bit 29 + unsigned long SCTM2 :1; // Bit 30 + unsigned long SCTM3 :1; // Bit 31 + } Bit; + u32 Reg[3]; +} CKCU_PeripClockConfig_TypeDef; + +#define CKCU_APBPCSR_OFFSET (5) +#define CKCU_APBPCSR0 (0 << CKCU_APBPCSR_OFFSET) +#define CKCU_APBPCSR1 (1 << CKCU_APBPCSR_OFFSET) +#define CKCU_APBPCSR2 (4 << CKCU_APBPCSR_OFFSET) +typedef enum +{ + CKCU_PCLK_I2C0 = (CKCU_APBPCSR0 | 0), + #if (LIBCFG_I2C1) + CKCU_PCLK_I2C1 = (CKCU_APBPCSR0 | 2), + #endif + CKCU_PCLK_SPI0 = (CKCU_APBPCSR0 | 4), + #if (LIBCFG_SPI1) + CKCU_PCLK_SPI1 = (CKCU_APBPCSR0 | 6), + #endif + #if (LIBCFG_UART2) + CKCU_PCLK_UART2 = (CKCU_APBPCSR0 | 8), + #endif + #if (LIBCFG_UART3) + CKCU_PCLK_UART3 = (CKCU_APBPCSR0 | 10), + #endif + CKCU_PCLK_BFTM0 = (CKCU_APBPCSR0 | 12), + #if (LIBCFG_BFTM1) + CKCU_PCLK_BFTM1 = (CKCU_APBPCSR0 | 14), + #endif + #if (LIBCFG_MCTM0) + CKCU_PCLK_MCTM0 = (CKCU_APBPCSR0 | 16), + #endif + #if (!LIBCFG_NO_GPTM0) + CKCU_PCLK_GPTM0 = (CKCU_APBPCSR0 | 20), + #endif + #if (LIBCFG_GPTM1) + CKCU_PCLK_GPTM1 = (CKCU_APBPCSR0 | 22), + #endif + #if (!LIBCFG_NO_USART0) + CKCU_PCLK_USART0 = (CKCU_APBPCSR0 | 24), + #endif + #if (LIBCFG_USART1) + CKCU_PCLK_USART1 = (CKCU_APBPCSR0 | 26), + #endif + CKCU_PCLK_UART0 = (CKCU_APBPCSR0 | 28), + #if (LIBCFG_UART1) + CKCU_PCLK_UART1 = (CKCU_APBPCSR0 | 30), + #endif + CKCU_PCLK_AFIO = (CKCU_APBPCSR1 | 0), + CKCU_PCLK_EXTI = (CKCU_APBPCSR1 | 2), + #if (!LIBCFG_NO_ADC) + CKCU_PCLK_ADC0 = (CKCU_APBPCSR1 | 4), + #endif + #if (LIBCFG_ADC1) + CKCU_PCLK_ADC1 = (CKCU_APBPCSR1 | 6), + #endif + #if (LIBCFG_CMP) + CKCU_PCLK_CMP = (CKCU_APBPCSR1 | 8), + #endif + #if (LIBCFG_OPA) + CKCU_PCLK_OPA = (CKCU_APBPCSR1 | 10), + #endif + CKCU_PCLK_WDTR = (CKCU_APBPCSR1 | 12), + CKCU_PCLK_BKPR = (CKCU_APBPCSR1 | 14), + #if (LIBCFG_SCI0) + CKCU_PCLK_SCI0 = (CKCU_APBPCSR1 | 16), + #endif + #if (LIBCFG_SCI1) + CKCU_PCLK_SCI1 = (CKCU_APBPCSR1 | 18), + #endif + #if (LIBCFG_I2S) + CKCU_PCLK_I2S = (CKCU_APBPCSR1 | 20), + #endif + #if (LIBCFG_I2C2) + CKCU_PCLK_I2C2 = (CKCU_APBPCSR1 | 22), + #endif + #if (LIBCFG_SCTM0) + CKCU_PCLK_SCTM0 = (CKCU_APBPCSR1 | 24), + #endif + #if (LIBCFG_SCTM1) + CKCU_PCLK_SCTM1 = (CKCU_APBPCSR1 | 26), + #endif + #if (LIBCFG_SCTM2) + CKCU_PCLK_SCTM2 = (CKCU_APBPCSR1 | 28), + #endif + #if (LIBCFG_SCTM3) + CKCU_PCLK_SCTM3 = (CKCU_APBPCSR1 | 30), + #endif + #if (LIBCFG_AFE0006) + CKCU_PCLK_AFE = (CKCU_APBPCSR2 | 0), + #endif + #if (LIBCFG_DACDUAL16) || (LIBCFG_DAC0) + CKCU_PCLK_DAC0 = (CKCU_APBPCSR2 | 2), + #endif + #if (LIBCFG_LEDC) + CKCU_PCLK_LEDC = (CKCU_APBPCSR2 | 6), + #endif + #if (LIBCFG_MIDI) + CKCU_PCLK_MIDI = (CKCU_APBPCSR2 | 8), + #endif + #if (LIBCFG_TKEY) + CKCU_PCLK_TKEY = (CKCU_APBPCSR2 | 10), + #endif + #if (LIBCFG_SLED0) + CKCU_PCLK_SLED0 = (CKCU_APBPCSR2 | 12), + #endif + #if (LIBCFG_SLED1) + CKCU_PCLK_SLED1 = (CKCU_APBPCSR2 | 14), + #endif + #if (LIBCFG_PWM0) + CKCU_PCLK_PWM0 = (CKCU_APBPCSR2 | 16), + #endif + #if (LIBCFG_PWM1) + CKCU_PCLK_PWM1 = (CKCU_APBPCSR2 | 18), + #endif + #if (LIBCFG_PWM2) + CKCU_PCLK_PWM2 = (CKCU_APBPCSR2 | 20), + #endif + #if (LIBCFG_CAN0) + CKCU_PCLK_CAN0 = (CKCU_APBPCSR2 | 20), + #endif + #if (LIBCFG_DAC1) + CKCU_PCLK_DAC1 = (CKCU_APBPCSR2 | 24), + #endif +} CKCU_PeripPrescaler_TypeDef; + +#define CKCU_PCLK_ADC CKCU_PCLK_ADC0 +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Exported_Constants CKCU exported constants + * @{ + */ + +/* Definitions of clock ready flag */ +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_FLAG_USBPLLRDY (1UL) +#endif +#if (!LIBCFG_NO_PLL) +#define CKCU_FLAG_PLLRDY (1UL << 1) +#endif +#define CKCU_FLAG_HSERDY (1UL << 2) +#define CKCU_FLAG_HSIRDY (1UL << 3) +#if (LIBCFG_LSE) +#define CKCU_FLAG_LSERDY (1UL << 4) +#endif +#define CKCU_FLAG_LSIRDY (1UL << 5) + +#define IS_CKCU_FLAG(FLAG) (((FLAG & 0xFFFFFFC0) == 0) && (FLAG != 0)) + +/* Definitions of clock interrupt & flag */ +#define CKCU_INT_CKS (1UL) +#define IS_CKCU_INT_FLAG(FLAG) (FLAG == CKCU_INT_CKS) + +#define CKCU_INT_CKSIE (1UL << 16) +#define IS_CKCU_INT(INT) (((INT & 0xFFFEFFFF) == 0) && (INT != 0)) + +#if (!LIBCFG_NO_PLL) +/* Definitions of PLL frequency */ +#define CKCU_PLL_4M_48M ((12UL << 23) | (0UL << 21)) +#define CKCU_PLL_4M_40M ((10UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_48M (( 6UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_40M (( 5UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_32M (( 4UL << 23) | (0UL << 21)) +#define CKCU_PLL_12M_48M (( 4UL << 23) | (0UL << 21)) +#define CKCU_PLL_16M_48M (( 3UL << 23) | (0UL << 21)) + +#if (LIBCFG_CKCU_SYS_CK_60M) +#define CKCU_PLL_4M_60M ((0UL << 28) | (15UL << 23) | (0UL << 21)) +#define CKCU_PLL_8M_60M ((1UL << 28) | (15UL << 23) | (0UL << 21)) +#define CKCU_PLL_12M_60M ((0UL << 28) | ( 5UL << 23) | (0UL << 21)) +#define CKCU_PLL_16M_56M ((1UL << 28) | ( 7UL << 23) | (0UL << 21)) +#endif + +#define IS_PLL_CFG(CFG) (((CFG & 0xE81FFFFF) == 0x0) && (CFG != 0)) +#endif + +#if (LIBCFG_CKCU_USB_PLL) +/* Definitions of USBPLL frequency */ +#if (LIBCFG_CKCU_USB_PLL_96M) +#define CKCU_USBPLL_4M_96M ((24UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_8M_96M ((12UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_12M_96M (( 8UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_16M_96M (( 6UL << 7) | (0UL << 5)) +#else +#define CKCU_USBPLL_4M_48M ((12UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_8M_48M (( 6UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_12M_48M (( 4UL << 7) | (0UL << 5)) +#define CKCU_USBPLL_16M_48M (( 3UL << 7) | (0UL << 5)) +#endif + +#define IS_USBPLL_CFG(CFG) (((CFG & 0xFFFFF81F) == 0x0) && (CFG != 0)) +#endif + + + + +/* Definitions of MCU debug control */ +#define CKCU_DBG_SLEEP (1UL) +#define CKCU_DBG_DEEPSLEEP1 (1UL << 1) +#define CKCU_DBG_POWERDOWN (1UL << 2) +#define CKCU_DBG_WDT_HALT (1UL << 3) + +#if (LIBCFG_MCTM0) +#define CKCU_DBG_MCTM0_HALT (1UL << 4) +#endif + +#if (!LIBCFG_NO_GPTM0) +#define CKCU_DBG_GPTM0_HALT (1UL << 6) +#endif + +#if (LIBCFG_GPTM1) +#define CKCU_DBG_GPTM1_HALT (1UL << 7) +#endif + +#if (!LIBCFG_NO_USART0) +#define CKCU_DBG_USART0_HALT (1UL << 8) +#endif + +#if (LIBCFG_USART1) +#define CKCU_DBG_USART1_HALT (1UL << 9) +#endif + +#define CKCU_DBG_SPI0_HALT (1UL << 10) + +#if (LIBCFG_SPI1) +#define CKCU_DBG_SPI1_HALT (1UL << 11) +#endif + +#if defined(USE_HT32F0006) || defined(USE_HT32F61244_45) +#define CKCU_DBG_QSPI_HALT (1UL << 11) +#endif + +#define CKCU_DBG_I2C0_HALT (1UL << 12) + +#if (LIBCFG_I2C1) +#define CKCU_DBG_I2C1_HALT (1UL << 13) +#endif + +#define CKCU_DBG_DEEPSLEEP2 (1UL << 14) + +#if (LIBCFG_SCI0) +#define CKCU_DBG_SCI0_HALT (1UL << 15) +#endif + +#define CKCU_DBG_BFTM0_HALT (1UL << 16) + +#if (LIBCFG_BFTM1) +#define CKCU_DBG_BFTM1_HALT (1UL << 17) +#endif + +#define CKCU_DBG_UART0_HALT (1UL << 18) + +#if (LIBCFG_UART1) +#define CKCU_DBG_UART1_HALT (1UL << 19) +#endif + +#if (LIBCFG_SCI1) +#define CKCU_DBG_SCI1_HALT (1UL << 21) +#endif + +#if (LIBCFG_SCTM0) +#define CKCU_DBG_SCTM0_HALT (1UL << 22) +#endif + +#if (LIBCFG_SCTM1) +#define CKCU_DBG_SCTM1_HALT (1UL << 23) +#endif + +#if (LIBCFG_SCTM2) +#define CKCU_DBG_SCTM2_HALT (1UL << 24) +#endif + +#if (LIBCFG_SCTM3) +#define CKCU_DBG_SCTM3_HALT (1UL << 25) +#endif + +#if (LIBCFG_CAN0) +#define CKCU_DBG_CAN0_HALT (1UL << 26) +#endif + +#if (LIBCFG_UART2) +#define CKCU_DBG_UART2_HALT (1UL << 26) +#endif + +#if (LIBCFG_UART3) +#define CKCU_DBG_UART3_HALT (1UL << 27) +#endif + +#if (LIBCFG_I2C2) +#define CKCU_DBG_I2C2_HALT (1UL << 28) +#endif + +#if (LIBCFG_PWM2) +#define CKCU_DBG_PWM2_HALT (1UL << 29) +#endif + +#if defined(USE_HT32F52357_67) +#define CKCU_DBG_QSPI_HALT (1UL << 29) +#endif + +#if (LIBCFG_PWM0) +#define CKCU_DBG_PWM0_HALT (1UL << 30) +#endif + +#if (LIBCFG_PWM1) +#define CKCU_DBG_PWM1_HALT (1UL << 31) +#endif + +#define IS_CKCU_DBG(MODE) (((MODE & ~(0xFFEFFFDF)) == 0) && (MODE != 0)) + +/* Definitions of AHB clock control */ +#define CKCU_AHBEN_SLEEP_FMC (1UL) +#define CKCU_AHBEN_SLEEP_SRAM (1UL << 2) +#define CKCU_AHBEN_SLEEP_BM (1UL << 5) +#define CKCU_AHBEN_SLEEP_APB0 (1UL << 6) + +#define IS_CKCU_SLEEP_AHB(PERIPH) (((PERIPH & 0xFFFFFF9A) == 0) && (PERIPH != 0)) + +/* Definitions of HSI Ready Counter Value */ +#if (LIBCFG_CKCU_HSIRDYCR) +#define IS_COUNTER_VALUE(VALUE) ((VALUE) < 0x20) +#endif +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Exported_Functions CKCU exported functions + * @{ + */ +void CKCU_DeInit(void); + +void CKCU_HSICmd(ControlStatus Cmd); +void CKCU_HSECmd(ControlStatus Cmd); +bool CKCU_IS_HSI_USED(CKCU_HSIST_TypeDef Target); +bool CKCU_IS_HSE_USED(CKCU_HSEST_TypeDef Target); +FlagStatus CKCU_GetClockReadyStatus(u32 CKCU_FLAG); +ErrStatus CKCU_WaitHSEReady(void); + +ErrStatus CKCU_SysClockConfig(CKCU_SW_TypeDef CLKSRC); +u32 CKCU_GetSysClockSource(void); + +void CKCU_PeripClockConfig(CKCU_PeripClockConfig_TypeDef Clock, ControlStatus Cmd); + +#if (LIBCFG_NO_PLL) +#else +void CKCU_PLLInit(CKCU_PLLInitTypeDef *PLL_InitStruct); +void CKCU_PLLCmd(ControlStatus Cmd); +bool CKCU_IS_PLL_USED(CKCU_PLLST_TypeDef Target); +#endif + +#if (LIBCFG_CKCU_USB_PLL) +void CKCU_USBPLLInit(CKCU_PLLInitTypeDef *USBPLL_InitStruct); +void CKCU_USBPLLCmd(ControlStatus Cmd); +void CKCU_USBClockConfig(CKCU_USBSRC_TypeDef USBSRC); +#endif + +#if (LIBCFG_CKCU_LCD_SRC) +void CKCU_LCDClockConfig(CKCU_LCDSRC_TypeDef LCDSRC); +#endif + +#if (LIBCFG_CKCU_MCTM_SRC) +void CKCU_MCTMClockConfig(CKCU_MCTMSRC_TypeDef CKCU_MCTMSRC_x); +#endif + +void CKCU_SleepClockConfig(u32 CKCU_CLK, ControlStatus Cmd); + +void CKCU_SetHCLKPrescaler(CKCU_SYSCLKDIV_TypeDef HCLKPRE); +void CKCU_SetCKREFPrescaler(CKCU_CKREFPRE_TypeDef CKREFPRE); +void CKCU_SetADCnPrescaler(CKCU_ADCPRE_ADCn_TypeDef CKCU_ADCPRE_ADCn, CKCU_ADCPRE_TypeDef CKCU_ADCPRE_DIVn); +#define CKCU_SetADCPrescaler(DIV) CKCU_SetADCnPrescaler(CKCU_ADCPRE_ADC0, DIV) + +#if (LIBCFG_MIDI) +void CKCU_SetMIDIPrescaler(CKCU_MIDIPRE_TypeDef MIDIPRE); +#endif + +#if (!LIBCFG_CKCU_NO_APB_PRESCALER) +void CKCU_SetPeripPrescaler(CKCU_PeripPrescaler_TypeDef Perip, CKCU_APBCLKPRE_TypeDef PCLKPRE); +#endif + +void CKCU_GetClocksFrequency(CKCU_ClocksTypeDef* CKCU_Clk); +u32 CKCU_GetPLLFrequency(void); +u32 CKCU_GetPeripFrequency(CKCU_PeripPrescaler_TypeDef Perip); + +void CKCU_CKMCmd(ControlStatus Cmd); +void CKCU_PSRCWKUPCmd(ControlStatus Cmd); + +#if (!LIBCFG_CKCU_NO_LPCR) +void CKCU_BKISOCmd(ControlStatus Cmd); +#endif + +void CKCU_CKOUTConfig(CKCU_CKOUTInitTypeDef *CKOUTInit); +void CKCU_MCUDBGConfig(u32 CKCU_DBGx, ControlStatus Cmd); + +void CKCU_IntConfig(u32 CKCU_INT, ControlStatus Cmd); +FlagStatus CKCU_GetIntStatus(u32 CKCU_INT); +void CKCU_ClearIntFlag(u32 CKCU_INT); + +#if (((LIBCFG_LSE) || (LIBCFG_USBD)) && (!LIBCFG_CKCU_NO_AUTO_TRIM)) +#if (LIBCFG_CKCU_ATM_V01) +void CKCU_ATCInit(CKCU_ATCInitTypeDef* ATC_InitStruct); +#endif +void CKCU_HSIAutoTrimClkConfig(CKCU_ATC_TypeDef CLKSRC); +void CKCU_HSIAutoTrimCmd(ControlStatus Cmd); +bool CKCU_HSIAutoTrimIsReady(void); +#endif + +#if (LIBCFG_CKCU_HSIRDYCR) +void CKCU_Set_HSIReadyCounter(u8 value); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_cmp.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_cmp.h new file mode 100644 index 0000000000..5869bcd21c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_cmp.h @@ -0,0 +1,362 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_cmp.h + * @version $Rev:: 7319 $ + * @date $Date:: 2023-10-28 #$ + * @brief The header file of the CMP library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_CMP_H +#define __HT32F5XXXX_CMP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CMP + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Types CMP exported types + * @{ + */ + +typedef struct +{ + u32 CMP_Wakeup; + u32 CMP_OutputSelection; + u32 CMP_ScalerSource; + u32 CMP_ScalerOutputBuf; + u32 CMP_ScalerEnable; + u32 CMP_CoutSync; + u32 CMP_OutputPol; + #if (LIBCFG_CMP_65x_VER) + u32 CMP_InputSelection; + #endif + u32 CMP_InvInputSelection; + u32 CMP_Hysteresis; + u32 CMP_Speed; +} CMP_InitTypeDef; + +#if (LIBCFG_CMP_CO) +typedef enum +{ + CMP_SYNCOUT_CMPnO = 0, + CMP_SYNCOUT_MCTM_CH0O = 1, + CMP_SYNCOUT_MCTM_CH0NO = 2, + CMP_SYNCOUT_MCTM_CH1O = 3, + CMP_SYNCOUT_MCTM_CH1NO = 4, + CMP_SYNCOUT_MCTM_CH2O = 5, + CMP_SYNCOUT_MCTM_CH2NO = 6, + CMP_SYNCOUT_MCTM_CH3O = 7, + CMP_SYNCOUT_MCTM_CH3OB = 8, // Inverted of MCTM_CH3O +} CMP_SYNCOUT_Enum; +#endif + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Constants CMP exported constants + * @{ + */ + +/* Definitions of CMP Protection Key */ +#define CMP_PROTECT_KEY ((u32)0x9C3A0000) + + +/* Definitions of CMP Output Status */ +#define CMP_OUTPUT_HIGH ((u32)0x00008000) +#define CMP_OUTPUT_LOW ((u32)0x00000000) + + +/* Definitions of CMP Wakeup Control Bit */ +#define CMP_WUP_ENABLE ((u32)0x00004000) +#define CMP_WUP_DISABLE ((u32)0x00000000) + +#define IS_CMP_Wakeup_Set(x) ((x == CMP_WUP_ENABLE) || (x == CMP_WUP_DISABLE)) + + +/* Definitions of CMP Output Selection for IP Trigger Source */ +#if (LIBCFG_CMP_65x_VER) +#define CMP_TRIG_NONE ((u32)0x0 << 11) +#define CMP_TRIG_GPTM_CH0 ((u32)0x1 << 11) // CMP0 +#define CMP_TRIG_GPTM_CH1 ((u32)0x1 << 11) // CMP1 + +#define IS_CMP_OutputSelection2(x) (0) +#if (LIBCFG_CMP2) +#define CMP_TRIG_GPTM_CH2 ((u32)0x1 << 11) // CMP2 +#undef IS_CMP_OutputSelection2 +#define IS_CMP_OutputSelection2(x) (x == CMP_TRIG_GPTM_CH2) +#endif + +#define CMP_TRIG_GPTM_CH3 ((u32)0x2 << 11) +#define CMP_TRIG_SCTM ((u32)0x3 << 11) +#define CMP_TRIG_MCTM_CH3 ((u32)0x4 << 11) +#define CMP_TRIG_MCTM_BK0 ((u32)0x5 << 11) +#define CMP_TRIG_MCTM_BK1 ((u32)0x6 << 11) +#define CMP_TRIG_ADC ((u32)0x7 << 11) + +#define IS_CMP_OutputSelection(x) ((x == CMP_TRIG_NONE) || \ + (x == CMP_TRIG_GPTM_CH0) || \ + (x == CMP_TRIG_GPTM_CH1) || \ + IS_CMP_OutputSelection2(x) || \ + (x == CMP_TRIG_GPTM_CH3) || \ + (x == CMP_TRIG_SCTM) || \ + (x == CMP_TRIG_MCTM_CH3) || \ + (x == CMP_TRIG_MCTM_BK0) || \ + (x == CMP_TRIG_MCTM_BK1) || \ + (x == CMP_TRIG_ADC)) +#else +#define CMP_TRIG_NONE ((u32)0x0 << 11) +#define CMP_TRIG_GPTM_CH3 ((u32)0x1 << 11) +#if (LIBCFG_MCTM0) +#define CMP_TRIG_MCTM_CH3 ((u32)0x2 << 11) +#define CMP_TRIG_MCTM_BK1 ((u32)0x3 << 11) +#endif +#define CMP_TRIG_ADC ((u32)0x4 << 11) + +#if (LIBCFG_MCTM0) +#define IS_CMP_OutSelMCTM(x) ((x == CMP_TRIG_MCTM_CH3) || (x == CMP_TRIG_MCTM_BK1)) +#else +#define IS_CMP_OutSelMCTM(x) (0) +#endif + +#define IS_CMP_OutputSelection(x) ((x == CMP_TRIG_NONE) || \ + (x == CMP_TRIG_GPTM_CH3) || \ + IS_CMP_OutSelMCTM(x) || \ + (x == CMP_TRIG_ADC)) +#endif + +/* Definitions of CMP Scaler Source Selection */ +#define CMP_SCALER_SRC_VDDA ((u32)0x00000000) + +#if (LIBCFG_CMP_NOSCALER_SRC) +#define IS_CMP_ScalerSource(x) ((x == CMP_SCALER_SRC_VDDA)) +#else +#define CMP_SCALER_SRC_VREF ((u32)0x00000400) +#define IS_CMP_ScalerSource(x) ((x == CMP_SCALER_SRC_VDDA) || (x == CMP_SCALER_SRC_VREF)) +#endif + + +/* Definitions of CMP Scaler Output Enable Bit */ +#define CMP_SCALER_OBUF_DISABLE ((u32)0x00000000) +#define CMP_SCALER_OBUF_ENABLE ((u32)0x00000200) + +#define IS_CMP_ScalerOutputBuf(x) ((x == CMP_SCALER_OBUF_DISABLE) || (x == CMP_SCALER_OBUF_ENABLE)) + + +/* Definitions of CMP Scaler Enable Bit */ +#define CMP_SCALER_DISABLE ((u32)0x00000000) +#define CMP_SCALER_ENABLE ((u32)0x00000100) + +#define IS_CMP_ScalerEnable(x) ((x == CMP_SCALER_DISABLE) || (x == CMP_SCALER_ENABLE)) + + +/* Definitions of CMP Sync Output Enable bit */ +#define CMP_ASYNC_OUTPUT ((u32)0x00000000) +#define CMP_SYNC_OUTPUT ((u32)0x00000080) + +#define IS_CMP_CoutSynchronized(x) ((x == CMP_ASYNC_OUTPUT) || (x == CMP_SYNC_OUTPUT)) + + +/* Definitions of CMP Output Polarity Selection */ +#define CMP_NONINV_OUTPUT ((u32)0x00000000) +#define CMP_INV_OUTPUT ((u32)0x00000040) + +#define IS_CMP_OutputPol_Set(x) ((x == CMP_NONINV_OUTPUT) || (x == CMP_INV_OUTPUT)) + + +/* Definitions of CMP Inverted Input Source Selection */ +#if (LIBCFG_CMP_65x_VER) +#if (LIBCFG_CMP_POS_INPUT_SEL_V2) +#define CMP_INPUT_CMPnP ((u32)0x00000000) +#define CMP_INPUT_CMPnP0 ((u32)0x00000000) +#define CMP_INPUT_CMPnP1 ((u32)0x00000001) +#define CMP_INPUT_CMPnP2 ((u32)0x00000002) +#define CMP_INPUT_OPA0O ((u32)0x00000003) + +#define IS_CMP_InputSelection(x) ((x == CMP_INPUT_CMPnP) || \ + (x == CMP_INPUT_CMPnP0) || \ + (x == CMP_INPUT_CMPnP1) || \ + (x == CMP_INPUT_CMPnP2) || \ + (x == CMP_INPUT_OPA0O)) +#else +#define CMP_INPUT_CMPnP ((u32)0x00000000) +#define CMP_INPUT_OPA0O ((u32)0x00000001) +#define CMP_INPUT_OPA1O ((u32)0x00000002) + +#define IS_CMP_InputSelection(x) ((x == CMP_INPUT_CMPnP) || (x == CMP_INPUT_OPA0O) || (x == CMP_INPUT_OPA1O)) +#endif +#endif + + +/* Definitions of CMP Inverted Input Source Selection */ +#define CMP_EXTERNAL_CN_IN ((u32)0x00000000) +#define CMP_SCALER_CN_IN ((u32)0x00000010) + +#define IS_CMP_InvInSel2(x) (0) + +#if (LIBCFG_CMP_IVREF_CN_IN) +#define CMP_IVREF_CN_IN ((u32)0x00000020) +#undef IS_CMP_InvInSel2 +#define IS_CMP_InvInSel2(x) ((x == CMP_IVREF_CN_IN)) +#endif + +#if defined(USE_HT32F65230_40) +#define CMP_CMP0N_CN_IN ((u32)0x00000020) +#undef IS_CMP_InvInSel2 +#define IS_CMP_InvInSel2(x) ((x == CMP_CMP0N_CN_IN)) +#endif + +#if defined(USE_HT32F65232) +#define CMP0_CMP1N_CN_IN ((u32)0x00000020) +#define CMP1_CMP0N_CN_IN ((u32)0x00000020) +#undef IS_CMP_InvInSel2 +#define IS_CMP_InvInSel2(x) ((x == CMP0_CMP1N_CN_IN)) +#endif + +#define IS_CMP_InvInputSelection(x) ((x == CMP_EXTERNAL_CN_IN) || (x == CMP_SCALER_CN_IN) || IS_CMP_InvInSel2(x)) + + +/* Definitions of CMP Hysteresis Level Selection */ +#define CMP_NO_HYSTERESIS ((u32)0x00000000) +#define CMP_LOW_HYSTERESIS ((u32)0x00000004) +#define CMP_MID_HYSTERESIS ((u32)0x00000008) +#define CMP_HIGH_HYSTERESIS ((u32)0x0000000C) + +#define IS_CMP_Hysteresis_Set(x) ((x == CMP_NO_HYSTERESIS) || (x == CMP_LOW_HYSTERESIS) || (x == CMP_MID_HYSTERESIS) || \ + (x == CMP_HIGH_HYSTERESIS)) + +/* Definitions of CMP Speed Mode Selection */ +#define CMP_HIGH_SPEED ((u32)0x00000002) +#define CMP_LOW_SPEED ((u32)0x00000000) + +#define IS_CMP_Speed_Set(x) ((x == CMP_HIGH_SPEED) || (x == CMP_LOW_SPEED)) + + +/* Definitions of CMP Enable bit */ +#define CMP_ENABLE ((u32)0x00000001) + + +/* Definitions of CMP Output Edge Interrupt Enable bit */ +#define CMP_INT_RE ((u32)0x00000002) +#define CMP_INT_FE ((u32)0x00000001) + +/* Check the CMP Interrupt Parameter */ +#define IS_CMP_INT(x) ((x & 0xFFFFFF00) != 0x0) + + +/* Definitions of CMP Output Edge Detection Enable bit */ +#define CMP_RE_Detect ((u32)0x00000200) +#define CMP_FE_Detect ((u32)0x00000100) + +#define IS_CMP_EdgeDetect(x) ((x == CMP_RE_Detect) || (x == CMP_FE_Detect)) + + +/* Definitions of CMP Output Edge Flag */ +#define CMP_FLAG_RE ((u32)0x00000002) +#define CMP_FLAG_FE ((u32)0x00000001) + +/* Check the CMP flag Parameter */ +#define IS_CMP_FLAG(x) ((x & 0xFFFFFF00) != 0x0) + + +/* Check the CMPx Parameter */ +#if (LIBCFG_CMP2) +#define IS_CMP2(x) (x == HT_CMP2) +#else +#define IS_CMP2(x) (0) +#endif +#define IS_CMP(x) ((x == HT_CMP0) || (x == HT_CMP1) || IS_CMP2(x)) + + +/* Check the Scaler Value */ +#if (LIBCFG_CMP_SCALER_8BIT) +#define IS_SCALER_VALUE(x) (x <= 0xFF) +#else +#define IS_SCALER_VALUE(x) (x <= 0x3F) +#endif + +#if (LIBCFG_CMP_CO) +#define IS_CMP_SYNC_SOURCE(x) ((x == CMP_SYNCOUT_CMPnO) || \ + (x == CMP_SYNCOUT_MCTM_CH0O) || \ + (x == CMP_SYNCOUT_MCTM_CH0NO) || \ + (x == CMP_SYNCOUT_MCTM_CH1O) || \ + (x == CMP_SYNCOUT_MCTM_CH1NO) || \ + (x == CMP_SYNCOUT_MCTM_CH2O) || \ + (x == CMP_SYNCOUT_MCTM_CH2NO) || \ + (x == CMP_SYNCOUT_MCTM_CH3O) || \ + (x == CMP_SYNCOUT_MCTM_CH3OB)) +#endif + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Functions CMP exported functions + * @{ + */ +void CMP_DeInit(HT_CMP_TypeDef* HT_CMPn); +void CMP_UnprotectConfig(HT_CMP_TypeDef* HT_CMPn); +void CMP_Init(HT_CMP_TypeDef* HT_CMPn, CMP_InitTypeDef* CMP_InitStruct); +void CMP_StructInit(CMP_InitTypeDef* CMP_InitStruct); +void CMP_Cmd(HT_CMP_TypeDef* HT_CMPn, ControlStatus NewState); +void CMP_IntConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_INT_x, ControlStatus NewState); +void CMP_EdgeDetectConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_xE_Detect, ControlStatus NewState); +FlagStatus CMP_GetFlagStatus(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x); +void CMP_ClearFlag(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x); +FlagStatus CMP_GetOutputStatus(HT_CMP_TypeDef* HT_CMPn); +void CMP_SetScalerValue(HT_CMP_TypeDef* HT_CMPn, u8 Scaler_Value); +#if (LIBCFG_CMP_CO) +void CMP_Output_SyncSource_Select(HT_CMP_TypeDef* HT_CMPn, CMP_SYNCOUT_Enum CMP_SYNCOUT_x); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_crc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_crc.h new file mode 100644 index 0000000000..d6d763777c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_crc.h @@ -0,0 +1,124 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_crc.h + * @version $Rev:: 5031 $ + * @date $Date:: 2020-11-03 #$ + * @brief The header file of the CRC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_CRC_H +#define __HT32F5XXXX_CRC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CRC + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Types CRC exported types + * @{ + */ + +/* Definition of CRC Init Structure */ +typedef enum +{ + CRC_CCITT_POLY = 0, + CRC_16_POLY = 1, + CRC_32_POLY = 2, + CRC_USER_DEFINE = 0xF +} CRC_Mode; + +typedef struct +{ + CRC_Mode Mode; + u32 uSeed; + u32 uCR; +} CRC_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Constants CRC exported constants + * @{ + */ +#define IS_CRC_POLY(POLY) ((POLY == CRC_CCITT_POLY) || \ + (POLY == CRC_16_POLY) || \ + (POLY == CRC_32_POLY) || \ + (POLY == CRC_USER_DEFINE)) + +#define CRC_NORMAL_WR (0) +#define CRC_BIT_RVS_WR (1UL << 2) +#define CRC_BYTE_RVS_WR (1UL << 3) +#define CRC_CMPL_WR (1UL << 4) + +#define CRC_NORMAL_SUM (0) +#define CRC_BIT_RVS_SUM (1UL << 5) +#define CRC_BYTE_RVS_SUM (1UL << 6) +#define CRC_CMPL_SUM (1UL << 7) + +#define IS_CRC_MOD(MOD) ((MOD & 0xFFFFFF00) == 0) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Functions CRC exported functions + * @{ + */ +void CRC_DeInit(HT_CRC_TypeDef* HT_CRCn); +void CRC_Init(HT_CRC_TypeDef* HT_CRCn, CRC_InitTypeDef* CRC_InitStruct); +u32 CRC_Process(HT_CRC_TypeDef* HT_CRCn, u8 *buffer, u32 length); + +u16 CRC_CCITT(u16 seed, u8 *buffer, u32 length); +u16 CRC_16(u16 seed, u8 *buffer, u32 length); +u32 CRC_32(u32 seed, u8 *buffer, u32 length); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac.h new file mode 100644 index 0000000000..50b56ac79c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac.h @@ -0,0 +1,130 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_dac.h + * @version $Rev:: 7081 $ + * @date $Date:: 2023-08-01 #$ + * @brief The header file of the DAC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_DAC_H +#define __HT32F5XXXX_DAC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup DAC + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup DAC_Exported_Types DAC exported types + * @{ + */ + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup DAC_Exported_Constants DAC exported constants + * @{ + */ +#define ASYNC_MODE (0x00000000) +#define SYNC_MODE (0x00000001) + +#if (LIBCFG_DAC1) +#define IS_DAC(DAC) (((DAC) == HT_DAC0) || ((DAC) == HT_DAC1)) +#else +#define IS_DAC(DAC) ((DAC) == HT_DAC0) +#endif + + +#define IS_DAC_CONVERSION_MODE(MODE) (((MODE) == ASYNC_MODE) || ((MODE) == SYNC_MODE)) + + +#define DAC_CH0 (0) +#define DAC_CH1 (1) + +#define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_CH0) || ((CHANNEL) == DAC_CH1)) + + + +#define DAC_REFERENCE_VDDA (0) +#define DAC_REFERENCE_VREF (1UL << 14) + +#define IS_DAC_REFERENCE(REF) (((REF) == DAC_REFERENCE_VDDA) || ((REF) == DAC_REFERENCE_VREF)) + + +#define DAC_RESOLUTION_12BIT (0) +#define DAC_RESOLUTION_8BIT (1UL << 2) + +#define IS_DAC_RESOLUTION(RES) (((RES) == DAC_RESOLUTION_8BIT) || ((RES) == DAC_RESOLUTION_12BIT)) + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup DAC_Exported_Functions DAC exported functions + * @{ + */ +void DAC_DeInit(HT_DAC_TypeDef* HT_DACn); + +void DAC_ModeConfig(HT_DAC_TypeDef* HT_DACn, u8 ModeSel); + +void DAC_ReferenceConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 RefSel); +void DAC_ResolutionConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 ResoSel); + +void DAC_OutBufCmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState); +void DAC_Cmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState); + +void DAC_SetData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 Data); +u16 DAC_GetOutData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch); + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac_dual16.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac_dual16.h new file mode 100644 index 0000000000..306cbb125f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_dac_dual16.h @@ -0,0 +1,92 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_dac_dual16.h + * @version $Rev:: 4282 $ + * @date $Date:: 2019-10-18 #$ + * @brief The header file of the DAC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_DAC_DUAL16_DAC_H +#define __HT32F5XXXX_DAC_DUAL16_DAC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup DAC_DUAL16 + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup DAC_Exported_Types DAC exported types + * @{ + */ +typedef enum +{ + DAC_CH_R = 0, + DAC_CH_L = 1, +} DAC_Dual16_Ch; + +typedef enum +{ + DATA_FROM_UC = 0, + DATA_FROM_MIDI = 1, +} DAC_Dual16_Source; +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup DAC_DUAL16_Exported_Functions DAC exported functions + * @{ + */ +void DACD16_DeInit(void); +void DACD16_DataSourceConfig(HT_DAC_DUAL16_TypeDef* DACx, DAC_Dual16_Ch DAC_CH_x, DAC_Dual16_Source DATA_FROM_x); +void DACD16_SetChannelData(HT_DAC_DUAL16_TypeDef* DACx, DAC_Dual16_Ch DAC_CH_x, u16 Data); +void DACD16_SoftwareStartConvCmd(HT_DAC_DUAL16_TypeDef* DACx, DAC_Dual16_Ch DAC_CH_x); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_div.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_div.h new file mode 100644 index 0000000000..9cf23f9c31 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_div.h @@ -0,0 +1,113 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_div.h + * @version $Rev:: 4617 $ + * @date $Date:: 2020-02-26 #$ + * @brief The header file of the DIV library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_DIV_H +#define __HT32F5XXXX_DIV_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup DIV + * @{ + */ + +/* Settings ------------------------------------------------------------------------------------------------*/ +/** @defgroup DIV_Settings DIV settings + * @{ + */ +#define DIV_ENABLE_DIVIDE_BY_ZERO_CHECK (0) +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup DIV_Exported_Types DIV exported types + * @{ + */ + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup DIV_Exported_Constants DIV exported constants + * @{ + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup DIV_Exported_Functions DIV exported functions + * @{ + */ +void DIV_DeInit(void); +s32 DIV_Div32(s32 dividend, s32 divisor); +s32 DIV_Mod(s32 dividend, s32 divisor); +bool DIV_IsDivByZero(void); + +u32 DIV_uDiv32(u32 dividend, u32 divisor); +u32 DIV_uGetLastRemainder(void); + +/*********************************************************************************************************//** + * @brief Retuen the remainder of last dividend/divisor calculatation. + * @retval The remainder of dividend/divisor + ************************************************************************************************************/ +__STATIC_INLINE s32 DIV_GetLastRemainder(void) +{ + return (HT_DIV->RMR); +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ebi.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ebi.h new file mode 100644 index 0000000000..98e6153146 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ebi.h @@ -0,0 +1,183 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_ebi.h + * @version $Rev:: 2772 $ + * @date $Date:: 2018-05-15 #$ + * @brief The header file of the EBI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_EBI_H +#define __HT32F5XXXX_EBI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup EBI + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Types EBI exported types + * @{ + */ +typedef struct +{ + u32 EBI_Bank; + u32 EBI_Mode; + u32 EBI_IdleCycle; + u32 EBI_ChipSelectPolarity; + u32 EBI_AddressLatchPolarity; + u32 EBI_WriteEnablePolarity; + u32 EBI_ReadEnablePolarity; + u32 EBI_IdleCycleTime; + u32 EBI_AddressSetupTime; + u32 EBI_AddressHoldTime; + u32 EBI_WriteSetupTime; + u32 EBI_WriteStrobeTime; + u32 EBI_WriteHoldTime; + u32 EBI_ReadSetupTime; + u32 EBI_ReadStrobeTime; + u32 EBI_ReadHoldTime; +} EBI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Constants EBI exported constants + * @{ + */ +#define EBI_BANK_0 ((u32)0x00000000) +#define EBI_BANK_1 ((u32)0x00000001) +#define EBI_BANK_2 ((u32)0x00000002) +#define EBI_BANK_3 ((u32)0x00000003) + +#define IS_EBI_BANK(BANK) ((BANK == EBI_BANK_0) || \ + (BANK == EBI_BANK_1) || \ + (BANK == EBI_BANK_2) || \ + (BANK == EBI_BANK_3)) + + +#define EBI_MODE_D8A8 ((u32)0x00000000) +#define EBI_MODE_D16A16ALE ((u32)0x00000001) +#define EBI_MODE_D8A24ALE ((u32)0x00000002) +#define EBI_MODE_D16 ((u32)0x00000003) + +#define IS_EBI_MODE(MODE) ((MODE == EBI_MODE_D8A8) || \ + (MODE == EBI_MODE_D16A16ALE) || \ + (MODE == EBI_MODE_D8A24ALE) || \ + (MODE == EBI_MODE_D16)) + + +#define EBI_IDLECYCLE_ENABLE ((u32)0x00000000) +#define EBI_IDLECYCLE_DISABLE ((u32)0x00001000) + +#define IS_EBI_IDLECYCLE(IDLECYCLE) ((IDLECYCLE == EBI_IDLECYCLE_ENABLE) || \ + (IDLECYCLE == EBI_IDLECYCLE_DISABLE)) + + +#define EBI_CHIPSELECTPOLARITY_LOW ((u32)0x00000000) +#define EBI_CHIPSELECTPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_CS_POLARITY(POLARITY) ((POLARITY == EBI_CHIPSELECTPOLARITY_LOW) || \ + (POLARITY == EBI_CHIPSELECTPOLARITY_HIGH)) + + +#define EBI_ADDRESSLATCHPOLARITY_LOW ((u32)0x00000000) +#define EBI_ADDRESSLATCHPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_ALE_POLARITY(POLARITY) ((POLARITY == EBI_ADDRESSLATCHPOLARITY_LOW) || \ + (POLARITY == EBI_ADDRESSLATCHPOLARITY_HIGH)) + + +#define EBI_WRITEENABLEPOLARITY_LOW ((u32)0x00000000) +#define EBI_WRITEENABLEPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_WE_POLARITY(POLARITY) ((POLARITY == EBI_WRITEENABLEPOLARITY_LOW) || \ + (POLARITY == EBI_WRITEENABLEPOLARITY_HIGH)) + + +#define EBI_READENABLEPOLARITY_LOW ((u32)0x00000000) +#define EBI_READENABLEPOLARITY_HIGH ((u32)0x00000001) + +#define IS_EBI_RE_POLARITY(POLARITY) ((POLARITY == EBI_READENABLEPOLARITY_LOW) || \ + (POLARITY == EBI_READENABLEPOLARITY_HIGH)) + + +#define IS_EBI_IDLE_CYCLE_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_ADDRESS_SETUP_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_ADDRESS_HOLD_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_WRITE_SETUP_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_WRITE_STROBE_TIME(TIME) (TIME < 0x40) + +#define IS_EBI_WRITE_HOLD_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_READ_SETUP_TIME(TIME) (TIME < 0x10) + +#define IS_EBI_READ_STROBE_TIME(TIME) (TIME < 0x40) + +#define IS_EBI_READ_HOLD_TIME(TIME) (TIME < 0x10) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Functions EBI exported functions + * @{ + */ +void EBI_DeInit(void); +void EBI_Init(EBI_InitTypeDef* EBI_InitStruct); +void EBI_StructInit(EBI_InitTypeDef* EBI_InitStruct); +void EBI_Cmd(u32 EBI_Bank, ControlStatus NewState); +FlagStatus EBI_GetBusyStatus(void); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_exti.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_exti.h new file mode 100644 index 0000000000..bdda2d2442 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_exti.h @@ -0,0 +1,263 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_exti.h + * @version $Rev:: 6496 $ + * @date $Date:: 2022-11-28 #$ + * @brief The header file of the EXTI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_EXTI_H +#define __HT32F5XXXX_EXTI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup EXTI + * @{ + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Macro EXTI exported macros + * @{ + */ +/*********************************************************************************************************//** + * @brief Convert the pin number of GPIO to the channel of EXTI. + * @param n: can be 0, 1 to 15 to select the pin number of GPIO. + ************************************************************************************************************/ +#if (LIBCFG_EXTI_8CH) + #define GPIO2EXTI(n) ((n >= 8) ? (n - 8) : n) +#else + #define GPIO2EXTI(n) (n) +#endif + +#define EXTI_GetIRQn(ch) gEXTIn_IRQn[ch] +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Types EXTI exported types + * @{ + */ + +/* Definitions of EXTI interrupt line */ +typedef enum +{ + EXTI_CHANNEL_0 = 0, + EXTI_CHANNEL_1, + EXTI_CHANNEL_2, + EXTI_CHANNEL_3, + EXTI_CHANNEL_4, + EXTI_CHANNEL_5, + EXTI_CHANNEL_6, + EXTI_CHANNEL_7, +#if (!LIBCFG_EXTI_8CH) + EXTI_CHANNEL_8, + EXTI_CHANNEL_9, + EXTI_CHANNEL_10, + EXTI_CHANNEL_11, + EXTI_CHANNEL_12, + EXTI_CHANNEL_13, + EXTI_CHANNEL_14, + EXTI_CHANNEL_15, +#endif +} EXTI_Channel_TypeDef; + +#if (LIBCFG_EXTI_8CH) +#define IS_CHANNEL_8(x) (0) +#define IS_CHANNEL_9(x) (0) +#define IS_CHANNEL_10(x) (0) +#define IS_CHANNEL_11(x) (0) +#define IS_CHANNEL_12(x) (0) +#define IS_CHANNEL_13(x) (0) +#define IS_CHANNEL_14(x) (0) +#define IS_CHANNEL_15(x) (0) +#else +#define IS_CHANNEL_8(x) (x == EXTI_CHANNEL_8) +#define IS_CHANNEL_9(x) (x == EXTI_CHANNEL_9) +#define IS_CHANNEL_10(x) (x == EXTI_CHANNEL_10) +#define IS_CHANNEL_11(x) (x == EXTI_CHANNEL_11) +#define IS_CHANNEL_12(x) (x == EXTI_CHANNEL_12) +#define IS_CHANNEL_13(x) (x == EXTI_CHANNEL_13) +#define IS_CHANNEL_14(x) (x == EXTI_CHANNEL_14) +#define IS_CHANNEL_15(x) (x == EXTI_CHANNEL_15) +#endif + + +#define IS_EXTI_CHANNEL(CHANNEL) ((CHANNEL == EXTI_CHANNEL_0) || \ + (CHANNEL == EXTI_CHANNEL_1) || \ + (CHANNEL == EXTI_CHANNEL_2) || \ + (CHANNEL == EXTI_CHANNEL_3) || \ + (CHANNEL == EXTI_CHANNEL_4) || \ + (CHANNEL == EXTI_CHANNEL_5) || \ + (CHANNEL == EXTI_CHANNEL_6) || \ + (CHANNEL == EXTI_CHANNEL_7) || \ + IS_CHANNEL_8(CHANNEL) || \ + IS_CHANNEL_9(CHANNEL) || \ + IS_CHANNEL_10(CHANNEL) || \ + IS_CHANNEL_11(CHANNEL) || \ + IS_CHANNEL_12(CHANNEL) || \ + IS_CHANNEL_13(CHANNEL) || \ + IS_CHANNEL_14(CHANNEL) || \ + IS_CHANNEL_15(CHANNEL)) + + +/* Definitions of EXTI init structure */ +typedef enum +{ + EXTI_LOW_LEVEL = 0x0, + EXTI_HIGH_LEVEL = 0x1, + EXTI_NEGATIVE_EDGE = 0x2, + EXTI_POSITIVE_EDGE = 0x3, + EXTI_BOTH_EDGE = 0x4 +} EXTI_Interrupt_TypeDef; + +#define IS_EXTI_INT_TYPE(TYPE) ((TYPE == EXTI_LOW_LEVEL) || \ + (TYPE == EXTI_HIGH_LEVEL) || \ + (TYPE == EXTI_NEGATIVE_EDGE) || \ + (TYPE == EXTI_POSITIVE_EDGE) || \ + (TYPE == EXTI_BOTH_EDGE)) + +typedef enum +{ + EXTI_DEBOUNCE_DISABLE = 0x0, + EXTI_DEBOUNCE_ENABLE = 0x1 +} EXTI_Deb_TypeDef; + +#define IS_EXTI_DEBOUNCE_TYPE(TYPE) ((TYPE == EXTI_DEBOUNCE_DISABLE) || \ + (TYPE == EXTI_DEBOUNCE_ENABLE)) + +#if (LIBCFG_EXTI_DEBCNTPRE) +typedef enum +{ + EXTI_DBCNTPRE_DIV1 = 0, + EXTI_DBCNTPRE_DIV2, + EXTI_DBCNTPRE_DIV4, + EXTI_DBCNTPRE_DIV8, + EXTI_DBCNTPRE_DIV16, + EXTI_DBCNTPRE_DIV32, + EXTI_DBCNTPRE_DIV64, + EXTI_DBCNTPRE_DIV128, +} EXTI_DebCntPre_TypeDef; + +#define IS_EXTI_DEBOUNCE_COUNTER_PRESCALER(TYPE) ((TYPE == EXTI_DBCNTPRE_DIV1) || \ + (TYPE == EXTI_DBCNTPRE_DIV2) || \ + (TYPE == EXTI_DBCNTPRE_DIV4) || \ + (TYPE == EXTI_DBCNTPRE_DIV8) || \ + (TYPE == EXTI_DBCNTPRE_DIV16) || \ + (TYPE == EXTI_DBCNTPRE_DIV32) || \ + (TYPE == EXTI_DBCNTPRE_DIV64) || \ + (TYPE == EXTI_DBCNTPRE_DIV128)) +#endif + +typedef struct +{ + u32 EXTI_Channel; + EXTI_Deb_TypeDef EXTI_Debounce; + #if (LIBCFG_EXTI_8BIT_DEBOUNCE_COUNTER) + u8 EXTI_DebounceCnt; + #else + u16 EXTI_DebounceCnt; + #endif + EXTI_Interrupt_TypeDef EXTI_IntType; +} EXTI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Constants EXTI exported constants + * @{ + */ + +/* Definitions of EXTI wake up polarity */ +#define EXTI_WAKEUP_HIGH_LEVEL ((u8)0x0) +#define EXTI_WAKEUP_LOW_LEVEL ((u8)0x1) + +#define IS_EXTI_WAKEUP_TYPE(TYPE) ((TYPE == EXTI_WAKEUP_HIGH_LEVEL) || \ + (TYPE == EXTI_WAKEUP_LOW_LEVEL)) + + +#define EXTI_EDGE_POSITIVE ((u8)0x0) +#define EXTI_EDGE_NEGATIVE ((u8)0x1) + +#define IS_EXTI_EDGE(EDGE) ((EDGE == EXTI_EDGE_POSITIVE) || \ + (EDGE == EXTI_EDGE_NEGATIVE)) + +#if (LIBCFG_EXTI_8BIT_DEBOUNCE_COUNTER) +#define IS_EXTI_DEBOUNCE_SIZE(SIZE) (SIZE <= 0xFF) +#else +#define IS_EXTI_DEBOUNCE_SIZE(SIZE) (SIZE <= 0xFFFF) +#endif + +extern const IRQn_Type gEXTIn_IRQn[16]; + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Functions EXTI exported functions + * @{ + */ +void EXTI_DeInit(u32 EXTI_Channel); +void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); +void EXTI_IntConfig(u32 EXTI_Channel, ControlStatus NewState); +#if (LIBCFG_EXTI_DEBCNTPRE) +void EXTI_SetDebounceCounterPrescaler(EXTI_DebCntPre_TypeDef EXTI_DBCNTPRE_DIVn); +#endif +void EXTI_WakeupEventConfig(u32 EXTI_Channel, u8 EXTI_WakeUpType, ControlStatus NewState); +void EXTI_WakeupEventIntConfig(ControlStatus NewState); +void EXTI_ClearEdgeFlag(u32 EXTI_Channel); +void EXTI_ClearWakeupFlag(u32 EXTI_Channel); +FlagStatus EXTI_GetEdgeFlag(u32 EXTI_Channel); +FlagStatus EXTI_GetEdgeStatus(u32 EXTI_Channel, u32 EXTI_Edge); +FlagStatus EXTI_GetWakeupFlagStatus(u32 EXTI_Channel); +void EXTI_SWIntCmd(u32 EXTI_Channel, ControlStatus NewState); +FlagStatus EXTI_GetSWCmdStatus(u32 EXTI_Channel); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_flash.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_flash.h new file mode 100644 index 0000000000..0ee8ba77d7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_flash.h @@ -0,0 +1,190 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_flash.h + * @version $Rev:: 5496 $ + * @date $Date:: 2021-07-19 #$ + * @brief The header file of the FLASH library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_FLASH_H +#define __HT32F5XXXX_FLASH_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup FLASH + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Types FLASH exported types + * @{ + */ + +/** + * @brief Enumeration of FLASH return status. + */ +typedef enum +{ + FLASH_COMPLETE = 0, + FLASH_ERR_ADDR_OUT_OF_RANGE, + FLASH_ERR_WRITE_PROTECTED, + FLASH_TIME_OUT +} FLASH_State; + +/** + * @brief Enumeration of FLASH boot mode. + */ +typedef enum +{ + FLASH_BOOT_LOADER = 1, + FLASH_BOOT_MAIN = 2 +} FLASH_Vector; + +typedef struct +{ + u32 WriteProtect[4]; + u32 MainSecurity; + u32 OptionProtect; +} FLASH_OptionByte; + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Constants FLASH exported constants + * @{ + */ + +/* Flash Information */ +#define FLASH_PAGE_SIZE (LIBCFG_FLASH_PAGESIZE) /* Flash page size */ + +#if (LIBCFG_FMC_PREFETCH) + +/* Flash Wait State */ +#define FLASH_WAITSTATE_0 (0x00000001) /* FLASH zero wait state */ +#define FLASH_WAITSTATE_1 (0x00000002) /* FLASH one wait state */ +#if (LIBCFG_FMC_WAIT_STATE_2) +#define FLASH_WAITSTATE_2 (0x00000003) /* FLASH two wait state */ +#endif + +#if (LIBCFG_FMC_WAIT_STATE_2) +#define FLASH_WAITSTATE_MAX (FLASH_WAITSTATE_2) +#else +#define FLASH_WAITSTATE_MAX (FLASH_WAITSTATE_1) +#endif + +#endif + +/* FLASH OISR Flags */ +#define FLASH_FLAG_ORFF (0x00000001) /* Operation Finished Flag */ +#define FLASH_FLAG_ITADF (0x00000002) /* Invalid Target Address Flag */ +#define FLASH_FLAG_OBEF (0x00000004) /* Option Byte Check Sum Error Flag */ +#define FLASH_FLAG_IOCMF (0x00000008) /* Invalid Operation Command Flag */ +#define FLASH_FLAG_OREF (0x00000010) /* Operation Error Flag */ +#define FLASH_FLAG_RORFF (0x00010000) /* Raw Operation Finished Flag */ +#define FLASH_FLAG_PPEF (0x00020000) /* Page Erase/Program Protected Error Flag */ + +/* FLASH OIER */ +#define FLASH_INT_ORFIEN (0x00000001) /* Flash Operation Finished Interrupt Enable */ +#define FLASH_INT_ITADIEN (0x00000002) /* Invalid Target Address Interrupt Enable */ +#define FLASH_INT_OBEIEN (0x00000004) /* Option Byte Checksum Error Interrupt Enable */ +#define FLASH_INT_IOCMIEN (0x00000008) /* Invalid Operation Command Interrupt Enable */ +#define FLASH_INT_OREIEN (0x00000010) /* Operation Error Interrupt Enable */ +#define FLASH_INT_ALL (0x0000001F) /* Flash all Interrupt Enable */ + +/* Option Bytes Address */ +#define OPTION_BYTE_BASE (0x1FF00000) /* Option Byte Base Address */ +#define OB_PP0 (0x1FF00000) /* Option Byte: Write Protection 0 */ +#define OB_PP1 (0x1FF00004) /* Option Byte: Write Protection 1 */ +#define OB_PP2 (0x1FF00008) /* Option Byte: Write Protection 2 */ +#define OB_PP3 (0x1FF0000C) /* Option Byte: Write Protection 3 */ +#define OB_CP (0x1FF00010) /* Option Byte: Security Protection */ +#define OB_CHECKSUM (0x1FF00020) /* Option Byte: Checksum */ + +/* Flash Write Protection Page Mask */ +#if (LIBCFG_FLASH_2PAGE_PER_WPBIT) + #define FLASH_WP_PAGE_SET(OP, PAGE) (OP.WriteProtect[PAGE / 64] |= 1 << ((PAGE % 64) / 2)) + #define FLASH_WP_PAGE_CLEAR(OP, PAGE) (OP.WriteProtect[PAGE / 64] &= ~(1 << ((PAGE % 64) / 2))) + #define FLASH_IS_WP_PAGE(OP, PAGE) (OP.WriteProtect[PAGE / 64] & (1 << ((PAGE % 64) / 2))) +#else + #define FLASH_WP_PAGE_SET(OP, PAGE) (OP.WriteProtect[PAGE / 32] |= 1 << (PAGE % 32)) + #define FLASH_WP_PAGE_CLEAR(OP, PAGE) (OP.WriteProtect[PAGE / 32] &= ~(1 << (PAGE % 32))) + #define FLASH_IS_WP_PAGE(OP, PAGE) (OP.WriteProtect[PAGE / 32] & (1 << (PAGE % 32))) +#endif +#define FLASH_WP_ALLPAGE_SET(OP) {u32 i; for (i = 0; i < 4; i++) { OP.WriteProtect[i] = 0xFFFFFFFF; } } + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Functions FLASH exported functions + * @{ + */ +#if (LIBCFG_FMC_PREFETCH) +void FLASH_SetWaitState(u32 FLASH_WAITSTATE_n); +void FLASH_PrefetchBufferCmd(ControlStatus NewState); +#endif +#if (LIBCFG_FMC_BRANCHCACHE) +void FLASH_BranchCacheCmd(ControlStatus NewState); +#endif +void FLASH_SetRemappingMode(FLASH_Vector RemapMode); +FLASH_State FLASH_ErasePage(u32 PageAddress); +FLASH_State FLASH_EraseOptionByte(void); +FLASH_State FLASH_MassErase(void); +FLASH_State FLASH_ProgramWordData(u32 Address, u32 Data); +FLASH_State FLASH_ProgramOptionByte(FLASH_OptionByte *Option); +void FLASH_GetOptionByteStatus(FLASH_OptionByte *Option); +void FLASH_IntConfig(u32 FLASH_INT, ControlStatus Cmd); +FlagStatus FLASH_GetIntStatus(u32 FLASH_FLAG_x); +void FLASH_ClearIntFlag(u32 FLASH_FLAG_x); +FLASH_State FLASH_WaitForOperationEnd(void); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_gpio.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_gpio.h new file mode 100644 index 0000000000..42f274c4e7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_gpio.h @@ -0,0 +1,508 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_gpio.h + * @version $Rev:: 7115 $ + * @date $Date:: 2023-08-11 #$ + * @brief The header file of the GPIO and AFIO library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_GPIO_H +#define __HT32F5XXXX_GPIO_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup GPIO + * @{ + */ + + +/* Settings ------------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Settings GPIO settings + * @{ + */ +#ifndef AUTO_CK_CONTROL +#define AUTO_CK_CONTROL (0) +#endif +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Types GPIO exported types + * @{ + */ + +/** + * @brief Enumeration of GPIO pull resistor. + */ +typedef enum +{ + GPIO_PR_UP = 0, /*!< weak pull-up resistor */ + GPIO_PR_DOWN, /*!< weak pull-down resistor */ + GPIO_PR_DISABLE, /*!< Tri-state */ + #if (LIBCFG_GPIO_PR_STRONG_UP) + GPIO_PR_STRONG_UP, /*!< strong pull-up resistor */ + GPIO_PR_STRONGEST_UP /*!< strongest pull-up resistor */ + #endif +} GPIO_PR_Enum; +/** + * @brief Enumeration of GPIO output drive current. + */ +typedef enum +{ + GPIO_DV_4MA = 0, /*!< 4mA source/sink current */ + GPIO_DV_8MA, /*!< 8mA source/sink current */ + GPIO_DV_12MA, /*!< 12mA source/sink current */ + GPIO_DV_16MA /*!< 16mA source/sink current */ +} GPIO_DV_Enum; +/** + * @brief Enumeration of GPIO direction. + */ +typedef enum +{ + GPIO_DIR_IN = 0, /*!< input mode */ + GPIO_DIR_OUT /*!< output mode */ +} GPIO_DIR_Enum; +/** + * @brief Enumeration of AFIO for EXTI channel. + */ +typedef enum +{ + AFIO_EXTI_CH_0 = 0, /*!< GPIO pin 0 */ + AFIO_EXTI_CH_1, /*!< GPIO pin 1 */ + AFIO_EXTI_CH_2, /*!< GPIO pin 2 */ + AFIO_EXTI_CH_3, /*!< GPIO pin 3 */ + AFIO_EXTI_CH_4, /*!< GPIO pin 4 */ + AFIO_EXTI_CH_5, /*!< GPIO pin 5 */ + AFIO_EXTI_CH_6, /*!< GPIO pin 6 */ + AFIO_EXTI_CH_7, /*!< GPIO pin 7 */ + AFIO_EXTI_CH_8, /*!< GPIO pin 8 */ + AFIO_EXTI_CH_9, /*!< GPIO pin 9 */ + AFIO_EXTI_CH_10, /*!< GPIO pin 10 */ + AFIO_EXTI_CH_11, /*!< GPIO pin 11 */ + AFIO_EXTI_CH_12, /*!< GPIO pin 12 */ + AFIO_EXTI_CH_13, /*!< GPIO pin 13 */ + AFIO_EXTI_CH_14, /*!< GPIO pin 14 */ + AFIO_EXTI_CH_15 /*!< GPIO pin 15 */ +} AFIO_EXTI_CH_Enum; +/** + * @brief Enumeration of AFIO_MODE. + */ +typedef enum +{ + AFIO_MODE_DEFAULT = 0, /*!< Default AFIO mode */ + AFIO_MODE_1, /*!< AFIO mode 1 */ + AFIO_MODE_2, /*!< AFIO mode 2 */ + AFIO_MODE_3, /*!< AFIO mode 3 */ + AFIO_MODE_4, /*!< AFIO mode 4 */ + AFIO_MODE_5, /*!< AFIO mode 5 */ + AFIO_MODE_6, /*!< AFIO mode 6 */ + AFIO_MODE_7, /*!< AFIO mode 7 */ + AFIO_MODE_8, /*!< AFIO mode 8 */ + AFIO_MODE_9, /*!< AFIO mode 9 */ + AFIO_MODE_10, /*!< AFIO mode 10 */ + AFIO_MODE_11, /*!< AFIO mode 11 */ + AFIO_MODE_12, /*!< AFIO mode 12 */ + AFIO_MODE_13, /*!< AFIO mode 13 */ + AFIO_MODE_14, /*!< AFIO mode 14 */ + AFIO_MODE_15 /*!< AFIO mode 15 */ +} AFIO_MODE_Enum; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Constants GPIO exported constants + * @{ + */ + +/* Definitions of AFIO_FUN */ +#define AFIO_FUN_DEFAULT AFIO_MODE_DEFAULT /*!< Default AFIO mode */ +#define AFIO_FUN_GPIO AFIO_MODE_1 /*!< AFIO mode GPIO */ +#if (LIBCFG_AFIO_SYSTEM_MODE1) +#define AFIO_FUN_SYSTEM AFIO_MODE_1 /*!< AFIO mode System */ +#else +#define AFIO_FUN_SYSTEM AFIO_MODE_15 /*!< AFIO mode System */ +#endif +#if (LIBCFG_AFIO_DAC_MODE3) +#define AFIO_FUN_DAC0 AFIO_MODE_3 /*!< AFIO mode DAC0 */ +#define AFIO_FUN_DAC1 AFIO_MODE_3 /*!< AFIO mode DAC1 */ +#else +#define AFIO_FUN_DAC0 AFIO_MODE_2 /*!< AFIO mode DAC0 */ +#endif +#define AFIO_FUN_ADC0 AFIO_MODE_2 /*!< AFIO mode ADC0 */ +#define AFIO_FUN_ADC1 AFIO_MODE_3 /*!< AFIO mode ADC1 */ +#if (LIBCFG_AFIO_LEDC_MODE3) +#define AFIO_FUN_LEDC AFIO_MODE_3 /*!< AFIO mode LEDC */ +#else +#define AFIO_FUN_LEDC AFIO_MODE_14 /*!< AFIO mode LEDC */ +#endif +#define AFIO_FUN_CMP AFIO_MODE_3 /*!< AFIO mode CMP */ +#define AFIO_FUN_MCTM_GPTM AFIO_MODE_4 /*!< AFIO mode MCTM/GPTM */ +#if (LIBCFG_AFIO_SCTM_MODE4) +#define AFIO_FUN_SCTM AFIO_MODE_4 /*!< AFIO mode SCTM */ +#elif (LIBCFG_AFIO_SCTM_MODE9) +#define AFIO_FUN_SCTM AFIO_MODE_9 /*!< AFIO mode SCTM */ +#else +#define AFIO_FUN_SCTM AFIO_MODE_13 /*!< AFIO mode SCTM */ +#endif +#if (LIBCFG_AFIO_PWM_MODE4) +#define AFIO_FUN_PWM AFIO_MODE_4 /*!< AFIO mode PWM */ +#else +#define AFIO_FUN_PWM AFIO_MODE_13 /*!< AFIO mode PWM */ +#endif +#define AFIO_FUN_SPI AFIO_MODE_5 /*!< AFIO mode SPI */ +#define AFIO_FUN_USART_UART AFIO_MODE_6 /*!< AFIO mode USART/UART */ +#define AFIO_FUN_I2C AFIO_MODE_7 /*!< AFIO mode I2C */ +#define AFIO_FUN_SCI AFIO_MODE_8 /*!< AFIO mode SCI */ +#define AFIO_FUN_CMP_OPA AFIO_MODE_8 /*!< AFIO mode CMP/OPA */ +#define AFIO_FUN_EBI AFIO_MODE_9 /*!< AFIO mode EBI */ +#define AFIO_FUN_I2S AFIO_MODE_10 /*!< AFIO mode I2S */ +#define AFIO_FUN_CAN AFIO_MODE_12 /*!< AFIO mode CAN */ +#define AFIO_FUN_TEKY AFIO_MODE_12 /*!< AFIO mode TKEY */ +#define AFIO_FUN_LCD AFIO_MODE_14 /*!< AFIO mode LCD */ +#define AFIO_FUN_SLED AFIO_MODE_14 /*!< AFIO mode SLED */ + +/* Definitions of AFIO_FUN alias */ +#define AFIO_FUN_MCTM0 AFIO_FUN_MCTM_GPTM + +#define AFIO_FUN_GPTM0 AFIO_FUN_MCTM_GPTM +#define AFIO_FUN_GPTM1 AFIO_FUN_MCTM_GPTM +#define AFIO_FUN_GPTM2 AFIO_FUN_MCTM_GPTM +#define AFIO_FUN_GPTM3 AFIO_FUN_MCTM_GPTM + +#define AFIO_FUN_PWM0 AFIO_FUN_PWM +#define AFIO_FUN_PWM1 AFIO_FUN_PWM +#define AFIO_FUN_PWM2 AFIO_FUN_PWM +#define AFIO_FUN_PWM3 AFIO_FUN_PWM + +#define AFIO_FUN_SCTM0 AFIO_FUN_SCTM +#define AFIO_FUN_SCTM1 AFIO_FUN_SCTM +#define AFIO_FUN_SCTM2 AFIO_FUN_SCTM +#define AFIO_FUN_SCTM3 AFIO_FUN_SCTM + +#define AFIO_FUN_ADC AFIO_FUN_ADC0 + +/* Definitions of GPIO_Px */ +#define GPIO_PORT_NUM (6) +#define GPIO_PIN_NUM (16) +#define GPIO_PA (0) +#define GPIO_PB (1) +#if (LIBCFG_GPIOC) +#define GPIO_PC (2) +#endif +#if (LIBCFG_GPIOD) +#define GPIO_PD (3) +#endif +#if (LIBCFG_GPIOE) +#define GPIO_PE (4) +#endif +#if (LIBCFG_GPIOF) +#define GPIO_PF (5) +#endif + +/* Definitions of GPIO port source for EXTI channel */ +#define AFIO_ESS_PA GPIO_PA /*!< EXTI channel x source come from GPIO Port A */ +#define AFIO_ESS_PB GPIO_PB /*!< EXTI channel x source come from GPIO Port B */ +#if (LIBCFG_GPIOC) +#define AFIO_ESS_PC GPIO_PC /*!< EXTI channel x source come from GPIO Port C */ +#endif +#if (LIBCFG_GPIOD) +#define AFIO_ESS_PD GPIO_PD /*!< EXTI channel x source come from GPIO Port D */ +#endif +#if (LIBCFG_GPIOE) +#define AFIO_ESS_PE GPIO_PE /*!< EXTI channel x source come from GPIO Port E */ +#endif +#if (LIBCFG_GPIOF) +#define AFIO_ESS_PF GPIO_PF /*!< EXTI channel x source come from GPIO Port F */ +#endif + +/* Definitions of GPIO_PIN */ +#define GPIO_PIN_0 0x0001 /*!< GPIO pin 0 selected */ +#define GPIO_PIN_1 0x0002 /*!< GPIO pin 1 selected */ +#define GPIO_PIN_2 0x0004 /*!< GPIO pin 2 selected */ +#define GPIO_PIN_3 0x0008 /*!< GPIO pin 3 selected */ +#define GPIO_PIN_4 0x0010 /*!< GPIO pin 4 selected */ +#define GPIO_PIN_5 0x0020 /*!< GPIO pin 5 selected */ +#define GPIO_PIN_6 0x0040 /*!< GPIO pin 6 selected */ +#define GPIO_PIN_7 0x0080 /*!< GPIO pin 7 selected */ +#define GPIO_PIN_8 0x0100 /*!< GPIO pin 8 selected */ +#define GPIO_PIN_9 0x0200 /*!< GPIO pin 9 selected */ +#define GPIO_PIN_10 0x0400 /*!< GPIO pin 10 selected */ +#define GPIO_PIN_11 0x0800 /*!< GPIO pin 11 selected */ +#define GPIO_PIN_12 0x1000 /*!< GPIO pin 12 selected */ +#define GPIO_PIN_13 0x2000 /*!< GPIO pin 13 selected */ +#define GPIO_PIN_14 0x4000 /*!< GPIO pin 14 selected */ +#define GPIO_PIN_15 0x8000 /*!< GPIO pin 15 selected */ +#define GPIO_PIN_ALL 0xFFFF /*!< GPIO all pins selected */ + +/* Definitions of AFIO_PIN */ +#define AFIO_PIN_0 0x0001 /*!< AFIO pin 0 selected */ +#define AFIO_PIN_1 0x0002 /*!< AFIO pin 1 selected */ +#define AFIO_PIN_2 0x0004 /*!< AFIO pin 2 selected */ +#define AFIO_PIN_3 0x0008 /*!< AFIO pin 3 selected */ +#define AFIO_PIN_4 0x0010 /*!< AFIO pin 4 selected */ +#define AFIO_PIN_5 0x0020 /*!< AFIO pin 5 selected */ +#define AFIO_PIN_6 0x0040 /*!< AFIO pin 6 selected */ +#define AFIO_PIN_7 0x0080 /*!< AFIO pin 7 selected */ +#define AFIO_PIN_8 0x0100 /*!< AFIO pin 8 selected */ +#define AFIO_PIN_9 0x0200 /*!< AFIO pin 9 selected */ +#define AFIO_PIN_10 0x0400 /*!< AFIO pin 10 selected */ +#define AFIO_PIN_11 0x0800 /*!< AFIO pin 11 selected */ +#define AFIO_PIN_12 0x1000 /*!< AFIO pin 12 selected */ +#define AFIO_PIN_13 0x2000 /*!< AFIO pin 13 selected */ +#define AFIO_PIN_14 0x4000 /*!< AFIO pin 14 selected */ +#define AFIO_PIN_15 0x8000 /*!< AFIO pin 15 selected */ +#define AFIO_PIN_ALL 0xFFFF /*!< All AFIO pins selected */ + +/* Definitions of GPIO_PIN_NUM */ +#define GPIO_PIN_NUM_0 0x00 /*!< GPIO pin number 0 selected */ +#define GPIO_PIN_NUM_1 0x01 /*!< GPIO pin number 1 selected */ +#define GPIO_PIN_NUM_2 0x02 /*!< GPIO pin number 2 selected */ +#define GPIO_PIN_NUM_3 0x03 /*!< GPIO pin number 3 selected */ +#define GPIO_PIN_NUM_4 0x04 /*!< GPIO pin number 4 selected */ +#define GPIO_PIN_NUM_5 0x05 /*!< GPIO pin number 5 selected */ +#define GPIO_PIN_NUM_6 0x06 /*!< GPIO pin number 6 selected */ +#define GPIO_PIN_NUM_7 0x07 /*!< GPIO pin number 7 selected */ +#define GPIO_PIN_NUM_8 0x08 /*!< GPIO pin number 8 selected */ +#define GPIO_PIN_NUM_9 0x09 /*!< GPIO pin number 9 selected */ +#define GPIO_PIN_NUM_10 0x0A /*!< GPIO pin number 10 selected */ +#define GPIO_PIN_NUM_11 0x0B /*!< GPIO pin number 11 selected */ +#define GPIO_PIN_NUM_12 0x0C /*!< GPIO pin number 12 selected */ +#define GPIO_PIN_NUM_13 0x0D /*!< GPIO pin number 13 selected */ +#define GPIO_PIN_NUM_14 0x0E /*!< GPIO pin number 14 selected */ +#define GPIO_PIN_NUM_15 0x0F /*!< GPIO pin number 15 selected */ + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Macro GPIO exported macro + * @{ + */ +/* check parameter of the GPIOx */ +#define IS_GPIO(x) (IS_GPIO1(x) || IS_GPIO2(x) || IS_GPIO3(x) || IS_GPIO4(x) || IS_GPIO5(x)) + +#define IS_GPIO1(x) ((x == HT_GPIOA) || (x == HT_GPIOB) ) + +#if (LIBCFG_GPIOC) +#define IS_GPIO2(x) (x == HT_GPIOC) +#else +#define IS_GPIO2(x) (0) +#endif +#if (LIBCFG_GPIOD) +#define IS_GPIO3(x) (x == HT_GPIOD) +#else +#define IS_GPIO3(x) (0) +#endif +#if (LIBCFG_GPIOE) +#define IS_GPIO4(x) (x == HT_GPIOE) +#else +#define IS_GPIO4(x) (0) + #endif +#if (LIBCFG_GPIOF) +#define IS_GPIO5(x) (x == HT_GPIOF) +#else +#define IS_GPIO5(x) (0) +#endif + +/* check parameter of the GPIO_Px */ +#define IS_GPIO_PORT(x) (IS_GPIO_PORT1(x) || IS_GPIO_PORT2(x) || IS_GPIO_PORT3(x) || IS_GPIO_PORT4(x) || IS_GPIO_PORT5(x)) + +#define IS_GPIO_PORT1(x) ((x == GPIO_PA) || (x == GPIO_PB)) + +#if (LIBCFG_GPIOC) +#define IS_GPIO_PORT2(x) (x == GPIO_PC) +#else +#define IS_GPIO_PORT2(x) (0) +#endif +#if (LIBCFG_GPIOD) +#define IS_GPIO_PORT3(x) (x == GPIO_PD) +#else +#define IS_GPIO_PORT3(x) (0) +#endif +#if (LIBCFG_GPIOE) +#define IS_GPIO_PORT4(x) (x == GPIO_PE) +#else +#define IS_GPIO_PORT4(x) (0) +#endif +#if (LIBCFG_GPIOF) +#define IS_GPIO_PORT5(x) (x == GPIO_PF) +#else +#define IS_GPIO_PORT5(x) (0) +#endif + +/* check parameter of the GPIO_PIN_NUM */ +#define IS_GPIO_PIN_NUM(x) (x < 16) + + +#define IS_GPIO_PR_UP(x) (x == GPIO_PR_UP) +#define IS_GPIO_PR_DOWN(x) (x == GPIO_PR_DOWN) +#define IS_GPIO_PR_DISABLE(x) (x == GPIO_PR_DISABLE) + +#if (LIBCFG_GPIO_PR_STRONG_UP) +#define IS_GPIO_PR_STRONG_UP(x) (x == GPIO_PR_STRONG_UP) +#define IS_GPIO_PR_STRONGEST_UP(x) (x == GPIO_PR_STRONGEST_UP) +#else +#define IS_GPIO_PR_STRONG_UP(x) (0) +#define IS_GPIO_PR_STRONGEST_UP(x) (0) +#endif + +/* check parameter of the GPIOx pull resistor */ +#define IS_GPIO_PR(x) (IS_GPIO_PR_UP(x) || \ + IS_GPIO_PR_DOWN(x) || \ + IS_GPIO_PR_DISABLE(x) || \ + IS_GPIO_PR_STRONG_UP(x) || \ + IS_GPIO_PR_STRONGEST_UP(x)) + +/* check parameter of the GPIOx driving current */ +#define IS_GPIO_DV(x) (((x) == GPIO_DV_4MA) || ((x) == GPIO_DV_8MA) || ((x) == GPIO_DV_12MA) || ((x) == GPIO_DV_16MA) ) + +/* check parameter of the GPIOx input/output direction */ +#define IS_GPIO_DIR(x) (((x) == GPIO_DIR_IN) || ((x) == GPIO_DIR_OUT)) + +/* check parameter of the EXTI source port */ +#define IS_AFIO_ESS(x) (IS_AFIO_ESS1(x) || IS_AFIO_ESS2(x) || IS_AFIO_ESS3(x) || IS_AFIO_ESS4(x) || IS_AFIO_ESS5(x)) + +#define IS_AFIO_ESS1(x) ((x == AFIO_ESS_PA) || (x == AFIO_ESS_PB)) +#if (LIBCFG_GPIOC) +#define IS_AFIO_ESS2(x) (x == AFIO_ESS_PC) +#else +#define IS_AFIO_ESS2(x) (0) +#endif +#if (LIBCFG_GPIOD) +#define IS_AFIO_ESS3(x) (x == AFIO_ESS_PD) +#else +#define IS_AFIO_ESS3(x) (0) +#endif +#if (LIBCFG_GPIOE) +#define IS_AFIO_ESS4(x) (x == AFIO_ESS_PE) +#else +#define IS_AFIO_ESS4(x) (0) +#endif +#if (LIBCFG_GPIOF) +#define IS_AFIO_ESS5(x) (x == AFIO_ESS_PF) +#else +#define IS_AFIO_ESS5(x) (0) +#endif + +/* check parameter of the EXTI channel */ +#if (LIBCFG_EXTI_8CH) +#define IS_AFIO_EXTI_CH(x) ((x == AFIO_EXTI_CH_0) || (x == AFIO_EXTI_CH_1) || \ + (x == AFIO_EXTI_CH_2) || (x == AFIO_EXTI_CH_3) || \ + (x == AFIO_EXTI_CH_4) || (x == AFIO_EXTI_CH_5) || \ + (x == AFIO_EXTI_CH_6) || (x == AFIO_EXTI_CH_7)) +#else +#define IS_AFIO_EXTI_CH(x) ((x == AFIO_EXTI_CH_0) || (x == AFIO_EXTI_CH_1) || \ + (x == AFIO_EXTI_CH_2) || (x == AFIO_EXTI_CH_3) || \ + (x == AFIO_EXTI_CH_4) || (x == AFIO_EXTI_CH_5) || \ + (x == AFIO_EXTI_CH_6) || (x == AFIO_EXTI_CH_7) || \ + (x == AFIO_EXTI_CH_8) || (x == AFIO_EXTI_CH_9) || \ + (x == AFIO_EXTI_CH_10) || (x == AFIO_EXTI_CH_11) || \ + (x == AFIO_EXTI_CH_12) || (x == AFIO_EXTI_CH_13) || \ + (x == AFIO_EXTI_CH_14) || (x == AFIO_EXTI_CH_15)) +#endif + +/* check parameter of the AFIO mode */ +#if (LIBCFG_AFIO_MODE_0_7) +#define IS_AFIO_MODE(x) ((x == AFIO_MODE_DEFAULT) || (x == AFIO_MODE_1) || \ + (x == AFIO_MODE_2) || (x == AFIO_MODE_3) || \ + (x == AFIO_MODE_4) || (x == AFIO_MODE_5) || \ + (x == AFIO_MODE_6) || (x == AFIO_MODE_7)) +#else +#define IS_AFIO_MODE(x) ((x == AFIO_MODE_DEFAULT) || (x == AFIO_MODE_1) || \ + (x == AFIO_MODE_2) || (x == AFIO_MODE_3) || \ + (x == AFIO_MODE_4) || (x == AFIO_MODE_5) || \ + (x == AFIO_MODE_6) || (x == AFIO_MODE_7) || \ + (x == AFIO_MODE_8) || (x == AFIO_MODE_9) || \ + (x == AFIO_MODE_10) || (x == AFIO_MODE_11) || \ + (x == AFIO_MODE_12) || (x == AFIO_MODE_13) || \ + (x == AFIO_MODE_14) || (x == AFIO_MODE_15)) +#endif +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Exported_Functions GPIO exported functions + * @{ + */ + +/* Prototype of related GPIO function */ +void GPIO_DeInit(HT_GPIO_TypeDef* HT_GPIOx); +void GPIO_DirectionConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DIR_Enum GPIO_DIR_INorOUT); +void GPIO_PullResistorConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_PR_Enum GPIO_PR_x); +void GPIO_InputConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd); +void GPIO_DriveConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DV_Enum GPIO_DV_nMA); +void GPIO_OpenDrainConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd); +#if LIBCFG_GPIO_SINK_CURRENT_ENHANCED +void GPIO_SinkConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n, ControlStatus Cmd); +#endif +FlagStatus GPIO_ReadInBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n); +FlagStatus GPIO_ReadOutBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n); +u16 GPIO_ReadInData(HT_GPIO_TypeDef* HT_GPIOx); +u16 GPIO_ReadOutData(HT_GPIO_TypeDef* HT_GPIOx); +void GPIO_SetOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP); +void GPIO_ClearOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP); +void GPIO_WriteOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, FlagStatus Status); +void GPIO_WriteOutData(HT_GPIO_TypeDef* HT_GPIOx, u16 Data); +void GPIO_PinLock(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP); +bool GPIO_IsPortLocked(HT_GPIO_TypeDef* HT_GPIOx); +bool GPIO_IsPinLocked(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n); +#if (LIBCFG_GPIO_DISABLE_DEBUG_PORT) +void GPIO_DisableDebugPort(void); +#endif +u32 GPIO_GetID(HT_GPIO_TypeDef* HT_GPIOx); + +/* Prototype of related AFIO function */ +void AFIO_DeInit(void); +void AFIO_GPxConfig(u32 GPIO_Px, u32 AFIO_PIN_n, AFIO_MODE_Enum AFIO_MODE_n); +void AFIO_EXTISourceConfig(u32 GPIO_PIN_NUM_n, u32 GPIO_Px); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2c.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2c.h new file mode 100644 index 0000000000..1f822f93d6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2c.h @@ -0,0 +1,412 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_i2c.h + * @version $Rev:: 7104 $ + * @date $Date:: 2023-08-08 #$ + * @brief The header file of the I2C library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_I2C_H +#define __HT32F5XXXX_I2C_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup I2C + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Types I2C exported types + * @{ + */ + +#if (LIBCFG_I2C_TWO_DEV_ADDR) +typedef u8 I2C_AddressTypeDef; +#else +typedef u16 I2C_AddressTypeDef; +#endif + +typedef struct +{ + u8 I2C_GeneralCall; + u8 I2C_AddressingMode; + u8 I2C_Acknowledge; + u8 I2C_SpeedOffset; /* Offset value to reach real speed, recommended I2C_SpeedOffset = I2C PCLK/8000000 */ + /* which based on 4.7K Pull up */ + u32 I2C_Speed; + u16 I2C_OwnAddress; +} I2C_InitTypeDef; + +#if (LIBCFG_I2C_TWO_DEV_ADDR) +typedef enum +{ + I2C_DEV_ADDR_0 = 0, + I2C_DEV_ADDR_1 +} I2C_ADDR_Enum; + +#define IS_I2C_ADDR(x) ((x == I2C_DEV_ADDR_0) || (x == I2C_DEV_ADDR_1)) +#endif +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Constants I2C exported constants + * @{ + */ +#define I2C_GENERALCALL_ENABLE ((u32)0x00000004) +#define I2C_GENERALCALL_DISABLE ((u32)0x00000000) + +#define IS_I2C_GENERAL_CALL(CALL) ((CALL == I2C_GENERALCALL_ENABLE) || \ + (CALL == I2C_GENERALCALL_DISABLE)) + +#define I2C_ADDRESSING_7BIT ((u32)0x00000000) +#if (LIBCFG_I2C_NO_10BIT_MODE) +#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS) ((ADDRESS == I2C_ADDRESSING_7BIT)) +#else +#define I2C_ADDRESSING_10BIT ((u32)0x00000080) + +#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS) ((ADDRESS == I2C_ADDRESSING_7BIT) || \ + (ADDRESS == I2C_ADDRESSING_10BIT)) +#endif + +#define I2C_ACK_ENABLE ((u32)0x00000001) +#define I2C_ACK_DISABLE ((u32)0x00000000) + +#define IS_I2C_ACKNOWLEDGE(ACKNOWLEDGE) ((ACKNOWLEDGE == I2C_ACK_ENABLE) || \ + (ACKNOWLEDGE == I2C_ACK_DISABLE)) + +#if (LIBCFG_I2C_TWO_DEV_ADDR) +#define I2C_DEV_ADDR0_ENABLE ((u32)0x00008000) +#define I2C_DEV_ADDR0_DISABLE ((u32)0x00000000) + +#define IS_I2C_ADDR0_ENABLE(ADDR) ((ADDR == I2C_ADDR0_ENABLE) || \ + (ADDR == I2C_ADDR0_DISABLE)) + +#define I2C_DEV_ADDR1_ENABLE ((u32)0x80000000) +#define I2C_DEV_ADDR1_DISABLE ((u32)0x00000000) + +#define IS_I2C_ADDR1(ADDR) ((ADDR == I2C_ADDR1_ENABLE) || \ + (ADDR == I2C_ADDR1_DISABLE)) +#endif + +#define I2C_INT_STA ((u32)0x00000001) +#define I2C_INT_STO ((u32)0x00000002) +#define I2C_INT_ADRS ((u32)0x00000004) +#define I2C_INT_GCS ((u32)0x00000008) +#if (LIBCFG_I2C_NO_ARBLOS == 0) +#define I2C_INT_ARBLOS ((u32)0x00000100) +#endif +#define I2C_INT_RXNACK ((u32)0x00000200) +#define I2C_INT_BUSERR ((u32)0x00000400) +#define I2C_INT_TOUT ((u32)0x00000800) +#define I2C_INT_RXDNE ((u32)0x00010000) +#define I2C_INT_TXDE ((u32)0x00020000) +#define I2C_INT_RXBF ((u32)0x00040000) +#if (LIBCFG_I2C_NO_ARBLOS) +#define I2C_INT_ALL ((u32)0x00070E0F) +#else +#define I2C_INT_ALL ((u32)0x00070F0F) +#endif + +#if (LIBCFG_I2C_NO_ARBLOS) +#define IS_I2C_INT(int) (((int & 0xFFF8F1F0) == 0x0) && (int != 0x0)) +#else +#define IS_I2C_INT(int) (((int & 0xFFF8F0F0) == 0x0) && (int != 0x0)) +#endif + +#define I2C_MASTER_READ ((u32)0x00000400) +#define I2C_MASTER_WRITE ((u32)0x00000000) + +#define IS_I2C_DIRECTION(DIRECTION) ((DIRECTION == I2C_MASTER_READ) || \ + (DIRECTION == I2C_MASTER_WRITE)) + + +#define I2C_REGISTER_CR ((u8)0x00) +#define I2C_REGISTER_IER ((u8)0x04) +#define I2C_REGISTER_ADDR ((u8)0x08) +#define I2C_REGISTER_SR ((u8)0x0C) +#define I2C_REGISTER_SHPGR ((u8)0x10) +#define I2C_REGISTER_SLPGR ((u8)0x14) +#define I2C_REGISTER_DR ((u8)0x18) +#define I2C_REGISTER_BFCLR ((u8)0x1C) +#define I2C_REGISTER_TAR ((u8)0x20) + +#define IS_I2C_REGISTER(REGISTER) ((REGISTER == I2C_REGISTER_CR) || \ + (REGISTER == I2C_REGISTER_IER) || \ + (REGISTER == I2C_REGISTER_ADDR) || \ + (REGISTER == I2C_REGISTER_SR) || \ + (REGISTER == I2C_REGISTER_SHPGR) || \ + (REGISTER == I2C_REGISTER_SLPGR) || \ + (REGISTER == I2C_REGISTER_DR) || \ + (REGISTER == I2C_REGISTER_BFCLR) || \ + (REGISTER == I2C_REGISTER_TAR)) + + +#define I2C_FLAG_STA ((u32)0x00000001) +#define I2C_FLAG_STO ((u32)0x00000002) +#define I2C_FLAG_ADRS ((u32)0x00000004) +#define I2C_FLAG_GCS ((u32)0x00000008) +#if (LIBCFG_I2C_NO_ARBLOS) +#define IS_FLAG_ARBLOS(x) (0) +#else +#define I2C_FLAG_ARBLOS ((u32)0x00000100) +#define IS_FLAG_ARBLOS(x) (x == I2C_FLAG_ARBLOS) +#endif +#define I2C_FLAG_RXNACK ((u32)0x00000200) +#define I2C_FLAG_BUSERR ((u32)0x00000400) +#define I2C_FLAG_TOUTF ((u32)0x00000800) +#define I2C_FLAG_RXDNE ((u32)0x00010000) +#define I2C_FLAG_TXDE ((u32)0x00020000) +#define I2C_FLAG_RXBF ((u32)0x00040000) +#define I2C_FLAG_BUSBUSY ((u32)0x00080000) +#define I2C_FLAG_MASTER ((u32)0x00100000) +#define I2C_FLAG_TXNRX ((u32)0x00200000) + +#define IS_I2C_FLAG(FLAG) ((FLAG == I2C_FLAG_STA) || \ + (FLAG == I2C_FLAG_STO) || \ + (FLAG == I2C_FLAG_ADRS) || \ + (FLAG == I2C_FLAG_GCS) || \ + IS_FLAG_ARBLOS(FLAG) || \ + (FLAG == I2C_FLAG_RXNACK) || \ + (FLAG == I2C_FLAG_BUSERR) || \ + (FLAG == I2C_FLAG_TOUTF) || \ + (FLAG == I2C_FLAG_RXDNE) || \ + (FLAG == I2C_FLAG_TXDE) || \ + (FLAG == I2C_FLAG_RXBF) || \ + (FLAG == I2C_FLAG_BUSBUSY)|| \ + (FLAG == I2C_FLAG_MASTER) || \ + (FLAG == I2C_FLAG_TXNRX)) + +#define IS_I2C_CLEAR_FLAG(FLAG) (IS_FLAG_ARBLOS(FLAG) || \ + (FLAG == I2C_FLAG_RXNACK) || \ + (FLAG == I2C_FLAG_BUSERR) || \ + (FLAG == I2C_FLAG_TOUTF)) + +#define I2C_MASTER_SEND_START ((u32)0x00180001) +#define I2C_MASTER_RECEIVER_MODE ((u32)0x00180004) +#define I2C_MASTER_TRANSMITTER_MODE ((u32)0x003A0004) +#define I2C_MASTER_RX_NOT_EMPTY ((u32)0x00190000) +#define I2C_MASTER_RX_NOT_EMPTY_NOBUSY ((u32)0x00010000) +#define I2C_MASTER_TX_EMPTY ((u32)0x003A0000) +#define I2C_MASTER_RX_BUFFER_FULL ((u32)0x001D0000) +#define I2C_SLAVE_ACK_TRANSMITTER_ADDRESS ((u32)0x002A0004) +#define I2C_SLAVE_ACK_RECEIVER_ADDRESS ((u32)0x00080004) +#define I2C_SLAVE_ACK_GCALL_ADDRESS ((u32)0x00080008) +#define I2C_SLAVE_RX_NOT_EMPTY ((u32)0x00090000) +#define I2C_SLAVE_RX_NOT_EMPTY_STOP ((u32)0x00010002) +#define I2C_SLAVE_TX_EMPTY ((u32)0x002A0000) +#define I2C_SLAVE_RX_BUFFER_FULL ((u32)0x000D0000) +#define I2C_SLAVE_RECEIVED_NACK ((u32)0x00080200) +#define I2C_SLAVE_RECEIVED_NACK_STOP ((u32)0x00000202) +#define I2C_SLAVE_STOP_DETECTED ((u32)0x00000002) + + +#define IS_I2C_STATUS(STATUS) ((STATUS == I2C_MASTER_SEND_START) || \ + (STATUS == I2C_MASTER_RECEIVER_MODE) || \ + (STATUS == I2C_MASTER_TRANSMITTER_MODE) || \ + (STATUS == I2C_MASTER_RX_NOT_EMPTY) || \ + (STATUS == I2C_MASTER_RX_NOT_EMPTY_NOBUSY) || \ + (STATUS == I2C_MASTER_TX_EMPTY) || \ + (STATUS == I2C_MASTER_RX_BUFFER_FULL) || \ + (STATUS == I2C_SLAVE_ACK_TRANSMITTER_ADDRESS) || \ + (STATUS == I2C_SLAVE_ACK_RECEIVER_ADDRESS) || \ + (STATUS == I2C_SLAVE_ACK_GCALL_ADDRESS) || \ + (STATUS == I2C_SLAVE_RX_NOT_EMPTY) || \ + (STATUS == I2C_SLAVE_RX_NOT_EMPTY_STOP) || \ + (STATUS == I2C_SLAVE_TX_EMPTY) || \ + (STATUS == I2C_SLAVE_RX_BUFFER_FULL) || \ + (STATUS == I2C_SLAVE_RECEIVED_NACK) || \ + (STATUS == I2C_SLAVE_RECEIVED_NACK_STOP) || \ + (STATUS == I2C_SLAVE_STOP_DETECTED)) + +#if (LIBCFG_PDMA) +#define I2C_PDMAREQ_TX ((u32)0x00000100) +#define I2C_PDMAREQ_RX ((u32)0x00000200) + +#define IS_I2C_PDMA_REQ(REQ) (((REQ & 0xFFFFFCFF) == 0x0) && (REQ != 0x0)) +#endif + +#define I2C_PRESCALER_1 ((u32)0x00000000) +#define I2C_PRESCALER_2 ((u32)0x00010000) +#define I2C_PRESCALER_4 ((u32)0x00020000) +#define I2C_PRESCALER_8 ((u32)0x00030000) +#if (LIBCFG_I2C_PRESCALER_2BIT == 0) +#define I2C_PRESCALER_16 ((u32)0x00040000) +#define I2C_PRESCALER_32 ((u32)0x00050000) +#define I2C_PRESCALER_64 ((u32)0x00060000) +#define I2C_PRESCALER_128 ((u32)0x00070000) +#endif + +#if (LIBCFG_I2C_PRESCALER_2BIT) +#define IS_I2C_PRESCALER(PRESCALER) ((PRESCALER == I2C_PRESCALER_1) || \ + (PRESCALER == I2C_PRESCALER_2) || \ + (PRESCALER == I2C_PRESCALER_4) || \ + (PRESCALER == I2C_PRESCALER_8)) +#else +#define IS_I2C_PRESCALER(PRESCALER) ((PRESCALER == I2C_PRESCALER_1) || \ + (PRESCALER == I2C_PRESCALER_2) || \ + (PRESCALER == I2C_PRESCALER_4) || \ + (PRESCALER == I2C_PRESCALER_8) || \ + (PRESCALER == I2C_PRESCALER_16) || \ + (PRESCALER == I2C_PRESCALER_32) || \ + (PRESCALER == I2C_PRESCALER_64) || \ + (PRESCALER == I2C_PRESCALER_128)) +#endif + +#if (LIBCFG_I2C_NO_ADDR_MASK == 0) +#define I2C_MASKBIT_0 ((u32)0x00000001) +#define I2C_MASKBIT_1 ((u32)0x00000002) +#define I2C_MASKBIT_2 ((u32)0x00000004) +#define I2C_MASKBIT_3 ((u32)0x00000008) +#define I2C_MASKBIT_4 ((u32)0x00000010) +#define I2C_MASKBIT_5 ((u32)0x00000020) +#define I2C_MASKBIT_6 ((u32)0x00000040) +#define I2C_MASKBIT_7 ((u32)0x00000080) +#define I2C_MASKBIT_8 ((u32)0x00000100) +#define I2C_MASKBIT_9 ((u32)0x00000200) + + +#define IS_I2C_ADDRESS_MASK(MASK) ((MASK == I2C_MASKBIT_0) || \ + (MASK == I2C_MASKBIT_1) || \ + (MASK == I2C_MASKBIT_2) || \ + (MASK == I2C_MASKBIT_3) || \ + (MASK == I2C_MASKBIT_4) || \ + (MASK == I2C_MASKBIT_5) || \ + (MASK == I2C_MASKBIT_6) || \ + (MASK == I2C_MASKBIT_7) || \ + (MASK == I2C_MASKBIT_8) || \ + (MASK == I2C_MASKBIT_9)) +#endif + +#define IS_I2C(x) (IS_I2C0(x) || IS_I2C1(x) || IS_I2C2(x)) +#define IS_I2C0(x) (x == HT_I2C0) + +#if (LIBCFG_I2C1) +#define IS_I2C1(x) (x == HT_I2C1) +#else +#define IS_I2C1(x) (0) +#endif + +#if (LIBCFG_I2C2) +#define IS_I2C2(x) (x == HT_I2C2) +#else +#define IS_I2C2(x) (0) +#endif + +#if (LIBCFG_I2C_NO_10BIT_MODE) +#define IS_I2C_ADDRESS(ADDRESS) (ADDRESS <= 0x7F) +#else +#define IS_I2C_ADDRESS(ADDRESS) (ADDRESS <= 0x3FF) +#endif + +#define IS_I2C_SPEED(SPEED) ((SPEED >= 1) && (SPEED <= 1000000)) + +#define IS_I2C_SCL_HIGH(HIGH) (HIGH <= 0xFFFF) + +#define IS_I2C_SCL_LOW(LOW) (LOW <= 0xFFFF) + +#if (LIBCFG_I2C_TOUT_COUNT_8BIT) +#define IS_I2C_TIMEOUT(TIMEOUT) (TIMEOUT <= 0xFF) +#else +#define IS_I2C_TIMEOUT(TIMEOUT) (TIMEOUT <= 0xFFFF) +#endif + +#define SEQ_FILTER_DISABLE ((u32)0x00000000) +#define SEQ_FILTER_1_PCLK ((u32)0x00004000) +#define SEQ_FILTER_2_PCLK ((u32)0x00008000) + +#define IS_I2C_SEQ_FILTER_MASK(CONFIG) ((CONFIG == SEQ_FILTER_DISABLE) || \ + (CONFIG == SEQ_FILTER_1_PCLK) || \ + (CONFIG == SEQ_FILTER_2_PCLK)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Functions I2C exported functions + * @{ + */ +void I2C_DeInit(HT_I2C_TypeDef* I2Cx); +void I2C_Init(HT_I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStructure); +void I2C_StructInit(I2C_InitTypeDef* I2C_InitStructure); +void I2C_Cmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_GenerateSTOP(HT_I2C_TypeDef* I2Cx); +void I2C_IntConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Int, ControlStatus NewState); +void I2C_GeneralCallCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_AckCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_SetOwnAddress(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address); +#if (LIBCFG_I2C_TWO_DEV_ADDR) +void I2C_SetOwnAddress1(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address); +void I2C_OwnAddressCmd(HT_I2C_TypeDef* I2Cx, I2C_ADDR_Enum Address, ControlStatus NewState); +#endif +void I2C_TargetAddressConfig(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address, u32 I2C_Direction); +void I2C_SendData(HT_I2C_TypeDef* I2Cx, u8 I2C_Data); +u8 I2C_ReceiveData(HT_I2C_TypeDef* I2Cx); +u32 I2C_ReadRegister(HT_I2C_TypeDef* I2Cx, u8 I2C_Register); +FlagStatus I2C_GetFlagStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag); +ErrStatus I2C_CheckStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Status); +void I2C_ClearFlag(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag); +void I2C_SetSCLHighPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_HighPeriod); +void I2C_SetSCLLowPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_LowPeriod); +#if (LIBCFG_PDMA) +void I2C_PDMACmd(HT_I2C_TypeDef* I2Cx, u32 I2C_PDMAREQ, ControlStatus NewState); +void I2C_PDMANACKCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +#endif +void I2C_TimeOutCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_SetTimeOutValue(HT_I2C_TypeDef* I2Cx, u32 I2C_Timeout); +void I2C_SetTimeOutPrescaler(HT_I2C_TypeDef* I2Cx, u32 I2C_Prescaler); +#if (LIBCFG_I2C_NO_ADDR_MASK == 0) +void I2C_AddressMaskConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Mask); +#endif +u16 I2C_GetAddressBuffer(HT_I2C_TypeDef* I2Cx); +void I2C_CombFilterCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState); +void I2C_SequentialFilterConfig(HT_I2C_TypeDef* I2Cx, u32 Seq_Filter_Select); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2s.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2s.h new file mode 100644 index 0000000000..2d4646c4d1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_i2s.h @@ -0,0 +1,240 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_i2s.h + * @version $Rev:: 2960 $ + * @date $Date:: 2018-08-02 #$ + * @brief The header file of the I2S library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_I2S_H +#define __HT32F5XXXX_I2S_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup I2S + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Types I2S exported types + * @{ + */ +typedef struct +{ + u32 I2S_Mode; + u32 I2S_Format; + u32 I2S_WordWidth; + u32 I2S_MclkOut; + u32 I2S_MclkInv; + u32 I2S_BclkInv; + u32 I2S_X_Div; + u32 I2S_Y_Div; + u32 I2S_N_Div; +} I2S_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Constants I2S exported constants + * @{ + */ +/* mode */ +#define I2S_MASTER_TX (1UL << 1) +#define I2S_MASTER_RX (1UL << 2) +#define I2S_MASTER_TX_RX ((1UL << 1) | (1UL << 2)) + +#define I2S_SLAVE_TX ((1UL << 3) | (1UL << 1)) +#define I2S_SLAVE_RX ((1UL << 3) | (1UL << 2)) +#define I2S_SLAVE_TX_RX ((1UL << 3) | (1UL << 1) | (1UL << 2)) + +#define IS_I2S_MODE(MOD) ((MOD == I2S_MASTER_TX) || \ + (MOD == I2S_MASTER_RX) || \ + (MOD == I2S_MASTER_TX_RX) || \ + (MOD == I2S_SLAVE_TX) || \ + (MOD == I2S_SLAVE_RX) || \ + (MOD == I2S_SLAVE_TX_RX)) + + +/* format */ +#define I2S_JUSTIFIED_STEREO (0) +#define LEFT_JUSTIFIED_STEREO (1UL << 6) +#define RIGHT_JUSTIFIED_STEREO (2UL << 6) +#define I2S_JUSTIFIED_REPEAT (1UL << 10) + +#define I2S_JUSTIFIED_STEREO_EXT (1UL << 8) +#define LEFT_JUSTIFIED_STEREO_EXT ((1UL << 8) | (1UL << 6)) +#define RIGHT_JUSTIFIED_STEREO_EXT ((1UL << 8) | (2UL << 6)) +#define I2S_JUSTIFIED_REPEAT_EXT ((1UL << 8) | (1UL << 10)) + +#define I2S_JUSTIFIED_MONO (1UL << 11) +#define LEFT_JUSTIFIED_MONO ((1UL << 11) | (1UL << 6)) +#define RIGHT_JUSTIFIED_MONO ((1UL << 11) | (2UL << 6)) + +#define I2S_JUSTIFIED_MONO_EXT ((1UL << 8) | (1UL << 11)) +#define LEFT_JUSTIFIED_MONO_EXT ((1UL << 8) | (1UL << 11) | (1UL << 6)) +#define RIGHT_JUSTIFIED_MONO_EXT ((1UL << 8) | (1UL << 11) | (2UL << 6)) + +#define IS_I2S_FORMAT(FMT) ((FMT == I2S_JUSTIFIED_STEREO) || \ + (FMT == LEFT_JUSTIFIED_STEREO) || \ + (FMT == RIGHT_JUSTIFIED_STEREO) || \ + (FMT == I2S_JUSTIFIED_REPEAT) || \ + (FMT == I2S_JUSTIFIED_STEREO_EXT) || \ + (FMT == LEFT_JUSTIFIED_STEREO_EXT) || \ + (FMT == RIGHT_JUSTIFIED_STEREO_EXT) || \ + (FMT == I2S_JUSTIFIED_REPEAT_EXT) || \ + (FMT == I2S_JUSTIFIED_MONO) || \ + (FMT == LEFT_JUSTIFIED_MONO) || \ + (FMT == RIGHT_JUSTIFIED_MONO) || \ + (FMT == I2S_JUSTIFIED_MONO_EXT) || \ + (FMT == LEFT_JUSTIFIED_MONO_EXT) || \ + (FMT == RIGHT_JUSTIFIED_MONO_EXT)) + + +/* word width */ +#define I2S_WORDWIDTH_8 (0) +#define I2S_WORDWIDTH_16 (1UL << 4) +#define I2S_WORDWIDTH_24 (2UL << 4) +#define I2S_WORDWIDTH_32 (3UL << 4) + +#define IS_I2S_WORD_WIDTH(WIDTH) ((WIDTH == I2S_WORDWIDTH_8) || \ + (WIDTH == I2S_WORDWIDTH_16) || \ + (WIDTH == I2S_WORDWIDTH_24) || \ + (WIDTH == I2S_WORDWIDTH_32)) + + +/* clock divider */ +#define IS_I2S_MCLK_DIV(X, Y) ((X > 0) && (X < 256) && (Y > 0) && (Y < 256) && (X <= Y)) + +#define IS_I2S_BCLK_DIV(N) (N < 256) + + +/* FIFO */ +#define I2S_TX_FIFO (1UL << 8) +#define I2S_RX_FIFO (2UL << 8) + +#define IS_I2S_ONE_FIFO(FIFO) ((FIFO == I2S_TX_FIFO) || (FIFO == I2S_RX_FIFO)) + +#define IS_I2S_TWO_FIFO(FIFO) (((FIFO & 0xFFFFFCFF) == 0) && (FIFO != 0)) + +#define IS_I2S_FIFO_LEVEL(LEVEL) ((LEVEL & 0x0000000F) < 9) + + +/* interrupt */ +#define I2S_INT_TXFIFO_TRI (1UL) +#define I2S_INT_TXFIFO_UDF (1UL << 1) +#define I2S_INT_TXFIFO_OVF (1UL << 2) + +#define I2S_INT_RXFIFO_TRI (1UL << 4) +#define I2S_INT_RXFIFO_UDF (1UL << 5) +#define I2S_INT_RXFIFO_OVF (1UL << 6) + +#define IS_I2S_INT(INT) (((INT & 0xFFFFFF88) == 0) && (INT != 0)) + + +/* flag */ +#define I2S_FLAG_TXFIFO_TRI (1UL) +#define I2S_FLAG_TXFIFO_UDF (1UL << 1) +#define I2S_FLAG_TXFIFO_OVF (1UL << 2) +#define I2S_FLAG_RXFIFO_TRI (1UL << 8) +#define I2S_FLAG_RXFIFO_UDF (1UL << 9) +#define I2S_FLAG_RXFIFO_OVF (1UL << 10) + +#define I2S_FLAG_TXFIFO_EMP (1UL << 3) +#define I2S_FLAG_TXFIFO_FUL (1UL << 4) +#define I2S_FLAG_RXFIFO_EMP (1UL << 11) +#define I2S_FLAG_RXFIFO_FUL (1UL << 12) +#define I2S_FLAG_RIGHT_CH (1UL << 16) +#define I2S_FLAG_TX_BUSY (1UL << 17) +#define I2S_FLAG_CLK_RDY (1UL << 18) + +#define IS_I2S_FLAG_CLEAR(FLAG) (((FLAG & 0xFFFFF8F8) == 0) && (FLAG != 0)) + +#define IS_I2S_FLAG(FLAG) ((FLAG == I2S_FLAG_TXFIFO_TRI) || \ + (FLAG == I2S_FLAG_TXFIFO_UDF) || \ + (FLAG == I2S_FLAG_TXFIFO_OVF) || \ + (FLAG == I2S_FLAG_TXFIFO_EMP) || \ + (FLAG == I2S_FLAG_TXFIFO_FUL) || \ + (FLAG == I2S_FLAG_RXFIFO_TRI) || \ + (FLAG == I2S_FLAG_RXFIFO_UDF) || \ + (FLAG == I2S_FLAG_RXFIFO_OVF) || \ + (FLAG == I2S_FLAG_RXFIFO_EMP) || \ + (FLAG == I2S_FLAG_RXFIFO_FUL) || \ + (FLAG == I2S_FLAG_RIGHT_CH) || \ + (FLAG == I2S_FLAG_TX_BUSY) || \ + (FLAG == I2S_FLAG_CLK_RDY)) + + +/* PDMA request */ +#define I2S_PDMAREQ_TX (1UL << 13) +#define I2S_PDMAREQ_RX (1UL << 14) + +#define IS_I2S_PDMA_REQ(REQ) (((REQ & 0xFFFF9FFF) == 0) && (REQ != 0)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Functions I2S exported functions + * @{ + */ +void I2S_DeInit(void); +void I2S_Init(I2S_InitTypeDef* I2S_InitStruct); +void I2S_Cmd(ControlStatus NewState); +void I2S_MclkOutputCmd(ControlStatus NewState); +void I2S_TxMuteCmd(ControlStatus NewState); +void I2S_PDMACmd(u32 I2S_PDMAREQ, ControlStatus NewState); +void I2S_FIFOReset(u32 I2S_FIFO); +void I2S_FIFOTrigLevelConfig(u32 I2S_FIFO, u32 I2S_FIFOLevel); +u8 I2S_GetFIFOStatus(u32 I2S_FIFO); +void I2S_IntConfig(u32 I2S_Int, ControlStatus NewState); +FlagStatus I2S_GetFlagStatus(u32 I2S_Flag); +void I2S_ClearFlag(u32 I2S_Flag); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lcd.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lcd.h new file mode 100644 index 0000000000..61070c721e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lcd.h @@ -0,0 +1,382 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_lcd.h + * @version V1.00 + * @date 11/15/2017 + * @brief The header file of the LCD library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_LCD_H +#define __HT32F5XXXX_LCD_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup LCD + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup LCD_Exported_Types LCD exported types + * @{ + */ +/** + * @brief Enumeration of LCD mask time. + */ +typedef enum { + LCD_MaskTime_25ns = (0x00 << 24), /*!< MCONT mask time = 25 ns */ + LCD_MaskTime_40ns = (0x01 << 24), /*!< MCONT mask time = 40 ns */ +} LCD_MaskTime_Enum; + +/** + * @brief Enumeration of LCD STATIC switch. + */ +typedef enum { + LCD_StaticSwitch_Close = (0x00 << 14), /*!< STATIC switch is closed during dead time */ + LCD_StaticSwitch_Open = (0x01 << 14), /*!< STATIC switch is open during dead time */ +} LCD_StaticSwitch_Enum; + +/** + * @brief Enumeration of LCD MUXCOM7. + */ +typedef enum +{ + /*!< 57341: SEG28/COM7 */ + /*!< 57352: SEG36/COM7 */ + LCD_MUXCOM7_IS_COM7 = (0x00 << 11), + LCD_MUXCOM7_IS_SEGx = (0x01 << 11), +} LCD_MUXCOM7_Enum; + +/** + * @brief Enumeration of LCD MUXCOM6. + */ +typedef enum +{ + /*!< 57341: SEG27/COM6 */ + /*!< 57352: SEG35/COM6 */ + LCD_MUXCOM6_IS_COM6 = (0x00 << 10), + LCD_MUXCOM6_IS_SEGx = (0x01 << 10), +} LCD_MUXCOM6_Enum; + +/** + * @brief Enumeration of LCD MUXCOM5. + */ +typedef enum +{ + /*!< 57341: SEG26/COM5 */ + /*!< 57352: SEG34/COM5 */ + LCD_MUXCOM5_IS_COM5 = (0x00 << 9), + LCD_MUXCOM5_IS_SEGx = (0x01 << 9), +} LCD_MUXCOM5_Enum; + +/** + * @brief Enumeration of LCD MUXCOM4. + */ +typedef enum +{ + /*!< 57341: SEG25/COM4 */ + /*!< 57352: SEG33/COM4 */ + LCD_MUXCOM4_IS_COM4 = (0x00 << 8), + LCD_MUXCOM4_IS_SEGx = (0x01 << 8), +} LCD_MUXCOM4_Enum; + +/** + * @brief Enumeration of LCD waveform. + */ +typedef enum +{ + LCD_Type_A_Waveform = (0x00 << 7), /*!< Type A waveform */ + LCD_Type_B_Waveform = (0x01 << 7), /*!< Type B waveform */ +} LCD_Waveform_Enum; + +/** + * @brief Enumeration of LCD bias. + */ +typedef enum { + LCD_Bias_1_4 = (0x00 << 5), /*!< 1/4 bias */ + LCD_Bias_1_2 = (0x01 << 5), /*!< 1/2 bias */ + LCD_Bias_1_3 = (0x02 << 5), /*!< 1/3 bias */ + LCD_Bias_Static = (0x03 << 5), /*!< Static bias */ +} LCD_Bias_Enum; + +/** + * @brief Enumeration of LCD duty. + */ +typedef enum { + LCD_Duty_Static = (0x00 << 2), /*!< Static duty */ + LCD_Duty_1_2 = (0x01 << 2), /*!< 1/2 duty */ + LCD_Duty_1_3 = (0x02 << 2), /*!< 1/3 duty */ + LCD_Duty_1_4 = (0x03 << 2), /*!< 1/4 duty */ + LCD_Duty_1_6 = (0x04 << 2), /*!< 1/6 duty */ + LCD_Duty_1_8 = (0x05 << 2), /*!< 1/8 duty */ +} LCD_Duty_Enum; + +/** + * @brief Enumeration of LCD voltage source. + */ +typedef enum { + LCD_VoltageSource_External = (0x00 << 1), /*!< External voltage source */ + LCD_VoltageSource_Internal = (0x01 << 1), /*!< Internal voltage source */ +} LCD_VoltageSource_Enum; + +/** + * @brief Enumeration of LCD clock prescaler. + */ +typedef enum { + LCD_Prescaler_1 = (0x00 << 22), /*!< CK_PS = CK_LCD / 1 */ + LCD_Prescaler_2 = (0x01 << 22), /*!< CK_PS = CK_LCD / 2 */ + LCD_Prescaler_4 = (0x02 << 22), /*!< CK_PS = CK_LCD / 4 */ + LCD_Prescaler_8 = (0x03 << 22), /*!< CK_PS = CK_LCD / 8 */ + LCD_Prescaler_16 = (0x04 << 22), /*!< CK_PS = CK_LCD / 16 */ + LCD_Prescaler_32 = (0x05 << 22), /*!< CK_PS = CK_LCD / 32 */ + LCD_Prescaler_64 = (0x06 << 22), /*!< CK_PS = CK_LCD / 64 */ + LCD_Prescaler_128 = (0x07 << 22), /*!< CK_PS = CK_LCD / 128 */ + LCD_Prescaler_256 = (0x08 << 22), /*!< CK_PS = CK_LCD / 256 */ + LCD_Prescaler_512 = (0x09 << 22), /*!< CK_PS = CK_LCD / 512 */ + LCD_Prescaler_1024 = (0x0A << 22), /*!< CK_PS = CK_LCD / 1024 */ + LCD_Prescaler_2048 = (0x0B << 22), /*!< CK_PS = CK_LCD / 2048 */ + LCD_Prescaler_4096 = (0x0C << 22), /*!< CK_PS = CK_LCD / 4096 */ + LCD_Prescaler_8192 = (0x0D << 22), /*!< CK_PS = CK_LCD / 8192 */ + LCD_Prescaler_16384 = (0x0E << 22), /*!< CK_PS = CK_LCD / 16384 */ + LCD_Prescaler_32768 = (0x0F << 22) /*!< CK_PS = CK_LCD / 32768 */ +} LCD_Prescaler_Enum; + +/** + * @brief Enumeration of LCD clock divider. + */ +typedef enum { + LCD_Divider_16 = (0x00 << 18), /*!< CK_DIV = CK_PS / 16 */ + LCD_Divider_17 = (0x01 << 18), /*!< CK_DIV = CK_PS / 17 */ + LCD_Divider_18 = (0x02 << 18), /*!< CK_DIV = CK_PS / 18 */ + LCD_Divider_19 = (0x03 << 18), /*!< CK_DIV = CK_PS / 19 */ + LCD_Divider_20 = (0x04 << 18), /*!< CK_DIV = CK_PS / 20 */ + LCD_Divider_21 = (0x05 << 18), /*!< CK_DIV = CK_PS / 21 */ + LCD_Divider_22 = (0x06 << 18), /*!< CK_DIV = CK_PS / 22 */ + LCD_Divider_23 = (0x07 << 18), /*!< CK_DIV = CK_PS / 23 */ + LCD_Divider_24 = (0x08 << 18), /*!< CK_DIV = CK_PS / 24 */ + LCD_Divider_25 = (0x09 << 18), /*!< CK_DIV = CK_PS / 25 */ + LCD_Divider_26 = (0x0A << 18), /*!< CK_DIV = CK_PS / 26 */ + LCD_Divider_27 = (0x0B << 18), /*!< CK_DIV = CK_PS / 27 */ + LCD_Divider_28 = (0x0C << 18), /*!< CK_DIV = CK_PS / 28 */ + LCD_Divider_29 = (0x0D << 18), /*!< CK_DIV = CK_PS / 29 */ + LCD_Divider_30 = (0x0E << 18), /*!< CK_DIV = CK_PS / 30 */ + LCD_Divider_31 = (0x0F << 18), /*!< CK_DIV = CK_PS / 31 */ +} LCD_Divider_Enum; + +/** + * @brief Enumeration of LCD blink mode. + */ +typedef enum { + LCD_BlinkMode_Off = (0x00 << 16), /*!< Blink inactive */ + LCD_BlinkMode_SEG0_COM0 = (0x01 << 16), /*!< SEG0 on COM0 blink */ + LCD_BlinkMode_SEG0_AllCOM = (0x02 << 16), /*!< SEG0 on All COM blink */ + LCD_BlinkMode_AllSEG_AllCOM = (0x03 << 16), /*!< All SEG on All COM blink */ +} LCD_BlinkMode_Enum; + +/** + * @brief Enumeration of LCD blink frequency. + */ +typedef enum +{ + LCD_BlinkFrequency_Div8 = (0x00 << 13), /*!< Blink frequency = frame rate / 8 */ + LCD_BlinkFrequency_Div16 = (0x01 << 13), /*!< Blink frequency = frame rate / 16 */ + LCD_BlinkFrequency_Div32 = (0x02 << 13), /*!< Blink frequency = frame rate / 32 */ + LCD_BlinkFrequency_Div64 = (0x03 << 13), /*!< Blink frequency = frame rate / 64 */ + LCD_BlinkFrequency_Div128 = (0x04 << 13), /*!< Blink frequency = frame rate / 128 */ + LCD_BlinkFrequency_Div256 = (0x05 << 13), /*!< Blink frequency = frame rate / 256 */ + LCD_BlinkFrequency_Div512 = (0x06 << 13), /*!< Blink frequency = frame rate / 512 */ + LCD_BlinkFrequency_Div1024 = (0x07 << 13), /*!< Blink frequency = frame rate / 1024 */ +} LCD_BlinkFrequency_Enum; + +/** + * @brief Enumeration of LCD charge pump. + */ +typedef enum +{ + LCD_ChargePump_2V65 = (0x00 << 10), /*!< Charge pump voltage = 2.65 V */ + LCD_ChargePump_2V75 = (0x01 << 10), /*!< Charge pump voltage = 2.75 V */ + LCD_ChargePump_2V85 = (0x02 << 10), /*!< Charge pump voltage = 2.85 V */ + LCD_ChargePump_2V95 = (0x03 << 10), /*!< Charge pump voltage = 2.95 V */ + LCD_ChargePump_3V10 = (0x04 << 10), /*!< Charge pump voltage = 3.10 V */ + LCD_ChargePump_3V25 = (0x05 << 10), /*!< Charge pump voltage = 3.25 V */ + LCD_ChargePump_3V40 = (0x06 << 10), /*!< Charge pump voltage = 3.40 V */ + LCD_ChargePump_3V55 = (0x07 << 10), /*!< Charge pump voltage = 3.55 V */ +} LCD_ChargePump_Enum; + +/** + * @brief Enumeration of LCD dead time. + */ +typedef enum +{ + LCD_Deadtime_0 = (0x00 << 7), /*!< No dead time */ + LCD_Deadtime_1 = (0x01 << 7), /*!< Type A: 1/2 phase period; Type B: 1 phase period */ + LCD_Deadtime_2 = (0x02 << 7), /*!< Type A: 2/2 phase period; Type B: 2 phase period */ + LCD_Deadtime_3 = (0x03 << 7), /*!< Type A: 3/2 phase period; Type B: 3 phase period */ + LCD_Deadtime_4 = (0x04 << 7), /*!< Type A: 4/2 phase period; Type B: 4 phase period */ + LCD_Deadtime_5 = (0x05 << 7), /*!< Type A: 5/2 phase period; Type B: 5 phase period */ + LCD_Deadtime_6 = (0x06 << 7), /*!< Type A: 6/2 phase period; Type B: 6 phase period */ + LCD_Deadtime_7 = (0x07 << 7), /*!< Type A: 7/2 phase period; Type B: 7 phase period */ +} LCD_DeadTime_Enum; + +/** + * @brief Enumeration of LCD high drive. + */ +typedef enum +{ + LCD_HighDrive_0 = (0x00 << 4), /*!< No high drive */ + LCD_HighDrive_1 = (0x01 << 4), /*!< High drive duration = 1 CK_PS pulses */ + LCD_HighDrive_2 = (0x02 << 4), /*!< High drive duration = 2 CK_PS pulses */ + LCD_HighDrive_3 = (0x03 << 4), /*!< High drive duration = 3 CK_PS pulses */ + LCD_HighDrive_4 = (0x04 << 4), /*!< High drive duration = 4 CK_PS pulses */ + LCD_HighDrive_5 = (0x05 << 4), /*!< High drive duration = 5 CK_PS pulses */ + LCD_HighDrive_6 = (0x06 << 4), /*!< High drive duration = 6 CK_PS pulses */ + LCD_HighDrive_7 = (0x07 << 4), /*!< High drive duration = 7 CK_PS pulses */ + LCD_HighDrive_Static = (0xff), /*!< Static high drive */ +} LCD_HighDrive_Enum; + +/** + * @brief Definition of LCD Init Structure. + */ +typedef struct +{ + LCD_Prescaler_Enum LCD_Prescaler; + LCD_Divider_Enum LCD_Divider; + LCD_Duty_Enum LCD_Duty; + LCD_Bias_Enum LCD_Bias; + LCD_Waveform_Enum LCD_Waveform; + LCD_VoltageSource_Enum LCD_VoltageSource; +} LCD_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup LCD_Exported_Constants LCD exported constants + * @{ + */ +#define LCD_INT_UDD ((u32)0x00000002) +#define LCD_INT_SOF ((u32)0x00000001) + +#define IS_LCD_INT(INT) ((((INT) & 0xFFFFFFFC) == 0) && ((INT) != 0)) + + +#define LCD_FLAG_FCRSF ((u32)0x00000020) +#define LCD_FLAG_RDY ((u32)0x00000010) +#define LCD_FLAG_UDD ((u32)0x00000008) +#define LCD_FLAG_UDR ((u32)0x00000004) +#define LCD_FLAG_SOF ((u32)0x00000002) +#define LCD_FLAG_ENS ((u32)0x00000001) + +#define IS_LCD_FLAG(FLAG) (((FLAG) == LCD_FLAG_FCRSF) || \ + ((FLAG) == LCD_FLAG_RDY) || \ + ((FLAG) == LCD_FLAG_UDD) || \ + ((FLAG) == LCD_FLAG_UDR) || \ + ((FLAG) == LCD_FLAG_SOF) || \ + ((FLAG) == LCD_FLAG_ENS)) + + +#define LCD_CLR_UDD ((u32)0x00000002) +#define LCD_CLR_SOF ((u32)0x00000001) + +#define IS_LCD_CLEAR(CLR) ((((CLR) & 0xFFFFFFFC) == 0) && ((CLR) != 0)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup LCD_Exported_Functions LCD exported functions + * @{ + */ + +/* !!! NOTICE !!! + Before using the following functions, be sure to confirm LCDENS = 0 by "LCD_GetFlagStatus(LCD_FLAG_ENS);", + otherwise the LCD may display abnormally. + LCD_DriverInit() + LCD_MaskTimeConfig() + LCD_StaticSwitchConfig() + LCD_MuxCOM7Config() + LCD_MuxCOM6Config() + LCD_MuxCOM5Config() + LCD_MuxCOM4Config() + LCD_WaveformConfig() + LCD_BiasConfig() + LCD_DutyConfig() + LCD_VoltageSourceConfig() + LCD_ChargePumpConfig() +*/ + +void LCD_DriverDeInit(void); +void LCD_DriverInit(LCD_InitTypeDef* LCD_InitStruct); + +void LCD_MaskTimeConfig(LCD_MaskTime_Enum Sel); +void LCD_HalfRLCmd(ControlStatus NewState); +void LCD_StaticSwitchConfig(LCD_StaticSwitch_Enum Sel); +void LCD_MuxCOM7Config(LCD_MUXCOM7_Enum Sel); +void LCD_MuxCOM6Config(LCD_MUXCOM6_Enum Sel); +void LCD_MuxCOM5Config(LCD_MUXCOM5_Enum Sel); +void LCD_MuxCOM4Config(LCD_MUXCOM4_Enum Sel); +void LCD_WaveformConfig(LCD_Waveform_Enum Sel); +void LCD_BiasConfig(LCD_Bias_Enum Sel); +void LCD_DutyConfig(LCD_Duty_Enum Sel); +void LCD_VoltageSourceConfig(LCD_VoltageSource_Enum Sel); +void LCD_Cmd(ControlStatus NewState); + +void LCD_PrescalerConfig(LCD_Prescaler_Enum Sel); +void LCD_DividerConfig(LCD_Divider_Enum Sel); +void LCD_BlinkModeConfig(LCD_BlinkMode_Enum Sel); +void LCD_BlinkFreqConfig(LCD_BlinkFrequency_Enum Sel); +void LCD_ChargePumpConfig(LCD_ChargePump_Enum Sel); +void LCD_DeadTimeConfig(LCD_DeadTime_Enum Sel); +void LCD_HighDriveConfig(LCD_HighDrive_Enum Sel); + +void LCD_IntConfig(u32 LCD_Int, ControlStatus NewState); +FlagStatus LCD_GetFlagStatus(u32 LCD_Flag); +void LCD_SetUpdateDisplayRequest(void); +void LCD_ClearFlag(u32 LCD_Flag); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ledc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ledc.h new file mode 100644 index 0000000000..c12c2a0b04 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_ledc.h @@ -0,0 +1,209 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_ledc.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The header file of the LED Controller library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_LEDC_H +#define __HT32F5XXXX_LEDC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup LEDC + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup LEDC_Exported_Types LEDC exported types + * @{ + */ + +/** + * @brief Selection of LEDC clock source + */ +typedef enum +{ + LEDC_SRC_PCLK = 0, + LEDC_SRC_LSI, /*!< Low speed internal clock, about 32KHz */ + LEDC_SRC_LSE /*!< Low speed external 32768 Hz clock */ +} LEDC_SRC_Enum; + +/** + * @brief Selection of LEDC duty clock numbers + */ +typedef enum +{ + LEDC_DTYNUM_8 = 0, + LEDC_DTYNUM_16, + LEDC_DTYNUM_32, + LEDC_DTYNUM_64 +} LEDC_DTYNUM_Enum; + +/** + * @brief Definition of LEDC Init Structure + */ +typedef struct +{ + LEDC_SRC_Enum LEDC_ClockSource; + LEDC_DTYNUM_Enum LEDC_DutyClockNumber; + u32 LEDC_ClockPrescaler; + u32 LEDC_COMxEN; + u32 LEDC_DeadTime; +} LEDC_InitTypeDef; + +/** + * @brief Enumeration of LED layout mode. + */ +typedef enum +{ + COMMON_CATHODE, /*!< LEDC SEG output polarity is non-inverted. */ + /*!< LEDC COM output polarity is non-inverted.*/ + COMMON_CATHODE_WITH_NPN, /*!< LEDC SEG output polarity is non-inverted. */ + /*!< LEDC COM output polarity is inverted.*/ + COMMON_ANODE_WITH_PNP, /*!< LEDC SEG output polarity is inverted. */ + /*!< LEDC COM output polarity is non-inverted.*/ + COMMON_ANODE_WITH_NPN, /*!< LEDC SEG output polarity is inverted. */ + /*!< LEDC COM output polarity is inverted.*/ +} LEDC_Mode; + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup LEDC_Exported_Constants LEDC exported constants + * @{ + */ + +/* Definitions of LEDCER */ +#define LEDC_COM0EN 0x0001 /*!< LEDC COM0 enable */ +#define LEDC_COM1EN 0x0002 /*!< LEDC COM1 enable */ +#define LEDC_COM2EN 0x0004 /*!< LEDC COM2 enable */ +#define LEDC_COM3EN 0x0008 /*!< LEDC COM3 enable */ +#define LEDC_COM4EN 0x0010 /*!< LEDC COM4 enable */ +#define LEDC_COM5EN 0x0020 /*!< LEDC COM5 enable */ +#define LEDC_COM6EN 0x0040 /*!< LEDC COM6 enable */ +#define LEDC_COM7EN 0x0080 /*!< LEDC COM7 enable */ +#if (LIBCFG_LEDC_NO_COM_8_11 == 0) +#define LEDC_COM8EN 0x0100 /*!< LEDC COM8 enable */ +#define LEDC_COM9EN 0x0200 /*!< LEDC COM9 enable */ +#define LEDC_COM10EN 0x0400 /*!< LEDC COM10 enable */ +#define LEDC_COM11EN 0x0800 /*!< LEDC COM11 enable */ +#endif + +/* Definitions of COMxPOL */ +#define LEDC_COM0POL 0x00000001 /*!< LEDC COM0 polarity */ +#define LEDC_COM1POL 0x00000002 /*!< LEDC COM1 polarity */ +#define LEDC_COM2POL 0x00000004 /*!< LEDC COM2 polarity */ +#define LEDC_COM3POL 0x00000008 /*!< LEDC COM3 polarity */ +#define LEDC_COM4POL 0x00000010 /*!< LEDC COM4 polarity */ +#define LEDC_COM5POL 0x00000020 /*!< LEDC COM5 polarity */ +#define LEDC_COM6POL 0x00000040 /*!< LEDC COM6 polarity */ +#define LEDC_COM7POL 0x00000080 /*!< LEDC COM7 polarity */ +#if (LIBCFG_LEDC_NO_COM_8_11 == 0) +#define LEDC_COM8POL 0x00000100 /*!< LEDC COM8 polarity */ +#define LEDC_COM9POL 0x00000200 /*!< LEDC COM9 polarity */ +#define LEDC_COM10POL 0x00000400 /*!< LEDC COM10 polarity */ +#define LEDC_COM11POL 0x00000800 /*!< LEDC COM11 polarity */ +#endif + +/* Definitions of SEGxPOL */ +#define LEDC_SEG0POL 0x00010000 /*!< LEDC SEG0 polarity */ +#define LEDC_SEG1POL 0x00020000 /*!< LEDC SEG1 polarity */ +#define LEDC_SEG2POL 0x00040000 /*!< LEDC SEG2 polarity */ +#define LEDC_SEG3POL 0x00080000 /*!< LEDC SEG3 polarity */ +#define LEDC_SEG4POL 0x00100000 /*!< LEDC SEG4 polarity */ +#define LEDC_SEG5POL 0x00200000 /*!< LEDC SEG5 polarity */ +#define LEDC_SEG6POL 0x00400000 /*!< LEDC SEG6 polarity */ +#define LEDC_SEG7POL 0x00800000 /*!< LEDC SEG7 polarity */ + +#define LEDC_FLAG_FRAME (1UL << 0) +#define LEDC_INT_FRAME (1UL << 0) + + +/* check parameter of the LEDC mode */ +#define IS_LEDC_MODE(x) ((x == COMMON_CATHODE) || (x == COMMON_CATHODE_WITH_NPN) || \ + (x == COMMON_ANODE_WITH_PNP) || (x == COMMON_ANODE_WITH_NPN)) + +/** + * @brief Used to check LEDC_SRC_Enum parameter + */ +#define IS_LEDC_SRC(x) ((x == LEDC_SRC_PCLK) || (x == LEDC_SRC_LSI) || (x == LEDC_SRC_LSE)) +#define IS_LEDC_DTYNUM(x) ((x == LEDC_DTYNUM_8) || (x == LEDC_DTYNUM_16) || (x == LEDC_DTYNUM_32) ||\ + (x == LEDC_DTYNUM_64)) +#define IS_LEDC_PSC(x) (x < 4096) +#define IS_LEDC_DTCR(x) (x < 64) +#define IS_LEDC_COMEN(x) (((x & 0xF000) == 0x0) && (x != 0x0)) +#define IS_LEDC_COMPOL(x) (((x & 0xFFFFF000) == 0x0) && (x != 0x0)) +#define IS_LEDC_SEGPOL(x) (((x & 0xFF00FFFF) == 0x0) && (x != 0x0)) + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup LEDC_Exported_Functions LEDC exported functions + * @{ + */ +void LEDC_DeInit(void); +void LEDC_Init(LEDC_InitTypeDef* LEDC_InitStruct); +void LEDC_ClockSourceConfig(LEDC_SRC_Enum Source); +void LEDC_Cmd(ControlStatus NewState); +void LEDC_IntConfig(ControlStatus NewState); +FlagStatus LEDC_GetFlagStatus(void); +void LEDC_ClearFlagStatus(void); +void LEDC_COMxConfig(u32 LEDC_COMxEN, ControlStatus Cmd); +void LEDC_SetDeadTimeDuty(u32 LEDC_DeadTimeDuty); +void LEDC_SetPolarityMode(u32 LEDC_COMxPOL, u32 LEDC_SEGxPOL , LEDC_Mode mode); +#define LEDC_SetData(COMx, data) HT_LEDC->DR[COMx] = data +#define LEDC_GetData(COMx) HT_LEDC->DR[COMx] +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lib.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lib.h new file mode 100644 index 0000000000..b04cdb33a4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_lib.h @@ -0,0 +1,332 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_lib.h + * @version $Rev:: 7319 $ + * @date $Date:: 2023-10-28 #$ + * @brief The header file includes all the header files of the libraries. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_LIB_H +#define __HT32F5XXXX_LIB_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Settings ------------------------------------------------------------------------------------------------*/ +#define HT32_FWLIB_VER (0x01009001) +#define HT32_FWLIB_SVN (0x7446) + +#if defined(USE_HT32F52220_30) + #include "ht32f52220_30_libcfg.h" +#endif +#if defined(USE_HT32F52231_41) + #include "ht32f52231_41_libcfg.h" +#endif +#if defined(USE_HT32F52331_41) + #include "ht32f52331_41_libcfg.h" +#endif +#if defined(USE_HT32F52342_52) + #include "ht32f52342_52_libcfg.h" +#endif +#if defined(USE_HT32F52243_53) + #include "ht32f52243_53_libcfg.h" +#endif +#if defined(USE_HT32F5826) + #include "ht32f5826_libcfg.h" +#endif +#if defined(USE_HT32F0008) + #include "ht32f0008_libcfg.h" +#endif +#if defined(USE_HT32F50220_30) + #include "ht32f50220_30_libcfg.h" +#endif +#if defined(USE_HT32F50231_41) + #include "ht32f50231_41_libcfg.h" +#endif +#if defined(USE_HT32F52344_54) + #include "ht32f52344_54_libcfg.h" +#endif +#if defined(USE_HT32F0006) + #include "ht32f0006_libcfg.h" +#endif +#if defined(USE_HT32F52357_67) + #include "ht32f52357_67_libcfg.h" +#endif +#if defined(USE_HT32F54231_41) + #include "ht32f54231_41_libcfg.h" +#endif +#if defined(USE_HT32F54243_53) + #include "ht32f54243_53_libcfg.h" +#endif +#if defined(USE_HT32F57342_52) + #include "ht32f57342_52_libcfg.h" +#endif +#if defined(USE_HT32F57331_41) + #include "ht32f57331_41_libcfg.h" +#endif +#if defined(USE_HT32F50343) + #include "ht32f50343_libcfg.h" +#endif +#if defined(USE_HT32F65230_40) + #include "ht32f65230_40_libcfg.h" +#endif +#if defined(USE_HT32F65232) + #include "ht32f65232_libcfg.h" +#endif +#if defined(USE_HT32F61141) + #include "ht32f61141_libcfg.h" +#endif +#if defined(USE_HT32F61244_45) + #include "ht32f61244_45_libcfg.h" +#endif +#if defined(USE_HT32F50020_30) + #include "ht32f50020_30_libcfg.h" +#endif +#if defined(USE_HT32F67041_51) + #include "ht32f67041_51_libcfg.h" +#endif +#if defined(USE_HT32F50442_52) + #include "ht32f50442_52_libcfg.h" +#endif +#if defined(USE_HT32F50431_41) + #include "ht32f50431_41_libcfg.h" +#endif +#if defined(USE_HT32F53242_52) + #include "ht32f53242_52_libcfg.h" +#endif +#if defined(USE_HT32F53231_41) + #include "ht32f53231_41_libcfg.h" +#endif +#if defined(USE_HT32F66242) + #include "ht32f66242_libcfg.h" +#endif +#if defined(USE_HT32F66246) + #include "ht32f66246_libcfg.h" +#endif +#if defined(USE_HT32F52234_44) + #include "ht32f52234_44_libcfg.h" +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include +#include "ht32f5xxxx_conf.h" + +#if (HT32_LIB_DEBUG == 1) +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define Assert_Param(expr) ((expr) ? (void)0 : assert_error((u8 *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- ------------------------------*/ +void assert_error(u8* file, u32 line); +#else + +#define Assert_Param(expr) ((void)0) + +#endif /* DEBUG --------------------------------------------------------------------------------------------*/ + + +#if _ADC + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F66242) || defined(USE_HT32F66246) + #include "ht32f65xxx_66xxx_adc.h" + #else + #include "ht32f5xxxx_adc.h" + #endif +#endif + +#if _AES && LIBCFG_AES + #include "ht32f5xxxx_aes.h" +#endif + +#if _BFTM + #include "ht32f5xxxx_bftm.h" +#endif + +#if _CAN && LIBCFG_CAN0 + #include "ht32f5xxxx_can.h" +#endif + +#if _CKCU + #include "ht32f5xxxx_ckcu.h" +#endif + +#if _CMP && LIBCFG_CMP + #include "ht32f5xxxx_cmp.h" +#endif + +#if _CRC && LIBCFG_CRC + #include "ht32f5xxxx_crc.h" +#endif + +#if _DAC && (LIBCFG_DAC0 || LIBCFG_DAC1) + #include "ht32f5xxxx_dac.h" +#endif + +#if _DAC && LIBCFG_DACDUAL16 + #include "ht32f5xxxx_dac_dual16.h" +#endif + +#if _DIV && LIBCFG_DIV + #include "ht32f5xxxx_div.h" +#endif + +#if _EBI && LIBCFG_EBI + #include "ht32f5xxxx_ebi.h" +#endif + +#if _EXTI + #include "ht32f5xxxx_exti.h" +#endif + +#if _FLASH + #include "ht32f5xxxx_flash.h" +#endif + +#if _GPIO + #include "ht32f5xxxx_gpio.h" +#endif + +#if _GPTM + #include "ht32f5xxxx_tm_type.h" + #include "ht32f5xxxx_tm.h" +#endif + +#if _I2C + #include "ht32f5xxxx_i2c.h" +#endif + +#if _I2S && LIBCFG_I2S + #include "ht32f5xxxx_i2s.h" +#endif + +#if _LCD && LIBCFG_LCD + #include "ht32f5xxxx_lcd.h" +#endif + +#if _LEDC && LIBCFG_LEDC + #include "ht32f5xxxx_ledc.h" +#endif + +#if _MCTM && LIBCFG_MCTM0 + #include "ht32f5xxxx_tm_type.h" + #include "ht32f5xxxx_tm.h" + #include "ht32f5xxxx_mctm.h" +#endif + +#if _MIDI && LIBCFG_MIDI + #include "ht32f5xxxx_midi.h" +#endif + +#if _OPA && LIBCFG_OPA + #if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) + #include "ht32f65xxx_66xxx_opa.h" + #else + #endif +#endif + +#if _PDMA && LIBCFG_PDMA + #include "ht32f5xxxx_pdma.h" +#endif + +#if _PWRCU + #include "ht32f5xxxx_pwrcu.h" +#endif + +#if _RSTCU + #include "ht32f5xxxx_rstcu.h" +#endif + +#if _RTC + #include "ht32f5xxxx_rtc.h" +#endif + +#if _SCI && LIBCFG_SCI0 + #include "ht32f5xxxx_sci.h" +#endif + +#if _SCTM + #include "ht32f5xxxx_tm_type.h" + #include "ht32f5xxxx_tm.h" +#endif + +#if _SLED && LIBCFG_SLED0 + #include "ht32f5xxxx_sled.h" +#endif + +#if _SPI + #include "ht32f5xxxx_spi.h" +#endif + +#if _TKEY && LIBCFG_TKEY + #include "ht32f5xxxx_tkey.h" +#endif + +#if _USART + #include "ht32f5xxxx_usart.h" +#endif + +#if _USB && LIBCFG_USBD + #include "ht32f5xxxx_usbd.h" +#endif + +#if _WDT + #include "ht32f5xxxx_wdt.h" +#endif + +#if _MISC + #include "ht32_cm0plus_misc.h" +#endif + +#if _SERIAL + #include "ht32_serial.h" +#endif + +#if _SWDIV + #include "ht32_div.h" +#endif + +#if _SWRAND + #include "ht32_rand.h" +#endif + +#if (_RETARGET) + #if defined (__GNUC__) + #undef getchar + #define getchar SERIAL_GetChar + #endif +#endif + +#ifdef HTCFG_TIME_IPSEL +#include "ht32_time.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_mctm.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_mctm.h new file mode 100644 index 0000000000..cbea7b628b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_mctm.h @@ -0,0 +1,298 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_mctm.h + * @version $Rev:: 5258 $ + * @date $Date:: 2021-02-04 #$ + * @brief The header file of the MCTM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_MCTM_H +#define __HT32F5XXXX_MCTM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_tm.h" +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup MCTM + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Types MCTM exported types + * @{ + */ +/** + * @brief Enumeration of MCTM channel output idle state. + */ +/** + * @brief Definition of Break & DeadTime init structure. + */ +typedef struct +{ + u32 OSSRState; + u32 OSSIState; + u32 LockLevel; + u32 Break0; + u32 Break0Polarity; + u32 AutomaticOutput; + u8 DeadTime; + u8 BreakFilter; +} MCTM_CHBRKCTRInitTypeDef; + +typedef union +{ + struct + { + /* Definitions of CHBRKCTR */ + unsigned long Break0 :1; // BK0E + unsigned long Break0Polarity :1; // BK0P + #if (LIBCFG_TM_652XX_V1) + unsigned long Break1 :1; // BK1E + unsigned long Break1Polarity :1; // BK1E + #else + unsigned long :1; + unsigned long :1; + #endif + unsigned long :1; // CHMOE + unsigned long AutomaticOutput :1; // CHAOE + #if (LIBCFG_TM_65232) + unsigned long Break0FromCMP0 :1; // BK0CMP0 + unsigned long Break0FromCMP1 :1; // BK0CMP1 + #else + unsigned long :1; + unsigned long :1; + #endif + + #if (LIBCFG_TM_652XX_V1) + unsigned long Break0EventCount :2; // BK0FN + unsigned long Break0FDiv :2; // BK0FF + unsigned long Break1EventCount :2; // BK1FN + unsigned long Break1FDiv :2; // BK1FF + #else + unsigned long Break0Filter :4; // BK0F + unsigned long :4; + #endif + + unsigned long LockLevel :2; // LOCKLV + unsigned long DeglitchFilte :1; // GFSEL + unsigned long :1; + unsigned long OSSIState :1; // CHOSSI + unsigned long OSSRState :1; // CHOSSR + #if (LIBCFG_TM_65232) + unsigned long Break1FromCMP0 :1; // BK1CMP0 + unsigned long Break1FromCMP1 :1; // BK1CMP1 + #else + unsigned long :1; + unsigned long :1; + #endif + + unsigned long DeadTime :8; // CHDTG + } Bit; + u32 Reg; +} MCTM_CHBRKCTRTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Constants MCTM exported constants + * @{ + */ + +/** @defgroup MCTM_BKE Definitions of MCTM break control + * @{ + */ +#define MCTM_BREAK_ENABLE 0x00000001 /*!< Break enable */ +#define MCTM_BREAK_DISABLE 0x00000000 /*!< Break disable */ +/** + * @} + */ + +/** @defgroup MCTM_BKP Definitions of MCTM break polarity + * @{ + */ +#define MCTM_BREAK_POLARITY_LOW 0x00000000 /*!< Break input pin active low level */ +#define MCTM_BREAK_POLARITY_HIGH 0x00000002 /*!< Break input pin active high level */ +/** + * @} + */ + +/** @defgroup MCTM_CHMOE Definitions of MCTM main output enable function state + * @{ + */ +#define MCTM_CHMOE_DISABLE 0x00000000 /*!< main output disable */ +#define MCTM_CHMOE_ENABLE 0x00000010 /*!< Main output enable */ +/** + * @} + */ + +/** @defgroup MCTM_CHAOE Definitions of MCTM automatic output enable function state + * @{ + */ +#define MCTM_CHAOE_DISABLE 0x00000000 /*!< Automatic output enable function disable */ +#define MCTM_CHAOE_ENABLE 0x00000020 /*!< Automatic output enable function enable */ +/** + * @} + */ + +/** @defgroup MCTM_LOCK_LEVEL Definitions of MCTM lock level selection + * @{ + */ +#define MCTM_LOCK_LEVEL_OFF 0x00000000 /*!< Lock Off */ +#define MCTM_LOCK_LEVEL_1 0x00010000 /*!< Lock level 1 */ +#define MCTM_LOCK_LEVEL_2 0x00020000 /*!< Lock level 2 */ +#define MCTM_LOCK_LEVEL_3 0x00030000 /*!< Lock level 3 */ +/** + * @} + */ + +/** @defgroup MCTM_OSSI Definitions of Off-State Selection for Idle mode states + * @{ + */ +#define MCTM_OSSI_STATE_ENABLE 0x00100000 +#define MCTM_OSSI_STATE_DISABLE 0x00000000 +/** + * @} + */ + +/** @defgroup MCTM_OSSR Definitions of Off-State Selection for Run mode states + * @{ + */ +#define MCTM_OSSR_STATE_ENABLE 0x00200000 +#define MCTM_OSSR_STATE_DISABLE 0x00000000 +/** + * @} + */ + +/** @defgroup MCTM_Check_Parameter Check parameter + * @{ + */ + +/** + * @brief Used to check parameter of the MCTMx. + */ +#define IS_MCTM(x) (IS_MCTM0(x)) + +#if (LIBCFG_MCTM0) +#define IS_MCTM0(x) (x == HT_MCTM0) +#else +#define IS_MCTM0(x) (0) +#endif + +/** + * @brief Used to check parameter of the complementary output channel. + */ +#define IS_MCTM_COMPLEMENTARY_CH(x) (((x) == TM_CH_0) || ((x) == TM_CH_1) || \ + ((x) == TM_CH_2)) +/** + * @brief Used to check parameter of the COMUS. + */ +#define IS_MCTM_COMUS(x) ((x == MCTM_COMUS_STIOFF) || (x == MCTM_COMUS_STION)) +/** + * @brief Used to check parameter of the channel output idle state. + */ +#define IS_MCTM_OIS(x) ((x == MCTM_OIS_LOW) || (x == MCTM_OIS_HIGH)) +/** + * @brief Used to check value of MCTM break control state. + */ +#define IS_MCTM_BREAK_STATE(STATE) (((STATE) == MCTM_BREAK_ENABLE) || \ + ((STATE) == MCTM_BREAK_DISABLE)) +/** + * @brief Used to check value of MCTM break polarity. + */ +#define IS_MCTM_BREAK_POLARITY(POLARITY) (((POLARITY) == MCTM_BREAK_POLARITY_LOW) || \ + ((POLARITY) == MCTM_BREAK_POLARITY_HIGH)) +/** + * @brief Used to check value of MCTM automatic output enable control state. + */ +#define IS_MCTM_CHAOE_STATE(STATE) (((STATE) == MCTM_CHAOE_ENABLE) || \ + ((STATE) == MCTM_CHAOE_DISABLE)) +/** + * @brief Used to check value of MCTM lock level. + */ +#define IS_MCTM_LOCK_LEVEL(LEVEL) (((LEVEL) == MCTM_LOCK_LEVEL_OFF) || \ + ((LEVEL) == MCTM_LOCK_LEVEL_1) || \ + ((LEVEL) == MCTM_LOCK_LEVEL_2) || \ + ((LEVEL) == MCTM_LOCK_LEVEL_3)) +/** + * @brief Used to check value of MCTM OSSI state. + */ +#define IS_MCTM_OSSI_STATE(STATE) (((STATE) == MCTM_OSSI_STATE_ENABLE) || \ + ((STATE) == MCTM_OSSI_STATE_DISABLE)) +/** + * @brief Used to check value of MCTM OSSR state. + */ +#define IS_MCTM_OSSR_STATE(STATE) (((STATE) == MCTM_OSSR_STATE_ENABLE) || \ + ((STATE) == MCTM_OSSR_STATE_DISABLE)) +/** + * @} + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Functions MCTM exported functions + * @{ + */ +void MCTM_ChNPolarityConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHP_Enum Pol); +void MCTM_ChannelNConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control); + +void MCTM_CHMOECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState); +void MCTM_CHBRKCTRConfig(HT_TM_TypeDef* MCTMx, MCTM_CHBRKCTRInitTypeDef *CHBRKCTRInit); +void MCTM_CHBRKCTRConfig2(HT_TM_TypeDef* MCTMx, MCTM_CHBRKCTRTypeDef *CHBRKCTRInit); +void MCTM_CHBRKCTRStructInit(MCTM_CHBRKCTRInitTypeDef* CHBRKCTRInit); +void MCTM_COMPRECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState); +void MCTM_COMUSConfig(HT_TM_TypeDef* MCTMx, MCTM_COMUS_Enum Sel); + +#if (LIBCFG_MCTM_UEV1DIS) +void MCTM_UpdateEventDisable(HT_TM_TypeDef* MCTMx, MCTM_UEV1DIS_Enum MCTM_UEV1x, FlagStatus NewState); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_midi.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_midi.h new file mode 100644 index 0000000000..08da134013 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_midi.h @@ -0,0 +1,404 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_midi.h + * @version $Rev:: 6684 $ + * @date $Date:: 2023-01-18 #$ + * @brief The header file of the MIDI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_MIDI_H +#define __HT32F5XXXX_MIDI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup MIDI + * @{ + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup MIDI_Exported_Types MIDI exported types + * @{ + */ + +/** + * @brief Enumeration of MIDI CTRL MCUCHEN3. + */ +typedef enum +{ + MCUCHEN3_OFF = DISABLE, + MCUCHEN3_ON = ENABLE, +} MIDI_CTRL_MCUCHEN3_Enum; +/** + * @brief Enumeration of MIDI CTRL MCUCHEN2. + */ +typedef enum +{ + MCUCHEN2_OFF = DISABLE, + MCUCHEN2_ON = ENABLE, +} MIDI_CTRL_MCUCHEN2_Enum; +/** + * @brief Enumeration of MIDI CTRL MCUCHEN1. + */ +typedef enum +{ + MCUCHEN1_OFF = DISABLE, + MCUCHEN1_ON = ENABLE, +} MIDI_CTRL_MCUCHEN1_Enum; +/** + * @brief Enumeration of MIDI CTRL MCUCHEN0. + */ +typedef enum +{ + MCUCHEN0_OFF = DISABLE, + MCUCHEN0_ON = ENABLE, +} MIDI_CTRL_MCUCHEN0_Enum; +/** + * @brief Enumeration of MIDI CTRL MUSIC. + */ +typedef enum +{ + MUSICEN_OFF = DISABLE, + MUSICEN_ON = ENABLE, +} MIDI_CTRL_MUSICEN_Enum; +/** + * @brief Enumeration of MIDI SPI RDEN. + */ +typedef enum +{ + SPIRDEN_OFF = DISABLE, + SPIRDEN_ON = ENABLE, +} MIDI_CTRL_SPIRDEN_Enum; +/** + * @brief Enumeration of MIDI SPI DISLOOP. + */ +typedef enum +{ + SPIDISLOOP_OFF = DISABLE, + SPIDISLOOP_ON = ENABLE, +} MIDI_CTRL_SPIDISLOOP_Enum; +/** + * @brief Enumeration of MIDI CTRL CHS. + */ +typedef enum +{ + CHS16 = 0, /*!< Select 16-Channel */ + CHS20, /*!< Select 20-Channel */ + CHS24, /*!< Select 24-Channel */ + CHS28, /*!< Select 28-Channel */ + CHS32, /*!< Select 32-Channel */ +} MIDI_CTRL_CHS_Enum; + +/** + * @brief Enumeration of MIDI Note. + */ +typedef enum +{ + BL0 = 0, + BL1, + BL2, + BL3, + BL4, + BL5, + BL6, + BL7, + BL8, + BL9, + BL10, + BL11, +} MIDI_FREQ_BL_Enum; + +/** + * @brief Enumeration of MIDI VOL AR. + */ +typedef enum +{ + ENV_RELEASE = RESET, + ENV_ATTACK = SET, +} MIDI_VOL_AR_Enum; +/** + * @brief Enumeration of MIDI VOL ENV. + */ +typedef enum +{ + ENV_TYPE0 = 0, + ENV_TYPE1, + ENV_TYPE2, + ENV_NO, +} MIDI_VOL_ENV_Enum; + +/** + * @brief Enumeration of MIDI RE_NUM WBS. + */ +typedef enum +{ + WBS8 = 0, /*!< WBS 8-bit */ + WBS12, /*!< WBS 12-bit */ + WBS16, /*!< WBS 16-bit */ +} MIDI_RENUM_WBS_Enum; + +/** + * @brief Enumeration of MIDI CHAN ST. + */ +typedef enum +{ + ST_OFF = DISABLE, + ST_ON = ENABLE, +} MIDI_CHAN_ST_Enum; +/** + * @brief Enumeration of MIDI CHAN VM. + */ +typedef enum +{ + VM_OFF = DISABLE, + VM_ON = ENABLE, +} MIDI_CHAN_VM_Enum; +/** + * @brief Enumeration of MIDI CHAN FR. + */ +typedef enum +{ + FR_OFF = DISABLE, + FR_ON = ENABLE, +} MIDI_CHAN_FR_Enum; +/** + * @brief Enumeration of MIDI CHAN CHx. + */ +typedef enum +{ + MIDI_CHx0 = 0, + MIDI_CHx1, + MIDI_CHx2, + MIDI_CHx3, + MIDI_CHx4, + MIDI_CHx5, + MIDI_CHx6, + MIDI_CHx7, + MIDI_CHx8, + MIDI_CHx9, + MIDI_CHx10, + MIDI_CHx11, + MIDI_CHx12, + MIDI_CHx13, + MIDI_CHx14, + MIDI_CHx15, + MIDI_CHx16, + MIDI_CHx17, + MIDI_CHx18, + MIDI_CHx19, + MIDI_CHx20, + MIDI_CHx21, + MIDI_CHx22, + MIDI_CHx23, + MIDI_CHx24, + MIDI_CHx25, + MIDI_CHx26, + MIDI_CHx27, + MIDI_CHx28, + MIDI_CHx29, + MIDI_CHx30, + MIDI_CHx31, +} MIDI_CHAN_CHx_Enum; + +typedef struct +{ + u8 MIDI_CTRL_DACDS; + ControlStatus MIDI_CTRL_MUSICEN; + ControlStatus MIDI_CTRL_SPIDISLOOP; + u8 MIDI_CTRL_CHS; + MIDI_FREQ_BL_Enum MIDI_FREQ_BL; + u16 MIDI_FREQ_FR; + MIDI_VOL_AR_Enum MIDI_VOL_AR; + MIDI_VOL_ENV_Enum MIDI_VOL_ENV; + u16 MIDI_VOL_VL; + u16 MIDI_VOL_VR; + u32 MIDI_STADDR; + MIDI_RENUM_WBS_Enum MIDI_RENUM_WBS; + u16 MIDI_RENUM_RE; + u32 MIDI_ENDADDR; + ControlStatus MIDI_CHAN_ST; + ControlStatus MIDI_CHAN_VM; + ControlStatus MIDI_CHAN_FR; + u8 MIDI_CHAN_CHx; +} MIDI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup MIDI_Exported_Constants MIDI exported constants + * @{ + */ +/* Definitions of MIDI_FLAG */ +#define MIDI_FLAG_INTF 0x0001 + +/* Definitions of MIDI_INT */ +#define MIDI_INT_INTEN 0x0001 +#define MIDI_INT_MIDII_DMAEN 0x0002 +#define MIDI_INT_MIDIO_DMAEN 0x0004 + +/* Definitions of MIDI_VOL */ +#define VOL_MAX 0 +#define VOL_MID 0x1FF +#define VOL_380 0x380 +#define VOL_MIN 0x3FF +#define VOL_MUTE VOL_MIN + +//#define IS_MIDI(x) ((MIDI == HT_MIDI)) +#define IS_MIDI(x) ((x == HT_MIDI)) + +#define IS_MIDI_INT(x) (((x & 0xFFFFFFF8) == 0x0) && (x != 0)) +#define IS_MIDI_FLAG(x) (x == MIDI_FLAG_INTF) +#define IS_MIDI_FLAG_CLEAR(x) (((x & 0xFFFFFFFE) == 0) && (x != 0)) + +#define IS_MIDI_CTRL_MCUCHEN3(x) ((x == MCUCHEN3_OFF) || (x == MCUCHEN3_ON)) +#define IS_MIDI_CTRL_MCUCHEN2(x) ((x == MCUCHEN2_OFF) || (x == MCUCHEN2_ON)) +#define IS_MIDI_CTRL_MCUCHEN1(x) ((x == MCUCHEN1_OFF) || (x == MCUCHEN1_ON)) +#define IS_MIDI_CTRL_MCUCHEN0(x) ((x == MCUCHEN0_OFF) || (x == MCUCHEN0_ON)) +#define IS_MIDI_CTRL_DACDS(x) (x < 8) +#define IS_MIDI_CTRL_MUSICEN(x) ((x == MUSICEN_OFF) || (x == MUSICEN_ON)) +#define IS_MIDI_CTRL_SPIRDEN(x) ((x == SPIRDEN_OFF) || (x == SPIRDEN_ON)) +#define IS_MIDI_CTRL_SPIDISLOOP(x) ((x == SPIDISLOOP_OFF) || (x == SPIDISLOOP_ON)) +#define IS_MIDI_CTRL_CHS(x) (x < 8) + +#define IS_MIDI_FREQ_BL(x) (x < 12) +#define IS_MIDI_FREQ_FR(x) (x < 0xFFF) + +#define IS_MIDI_VOL_AR(x) (ENV_ATTACK || ENV_RELEASE) +#define IS_MIDI_VOL_ENV(x) (ENV_TYPE0 || ENV_TYPE1 || ENV_TYPE2 || ENV_NO) +#define IS_MIDI_VOL_VL(x) (x < 0x3FF) +#define IS_MIDI_VOL_VR(x) (x < 0x3FF) + +#define IS_MIDI_STADDR(x) (x < 0x7FFFF) + +#define IS_MIDI_RENUM_WBS(x) ((x == WBS8) || (x == WBS12) || (x == WBS16)) +#define IS_MIDI_RENUM_RE(x) (x < 0x7FFF) + +#define IS_MIDI_ENDADDR(x) (x < 0xFFFFFF) + +#define IS_MIDI_CHAN_ST(x) ((x == ST_OFF) || (x == ST_ON)) +#define IS_MIDI_CHAN_VM(x) ((x == VM_OFF) || (x == VM_ON)) +#define IS_MIDI_CHAN_FR(x) ((x == FR_OFF) || (x == FR_ON)) +#define IS_MIDI_CHAN_CHx(x) (x < 32) + +#define IS_MIDI_MCUCHx11_BH(x) (x < 0xFFFF) +#define IS_MIDI_MCUCHx11_BL(x) (x < 0xFFFF) + +#define IS_MIDI_MCUCHx12_CH(x) (x < 0xFFFF) +#define IS_MIDI_MCUCHx12_CL(x) (x < 0xFFFF) + +#define IS_MIDI_MCUCHx13_DH(x) (x < 0xFFFF) +#define IS_MIDI_MCUCHx13_DL(x) (x < 0xFFFF) + +#define IS_MIDI_MCUCHx14_EH(x) (x < 0xFFFF) +#define IS_MIDI_MCUCHx14_EL(x) (x < 0xFFFF) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup MIDI_Exported_Functions MIDI exported functions + * @{ + */ +void MIDI_DeInit(void); +void MIDI_Init(HT_MIDI_TypeDef* MIDIx, MIDI_InitTypeDef* MIDI_InitStruct); +void MIDI_StructInit(MIDI_InitTypeDef* MIDI_InitStruct); +void MIDI_IntConfig(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Int, ControlStatus NewState); +FlagStatus MIDI_GetFlagStatus(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Flag); +void MIDI_ClearFlag(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Flag); + +void MIDI_CTRL(HT_MIDI_TypeDef* MIDIx, + MIDI_CTRL_MCUCHEN3_Enum MCUCHEN3, MIDI_CTRL_MCUCHEN2_Enum MCUCHEN2, + MIDI_CTRL_MCUCHEN1_Enum MCUCHEN1, MIDI_CTRL_MCUCHEN0_Enum MCUCHEN0, + u8 DACDS, + MIDI_CTRL_MUSICEN_Enum MUSICEN, + MIDI_CTRL_SPIRDEN_Enum SPIRDEN, MIDI_CTRL_SPIDISLOOP_Enum SPIDISLOOP, + MIDI_CTRL_CHS_Enum CHS); +void MIDI_FREQ(HT_MIDI_TypeDef* MIDIx, MIDI_FREQ_BL_Enum BL, u16 FR); +void MIDI_VOL(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_AR_Enum A_R, MIDI_VOL_ENV_Enum ENV, u16 VL, u16 VR); +void MIDI_STADDR(HT_MIDI_TypeDef* MIDIx, u32 ST_ADDR); +void MIDI_RENUM(HT_MIDI_TypeDef* MIDIx, MIDI_RENUM_WBS_Enum WBS, u16 RE); +void MIDI_ENDADDR(HT_MIDI_TypeDef* MIDIx, u32 END_ADDR); +void MIDI_CHAN(HT_MIDI_TypeDef* MIDIx, MIDI_CHAN_ST_Enum ST, MIDI_CHAN_VM_Enum VM, MIDI_CHAN_FR_Enum FR, u8 CHx); + +void MIDI_MCUCH0(HT_MIDI_TypeDef* MIDIx, u16 CH0B, u16 CH0A); +void MIDI_MCUCH1(HT_MIDI_TypeDef* MIDIx, u16 CH1B, u16 CH1A); +void MIDI_MCUCH2(HT_MIDI_TypeDef* MIDIx, u16 CH2B, u16 CH2A); +void MIDI_MCUCH3(HT_MIDI_TypeDef* MIDIx, u16 CH3B, u16 CH3A); + +void MIDI_FREQ_BL(HT_MIDI_TypeDef* MIDIx, MIDI_FREQ_BL_Enum BL); +void MIDI_FREQ_FR(HT_MIDI_TypeDef* MIDIx, u16 FR); +void MIDI_VOL_AR(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_AR_Enum A_R); +void MIDI_VOL_ENV(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_ENV_Enum ENV); +void MIDI_VOL_VL(HT_MIDI_TypeDef* MIDIx, u16 VL); +void MIDI_VOL_VR(HT_MIDI_TypeDef* MIDIx, u16 VR); +void MIDI_RENUM_WBS(HT_MIDI_TypeDef* MIDIx, MIDI_RENUM_WBS_Enum WBS); +void MIDI_RENUM_RE(HT_MIDI_TypeDef* MIDIx, u16 RE); +void MIDI_CHAN_STCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CHAN_VMCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CHAN_FRCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CHAN_CHx(HT_MIDI_TypeDef* MIDIx, u8 CHx); +void MIDI_MCUCH0_CH0B(HT_MIDI_TypeDef* MIDIx, u16 CH0B); +void MIDI_MCUCH0_CH0A(HT_MIDI_TypeDef* MIDIx, u16 CH0A); +void MIDI_MCUCH1_CH1B(HT_MIDI_TypeDef* MIDIx, u16 CH1B); +void MIDI_MCUCH1_CH1A(HT_MIDI_TypeDef* MIDIx, u16 CH1A); +void MIDI_MCUCH2_CH2B(HT_MIDI_TypeDef* MIDIx, u16 CH2B); +void MIDI_MCUCH2_CH2A(HT_MIDI_TypeDef* MIDIx, u16 CH2A); +void MIDI_MCUCH3_CH3B(HT_MIDI_TypeDef* MIDIx, u16 CH3B); +void MIDI_MCUCH3_CH3A(HT_MIDI_TypeDef* MIDIx, u16 CH3A); +void MIDI_CTRL_MCUCHEN3(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CTRL_MCUCHEN2(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CTRL_MCUCHEN1(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CTRL_MCUCHEN0(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CTRL_DACDS(HT_MIDI_TypeDef* MIDIx, u8 DACDS); +void MIDI_CTRL_MUSICENCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CTRL_SPIRDENCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CTRL_SPIDISLOOPCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState); +void MIDI_CTRL_CHS(HT_MIDI_TypeDef* MIDIx, u8 CHS); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pdma.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pdma.h new file mode 100644 index 0000000000..1dbea97ba3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pdma.h @@ -0,0 +1,377 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_pdma.h + * @version $Rev:: 7319 $ + * @date $Date:: 2023-10-28 #$ + * @brief The header file of the PDMA library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_PDMA_H +#define __HT32F5XXXX_PDMA_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup PDMA + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Types PDMA exported types + * @{ + */ + +/** + * @brief Definition of PDMA channel Init Structure + */ +typedef struct +{ + u32 PDMACH_SrcAddr; /*!< source address */ + u32 PDMACH_DstAddr; /*!< destination address */ + u16 PDMACH_BlkCnt; /*!< number of blocks for a PDMA transfer (1 ~ 65,535) */ + u8 PDMACH_BlkLen; /*!< number of data for a block (1 ~ 255) */ + u8 PDMACH_DataSize; /*!< number of bits for a data (8-bit/16-bit/32-bit) */ + u16 PDMACH_Priority; /*!< software priority for a PDMA transfer (L/M/H/VH) */ + u16 PDMACH_AdrMod; /*!< address mode (LIN_INC/LIN_DEC/CIR_INC/CIR_DEC/FIX/AUTO_RELOAD) */ +} PDMACH_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Constants PDMA exported constants + * @{ + */ +/* priority */ +#define L_PRIO (0) /*!< low priority */ +#define M_PRIO (1UL << 8) /*!< medium priority */ +#define H_PRIO (2UL << 8) /*!< high priority */ +#define VH_PRIO (3UL << 8) /*!< very high priority */ + +#define IS_PDMA_PRIO(PRIO) ((PRIO >> 8) < 4) /*!< check channel priority parameter */ + +/* address mode */ +#define AUTO_RELOAD (1UL << 11) /*!< enable auto reload */ +#define ADR_FIX (1UL << 10) /*!< enable address fix */ + +#define SRC_ADR_LIN_INC (0) /*!< source address linear increment */ +#define SRC_ADR_LIN_DEC (1UL << 6) /*!< source address linear decrement */ +#define SRC_ADR_CIR_INC (2UL << 6) /*!< source address circular increment */ +#define SRC_ADR_CIR_DEC (3UL << 6) /*!< source address circular decrement */ +#define SRC_ADR_FIX (ADR_FIX | SRC_ADR_CIR_INC) /*!< source address fix */ + +#define DST_ADR_LIN_INC (0) /*!< destination address linear increment */ +#define DST_ADR_LIN_DEC (1UL << 4) /*!< destination address linear decrement */ +#define DST_ADR_CIR_INC (2UL << 4) /*!< destination address circular increment */ +#define DST_ADR_CIR_DEC (3UL << 4) /*!< destination address circular decrement */ +#define DST_ADR_FIX (ADR_FIX | DST_ADR_CIR_INC) /*!< destination address fix */ + +#define IS_PDMA_ADR_MOD(MOD) ((MOD & 0xFFFFF30F) == 0) /*!< check address mode parameters */ + +/* transfer size */ +#define IS_PDMA_BLK_CNT(CNT) ((CNT > 0) && (CNT <= 65535)) /*!< block count per transfer */ +#define IS_PDMA_BLK_LEN(LEN) ((LEN > 0) && (LEN <= 255)) /*!< block size per block count */ + +/* transfer width */ +#define WIDTH_8BIT (0) /*!< 8-bit transfer width */ +#define WIDTH_16BIT (1UL << 2) /*!< 16-bit transfer width */ +#define WIDTH_32BIT (2UL << 2) /*!< 32-bit transfer width */ + +#define IS_PDMA_WIDTH(WIDTH) ((WIDTH >> 2) < 3) /*!< check transfer width parameter */ + +/* channel number */ +#define PDMA_CH0 (0) /*!< channel 0 number */ +#define PDMA_CH1 (1UL) /*!< channel 1 number */ +#define PDMA_CH2 (2UL) /*!< channel 2 number */ +#define PDMA_CH3 (3UL) /*!< channel 3 number */ +#define PDMA_CH4 (4UL) /*!< channel 4 number */ +#define PDMA_CH5 (5UL) /*!< channel 5 number */ + +#define IS_PDMA_CH(CH) (CH < 6) /*!< check channel number parameter */ + +#define PDMA_ADC0 PDMA_CH0 /*!< ADC PDMA channel number */ +#if (LIBCFG_ADC1) +#define PDMA_ADC1 PDMA_CH1 /*!< ADC PDMA channel number */ +#endif +#define PDMA_ADC PDMA_ADC0 + +#if(LIBCFG_DAC0) +#define PDMA_DAC0_CH0 PDMA_CH1 /*!< DAC0 CH0 PDMA channel number */ +#define PDMA_DAC0_CH1 PDMA_CH3 /*!< DAC0 CH1 PDMA channel number */ +#endif + +#if(LIBCFG_DAC1) +#define PDMA_DAC1_CH0 PDMA_CH4 /*!< DAC1 CH0 PDMA channel number */ +#define PDMA_DAC1_CH1 PDMA_CH5 /*!< DAC1 CH1 PDMA channel number */ +#endif + +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) || defined(USE_HT32F0006) || defined(USE_HT32F61244_45) +#define PDMA_SPI0_RX PDMA_CH4 /*!< SPI0_RX PDMA channel number */ +#define PDMA_SPI0_TX PDMA_CH5 /*!< SPI0_TX PDMA channel number */ +#elif defined(USE_HT32F57342_52) || defined(USE_HT32F52357_67) || defined(USE_HT32F67041_51) || defined(USE_HT32F52234_44) +#define PDMA_SPI0_RX PDMA_CH2 /*!< SPI0_RX PDMA channel number */ +#define PDMA_SPI0_TX PDMA_CH3 /*!< SPI0_TX PDMA channel number */ +#else +#define PDMA_SPI0_RX PDMA_CH0 /*!< SPI0_RX PDMA channel number */ +#define PDMA_SPI0_TX PDMA_CH1 /*!< SPI0_TX PDMA channel number */ +#endif + +#if (LIBCFG_SPI1) +#define PDMA_SPI1_RX PDMA_CH4 /*!< SPI1_RX PDMA channel number */ +#define PDMA_SPI1_TX PDMA_CH5 /*!< SPI1_TX PDMA channel number */ +#endif + +#if (LIBCFG_QSPI) +#define PDMA_QSPI_TX PDMA_CH1 /*!< QSPI_TX PDMA channel number */ +#define PDMA_QSPI_RX PDMA_CH0 /*!< QSPI_RX PDMA channel number */ +#endif + +#define PDMA_USART0_RX PDMA_CH0 /*!< USART0_RX PDMA channel number */ +#define PDMA_USART0_TX PDMA_CH1 /*!< USART0_TX PDMA channel number */ +#if (LIBCFG_USART1) +#define PDMA_USART1_RX PDMA_CH2 /*!< USART1_RX PDMA channel number */ +#define PDMA_USART1_TX PDMA_CH3 /*!< USART1_TX PDMA channel number */ +#endif + +#if defined(USE_HT32F52243_53) || defined(USE_HT32F52357_67) || defined(USE_HT32F54243_53) +#define PDMA_UART2_RX PDMA_CH0 /*!< UART2_RX PDMA channel number */ +#define PDMA_UART2_TX PDMA_CH1 /*!< UART2_TX PDMA channel number */ +#define PDMA_UART3_RX PDMA_CH4 /*!< UART3_RX PDMA channel number */ +#define PDMA_UART3_TX PDMA_CH5 /*!< UART3_TX PDMA channel number */ +#endif + +#define PDMA_UART0_RX PDMA_CH2 /*!< UART0_RX PDMA channel number */ +#define PDMA_UART0_TX PDMA_CH3 /*!< UART0_TX PDMA channel number */ +#if (LIBCFG_UART1) +#define PDMA_UART1_RX PDMA_CH4 /*!< UART1_RX PDMA channel number */ +#define PDMA_UART1_TX PDMA_CH5 /*!< UART1_TX PDMA channel number */ +#endif + +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) +#define PDMA_I2C0_RX PDMA_CH2 /*!< I2C0_RX PDMA channel number */ +#define PDMA_I2C0_TX PDMA_CH3 /*!< I2C0_TX PDMA channel number */ +#elif defined(USE_HT32F52234_44) +#define PDMA_I2C0_RX PDMA_CH2 /*!< I2C0_RX PDMA channel number */ +#define PDMA_I2C0_TX PDMA_CH0 /*!< I2C0_TX PDMA channel number */ +#else +#define PDMA_I2C0_RX PDMA_CH2 /*!< I2C0_RX PDMA channel number */ +#define PDMA_I2C0_TX PDMA_CH4 /*!< I2C0_TX PDMA channel number */ +#endif +#if (LIBCFG_I2C1) +#if defined(USE_HT32F52234_44) +#define PDMA_I2C1_RX PDMA_CH3 /*!< I2C1_RX PDMA channel number */ +#define PDMA_I2C1_TX PDMA_CH1 /*!< I2C1_TX PDMA channel number */ +#else +#define PDMA_I2C1_RX PDMA_CH3 /*!< I2C1_RX PDMA channel number */ +#define PDMA_I2C1_TX PDMA_CH5 /*!< I2C1_TX PDMA channel number */ +#endif +#endif + +#if defined(USE_HT32F52243_53) || defined(USE_HT32F54243_53) +#define PDMA_I2C2_RX PDMA_CH0 /*!< I2C2_RX PDMA channel number */ +#define PDMA_I2C2_TX PDMA_CH1 /*!< I2C2_TX PDMA channel number */ +#elif defined(USE_HT32F52234_44) +#define PDMA_I2C2_RX PDMA_CH4 /*!< I2C2_RX PDMA channel number */ +#define PDMA_I2C2_TX PDMA_CH5 /*!< I2C2_TX PDMA channel number */ +#endif + +#if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) || defined(USE_HT32F57342_52) || defined(USE_HT32F52357_67) +#define PDMA_SCI0_TX PDMA_CH5 /*!< SCI0_TX PDMA channel number */ +#define PDMA_SCI0_RX PDMA_CH4 /*!< SCI0_RX PDMA channel number */ +#define PDMA_SCI1_TX PDMA_CH3 /*!< SCI1_TX PDMA channel number */ +#define PDMA_SCI1_RX PDMA_CH2 /*!< SCI1_RX PDMA channel number */ +#endif + +#if (LIBCFG_I2S) +#define PDMA_I2S_TX PDMA_CH2 /*!< I2S_TX PDMA channel number */ +#define PDMA_I2S_RX PDMA_CH1 /*!< I2S_RX PDMA channel number */ +#endif + +#if (LIBCFG_MCTM0) +#define PDMA_MCTM0_CH0 PDMA_CH0 /*!< MCTM0_CH0 PDMA channel number */ +#define PDMA_MCTM0_TRIG PDMA_CH1 /*!< MCTM0_TRIG PDMA channel number */ +#define PDMA_MCTM0_CH1 PDMA_CH2 /*!< MCTM0_CH1 PDMA channel number */ +#define PDMA_MCTM0_CH2 PDMA_CH3 /*!< MCTM0_CH2 PDMA channel number */ +#define PDMA_MCTM0_CH3 PDMA_CH4 /*!< MCTM0_CH3 PDMA channel number */ +#define PDMA_MCTM0_UEV2 PDMA_CH4 /*!< MCTM0_UEV2 PDMA channel number */ +#define PDMA_MCTM0_UEV1 PDMA_CH5 /*!< MCTM0_UEV1 PDMA channel number */ +#endif + +#if (LIBCFG_NO_GPTM0) +#else +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) +#define PDMA_GPTM0_CH1 PDMA_CH0 /*!< GPTM0_CH1 PDMA channel number */ +#define PDMA_GPTM0_CH2 PDMA_CH1 /*!< GPTM0_CH2 PDMA channel number */ +#define PDMA_GPTM0_CH0 PDMA_CH2 /*!< GPTM0_CH0 PDMA channel number */ +#define PDMA_GPTM0_CH3 PDMA_CH3 /*!< GPTM0_CH3 PDMA channel number */ +#define PDMA_GPTM0_UEV PDMA_CH4 /*!< GPTM0_UEV PDMA channel number */ +#define PDMA_GPTM0_TRIG PDMA_CH5 /*!< GPTM0_TRIG PDMA channel number */ +#else +#define PDMA_GPTM0_CH1 PDMA_CH0 /*!< GPTM0_CH1 PDMA channel number */ +#define PDMA_GPTM0_CH3 PDMA_CH0 /*!< GPTM0_CH3 PDMA channel number */ +#define PDMA_GPTM0_CH2 PDMA_CH1 /*!< GPTM0_CH2 PDMA channel number */ +#define PDMA_GPTM0_UEV PDMA_CH1 /*!< GPTM0_UEV PDMA channel number */ +#define PDMA_GPTM0_CH0 PDMA_CH2 /*!< GPTM0_CH0 PDMA channel number */ +#define PDMA_GPTM0_TRIG PDMA_CH2 /*!< GPTM0_TRIG PDMA channel number */ +#endif +#endif + +#if (LIBCFG_GPTM1) +#define PDMA_GPTM1_CH0 PDMA_CH3 /*!< GPTM1_CH0 PDMA channel number */ +#define PDMA_GPTM1_CH3 PDMA_CH3 /*!< GPTM1_CH3 PDMA channel number */ +#define PDMA_GPTM1_CH1 PDMA_CH4 /*!< GPTM1_CH1 PDMA channel number */ +#define PDMA_GPTM1_UEV PDMA_CH4 /*!< GPTM1_UEV PDMA channel number */ +#define PDMA_GPTM1_CH2 PDMA_CH5 /*!< GPTM1_CH2 PDMA channel number */ +#define PDMA_GPTM1_TRIG PDMA_CH5 /*!< GPTM1_TRIG PDMA channel number */ +#endif + +#if defined(USE_HT32F65230_40) || defined(USE_HT32F65232) +#define PDMA_SCTM0_CH0 PDMA_CH0 /*!< SCTM0_CH0 PDMA channel number */ +#define PDMA_SCTM0_CH1 PDMA_CH1 /*!< SCTM0_CH1 PDMA channel number */ +#define PDMA_SCTM1_CH0 PDMA_CH2 /*!< SCTM1_CH0 PDMA channel number */ +#define PDMA_SCTM1_CH1 PDMA_CH3 /*!< SCTM1_CH1 PDMA channel number */ +#define PDMA_SCTM2_CH0 PDMA_CH4 /*!< SCTM2_CH0 PDMA channel number */ +#define PDMA_SCTM2_CH1 PDMA_CH5 /*!< SCTM2_CH1 PDMA channel number */ +#define PDMA_SCTM3_CH0 PDMA_CH4 /*!< SCTM3_CH0 PDMA channel number */ +#define PDMA_SCTM3_CH1 PDMA_CH5 /*!< SCTM3_CH1 PDMA channel number */ +#endif + +#if (LIBCFG_PWM0) +#if defined(USE_HT32F52234_44) +#define PDMA_PWM0_CH0 PDMA_CH5 /*!< PWM0_CH0 PDMA channel number */ +#define PDMA_PWM0_CH1 PDMA_CH3 /*!< PWM0_CH1 PDMA channel number */ +#define PDMA_PWM0_CH2 PDMA_CH4 /*!< PWM0_CH2 PDMA channel number */ +#define PDMA_PWM0_CH3 PDMA_CH3 /*!< PWM0_CH3 PDMA channel number */ +#define PDMA_PWM0_TRIG PDMA_CH5 /*!< PWM0_TRIG PDMA channel number */ +#define PDMA_PWM0_UEV PDMA_CH4 /*!< PWM0_UEV PDMA channel number */ +#else +#define PDMA_PWM0_CH0 PDMA_CH2 /*!< PWM0_CH0 PDMA channel number */ +#define PDMA_PWM0_CH1 PDMA_CH0 /*!< PWM0_CH1 PDMA channel number */ +#define PDMA_PWM0_CH2 PDMA_CH1 /*!< PWM0_CH2 PDMA channel number */ +#define PDMA_PWM0_CH3 PDMA_CH0 /*!< PWM0_CH3 PDMA channel number */ +#define PDMA_PWM0_TRIG PDMA_CH2 /*!< PWM0_TRIG PDMA channel number */ +#define PDMA_PWM0_UEV PDMA_CH1 /*!< PWM0_UEV PDMA channel number */ +#endif +#endif + +#if (LIBCFG_PWM1) +#define PDMA_PWM1_CH0 PDMA_CH5 /*!< PWM1_CH0 PDMA channel number */ +#define PDMA_PWM1_CH1 PDMA_CH3 /*!< PWM1_CH1 PDMA channel number */ +#define PDMA_PWM1_CH2 PDMA_CH4 /*!< PWM1_CH2 PDMA channel number */ +#define PDMA_PWM1_CH3 PDMA_CH3 /*!< PWM1_CH3 PDMA channel number */ +#define PDMA_PWM1_TRIG PDMA_CH5 /*!< PWM1_TRIG PDMA channel number */ +#define PDMA_PWM1_UEV PDMA_CH4 /*!< PWM1_UEV PDMA channel number */ +#endif + +#if (LIBCFG_PWM2) +#define PDMA_PWM2_CH0 PDMA_CH5 /*!< PWM2_CH0 PDMA channel number */ +#define PDMA_PWM2_CH1 PDMA_CH3 /*!< PWM2_CH1 PDMA channel number */ +#define PDMA_PWM2_CH2 PDMA_CH4 /*!< PWM2_CH2 PDMA channel number */ +#define PDMA_PWM2_CH3 PDMA_CH3 /*!< PWM2_CH3 PDMA channel number */ +#define PDMA_PWM2_TRIG PDMA_CH5 /*!< PWM2_TRIG PDMA channel number */ +#define PDMA_PWM2_UEV PDMA_CH4 /*!< PWM2_UEV PDMA channel number */ +#endif + +#if (LIBCFG_SLED0) +#define PDMA_SLED0 PDMA_CH0 /*!< SLED0 PDMA channel number */ +#endif +#if (LIBCFG_SLED1) +#define PDMA_SLED1 PDMA_CH1 /*!< SLED1 PDMA channel number */ +#endif + +#if (LIBCFG_AES) +#define PDMA_AES_OUT PDMA_CH4 /*!< AES_OUT PDMA channel number */ +#define PDMA_AES_IN PDMA_CH5 /*!< AES_IN PDMA channel number */ +#endif + +#if (LIBCFG_MIDI) +#define PDMA_MIDI_IN PDMA_CH3 /*!< MIDI_IN PDMA channel number */ +#define PDMA_MIDI_OUT PDMA_CH4 /*!< MIDI_OUT PDMA channel number */ +#endif + +/* flag */ +#define PDMA_FLAG_GE (1UL << 0) /*!< PDMA channel global event flag */ +#define PDMA_FLAG_BE (1UL << 1) /*!< PDMA channel block end flag */ +#define PDMA_FLAG_HT (1UL << 2) /*!< PDMA channel half transfer flag */ +#define PDMA_FLAG_TC (1UL << 3) /*!< PDMA channel transfer complete flag */ +#define PDMA_FLAG_TE (1UL << 4) /*!< PDMA channel transfer error flag */ + +#define IS_PDMA_FLAG(FLAG) (((FLAG & 0xFFFFFFE0) == 0) && (FLAG != 0)) +#define IS_PDMA_CLEAR_FLAG(FLAG) (((FLAG & 0xFFFFFFE0) == 0) && (FLAG != 0)) + +/* interrupt */ +#define PDMA_INT_GE (1UL << 0) /*!< PDMA channel global event interrupt */ +#define PDMA_INT_BE (1UL << 1) /*!< PDMA channel block end interrupt */ +#define PDMA_INT_HT (1UL << 2) /*!< PDMA channel half transfer interrupt */ +#define PDMA_INT_TC (1UL << 3) /*!< PDMA channel transfer complete interrupt */ +#define PDMA_INT_TE (1UL << 4) /*!< PDMA channel transfer error interrupt */ + +#define IS_PDMA_INT(INT) (((INT & 0xFFFFFFE0) == 0) && (INT != 0)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Functions PDMA exported functions + * @{ + */ +void PDMA_DeInit(void); +void PDMA_Config(u32 PDMA_CHn, PDMACH_InitTypeDef *PDMACH_InitStruct); +void PDMA_AddrConfig(u32 PDMA_CHn, u32 SrcAddr, u32 DstAddr); +void PDMA_SrcAddrConfig(u32 PDMA_CHn, u32 SrcAddr); +void PDMA_DstAddrConfig(u32 PDMA_CHn, u32 DstAddr); +void PDMA_TranSizeConfig(u32 PDMA_CHn, u16 BlkCnt, u16 BlkLen); +void PDMA_EnaCmd(u32 PDMA_CHn, ControlStatus NewState); +void PDMA_SwTrigCmd(u32 PDMA_CHn, ControlStatus NewState); + +void PDMA_IntConfig(u32 PDMA_CHn, u32 PDMA_INT_x, ControlStatus NewState); +FlagStatus PDMA_GetFlagStatus(u32 PDMA_CHn, u32 PDMA_FLAG_x); +void PDMA_ClearFlag(u32 PDMA_CHn, u32 PDMA_FLAG_x); +u16 PDMA_GetRemainBlkCnt(u32 PDMA_CHn); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pwrcu.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pwrcu.h new file mode 100644 index 0000000000..a98fb16289 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_pwrcu.h @@ -0,0 +1,376 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_pwrcu.h + * @version $Rev:: 7054 $ + * @date $Date:: 2023-07-24 #$ + * @brief The header file of the Power Control Unit library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_PWRCU_H +#define __HT32F5XXXX_PWRCU_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup PWRCU + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Types PWRCU exported types + * @{ + */ + +/** + * @brief Status of Power control unit + */ + +/** + * @brief Wakeup pin selection + */ +typedef enum +{ + PWRCU_WAKEUP_PIN_0 = 0, + #if (LIBCFG_PWRCU_WAKEUP1) + PWRCU_WAKEUP_PIN_1 + #endif +} PWRCU_WUP_Enum; +/** + * @brief Wakeup pin trigger type selection + */ +#if (LIBCFG_PWRCU_WAKEUP_V01) +typedef enum +{ + PWRCU_WUP_POSITIVE_EDGE = 0, /*!< Wakeup pin positive_edge triggered */ + PWRCU_WUP_NEGATIVE_EDGE, /*!< Wakeup pin negative_edge triggered */ + PWRCU_WUP_HIGH_LEVEL, /*!< Wakeup pin high-level sensitive */ + PWRCU_WUP_LOW_LEVEL, /*!< Wakeup pin low-level sensitive */ +} PWRCU_WUPTYPE_Enum; +#endif +typedef enum +{ + PWRCU_OK = 0, /*!< Ready for access or VDD power domain power-on reset is released */ + PWRCU_TIMEOUT, /*!< Time out */ + PWRCU_ERROR /*!< Error */ +} PWRCU_Status; +/** + * @brief DMOS status + */ +typedef enum +{ + PWRCU_DMOS_STS_ON = 0, /*!< DMOS on */ + PWRCU_DMOS_STS_OFF, /*!< DMOS off */ + PWRCU_DMOS_STS_OFF_BY_BODRESET /*!< DMOS off caused by brow out reset */ +} PWRCU_DMOSStatus; +/** + * @brief LVD level selection + */ +typedef enum +{ + PWRCU_LVDS_LV1 = 0x00000000, /*!< LVD level 1 */ + PWRCU_LVDS_LV2 = 0x00020000, /*!< LVD level 2 */ + PWRCU_LVDS_LV3 = 0x00040000, /*!< LVD level 3 */ + PWRCU_LVDS_LV4 = 0x00060000, /*!< LVD level 4 */ + PWRCU_LVDS_LV5 = 0x00400000, /*!< LVD level 5 */ + PWRCU_LVDS_LV6 = 0x00420000, /*!< LVD level 6 */ + PWRCU_LVDS_LV7 = 0x00440000, /*!< LVD level 7 */ + PWRCU_LVDS_LV8 = 0x00460000 /*!< LVD level 8 */ +} PWRCU_LVDS_Enum; +#if (LIBCFG_PWRCU_VDD_5V) + #define PWRCU_LVDS_2V65 PWRCU_LVDS_LV1 + #define PWRCU_LVDS_2V85 PWRCU_LVDS_LV2 + #define PWRCU_LVDS_3V05 PWRCU_LVDS_LV3 + #define PWRCU_LVDS_3V25 PWRCU_LVDS_LV4 + #define PWRCU_LVDS_3V45 PWRCU_LVDS_LV5 + #define PWRCU_LVDS_4V25 PWRCU_LVDS_LV6 + #define PWRCU_LVDS_4V45 PWRCU_LVDS_LV7 + #define PWRCU_LVDS_4V65 PWRCU_LVDS_LV8 +#elif (LIBCFG_PWRCU_VDD_2V0_3V6) + #define PWRCU_LVDS_2V25 PWRCU_LVDS_LV1 + #define PWRCU_LVDS_2V4 PWRCU_LVDS_LV2 + #define PWRCU_LVDS_2V55 PWRCU_LVDS_LV3 + #define PWRCU_LVDS_2V7 PWRCU_LVDS_LV4 + #define PWRCU_LVDS_2V85 PWRCU_LVDS_LV5 + #define PWRCU_LVDS_3V PWRCU_LVDS_LV6 + #define PWRCU_LVDS_3V15 PWRCU_LVDS_LV7 + #define PWRCU_LVDS_3V3 PWRCU_LVDS_LV8 +#else + #define PWRCU_LVDS_1V75 PWRCU_LVDS_LV1 + #define PWRCU_LVDS_1V95 PWRCU_LVDS_LV2 + #define PWRCU_LVDS_2V15 PWRCU_LVDS_LV3 + #define PWRCU_LVDS_2V35 PWRCU_LVDS_LV4 + #define PWRCU_LVDS_2V55 PWRCU_LVDS_LV5 + #define PWRCU_LVDS_2V75 PWRCU_LVDS_LV6 + #define PWRCU_LVDS_2V95 PWRCU_LVDS_LV7 + #define PWRCU_LVDS_3V15 PWRCU_LVDS_LV8 +#endif +/** + * @brief BOD reset or interrupt selection + */ +typedef enum +{ + PWRCU_BODRIS_RESET = 0, /*!< Reset the whole chip */ + PWRCU_BODRIS_INT = 1, /*!< Assert interrupt */ +} PWRCU_BODRIS_Enum; +/** + * @brief Sleep entry instruction selection + */ +typedef enum +{ + PWRCU_SLEEP_ENTRY_WFE = 0, /*!< Sleep then wait for event */ + PWRCU_SLEEP_ENTRY_WFI /*!< Sleep then wait for interrupt */ +} PWRCU_SLEEP_ENTRY_Enum; +#if (LIBCFG_BAKREG) +/** + * @brief Backup register selection + */ +typedef enum +{ + PWRCU_BAKREG_0 = 0, + PWRCU_BAKREG_1, + PWRCU_BAKREG_2, + PWRCU_BAKREG_3, + PWRCU_BAKREG_4, + PWRCU_BAKREG_5, + PWRCU_BAKREG_6, + PWRCU_BAKREG_7, + PWRCU_BAKREG_8, + PWRCU_BAKREG_9 +} PWRCU_BAKREG_Enum; +#endif +/** + * @brief Vdd15 power good source selection + */ +typedef enum +{ + PWRCU_V15RDYSC_V33ISO = 0, /*!< Vdd15 power good source come from BK_ISO bit in CKCU unit */ + PWRCU_V15RDYSC_V15POR /*!< Vdd15 power good source come from Vdd15 power on reset */ +} PWRCU_V15RDYSC_Enum; +/** + * @brief LDO operation mode selection + */ +typedef enum +{ + PWRCU_LDO_NORMAL = 0, /*!< The LDO is operated in normal current mode */ + PWRCU_LDO_LOWCURRENT /*!< The LDO is operated in low current mode */ +} PWRCU_LDOMODE_Enum; +#if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) +/** + * @brief HSI ready counter bit length selection + */ +typedef enum +{ + PWRCU_HSIRCBL_4 = 0, /*!< 4 bits */ + PWRCU_HSIRCBL_5, /*!< 5 bits */ + PWRCU_HSIRCBL_6, /*!< 5 bits */ + PWRCU_HSIRCBL_7 /*!< 7 bits (Default) */ +} PWRCU_HSIRCBL_Enum; +#endif +#if (LIBCFG_PWRCU_VREG) +/** + * @brief VREG output voltage selection + */ +typedef enum +{ + #if (LIBCFG_PWRCU_VREG_2V5) + PWRCU_VREG_2V5 = 0x08000000, /*!< VREG output voltage is 2.5 V */ + #else + PWRCU_VREG_4V0 = 0x08000000, /*!< VREG output voltage is 4.0 V */ + #endif + PWRCU_VREG_3V3 = 0x00000000, /*!< VREG output voltage is 3.3 V */ + PWRCU_VREG_3V0 = 0x04000000, /*!< VREG output voltage is 3.0 V */ + PWRCU_VREG_1V8 = 0x0C000000, /*!< VREG output voltage is 1.8 V */ +} PWRCU_VREG_VOLT_Enum; +/** + * @brief VREG operation mode + */ +typedef enum +{ + PWRCU_VREG_DISABLE = 0x00000000, /*!< VREG is disabled */ + PWRCU_VREG_ENABLE = 0x01000000, /*!< VREG is enabled */ + PWRCU_VREG_BYPASS = 0x02000000, /*!< VREG is bypassed */ +} PWRCU_VREG_MODE_Enum; +#endif +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Constants PWRCU exported constants + * @{ + */ + +/* Definitions of PWRCU_FLAG */ +#if (!LIBCFG_PWRCU_NO_VDDPORF) +#define PWRCU_FLAG_PWRPOR 0x0001 /*!< VDD power domain power-on reset flag */ +#endif +#if (!LIBCFG_PWRCU_NO_PDF) +#define PWRCU_FLAG_PD 0x0002 /*!< Power-Down flag */ +#endif +#if (LIBCFG_PWRCU_PORF) +#define PWRCU_FLAG_POR 0x0010 /*!< Power-on reset flag */ +#endif +#define PWRCU_FLAG_WUP 0x0100 /*!< External WAKEUP pin flag */ +#define PWRCU_FLAG_WUP0 0x0100 /*!< External WAKEUP0 pin flag */ +#if (LIBCFG_PWRCU_WAKEUP1) +#define PWRCU_FLAG_WUP1 0x0200 /*!< External WAKEUP1 pin flag */ +#endif + +/* check PWRCU_LVDS parameter */ +#define IS_PWRCU_LVDS(x) ((x == PWRCU_LVDS_LV1) || (x == PWRCU_LVDS_LV2) || \ + (x == PWRCU_LVDS_LV3) || (x == PWRCU_LVDS_LV4) || \ + (x == PWRCU_LVDS_LV5) || (x == PWRCU_LVDS_LV6) || \ + (x == PWRCU_LVDS_LV7) || (x == PWRCU_LVDS_LV8)) + +/* check PWRCU_BODRIS parameter */ +#define IS_PWRCU_BODRIS(x) ((x == PWRCU_BODRIS_RESET) || (x == PWRCU_BODRIS_INT)) + +/* check PWRCU_HSIRCBL parameter */ +#define IS_PWRCU_HSIRCBL(x) (x <= 3) + +/* check PWRCU_SLEEP_ENTRY parameter */ +#define IS_PWRCU_SLEEP_ENTRY(x) ((x == PWRCU_SLEEP_ENTRY_WFI) || (x == PWRCU_SLEEP_ENTRY_WFE)) + +/* check PWRCU_BAKREG parameter */ +#define IS_PWRCU_BAKREG(x) (x < 10) + +/* check PWRCU_V15RDY_SRC parameter */ +#define IS_PWRCU_V15RDYSC(x) ((x == PWRCU_V15RDYSC_V33ISO) || (x == PWRCU_V15RDYSC_V15POR)) + +/* check PWRCU_LDOMODE parameter */ +#define IS_PWRCU_LDOMODE(x) ((x == PWRCU_LDO_NORMAL) || (x == PWRCU_LDO_LOWCURRENT)) + +/* check PWRCU_WUP parameter */ +#define IS_PWRCU_WAKEUPPIN(x) (IS_PWRCU_WAKE0(x) || IS_PWRCU_WAKE1(x)) + +#define IS_PWRCU_WAKE0(x) (x == PWRCU_WAKEUP_PIN_0) + +#if (LIBCFG_PWRCU_WAKEUP1) +#define IS_PWRCU_WAKE1(x) (x == PWRCU_WAKEUP_PIN_1) +#else +#define IS_PWRCU_WAKE1(x) (0) +#endif + +/* check PWRCU_WUPTYPE parameter */ +#define IS_PWRCU_TRIGGERTYPE(x) ((x == PWRCU_WUP_POSITIVE_EDGE) || \ + (x == PWRCU_WUP_NEGATIVE_EDGE) || \ + (x == PWRCU_WUP_HIGH_LEVEL) || \ + (x == PWRCU_WUP_LOW_LEVEL)) + +#if (LIBCFG_PWRCU_VREG) +#define IS_PWRCU_VREG_VOLT(x) ((IS_PWRCU_VREG_VOLT_L2(x)) || \ + (x == PWRCU_VREG_3V3) || \ + (x == PWRCU_VREG_3V0) || \ + (x == PWRCU_VREG_1V8)) + +#if (LIBCFG_PWRCU_VREG_2V5) +#define IS_PWRCU_VREG_VOLT_L2(x) (x == PWRCU_VREG_2V5) +#else +#define IS_PWRCU_VREG_VOLT_L2(x) (x == PWRCU_VREG_4V0) +#endif + +#define IS_PWRCU_VREG_MODE(x) ((x == PWRCU_VREG_DISABLE) || \ + (x == PWRCU_VREG_ENABLE) || \ + (x == PWRCU_VREG_BYPASS)) + + +#endif + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Functions PWRCU exported functions + * @{ + */ +void PWRCU_DeInit(void); +#if (!LIBCFG_NO_PWRCU_TEST_REG) +PWRCU_Status PWRCU_CheckReadyAccessed(void); +#endif +u16 PWRCU_GetFlagStatus(void); +#if (LIBCFG_BAKREG) +u32 PWRCU_ReadBackupRegister(PWRCU_BAKREG_Enum BAKREGx); +void PWRCU_WriteBackupRegister(PWRCU_BAKREG_Enum BAKREGx, u32 DATA); +#endif +void PWRCU_Sleep(PWRCU_SLEEP_ENTRY_Enum SleepEntry); +void PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_Enum SleepEntry); +void PWRCU_DeepSleep2(PWRCU_SLEEP_ENTRY_Enum SleepEntry); +#if !defined(USE_HT32F52220_30) +void PWRCU_DeepSleep2Ex(PWRCU_SLEEP_ENTRY_Enum SleepEntry); +#endif +#if (!LIBCFG_PWRCU_NO_PD_MODE) +void PWRCU_PowerDown(void); +#endif +void PWRCU_SetLVDS(PWRCU_LVDS_Enum Level); +void PWRCU_LDOConfig(PWRCU_LDOMODE_Enum Sel); +void PWRCU_LVDCmd(ControlStatus NewState); +void PWRCU_BODCmd(ControlStatus NewState); +void PWRCU_BODRISConfig(PWRCU_BODRIS_Enum Selection); +FlagStatus PWRCU_GetLVDFlagStatus(void); +FlagStatus PWRCU_GetBODFlagStatus(void); +PWRCU_DMOSStatus PWRCU_GetDMOSStatus(void); +void PWRCU_DMOSCmd(ControlStatus NewState); +#if (LIBCFG_PWRCU_V15_READY_SOURCE) +void PWRCU_V15RDYSourceConfig(PWRCU_V15RDYSC_Enum Sel); +#endif +void PWRCU_LVDIntWakeupConfig(ControlStatus NewState); +void PWRCU_LVDEventWakeupConfig(ControlStatus NewState); +#if (LIBCFG_PWRCU_VREG) +void PWRCU_SetVREG(PWRCU_VREG_VOLT_Enum Volt); +void PWRCU_VREGConfig(PWRCU_VREG_MODE_Enum Mode); +#endif +void PWRCU_WakeupPinCmd(ControlStatus NewState); +#if (LIBCFG_PWRCU_WAKEUP_V01) +void PWRCU_WakeupMultiPinCmd(PWRCU_WUP_Enum Pin, PWRCU_WUPTYPE_Enum Type, ControlStatus NewState); +#endif +#if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) +void PWRCU_HSIReadyCounterBitLengthConfig(PWRCU_HSIRCBL_Enum BitLength); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rstcu.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rstcu.h new file mode 100644 index 0000000000..60eabde780 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rstcu.h @@ -0,0 +1,238 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_rstcu.h + * @version $Rev:: 7115 $ + * @date $Date:: 2023-08-11 #$ + * @brief The header file of the Reset Control Unit library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_RSTCU_H +#define __HT32F5XXXX_RSTCU_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup RSTCU + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Types RSTCU exported types + * @{ + */ + +/** + * @brief Enumeration of Global reset status. + */ +typedef enum +{ + RSTCU_FLAG_SYSRST = 0, + RSTCU_FLAG_EXTRST, + RSTCU_FLAG_WDTRST, + RSTCU_FLAG_PORST +} RSTCU_RSTF_TypeDef; + +/** + * @brief Definition of initial structure of peripheral reset. + */ +typedef union +{ + struct + { + /* Definitions of AHB peripheral reset */ + unsigned long PDMA :1; // Bit 0 + unsigned long :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long :1; // Bit 4 + unsigned long USBD :1; // Bit 5 + unsigned long EBI :1; // Bit 6 + unsigned long CRC :1; // Bit 7 + + unsigned long PA :1; // Bit 8 + unsigned long PB :1; // Bit 9 + unsigned long PC :1; // Bit 10 + unsigned long PD :1; // Bit 11 + unsigned long PE :1; // Bit 12 + unsigned long PF :1; // Bit 13 + unsigned long :1; // Bit 14 + unsigned long AES :1; // Bit 15 + + #ifdef USE_HT32F65230_40 + unsigned long DIV :1; // Bit 16 + #else + unsigned long :1; // Bit 16 + #endif + unsigned long :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 + unsigned long :1; // Bit 22 + unsigned long :1; // Bit 23 + + #ifndef USE_HT32F65230_40 + unsigned long DIV :1; // Bit 24 + #else + unsigned long :1; // Bit 24 + #endif + unsigned long QSPI :1; // Bit 25 + unsigned long RF :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long :1; // Bit 28 + unsigned long :1; // Bit 29 + unsigned long :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB peripheral 0 reset */ + unsigned long I2C0 :1; // Bit 0 + unsigned long I2C1 :1; // Bit 1 + unsigned long I2C2 :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long SPI0 :1; // Bit 4 + unsigned long SPI1 :1; // Bit 5 + unsigned long :1; // Bit 6 + unsigned long :1; // Bit 7 + + unsigned long USART0 :1; // Bit 8 + unsigned long USART1 :1; // Bit 9 + unsigned long UART0 :1; // Bit 10 + unsigned long UART1 :1; // Bit 11 + unsigned long UART2 :1; // Bit 12 + unsigned long UART3 :1; // Bit 13 + unsigned long AFIO :1; // Bit 14 + unsigned long EXTI :1; // Bit 15 + + unsigned long :1; // Bit 16 + unsigned long :1; // Bit 17 + unsigned long :1; // Bit 18 + unsigned long :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long :1; // Bit 21 + unsigned long SLED0 :1; // Bit 22 + unsigned long SLED1 :1; // Bit 23 + + unsigned long SCI0 :1; // Bit 24 + unsigned long I2S :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long SCI1 :1; // Bit 27 + unsigned long MIDI :1; // Bit 28 + unsigned long LEDC :1; // Bit 29 + unsigned long CAN0 :1; // Bit 30 + unsigned long :1; // Bit 31 + + /* Definitions of APB peripheral 1 reset */ + unsigned long MCTM0 :1; // Bit 0 + unsigned long :1; // Bit 1 + unsigned long :1; // Bit 2 + unsigned long :1; // Bit 3 + unsigned long WDT :1; // Bit 4 + unsigned long :1; // Bit 5 + unsigned long :1; // Bit 6 + unsigned long DAC1 :1; // Bit 7 + + unsigned long GPTM0 :1; // Bit 8 + unsigned long GPTM1 :1; // Bit 9 + unsigned long :1; // Bit 10 + unsigned long :1; // Bit 11 + unsigned long PWM0 :1; // Bit 12 + unsigned long PWM1 :1; // Bit 13 + unsigned long PWM2 :1; // Bit 14 + unsigned long :1; // Bit 15 + + unsigned long BFTM0 :1; // Bit 16 + unsigned long BFTM1 :1; // Bit 17 + unsigned long TKEY :1; // Bit 18 + unsigned long LCD :1; // Bit 19 + unsigned long :1; // Bit 20 + unsigned long DAC0 :1; // Bit 21 + unsigned long CMP :1; // Bit 22 + unsigned long OPA :1; // Bit 23 + + unsigned long ADC0 :1; // Bit 24 + unsigned long ADC1 :1; // Bit 25 + unsigned long :1; // Bit 26 + unsigned long :1; // Bit 27 + unsigned long SCTM0 :1; // Bit 28 + unsigned long SCTM1 :1; // Bit 29 + unsigned long SCTM2 :1; // Bit 30 + unsigned long SCTM3 :1; // Bit 31 + } Bit; + u32 Reg[3]; +} RSTCU_PeripReset_TypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Constants RSTCU exported constants + * @{ + */ + +/* Other definitions */ +#define IS_RSTCU_FLAG(FLAG) ((FLAG == RSTCU_FLAG_SYSRST) || \ + (FLAG == RSTCU_FLAG_EXTRST) || \ + (FLAG == RSTCU_FLAG_WDTRST) || \ + (FLAG == RSTCU_FLAG_PORST)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Functions RSTCU exported functions + * @{ + */ +FlagStatus RSTCU_GetResetFlagStatus(RSTCU_RSTF_TypeDef RSTCU_RSTF); +void RSTCU_ClearResetFlag(RSTCU_RSTF_TypeDef RSTCU_RSTF); +void RSTCU_ClearAllResetFlag(void); +void RSTCU_PeripReset(RSTCU_PeripReset_TypeDef Reset, ControlStatus Cmd); + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rtc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rtc.h new file mode 100644 index 0000000000..0677ae6717 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_rtc.h @@ -0,0 +1,255 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_rtc.h + * @version $Rev:: 7278 $ + * @date $Date:: 2023-10-04 #$ + * @brief The header file of the RTC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_RTC_H +#define __HT32F5XXXX_RTC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup RTC + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Types RTC exported types + * @{ + */ + +/** + * @brief Selection of RTC clock source + */ +typedef enum +{ + RTC_SRC_LSI = 0, /*!< Low speed internal clock, about 32 kHz */ + #if (LIBCFG_LSE) + RTC_SRC_LSE /*!< Low speed external 32768 Hz clock */ + #endif +} RTC_SRC_Enum; +/** + * @brief Selection of RTC LSE startup mode + */ +typedef enum +{ + RTC_LSESM_NORMAL = 0, /*!< Little power consumption but longer startup time. */ + RTC_LSESM_FAST /*!< Shortly startup time but higher power consumption. */ +} RTC_LSESM_Enum; +/** + * @brief Selection of RTC prescaler + */ +typedef enum +{ + RTC_RPRE_1 = 0x0000, /*!< CK_SECOND = CK_RTC */ + RTC_RPRE_2 = 0x0100, /*!< CK_SECOND = CK_RTC / 2 */ + RTC_RPRE_4 = 0x0200, /*!< CK_SECOND = CK_RTC / 4 */ + RTC_RPRE_8 = 0x0300, /*!< CK_SECOND = CK_RTC / 8 */ + RTC_RPRE_16 = 0x0400, /*!< CK_SECOND = CK_RTC / 16 */ + RTC_RPRE_32 = 0x0500, /*!< CK_SECOND = CK_RTC / 32 */ + RTC_RPRE_64 = 0x0600, /*!< CK_SECOND = CK_RTC / 64 */ + RTC_RPRE_128 = 0x0700, /*!< CK_SECOND = CK_RTC / 128 */ + RTC_RPRE_256 = 0x0800, /*!< CK_SECOND = CK_RTC / 256 */ + RTC_RPRE_512 = 0x0900, /*!< CK_SECOND = CK_RTC / 512 */ + RTC_RPRE_1024 = 0x0A00, /*!< CK_SECOND = CK_RTC / 1024 */ + RTC_RPRE_2048 = 0x0B00, /*!< CK_SECOND = CK_RTC / 2048 */ + RTC_RPRE_4096 = 0x0C00, /*!< CK_SECOND = CK_RTC / 4096 */ + RTC_RPRE_8192 = 0x0D00, /*!< CK_SECOND = CK_RTC / 8192 */ + RTC_RPRE_16384 = 0x0E00, /*!< CK_SECOND = CK_RTC / 16384 */ + RTC_RPRE_32768 = 0x0F00 /*!< CK_SECOND = CK_RTC / 32768 */ +} RTC_RPRE_Enum; +/** + * @brief Active polarity of RTC output + */ +typedef enum +{ + RTC_ROAP_HIGH = 0, /*!< Active level is high */ + RTC_ROAP_LOW /*!< Active level is low */ +} RTC_ROAP_Enum; +/** + * @brief Waveform mode of RTC output + */ +typedef enum +{ + RTC_ROWM_PULSE = 0, /*!< Pulse mode. */ + RTC_ROWM_LEVEL /*!< Level mode. */ +} RTC_ROWM_Enum; +/** + * @brief Waveform mode of RTC output + */ +typedef enum +{ + RTC_ROES_MATCH = 0, /*!< Selected RTC compare match. */ + RTC_ROES_SECOND /*!< Selected RTC second clock. */ +} RTC_ROES_Enum; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Constants RTC exported constants + * @{ + */ + +/** @defgroup RTC_WAKEUP Selection of RTC wakeup source + * @{ + */ +#define RTC_WAKEUP_CSEC 0x00000100 +#define RTC_WAKEUP_CM 0x00000200 +#define RTC_WAKEUP_OV 0x00000400 +/** + * @} + */ + +/** @defgroup RTC_IT RTC Selection of interrupt source + * @{ + */ +#define RTC_INT_CSEC 0x00000001 +#define RTC_INT_CM 0x00000002 +#define RTC_INT_OV 0x00000004 +/** + * @} + */ + +/** @defgroup RTC_FLAG RTC Definitions of flags + * @{ + */ +#define RTC_FLAG_CSEC 0x00000001 +#define RTC_FLAG_CM 0x00000002 +#define RTC_FLAG_OV 0x00000004 +/** + * @} + */ + +/** @defgroup RTC_Check_Parameter Selection of Vdd18 power good + * @{ + */ + +/** + * @brief Used to check RTC_SRC_Enum parameter + */ +#if (LIBCFG_LSE) +#define IS_RTC_SRC_LSE(x) (x == RTC_SRC_LSE) +#else +#define IS_RTC_SRC_LSE(x) (0) +#endif +#define IS_RTC_SRC(x) ((x == RTC_SRC_LSI) || IS_RTC_SRC_LSE(x)) +/** + * @brief Used to check RTC_LSESM_Enum parameter + */ +#define IS_RTC_LSESM(x) ((x == RTC_LSESM_NORMAL) || (x == RTC_LSESM_FAST)) +/** + * @brief Used to check RTC_RPRE_Enum parameter + */ +#define IS_RTC_PSC(x) ((x == RTC_RPRE_1) || (x == RTC_RPRE_2) || (x == RTC_RPRE_4) ||\ + (x == RTC_RPRE_8) || (x == RTC_RPRE_16) || (x == RTC_RPRE_32) ||\ + (x == RTC_RPRE_64) || (x == RTC_RPRE_128) || (x == RTC_RPRE_256) ||\ + (x == RTC_RPRE_512) || (x == RTC_RPRE_1024) || (x == RTC_RPRE_2048) ||\ + (x == RTC_RPRE_4096) || (x == RTC_RPRE_8192) || (x == RTC_RPRE_16384) ||\ + (x == RTC_RPRE_32768)) +/** + * @brief Used to check RTC_ROAP_Enum parameter + */ +#define IS_RTC_ROAP(x) ((x == RTC_ROAP_HIGH) || (x == RTC_ROAP_LOW)) +/** + * @brief Used to check RTC_ROWM_Enum parameter + */ +#define IS_RTC_ROWM(x) ((x == RTC_ROWM_PULSE) || (x == RTC_ROWM_LEVEL)) +/** + * @brief Used to check RTC_ROES_Enum parameter + */ +#define IS_RTC_ROES(x) ((x == RTC_ROES_MATCH) || (x == RTC_ROES_SECOND)) +/** + * @brief Used to check RTC_WAKEUP parameter + */ +#define IS_RTC_WAKEUP(x) ((((x) & (u32)0xFFFFF8FF) == 0x00) && ((x) != 0x00)) +/** + * @brief Used to check RTC_INT parameter + */ +#define IS_RTC_INT(x) ((((x) & (u32)0xFFFFFFF8) == 0x00) && ((x) != 0x00)) +/** + * @brief Used to check RTC_FLAG parameter + */ +#define IS_RTC_FLAG(x) ((((x) & (u32)0xFFFFFFF8) == 0x00) && ((x) != 0x00)) +/** + * @} + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Functions RTC exported functions + * @{ + */ +void RTC_DeInit(void); +void RTC_ClockSourceConfig(RTC_SRC_Enum Source); +#if (LIBCFG_RTC_LSI_LOAD_TRIM) +void RTC_LSILoadTrimData(void); +#endif +void RTC_LSESMConfig(RTC_LSESM_Enum Mode); +void RTC_LSECmd(ControlStatus NewState); +void RTC_CMPCLRCmd(ControlStatus NewState); +void RTC_SetPrescaler(RTC_RPRE_Enum Psc); +u16 RTC_GetPrescaler(void); +void RTC_Cmd(ControlStatus NewState); +u32 RTC_GetCounter(void); +void RTC_SetCompare(u32 Compare); +u32 RTC_GetCompare(void); +void RTC_WakeupConfig(u32 RTC_WAKEUP, ControlStatus NewState); +void RTC_IntConfig(u32 RTC_INT, ControlStatus NewState); +u8 RTC_GetFlagStatus(void); +void RTC_OutConfig(RTC_ROWM_Enum WMode, RTC_ROES_Enum EventSel, RTC_ROAP_Enum Pol); +void RTC_OutCmd(ControlStatus NewState); +FlagStatus RTC_GetOutStatus(void); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sci.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sci.h new file mode 100644 index 0000000000..b95ff72343 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sci.h @@ -0,0 +1,280 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_sci.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The header file of the SCI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_SCI_H +#define __HT32F5XXXX_SCI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup SCI + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Types SCI exported types + * @{ + */ +typedef struct +{ + u32 SCI_Mode; + u32 SCI_Retry; + u32 SCI_Convention; + u32 SCI_CardPolarity; + u32 SCI_ClockPrescale; +} SCI_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Constants SCI exported constants + * @{ + */ +#define SCI_MODE_MANUAL ((u32)0x00000000) +#define SCI_MODE_SCI ((u32)0x00000008) + +#define IS_SCI_MODE(MODE) ((MODE == SCI_MODE_MANUAL) || \ + (MODE == SCI_MODE_SCI)) + + +#define SCI_RETRY_NO ((u32)0x00000000) +#define SCI_RETRY_4 ((u32)0x00000012) +#define SCI_RETRY_5 ((u32)0x00000002) + +#define IS_SCI_RETRY(RETRY) ((RETRY == SCI_RETRY_NO) || \ + (RETRY == SCI_RETRY_4) || \ + (RETRY == SCI_RETRY_5)) + + +#define SCI_CONVENTION_DIRECT ((u32)0x00000000) +#define SCI_CONVENTION_INVERSE ((u32)0x00000001) + +#define IS_SCI_CONVENTION(CONVENTION) ((CONVENTION == SCI_CONVENTION_DIRECT) || \ + (CONVENTION == SCI_CONVENTION_INVERSE)) + + +#define SCI_CARDPOLARITY_LOW ((u32)0x00000000) +#define SCI_CARDPOLARITY_HIGH ((u32)0x00000040) + +#define IS_SCI_CARD_POLARITY(POLARITY) ((POLARITY == SCI_CARDPOLARITY_LOW) || \ + (POLARITY == SCI_CARDPOLARITY_HIGH)) + + +#define SCI_CLKPRESCALER_1 ((u32)0x00000000) +#define SCI_CLKPRESCALER_2 ((u32)0x00000001) +#define SCI_CLKPRESCALER_4 ((u32)0x00000002) +#define SCI_CLKPRESCALER_6 ((u32)0x00000003) +#define SCI_CLKPRESCALER_8 ((u32)0x00000004) +#define SCI_CLKPRESCALER_10 ((u32)0x00000005) +#define SCI_CLKPRESCALER_12 ((u32)0x00000006) +#define SCI_CLKPRESCALER_14 ((u32)0x00000007) +#define SCI_CLKPRESCALER_16 ((u32)0x00000008) +#define SCI_CLKPRESCALER_18 ((u32)0x00000009) +#define SCI_CLKPRESCALER_20 ((u32)0x0000000A) +#define SCI_CLKPRESCALER_22 ((u32)0x0000000B) +#define SCI_CLKPRESCALER_24 ((u32)0x0000000C) +#define SCI_CLKPRESCALER_26 ((u32)0x0000000D) +#define SCI_CLKPRESCALER_28 ((u32)0x0000000E) +#define SCI_CLKPRESCALER_30 ((u32)0x0000000F) +#define SCI_CLKPRESCALER_32 ((u32)0x00000010) +#define SCI_CLKPRESCALER_34 ((u32)0x00000011) +#define SCI_CLKPRESCALER_36 ((u32)0x00000012) +#define SCI_CLKPRESCALER_38 ((u32)0x00000013) +#define SCI_CLKPRESCALER_40 ((u32)0x00000014) +#define SCI_CLKPRESCALER_42 ((u32)0x00000015) +#define SCI_CLKPRESCALER_44 ((u32)0x00000016) +#define SCI_CLKPRESCALER_46 ((u32)0x00000017) +#define SCI_CLKPRESCALER_48 ((u32)0x00000018) +#define SCI_CLKPRESCALER_50 ((u32)0x00000019) +#define SCI_CLKPRESCALER_52 ((u32)0x0000001A) +#define SCI_CLKPRESCALER_54 ((u32)0x0000001B) +#define SCI_CLKPRESCALER_56 ((u32)0x0000001C) +#define SCI_CLKPRESCALER_58 ((u32)0x0000001D) +#define SCI_CLKPRESCALER_60 ((u32)0x0000001E) +#define SCI_CLKPRESCALER_62 ((u32)0x0000001F) +#define SCI_CLKPRESCALER_64 ((u32)0x00000020) +#define SCI_CLKPRESCALER_66 ((u32)0x00000021) +#define SCI_CLKPRESCALER_68 ((u32)0x00000022) +#define SCI_CLKPRESCALER_70 ((u32)0x00000023) +#define SCI_CLKPRESCALER_72 ((u32)0x00000024) +#define SCI_CLKPRESCALER_74 ((u32)0x00000025) +#define SCI_CLKPRESCALER_76 ((u32)0x00000026) +#define SCI_CLKPRESCALER_78 ((u32)0x00000027) +#define SCI_CLKPRESCALER_80 ((u32)0x00000028) +#define SCI_CLKPRESCALER_82 ((u32)0x00000029) +#define SCI_CLKPRESCALER_84 ((u32)0x0000002A) +#define SCI_CLKPRESCALER_86 ((u32)0x0000002B) +#define SCI_CLKPRESCALER_88 ((u32)0x0000002C) +#define SCI_CLKPRESCALER_90 ((u32)0x0000002D) +#define SCI_CLKPRESCALER_92 ((u32)0x0000002E) +#define SCI_CLKPRESCALER_94 ((u32)0x0000002F) +#define SCI_CLKPRESCALER_96 ((u32)0x00000030) +#define SCI_CLKPRESCALER_98 ((u32)0x00000031) +#define SCI_CLKPRESCALER_100 ((u32)0x00000032) +#define SCI_CLKPRESCALER_102 ((u32)0x00000033) +#define SCI_CLKPRESCALER_104 ((u32)0x00000034) +#define SCI_CLKPRESCALER_106 ((u32)0x00000035) +#define SCI_CLKPRESCALER_108 ((u32)0x00000036) +#define SCI_CLKPRESCALER_110 ((u32)0x00000037) +#define SCI_CLKPRESCALER_112 ((u32)0x00000038) +#define SCI_CLKPRESCALER_114 ((u32)0x00000039) +#define SCI_CLKPRESCALER_116 ((u32)0x0000003A) +#define SCI_CLKPRESCALER_118 ((u32)0x0000003B) +#define SCI_CLKPRESCALER_120 ((u32)0x0000003C) +#define SCI_CLKPRESCALER_122 ((u32)0x0000003D) +#define SCI_CLKPRESCALER_124 ((u32)0x0000003E) +#define SCI_CLKPRESCALER_126 ((u32)0x0000003F) + +#define IS_SCI_CLOCK_PRESCALER(PRESCALER) (PRESCALER <= 0x3F) + + +#define SCI_COMPENSATION_ENABLE ((u32)0x00008000) +#define SCI_COMPENSATION_DISABLE ((u32)0x00000000) + +#define IS_SCI_ETU_COMPENSATION(COMPENSATION) ((COMPENSATION == SCI_COMPENSATION_ENABLE) || \ + (COMPENSATION == SCI_COMPENSATION_DISABLE)) + + +#define SCI_CLK_HARDWARE ((u32)0x00000080) +#define SCI_CLK_SOFTWARE ((u32)0xFFFFFF7F) + +#define IS_SCI_CLK_MODE(MODE) ((MODE == SCI_CLK_HARDWARE) || \ + (MODE == SCI_CLK_SOFTWARE)) + + +#define SCI_CLK_HIGH ((u32)0x00000004) +#define SCI_CLK_LOW ((u32)0xFFFFFFFB) + +#define IS_SCI_CLK(CLK) ((CLK == SCI_CLK_HIGH) || \ + (CLK == SCI_CLK_LOW)) + + +#define SCI_DIO_HIGH ((u32)0x00000008) +#define SCI_DIO_LOW ((u32)0xFFFFFFF7) + +#define IS_SCI_DIO(DIO) ((DIO == SCI_DIO_HIGH) || \ + (DIO == SCI_DIO_LOW)) + + +#define SCI_INT_PAR ((u32)0x00000001) +#define SCI_INT_RXC ((u32)0x00000002) +#define SCI_INT_TXC ((u32)0x00000004) +#define SCI_INT_WT ((u32)0x00000008) +#define SCI_INT_CARD ((u32)0x00000040) +#define SCI_INT_TXBE ((u32)0x00000080) +#define SCI_INT_ALL ((u32)0x000000CF) + +#define IS_SCI_INT(INT) (((INT & 0xFFFFFF30) == 0x0) && (INT != 0)) + + + +#define SCI_FLAG_PAR ((u32)0x00000001) +#define SCI_FLAG_RXC ((u32)0x00000002) +#define SCI_FLAG_TXC ((u32)0x00000004) +#define SCI_FLAG_WT ((u32)0x00000008) +#define SCI_FLAG_CARD ((u32)0x00000040) +#define SCI_FLAG_TXBE ((u32)0x00000080) + +#define IS_SCI_FLAG(FLAG) ((FLAG == SCI_FLAG_PAR) || \ + (FLAG == SCI_FLAG_RXC) || \ + (FLAG == SCI_FLAG_TXC) || \ + (FLAG == SCI_FLAG_WT) || \ + (FLAG == SCI_FLAG_CARD) || \ + (FLAG == SCI_FLAG_TXBE)) + +#define IS_SCI_CLEAR_FLAG(FLAG) ((FLAG == SCI_FLAG_PAR) || \ + (FLAG == SCI_FLAG_TXC) || \ + (FLAG == SCI_FLAG_WT)) + + +#define SCI_PDMAREQ_TX ((u32)0x00000100) +#define SCI_PDMAREQ_RX ((u32)0x00000200) + +#define IS_SCI_PDMA_REQ(REQ) (((REQ & 0xFFFFFCFF) == 0x0) && (REQ != 0)) + + +#define IS_SCI_ETU(ETU) ((ETU >= 12) & (ETU <= 2047)) + +#define IS_SCI_GUARDTIME(GUARDTIME) ((GUARDTIME >= 11) & (GUARDTIME <= 511)) + +#define IS_SCI_WAITING_TIME(TIME) ((TIME >= 372) & (TIME <= 16777215)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Functions SCI exported functions + * @{ + */ +void SCI_DeInit(HT_SCI_TypeDef* SCIx); +void SCI_Init(HT_SCI_TypeDef* SCIx, SCI_InitTypeDef* SCI_InitStruct); +void SCI_StructInit(SCI_InitTypeDef* SCI_InitStruct); +void SCI_Cmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState); +void SCI_ETUConfig(HT_SCI_TypeDef* SCIx, u32 SCI_ETU, u32 SCI_Compensation); +void SCI_SetGuardTimeValue(HT_SCI_TypeDef* SCIx, u16 SCI_GuardTime); +void SCI_SetWaitingTimeValue(HT_SCI_TypeDef* SCIx, u32 SCI_WaitingTime); +void SCI_WaitingTimeCounterCmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState); +void SCI_SendData(HT_SCI_TypeDef* SCIx, u8 SCI_Data); +u8 SCI_ReceiveData(HT_SCI_TypeDef* SCIx); +void SCI_ClockModeConfig(HT_SCI_TypeDef* SCIx, u32 SCI_CLKMode); +void SCI_SoftwareClockCmd(HT_SCI_TypeDef* SCIx, u32 SCI_CLK); +void SCI_OutputDIO(HT_SCI_TypeDef* SCIx, u32 SCI_DIO); +void SCI_IntConfig(HT_SCI_TypeDef* SCIx, u32 SCI_Int, ControlStatus NewState); +FlagStatus SCI_GetFlagStatus(HT_SCI_TypeDef* SCIx, u32 SCI_Flag); +void SCI_ClearFlag(HT_SCI_TypeDef* SCIx, u32 SCI_Flag); +#if (LIBCFG_PDMA) +void SCI_PDMACmd(HT_SCI_TypeDef* SCIx, u32 SCI_PDMAREQ, ControlStatus NewState); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sled.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sled.h new file mode 100644 index 0000000000..15a57294ca --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_sled.h @@ -0,0 +1,157 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_sled.h + * @version $Rev:: 3875 $ + * @date $Date:: 2019-05-10 #$ + * @brief The header file of the SLED library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_SLED_H +#define __HT32F5XXXX_SLED_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup SLED + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup SLED_Exported_Types SLED exported types + * @{ + */ + +/** + * @brief Enumeration of CK_SLED prescaler. + */ +typedef enum +{ + SLED_CLKPRE_DIV1 = 0, + SLED_CLKPRE_DIV2, + SLED_CLKPRE_DIV4, + SLED_CLKPRE_DIV3 +} SLED_CLKPRE_TypeDef; + +/** + * @brief Definition of SLED Init Structure. + */ +typedef struct +{ + u8 ClockPrescaler; + u8 BaudRate; + u8 T0H; + u8 T1H; + u8 TRST; + u8 SyncState; + u8 IdleState; + u8 ResetState; + u8 SyncMode; + u8 OutputPolarity; +} SLED_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup SLED_Exported_Constants SLED exported constants + * @{ + */ +#define SLED_SYNC_STATE_T0 (0) +#define SLED_SYNC_STATE_T1 (1) + +#define SLED_IDLE_STATE_LOW (0) +#define SLED_IDLE_STATE_HIGH (1) + +#define SLED_RESET_STATE_LOW (0) +#define SLED_RESET_STATE_HIGH (1) + +#define SLED_SYNC_MODE_DISABLE (0) +#define SLED_SYNC_MODE_ENABLE (1) + +#define SLED_OUTPUT_NONINVERTING (0) +#define SLED_OUTPUT_INVERTING (1) + +#define SLED_FIFO_LEVEL_0 (0 << 6) +#define SLED_FIFO_LEVEL_1 (1 << 6) +#define SLED_FIFO_LEVEL_2 (2 << 6) +#define SLED_FIFO_LEVEL_3 (3 << 6) + +#define IS_SLED_FIFO_LEVEL(LEVEL) ((LEVEL == SLED_FIFO_LEVEL_0) || \ + (LEVEL == SLED_FIFO_LEVEL_1) || \ + (LEVEL == SLED_FIFO_LEVEL_2) || \ + (LEVEL == SLED_FIFO_LEVEL_3)) + +#define IS_SLED(SLED) ((SLED == HT_SLED0) || (SLED == HT_SLED1)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SLED_Exported_Functions SLED exported functions + * @{ + */ +void SLED_DeInit(HT_SLED_TypeDef* SLEDx); +void SLED_Init(HT_SLED_TypeDef* SLEDx, SLED_InitTypeDef* SLED_InitStruct); + +void SLED_Cmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); +void SLED_OutputCmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); +void SLED_PDMACmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); + +void SLED_IntCmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); +void SLED_ClearIntFlag(HT_SLED_TypeDef* SLEDx); + +void SLED_InsertResetCode(HT_SLED_TypeDef* SLEDx); +FlagStatus SLED_GetResetCodeStatus(HT_SLED_TypeDef* SLEDx); + +FlagStatus SLED_GetBusyStatus(HT_SLED_TypeDef* SLEDx); + +void SLED_FIFOTrigLevelConfig(HT_SLED_TypeDef* SLEDx, u8 FifoLevel); +u8 SLED_GetFIFOStatus(HT_SLED_TypeDef* SLEDx); +void SLED_FIFOReset(HT_SLED_TypeDef* SLEDx); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi.h new file mode 100644 index 0000000000..b92fb0d006 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi.h @@ -0,0 +1,375 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_spi.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The header file of the SPI library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_SPI_H +#define __HT32F5XXXX_SPI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup SPI + * @{ + */ + + +#if (LIBCFG_MIDI) +#include "ht32f5xxxx_spi_midi.h" +#endif + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Types SPI exported types + * @{ + */ + +#if (LIBCFG_SPI_DATA_LENGTH_V01) +typedef u8 SPI_DataTypeDef; +#else +typedef u16 SPI_DataTypeDef; +#endif + +#if (LIBCFG_SPI_TIMEOUT_LENGTH_V01) +typedef u8 SPI_TimeoutTypeDef; +#else +typedef u16 SPI_TimeoutTypeDef; +#endif + +typedef struct +{ + u32 SPI_Mode; + u32 SPI_FIFO; + u32 SPI_DataLength; + u32 SPI_SELMode; + u32 SPI_SELPolarity; + u32 SPI_CPOL; + u32 SPI_CPHA; + u32 SPI_FirstBit; + u32 SPI_RxFIFOTriggerLevel; + u32 SPI_TxFIFOTriggerLevel; + u32 SPI_ClockPrescaler; +} SPI_InitTypeDef; + +/** + * @brief Enumeration of SIO direction. + */ +#if (LIBCFG_QSPI) +typedef enum +{ + SIO_DIR_IN = 0, /*!< input mode */ + SIO_DIR_OUT /*!< output mode */ +} SIO_DIR_Enum; +#endif +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Constants SPI exported constants + * @{ + */ +#define SPI_FIFO_ENABLE ((u32)0x00000400) +#define SPI_FIFO_DISABLE ((u32)0x00000000) + +#define IS_SPI_FIFO_SET(FIFO) ((FIFO == SPI_FIFO_ENABLE) || \ + (FIFO == SPI_FIFO_DISABLE)) + +#define SPI_DATALENGTH_1 ((u32)0x00000001) +#define SPI_DATALENGTH_2 ((u32)0x00000002) +#define SPI_DATALENGTH_3 ((u32)0x00000003) +#define SPI_DATALENGTH_4 ((u32)0x00000004) +#define SPI_DATALENGTH_5 ((u32)0x00000005) +#define SPI_DATALENGTH_6 ((u32)0x00000006) +#define SPI_DATALENGTH_7 ((u32)0x00000007) + +#if (LIBCFG_SPI_DATA_LENGTH_V01) +#define SPI_DATALENGTH_8 ((u32)0x00000000) + +#define IS_SPI_DATALENGTH(DATALENGTH) ((DATALENGTH <= 0x07)) +#else +#define SPI_DATALENGTH_8 ((u32)0x00000008) +#define SPI_DATALENGTH_9 ((u32)0x00000009) +#define SPI_DATALENGTH_10 ((u32)0x0000000A) +#define SPI_DATALENGTH_11 ((u32)0x0000000B) +#define SPI_DATALENGTH_12 ((u32)0x0000000C) +#define SPI_DATALENGTH_13 ((u32)0x0000000D) +#define SPI_DATALENGTH_14 ((u32)0x0000000E) +#define SPI_DATALENGTH_15 ((u32)0x0000000F) +#define SPI_DATALENGTH_16 ((u32)0x00000000) + +#define IS_SPI_DATALENGTH(DATALENGTH) ((DATALENGTH <= 0xF)) +#endif + +#define SPI_MASTER ((u32)0x00004000) +#define SPI_SLAVE ((u32)0x00000000) + +#define IS_SPI_MODE(MODE) ((MODE == SPI_MASTER) || \ + (MODE == SPI_SLAVE)) + + +#define SPI_SEL_HARDWARE ((u32)0x00002000) +#define SPI_SEL_SOFTWARE ((u32)0x00000000) + +#define IS_SPI_SEL_MODE(SELMODE) ((SELMODE == SPI_SEL_HARDWARE) || \ + (SELMODE == SPI_SEL_SOFTWARE)) + + +#define SPI_SEL_ACTIVE ((u32)0x00000010) +#define SPI_SEL_INACTIVE ((u32)0xFFFFFFEF) + +#define IS_SPI_SOFTWARE_SEL(SEL) ((SEL == SPI_SEL_ACTIVE) || \ + (SEL == SPI_SEL_INACTIVE)) + + +#define SPI_SELPOLARITY_HIGH ((u32)0x00000800) +#define SPI_SELPOLARITY_LOW ((u32)0x00000000) + +#define IS_SPI_SEL_POLARITY(POLARITY) ((POLARITY == SPI_SELPOLARITY_HIGH) || \ + (POLARITY == SPI_SELPOLARITY_LOW)) + + +#define SPI_CPOL_HIGH ((u32)0x00000400) +#define SPI_CPOL_LOW ((u32)0x00000000) + +#define IS_SPI_CPOL(CPOL) ((CPOL == SPI_CPOL_HIGH) || \ + (CPOL == SPI_CPOL_LOW)) + + +#define SPI_CPHA_FIRST ((u32)0x00000000) +#define SPI_CPHA_SECOND ((u32)0x00000001) + +#define IS_SPI_CPHA(CPHA) ((CPHA == SPI_CPHA_FIRST) || \ + (CPHA == SPI_CPHA_SECOND)) + + +#define SPI_FIRSTBIT_LSB ((u32)0x00001000) +#define SPI_FIRSTBIT_MSB ((u32)0x00000000) + +#define IS_SPI_FIRST_BIT(BIT) ((BIT == SPI_FIRSTBIT_LSB) || \ + (BIT == SPI_FIRSTBIT_MSB)) + + +#define SPI_FLAG_TXBE ((u32)0x00000001) +#define SPI_FLAG_TXE ((u32)0x00000002) +#define SPI_FLAG_RXBNE ((u32)0x00000004) +#define SPI_FLAG_WC ((u32)0x00000008) +#define SPI_FLAG_RO ((u32)0x00000010) +#if (LIBCFG_SPI_NO_MULTI_MASTER) +#define IS_FLAG_MF(x) (0) +#else +#define SPI_FLAG_MF ((u32)0x00000020) +#define IS_FLAG_MF(x) (x == SPI_FLAG_MF) +#endif +#define SPI_FLAG_SA ((u32)0x00000040) +#define SPI_FLAG_TOUT ((u32)0x00000080) +#define SPI_FLAG_BUSY ((u32)0x00000100) + +#define IS_SPI_FLAG(FLAG) ((FLAG == SPI_FLAG_TXBE) || \ + (FLAG == SPI_FLAG_TXE) || \ + (FLAG == SPI_FLAG_RXBNE) || \ + (FLAG == SPI_FLAG_WC) || \ + (FLAG == SPI_FLAG_RO) || \ + IS_FLAG_MF(FLAG) || \ + (FLAG == SPI_FLAG_SA) || \ + (FLAG == SPI_FLAG_TOUT) || \ + (FLAG == SPI_FLAG_BUSY)) + +#define IS_SPI_FLAG_CLEAR(CLEAR) ((CLEAR == SPI_FLAG_WC) || \ + (CLEAR == SPI_FLAG_RO) || \ + IS_FLAG_MF(CLEAR) || \ + (CLEAR == SPI_FLAG_SA) || \ + (CLEAR == SPI_FLAG_TOUT)) + + +#define SPI_INT_TXBE ((u32)0x00000001) +#define SPI_INT_TXE ((u32)0x00000002) +#define SPI_INT_RXBNE ((u32)0x00000004) +#define SPI_INT_WC ((u32)0x00000008) +#define SPI_INT_RO ((u32)0x00000010) +#if (!LIBCFG_SPI_NO_MULTI_MASTER) +#define SPI_INT_MF ((u32)0x00000020) +#endif +#define SPI_INT_SA ((u32)0x00000040) +#define SPI_INT_TOUT ((u32)0x00000080) +#if (LIBCFG_SPI_NO_MULTI_MASTER) +#define SPI_INT_ALL ((u32)0x000000DF) +#else +#define SPI_INT_ALL ((u32)0x000000FF) +#endif + +#define IS_SPI_INT(SPI_INT) (((SPI_INT & 0xFFFFFF00) == 0x0) && (SPI_INT != 0x0)) + + + +#define SPI_FIFO_TX ((u32)0x00000100) +#define SPI_FIFO_RX ((u32)0x00000200) + +#define IS_SPI_FIFO_DIRECTION(DIRECTION) (((DIRECTION & 0xFFFFFCFF) == 0) && (DIRECTION != 0)) + + +#if (LIBCFG_PDMA) +#define SPI_PDMAREQ_TX ((u32)0x00000002) +#define SPI_PDMAREQ_RX ((u32)0x00000004) + +#define IS_SPI_PDMA_REQ(REQ) (((REQ & 0xFFFFFFF9) == 0x0) && (REQ != 0x0)) +#endif + +/* Check parameter of the SIOx input/output direction */ +#if (LIBCFG_QSPI) +#define IS_SIO_DIR(x) (((x) == SIO_DIR_IN) || ((x) == SIO_DIR_OUT)) +#endif + +#define IS_SPI(x) (IS_SPI0(x) || IS_SPI1(x)) +#define IS_SPI0(x) (x == HT_SPI0) +#if (LIBCFG_SPI1) +#define IS_SPI1(x) (x == HT_SPI1) +#else +#define IS_SPI1(x) (0) +#endif +#if (LIBCFG_QSPI) +#define IS_QSPI(x) (x == HT_QSPI) +#else +#define IS_QSPI(x) (0) +#endif + +#if (LIBCFG_SPI_DATA_LENGTH_V01) +#define IS_SPI_DATA(DATA) (DATA <= 0xff) +#else +#define IS_SPI_DATA(DATA) (DATA <= 0xffff) +#endif + +#if (LIBCFG_SPI_FIFO_DEPTH_V01) +#define IS_SPI_FIFO_LEVEL(LEVEL) (LEVEL <= 4) +#else +#define IS_SPI_FIFO_LEVEL(LEVEL) (LEVEL <= 8) +#endif + +#define IS_SPI_CLOCK_PRESCALER(PRESCALER) (PRESCALER >= 2) + +#define SPI_GUADTIME_1_SCK ((u16)0x0000) +#define SPI_GUADTIME_2_SCK ((u16)0x0001) +#define SPI_GUADTIME_3_SCK ((u16)0x0002) +#define SPI_GUADTIME_4_SCK ((u16)0x0003) +#define SPI_GUADTIME_5_SCK ((u16)0x0004) +#define SPI_GUADTIME_6_SCK ((u16)0x0005) +#define SPI_GUADTIME_7_SCK ((u16)0x0006) +#define SPI_GUADTIME_8_SCK ((u16)0x0007) +#define SPI_GUADTIME_9_SCK ((u16)0x0008) +#define SPI_GUADTIME_10_SCK ((u16)0x0009) +#define SPI_GUADTIME_11_SCK ((u16)0x000A) +#define SPI_GUADTIME_12_SCK ((u16)0x000B) +#define SPI_GUADTIME_13_SCK ((u16)0x000C) +#define SPI_GUADTIME_14_SCK ((u16)0x000D) +#define SPI_GUADTIME_15_SCK ((u16)0x000E) +#define SPI_GUADTIME_16_SCK ((u16)0x000F) + +#define IS_SPI_GUADTIME(GUADTIMEPERIOD) ((GUADTIMEPERIOD <= 0x000F)) + + +#define SPI_SELHOLDTIME_HALF_SCK ((u16)0x0000) +#define SPI_SELHOLDTIME_1_SCK ((u16)0x0001) +#define SPI_SELHOLDTIME_1_HALF_SCK ((u16)0x0002) +#define SPI_SELHOLDTIME_2_SCK ((u16)0x0003) +#define SPI_SELHOLDTIME_2_HALF_SCK ((u16)0x0004) +#define SPI_SELHOLDTIME_3_SCK ((u16)0x0005) +#define SPI_SELHOLDTIME_3_HALF_SCK ((u16)0x0006) +#define SPI_SELHOLDTIME_4_SCK ((u16)0x0007) +#define SPI_SELHOLDTIME_4_HALF_SCK ((u16)0x0008) +#define SPI_SELHOLDTIME_5_SCK ((u16)0x0009) +#define SPI_SELHOLDTIME_5_HALF_SCK ((u16)0x000A) +#define SPI_SELHOLDTIME_6_SCK ((u16)0x000B) +#define SPI_SELHOLDTIME_6_HALF_SCK ((u16)0x000C) +#define SPI_SELHOLDTIME_7_SCK ((u16)0x000D) +#define SPI_SELHOLDTIME_7_HALF_SCK ((u16)0x000E) +#define SPI_SELHOLDTIME_8_SCK ((u16)0x000F) + +#define IS_SPI_SELHOLDTIME(SELHOLDTIME) ((SELHOLDTIME <= 0x000F)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Functions SPI exported functions + * @{ + */ +void SPI_DeInit(HT_SPI_TypeDef* SPIx); +void SPI_Init(HT_SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct); +void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct); +void SPI_Cmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +#if (!LIBCFG_SPI_NO_MULTI_MASTER) +void SPI_SELOutputCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +#endif +void SPI_FIFOCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void SPI_SetDataLength(HT_SPI_TypeDef* SPIx, u16 SPI_DataLength); +void SPI_SELModeConfig(HT_SPI_TypeDef* SPIx, u32 SPI_SELMode); +void SPI_SoftwareSELCmd(HT_SPI_TypeDef* SPIx, u32 SPI_SoftwareSEL); +void SPI_SendData(HT_SPI_TypeDef* SPIx, SPI_DataTypeDef SPI_Data); +SPI_DataTypeDef SPI_ReceiveData(HT_SPI_TypeDef* SPIx); +void SPI_SetTimeOutValue(HT_SPI_TypeDef* SPIx, SPI_TimeoutTypeDef SPI_Timeout); +void SPI_IntConfig(HT_SPI_TypeDef* SPIx, u32 SPI_Int, ControlStatus NewState); +FlagStatus SPI_GetFlagStatus(HT_SPI_TypeDef* SPIx, u32 SPI_Flag); +u8 SPI_GetFIFOStatus(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection); +void SPI_ClearFlag(HT_SPI_TypeDef* SPIx, u32 SPI_FlagClear); +void SPI_FIFOTriggerLevelConfig(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection, u8 SPI_FIFOLevel); +#if (LIBCFG_PDMA) +void SPI_PDMACmd(HT_SPI_TypeDef* SPIx, u32 SPI_PDMAREQ, ControlStatus NewState); +#endif +#if (!LIBCFG_SPI_NO_DUAL) +void SPI_DUALCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +#endif +void SPI_GUARDTCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void SPI_GUARDTConfig(HT_SPI_TypeDef* SPIx, u32 Guard_Time); +void SPI_SELHTConfig(HT_SPI_TypeDef* SPIx, u32 CS_Hold_Time); +#if (LIBCFG_QSPI) +void QSPI_QuadCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState); +void QSPI_DirectionConfig(HT_SPI_TypeDef* SPIx, SIO_DIR_Enum SIO_DIR_INorOUT); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi_midi.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi_midi.h new file mode 100644 index 0000000000..9494a08e46 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_spi_midi.h @@ -0,0 +1,204 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_spi_midi.h + * @version $Rev:: 7075 $ + * @date $Date:: 2023-07-31 #$ + * @brief The header file of SPI library (MIDI Control). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_SPI_MIDI_H +#define __HT32F5XXXX_SPI_MIDI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup SPI + * @{ + */ + + +/* Exported typedef ----------------------------------------------------------------------------------------*/ +/** @defgroup SPI_MIDI_Exported_Types QSPI MIDI exported types + * @{ + */ +typedef struct +{ + u32 MIDICTRL_MODE; + u32 MIDICTRL_CommandLength; + u32 MIDICTRL_AddressLength; + u32 MIDICTRL_ModeLength; + u32 MIDICTRL_DummyLength; + u32 MIDICTRL_DataLength; + u32 MIDICTRL_CommandValue; + u32 MIDICTRL_ModeValue; +} MIDICTRL_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Constants SPI exported constants + * @{ + */ +#define QDIOEN_POS (22) +#define SMDEL_POS (6) + +#define DOR_MODE (0UL << QDIOEN_POS | 1UL << SMDEL_POS ) +#define DIOR_MODE (1UL << QDIOEN_POS | 1UL << SMDEL_POS ) +#define QOR_MODE (0UL << QDIOEN_POS | 2UL << SMDEL_POS ) +#define QIOR_MODE (1UL << QDIOEN_POS | 2UL << SMDEL_POS ) +#define QPI_MODE (3UL << SMDEL_POS ) +#define SERIAL_MODE (0UL << SMDEL_POS ) + +/* QSPI Flash Command Field Length -------------------------------------------------------------------------*/ +#define MIDICTRL_CMDLENGTH_0 ((u32)0x00000000) +#define MIDICTRL_CMDLENGTH_1 ((u32)0x01000000) +#define MIDICTRL_CMDLENGTH_2 ((u32)0x02000000) +#define MIDICTRL_CMDLENGTH_3 ((u32)0x03000000) +#define MIDICTRL_CMDLENGTH_4 ((u32)0x04000000) +#define MIDICTRL_CMDLENGTH_5 ((u32)0x05000000) +#define MIDICTRL_CMDLENGTH_6 ((u32)0x06000000) +#define MIDICTRL_CMDLENGTH_7 ((u32)0x07000000) +#define MIDICTRL_CMDLENGTH_8 ((u32)0x08000000) + +/* QSPI FlashAddress Field Length --------------------------------------------------------------------------*/ +#define MIDICTRL_ADLENGTH_0 ((u32)0x00000000) +#define MIDICTRL_ADLENGTH_1 ((u32)0x00010000) +#define MIDICTRL_ADLENGTH_2 ((u32)0x00020000) +#define MIDICTRL_ADLENGTH_3 ((u32)0x00030000) +#define MIDICTRL_ADLENGTH_4 ((u32)0x00040000) +#define MIDICTRL_ADLENGTH_5 ((u32)0x00050000) +#define MIDICTRL_ADLENGTH_6 ((u32)0x00060000) +#define MIDICTRL_ADLENGTH_7 ((u32)0x00070000) +#define MIDICTRL_ADLENGTH_8 ((u32)0x00080000) +#define MIDICTRL_ADLENGTH_9 ((u32)0x00090000) +#define MIDICTRL_ADLENGTH_10 ((u32)0x000A0000) +#define MIDICTRL_ADLENGTH_11 ((u32)0x000B0000) +#define MIDICTRL_ADLENGTH_12 ((u32)0x000C0000) +#define MIDICTRL_ADLENGTH_13 ((u32)0x000D0000) +#define MIDICTRL_ADLENGTH_14 ((u32)0x000E0000) +#define MIDICTRL_ADLENGTH_15 ((u32)0x000F0000) +#define MIDICTRL_ADLENGTH_16 ((u32)0x00100000) +#define MIDICTRL_ADLENGTH_17 ((u32)0x00110000) +#define MIDICTRL_ADLENGTH_18 ((u32)0x00120000) +#define MIDICTRL_ADLENGTH_19 ((u32)0x00130000) +#define MIDICTRL_ADLENGTH_20 ((u32)0x00140000) +#define MIDICTRL_ADLENGTH_21 ((u32)0x00150000) +#define MIDICTRL_ADLENGTH_22 ((u32)0x00160000) +#define MIDICTRL_ADLENGTH_23 ((u32)0x00170000) +#define MIDICTRL_ADLENGTH_24 ((u32)0x00180000) + +/* QSPI Flash Command Field Length -------------------------------------------------------------------------*/ +#define MIDICTRL_MODELENGTH_0 ((u32)0x00000000) +#define MIDICTRL_MODELENGTH_1 ((u32)0x00001000) +#define MIDICTRL_MODELENGTH_2 ((u32)0x00002000) +#define MIDICTRL_MODELENGTH_3 ((u32)0x00003000) +#define MIDICTRL_MODELENGTH_4 ((u32)0x00004000) +#define MIDICTRL_MODELENGTH_5 ((u32)0x00005000) +#define MIDICTRL_MODELENGTH_6 ((u32)0x00006000) +#define MIDICTRL_MODELENGTH_7 ((u32)0x00007000) +#define MIDICTRL_MODELENGTH_8 ((u32)0x00008000) + +/* QSPI Flash Dummy Field Length ---------------------------------------------------------------------------*/ +#define MIDICTRL_DUMMYLENGTH_0 ((u32)0x00000000) +#define MIDICTRL_DUMMYLENGTH_1 ((u32)0x00000100) +#define MIDICTRL_DUMMYLENGTH_2 ((u32)0x00000200) +#define MIDICTRL_DUMMYLENGTH_3 ((u32)0x00000300) +#define MIDICTRL_DUMMYLENGTH_4 ((u32)0x00000400) +#define MIDICTRL_DUMMYLENGTH_5 ((u32)0x00000500) +#define MIDICTRL_DUMMYLENGTH_6 ((u32)0x00000600) +#define MIDICTRL_DUMMYLENGTH_7 ((u32)0x00000700) +#define MIDICTRL_DUMMYLENGTH_8 ((u32)0x00000800) + +/* QSPI Flash Data Field Length ----------------------------------------------------------------------------*/ +#define MIDICTRL_DATALENGTH_0 ((u32)0x00000000) +#define MIDICTRL_DATALENGTH_1 ((u32)0x00000001) +#define MIDICTRL_DATALENGTH_2 ((u32)0x00000002) +#define MIDICTRL_DATALENGTH_3 ((u32)0x00000003) +#define MIDICTRL_DATALENGTH_4 ((u32)0x00000004) +#define MIDICTRL_DATALENGTH_5 ((u32)0x00000005) +#define MIDICTRL_DATALENGTH_6 ((u32)0x00000006) +#define MIDICTRL_DATALENGTH_7 ((u32)0x00000007) +#define MIDICTRL_DATALENGTH_8 ((u32)0x00000008) +#define MIDICTRL_DATALENGTH_9 ((u32)0x00000009) +#define MIDICTRL_DATALENGTH_10 ((u32)0x0000000A) +#define MIDICTRL_DATALENGTH_11 ((u32)0x0000000B) +#define MIDICTRL_DATALENGTH_12 ((u32)0x0000000C) +#define MIDICTRL_DATALENGTH_13 ((u32)0x0000000D) +#define MIDICTRL_DATALENGTH_14 ((u32)0x0000000E) +#define MIDICTRL_DATALENGTH_15 ((u32)0x0000000F) +#define MIDICTRL_DATALENGTH_16 ((u32)0x00000010) +#define MIDICTRL_DATALENGTH_17 ((u32)0x00000011) +#define MIDICTRL_DATALENGTH_18 ((u32)0x00000012) +#define MIDICTRL_DATALENGTH_19 ((u32)0x00000013) +#define MIDICTRL_DATALENGTH_20 ((u32)0x00000014) +#define MIDICTRL_DATALENGTH_21 ((u32)0x00000015) +#define MIDICTRL_DATALENGTH_22 ((u32)0x00000016) +#define MIDICTRL_DATALENGTH_23 ((u32)0x00000017) +#define MIDICTRL_DATALENGTH_24 ((u32)0x00000018) +#define MIDICTRL_DATALENGTH_25 ((u32)0x00000019) +#define MIDICTRL_DATALENGTH_26 ((u32)0x0000001A) +#define MIDICTRL_DATALENGTH_27 ((u32)0x0000001B) +#define MIDICTRL_DATALENGTH_28 ((u32)0x0000001C) +#define MIDICTRL_DATALENGTH_29 ((u32)0x0000001D) +#define MIDICTRL_DATALENGTH_30 ((u32)0x0000001E) +#define MIDICTRL_DATALENGTH_31 ((u32)0x0000001F) +#define MIDICTRL_DATALENGTH_32 ((u32)0x00000020) + +#define MIDICTRL_ON ((u32)0x00800000) +#define MIDICTRL_OFF ((u32)0xFF7FFFFF) + +#define CMDVALUE_POS (8) +#define MDVALUE_POS (0) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Functions SPI exported functions + * @{ + */ +void MIDICTRL_Cmd(HT_SPI_TypeDef* QSPIx ,ControlStatus NewState); +void MIDICTRL_Init(HT_SPI_TypeDef* QSPIx, MIDICTRL_InitTypeDef* MIDICTRL_InitStruct); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tkey.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tkey.h new file mode 100644 index 0000000000..e51f1292b5 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tkey.h @@ -0,0 +1,311 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_tkey.h + * @version $Rev:: 5483 $ + * @date $Date:: 2021-07-19 #$ + * @brief The header file of the TKEY library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_TKEY_H +#define __HT32F5XXXX_TKEY_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup TKEY + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup TKEY_Exported_Types TKEY exported types + * @{ + */ + +typedef enum +{ /*!< Touch key IP clock source */ + TKEY_PCLK = 0 , /*!< PCLK */ + TKEY_LSI /*!< LSI */ +} TKEY_IP_CLK_Enum; + +typedef enum +{ /*!< Periodic auto scan mode time-out selection */ + TKEY_RefOSC_DelayTime_0 = (0 << 13), /*!< 4 RefOSC clock */ + TKEY_RefOSC_DelayTime_1 = (1 << 13), /*!< 2 RefOSC clock */ + TKEY_RefOSC_DelayTime_2 = (2 << 13), /*!< 4 RefOSC clock */ + TKEY_RefOSC_DelayTime_3 = (3 << 13), /*!< 8 RefOSC clock */ + TKEY_RefOSC_DelayTime_4 = (4 << 13), /*!< 16 RefOSC clock */ + TKEY_RefOSC_DelayTime_5 = (5 << 13), /*!< 32 RefOSC clock */ + TKEY_RefOSC_DelayTime_6 = (6 << 13), /*!< 64 RefOSC clock */ + TKEY_RefOSC_DelayTime_7 = (7 << 13), /*!< 4 RefOSC clock */ +} TKEY_RefOSC_DelayTime_Enum; + + +typedef enum +{ /*!< Periodic auto scan mode time-out selection */ + TKEY_PASM_TIMEOUT_0 = (0 << 10), /*!< 2^13/FLIRC */ + TKEY_PASM_TIMEOUT_1 = (1 << 10), /*!< 2^14/FLIRC */ + TKEY_PASM_TIMEOUT_2 = (2 << 10), /*!< 2^15/FLIRC */ + TKEY_PASM_TIMEOUT_3 = (3 << 10), /*!< 2^16/FLIRC */ + TKEY_PASM_TIMEOUT_4 = (4 << 10), /*!< 2^17/FLIRC */ + TKEY_PASM_TIMEOUT_5 = (5 << 10), /*!< 2^18/FLIRC */ +} TKEY_PASM_TIMEOUT_Enum; + +typedef enum +{ /*!< Periodic auto scan mode period selection */ + TKEY_PASM_PERIOD_0 = (0 << 8), /*!< 2^14/FLIRC */ + TKEY_PASM_PERIOD_1 = (1 << 8), /*!< 2^13/FLIRC */ + TKEY_PASM_PERIOD_2 = (2 << 8), /*!< 2^12/FLIRC */ + TKEY_PASM_PERIOD_3 = (3 << 8), /*!< 2^11/FLIRC */ +} TKEY_PASM_PERIOD_Enum; + +typedef enum +{ /*!< 16-bit counter clock source selection */ + TKEY_TK16S_CLK_0 = (0 << 5), /*!< TKCLK/16 */ + TKEY_TK16S_CLK_1 = (1 << 5), /*!< TKCLK/32 */ + TKEY_TK16S_CLK_2 = (2 << 5), /*!< TKCLK/64 */ + TKEY_TK16S_CLK_3 = (3 << 5), /*!< TKCLK/128 */ +} TKEY_TK16S_CLK_Enum; + +typedef enum +{ /*!< OSC frequency selection */ + TKEY_TKFS_FREQ_0 = (0 << 3), /*!< 1MHz */ + TKEY_TKFS_FREQ_1 = (1 << 3), /*!< 3MHz */ + TKEY_TKFS_FREQ_2 = (2 << 3), /*!< 7MHz */ + TKEY_TKFS_FREQ_3 = (3 << 3), /*!< 11MHz */ +} TKEY_TKFS_FREQ_Enum; + +typedef enum +{ /*!< Mode selection */ + TKEY_MODE_AUTOSCAN = (0 << 1), /*!< Auto scan mode */ + TKEY_MODE_MANUAL = (1 << 1), /*!< Manual mode */ + TKEY_MODE_PASM = (2 << 1), /*!< Periodic auto scan mode */ +} TKEY_MODE_Enum; + +typedef enum +{ /*!< TKEY module selection */ + TKM_0 = 0, /*!< TKEY module 0 */ + TKM_1, /*!< TKEY module 1 */ + TKM_2, /*!< TKEY module 2 */ + TKM_3, /*!< TKEY module 3 */ + TKM_4, /*!< TKEY module 4 */ + TKM_5, /*!< TKEY module 5 */ +} TKM_Enum; + +typedef enum +{ /*!< 8-bit time slot counter clock source */ + TKM_TSS_CLK_0 = (0 << 8), /*!< Ref. OSC */ + TKM_TSS_CLK_1 = (1 << 8), /*!< TKCLK/32 */ + TKM_TSS_CLK_2 = (2 << 8), /*!< TKCLK/64 */ + TKM_TSS_CLK_3 = (3 << 8), /*!< TKCLK/128 */ +} TKM_TSS_CLK_Enum; + +typedef enum +{ /*!< C/F OSC frequency hopping selection */ + TKM_SOF_CTRL_SW = (0 << 3), /*!< S/W controlled frequency hopping */ + TKM_SOF_CTRL_HW = (1 << 3), /*!< H/W controlled frequency hopping */ +} TKM_SOF_CTRL_Enum; + +typedef enum +{ /*!< Key OSC and Ref OSC frequency selection */ + TKM_SOF_FREQ_0 = (0 << 0), /*!< 1.020MHz. */ + TKM_SOF_FREQ_1 = (1 << 0), /*!< 1.040MHz. */ + TKM_SOF_FREQ_2 = (2 << 0), /*!< 1.059MHz. */ + TKM_SOF_FREQ_3 = (3 << 0), /*!< 1.074MHz. */ + TKM_SOF_FREQ_4 = (4 << 0), /*!< 1.085MHz. */ + TKM_SOF_FREQ_5 = (5 << 0), /*!< 1.099MHz. */ + TKM_SOF_FREQ_6 = (6 << 0), /*!< 1.111MHz. */ + TKM_SOF_FREQ_7 = (7 << 0) /*!< 1.125MHz. */ +} TKM_SOF_FREQ_Enum; + +typedef enum +{ /*!< Key selection */ + TKM_KEY_0 = 0, /*!< Key 0 */ + TKM_KEY_1, /*!< Key 1 */ + TKM_KEY_2, /*!< Key 2 */ + TKM_KEY_3, /*!< Key 3 */ +} TKM_KEY_Enum; + +typedef enum +{ /*!< Time slot selection */ + TKM_TIME_SLOT_0 = 0, /*!< Time slot 0 */ + TKM_TIME_SLOT_1, /*!< Time slot 1 */ + TKM_TIME_SLOT_2, /*!< Time slot 2 */ + TKM_TIME_SLOT_3, /*!< Time slot 3 */ +} TKM_TIME_SLOT_Enum; + +typedef enum +{ /*!< Key threshold selection */ + TKM_KEY_THR_LOWER = 0, /*!< Lower threshold */ + TKM_KEY_THR_UPPER, /*!< Upper threshold */ +} TKM_KEY_THR_Enum; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup TKEY_Exported_Constants TKEY exported constants + * @{ + */ +#define IS_TKEY_IP_CLK(x) (((x) == TKEY_PCLK) || ((x) == TKEY_LSI) ) + +#define IS_TKEY_RefOSC_DelayTime(x) (((x) == TKEY_RefOSC_DelayTime_0) || ((x) == TKEY_RefOSC_DelayTime_1) || \ + ((x) == TKEY_RefOSC_DelayTime_2) || ((x) == TKEY_RefOSC_DelayTime_3) || \ + ((x) == TKEY_RefOSC_DelayTime_4) || ((x) == TKEY_RefOSC_DelayTime_5)|| \ + ((x) == TKEY_RefOSC_DelayTime_6) || ((x) == TKEY_RefOSC_DelayTime_7)) + +#define IS_TKEY_PASM_TIMEOUT(x) (((x) == TKEY_PASM_TIMEOUT_0) || ((x) == TKEY_PASM_TIMEOUT_1) || \ + ((x) == TKEY_PASM_TIMEOUT_2) || ((x) == TKEY_PASM_TIMEOUT_3) || \ + ((x) == TKEY_PASM_TIMEOUT_4) || ((x) == TKEY_PASM_TIMEOUT_5)) + +#define IS_TKEY_PASM_PERIOD(x) (((x) == TKEY_PASM_PERIOD_0) || ((x) == TKEY_PASM_PERIOD_1) || \ + ((x) == TKEY_PASM_PERIOD_2) || ((x) == TKEY_PASM_PERIOD_3)) + +#define IS_TKEY_TK16S_CLK(x) (((x) == TKEY_TK16S_CLK_0) || ((x) == TKEY_TK16S_CLK_1) || \ + ((x) == TKEY_TK16S_CLK_2) || ((x) == TKEY_TK16S_CLK_3)) + + +#define IS_TKEY_TKFS_FREQ(x) (((x) == TKEY_TKFS_FREQ_0) || ((x) == TKEY_TKFS_FREQ_1) || \ + ((x) == TKEY_TKFS_FREQ_2) || ((x) == TKEY_TKFS_FREQ_3)) + +#define IS_TKEY_MODE(x) (((x) == TKEY_MODE_AUTOSCAN) || ((x) == TKEY_MODE_MANUAL) || \ + ((x) == TKEY_MODE_PASM)) + +#define TKEY_INT_TKTHE ((u32)0x00000001) +#define TKEY_INT_TKRCOVE ((u32)0x00000002) +#define TKEY_INT_TKTHWUEN ((u32)0x00000004) +#define TKEY_INT_TKRCOVWUEN ((u32)0x00000008) + +#define IS_TKEY_INT(TKEY_INT) (((TKEY_INT & 0xFFFFFFFC) == 0) && (TKEY_INT != 0)) + +#define TKEY_FLAG_TKTHF ((u32)0x00000001) +#define TKEY_FLAG_TKRCOVF ((u32)0x00000002) +#define TKEY_FLAG_TK16OV ((u32)0x00000004) +#define TKEY_FLAG_TKCFOV ((u32)0x00000008) +#define TKEY_FLAG_TKBUSY ((u32)0x00000010) + +#define IS_TKEY_FLAG(FLAG) ((FLAG == TKEY_FLAG_TKTHF) || \ + (FLAG == TKEY_FLAG_TKRCOVF) || \ + (FLAG == TKEY_FLAG_TK16OV) || \ + (FLAG == TKEY_FLAG_TKCFOV) || \ + (FLAG == TKEY_FLAG_TKBUSY)) + + +#define IS_TKEY_FLAG_CLEAR(CLEAR) ((CLEAR == TKEY_FLAG_TKTHF) || \ + (CLEAR == TKEY_FLAG_TKRCOVF) || \ + (CLEAR == TKEY_FLAG_TK16OV) || \ + (CLEAR == TKEY_FLAG_TKCFOV)) + +#define IS_TKM(x) (((x) == TKM_0) || ((x) == TKM_1) || \ + ((x) == TKM_2) || ((x) == TKM_3) || \ + ((x) == TKM_4) || ((x) == TKM_5)) + +#define IS_TKM_TSS_CLK(x) (((x) == TKM_TSS_CLK_0) || ((x) == TKM_TSS_CLK_1) || \ + ((x) == TKM_TSS_CLK_2) || ((x) == TKM_TSS_CLK_3)) + + +#define IS_TKM_SOFC_CTRL(x) (((x) == TKM_SOFC_SW) || ((x) == TKM_SOFC_HW)) + +#define IS_TKM_SOF_FREQ(x) (((x) == TKM_SOF_FREQ_0) || ((x) == TKM_SOF_FREQ_1) || \ + ((x) == TKM_SOF_FREQ_2) || ((x) == TKM_SOF_FREQ_3) || \ + ((x) == TKM_SOF_FREQ_4) || ((x) == TKM_SOF_FREQ_5) || \ + ((x) == TKM_SOF_FREQ_6) || ((x) == TKM_SOF_FREQ_7)) + +#define IS_TKM_KEY(x) (((x) == TKM_KEY_3) || ((x) == TKM_KEY_2) || \ + ((x) == TKM_KEY_1) || ((x) == TKM_KEY_0)) + +#define IS_TKM_SOF_CTRL(x) (((x) == TKM_SOF_CTRL_SW) || ((x) == TKM_SOF_CTRL_HW)) + +#define IS_TKM_TIME_SLOT(x) (((x) == TKM_TIME_SLOT_0) || ((x) == TKM_TIME_SLOT_1) || \ + ((x) == TKM_TIME_SLOT_2) || ((x) == TKM_TIME_SLOT_3)) + +#define IS_TKM_KEY_THR(x) (((x) == TKM_KEY_THR_LOWER) || ((x) == TKM_KEY_THR_UPPER)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup TKEY_Exported_Functions TKEY exported functions + * @{ + */ +void TKEY_DeInit(void); +void TKEY_IPClockConfig(TKEY_IP_CLK_Enum Sel); +void TKEY_RefOSCDelayTimeConfig(TKEY_RefOSC_DelayTime_Enum Sel); +void TKEY_PASMTimeoutConfig(TKEY_PASM_TIMEOUT_Enum Sel); +void TKEY_PASMPeriodConfig(TKEY_PASM_PERIOD_Enum Sel); +void TKEY_16BitCounterClockConfig(TKEY_TK16S_CLK_Enum Sel); +void TKEY_OSCFreqConfig(TKEY_TKFS_FREQ_Enum Sel); +void TKEY_ModeConfig(TKEY_MODE_Enum Sel); +void TKEY_StartCmd(ControlStatus NewState); +void TKEY_IntConfig(u32 TKEY_Int, ControlStatus NewState); +FlagStatus TKEY_GetFlagStatus(u32 TKEY_Flag); +void TKEY_ClearFlag(u32 TKEY_Flag); +u32 TKEY_Get16BitCounterValue(void); +void TKEY_Set8BitCounterReload(u32 Reload); +u32 TKEY_Get8BitCounterReload(void); + +void TKM_TimeSlotCounterClockConfig(TKM_Enum TKMn, TKM_TSS_CLK_Enum Sel); +void TKM_RefOSCCmd(TKM_Enum TKMn, ControlStatus NewState); +void TKM_KeyOSCCmd(TKM_Enum TKMn, ControlStatus NewState); +void TKM_MultiFreqCmd(TKM_Enum TKMn, ControlStatus NewState); +void TKM_SOFCtrlConfig(TKM_Enum TKMn, TKM_SOF_CTRL_Enum Sel); +void TKM_SOFFreqConfig(TKM_Enum TKMn, TKM_SOF_FREQ_Enum Sel); +void TKM_KeyCmd(TKM_Enum TKMn, TKM_KEY_Enum Key, ControlStatus NewState); +void TKM_TimeSlotKeyConfig(TKM_Enum TKMn, TKM_TIME_SLOT_Enum Slot, TKM_KEY_Enum Key); +void TKM_KeyThresholdConfig(TKM_Enum TKMn, TKM_KEY_Enum Key, TKM_KEY_THR_Enum Sel); +FlagStatus TKM_GetMatchFlagStatus(TKM_Enum TKMn, TKM_KEY_Enum Key); +void TKM_ClearMatchFlag(TKM_Enum TKMn, TKM_KEY_Enum Key); +void TKM_SetRefOSCCapacitor(TKM_Enum TKMn, u32 Value); +u32 TKM_GetRefOSCCapacitor(TKM_Enum TKMn); +void TKM_SetKeyCapacitor(TKM_Enum TKMn, TKM_KEY_Enum Key, u32 Value); +u32 TKM_GetKeyCapacitor(TKM_Enum TKMn, TKM_KEY_Enum Key); +u32 TKM_Get16BitCFCounterValue(TKM_Enum TKMn); +u32 TKM_GetKeyCounterValue(TKM_Enum TKMn, TKM_KEY_Enum Key); +void TKM_SetKeyThreshold(TKM_Enum TKMn, TKM_KEY_Enum Key, u32 Value); +u32 TKM_GetKeyThreshold(TKM_Enum TKMn, TKM_KEY_Enum Key); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm.h new file mode 100644 index 0000000000..eb0d814f23 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm.h @@ -0,0 +1,942 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_tm.h + * @version $Rev:: 7319 $ + * @date $Date:: 2023-10-28 #$ + * @brief The header file of the TM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_TM_H +#define __HT32F5XXXX_TM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup TM + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Types TM exported types + * @{ + */ +/** + * @brief Enumeration of TM counter mode. + */ +typedef enum +{ + TM_CNT_MODE_UP = 0x00000000, /*!< Edge up-counting mode */ + TM_CNT_MODE_CA1 = 0x00010000, /*!< Center-align mode 1 */ + TM_CNT_MODE_CA2 = 0x00020000, /*!< Center-align mode 2 */ + TM_CNT_MODE_CA3 = 0x00030000, /*!< Center-align mode 3 */ + TM_CNT_MODE_DOWN = 0x01000000 /*!< Edge down-counting mode */ +} TM_CNT_MODE_Enum; +/** + * @brief Enumeration of TM prescaler reload time. + */ +typedef enum +{ + TM_PSC_RLD_UPDATE = 0x0000, /*!< Reload prescaler at next update event */ + TM_PSC_RLD_IMMEDIATE = 0x0100 /*!< Reload prescaler immediately */ +} TM_PSC_RLD_Enum; +/** + * @brief Enumeration of TM channel output mode. + */ +typedef enum +{ + TM_OM_MATCH_NOCHANGE = 0x0000, /*!< TM channel output no change on match */ + TM_OM_MATCH_INACTIVE = 0x0001, /*!< TM channel output inactive level on match */ + TM_OM_MATCH_ACTIVE = 0x0002, /*!< TM channel output active level on match */ + TM_OM_MATCH_TOGGLE = 0x0003, /*!< TM channel output toggle on match */ + TM_OM_FORCED_INACTIVE = 0x0004, /*!< TM channel output forced inactive level */ + TM_OM_FORCED_ACTIVE = 0x0005, /*!< TM channel output forced active level */ + TM_OM_PWM1 = 0x0006, /*!< TM channel pwm1 output mode */ + TM_OM_PWM2 = 0x0007, /*!< TM channel pwm2 output mode */ + TM_OM_ASYMMETRIC_PWM1 = 0x0106, /*!< TM channel asymmetric pwm1 output mode */ + TM_OM_ASYMMETRIC_PWM2 = 0x0107 /*!< TM channel asymmetric pwm2 output mode */ +} TM_OM_Enum; +/** + * @brief Enumeration of TM channel capture source selection. + */ +typedef enum +{ + TM_CHCCS_DIRECT = 0x00010000, /*!< TM channel capture selection direct input */ + TM_CHCCS_INDIRECT = 0x00020000, /*!< TM channel capture selection indirect input */ + TM_CHCCS_TRCED = 0x00030000 /*!< TM channel capture selection TRCED of trigger control block */ +} TM_CHCCS_Enum; +/** + * @brief Enumeration of TM channel capture prescaler. + */ +typedef enum +{ + TM_CHPSC_OFF = 0x00000000, /*!< TM channel capture no prescaler, capture is done each event */ + TM_CHPSC_2 = 0x00040000, /*!< TM channel capture is done once every 2 event */ + TM_CHPSC_4 = 0x00080000, /*!< TM channel capture is done once every 4 event */ + TM_CHPSC_8 = 0x000C0000 /*!< TM channel capture is done once every 8 event */ +} TM_CHPSC_Enum; +#if (LIBCFG_TM_652XX_V1) +/** + * @brief Enumeration of TM channel Filter (Fsampling) Clock Divider. + */ +typedef enum +{ + TM_CHFDIV_1 = 0x00000000, /*!< TM channel Filter Fsampling = Fdts */ + TM_CHFDIV_2 = 0x00000001, /*!< TM channel Filter Fsampling = Fdts/2 */ + TM_CHFDIV_4 = 0x00000002, /*!< TM channel Filter Fsampling = Fdts/4 */ + TM_CHFDIV_8 = 0x00000003, /*!< TM channel Filter Fsampling = Fdts/8 */ + TM_CHFDIV_16 = 0x00000004, /*!< TM channel Filter Fsampling = Fdts/16 */ + TM_CHFDIV_32 = 0x00000005, /*!< TM channel Filter Fsampling = Fdts/32 */ + TM_CHFDIV_64 = 0x00000006 /*!< TM channel Filter Fsampling = Fdts/64 */ +} TM_CHFDIV_Enum; +/** + * @brief Enumeration of TM channel Filter N-event counter + */ +#if (LIBCFG_TM_TIFN_5BIT) +typedef enum +{ + TM_CHFEV_OFF = 0, /*!< TM channel Filter off */ + TM_CHFEV_1, /*!< TM channel Filter n event counter Setting */ + TM_CHFEV_2, + TM_CHFEV_3, + TM_CHFEV_4, + TM_CHFEV_5, + TM_CHFEV_6, + TM_CHFEV_7, + TM_CHFEV_8, + TM_CHFEV_9, + TM_CHFEV_10, + TM_CHFEV_11, + TM_CHFEV_12, + TM_CHFEV_13, + TM_CHFEV_14, + TM_CHFEV_15, + TM_CHFEV_16, + TM_CHFEV_17, + TM_CHFEV_18, + TM_CHFEV_19, + TM_CHFEV_20, + TM_CHFEV_21, + TM_CHFEV_22, + TM_CHFEV_23, + TM_CHFEV_24, + TM_CHFEV_25, + TM_CHFEV_26, + TM_CHFEV_27, + TM_CHFEV_28, + TM_CHFEV_29, + TM_CHFEV_30, + TM_CHFEV_31, +} TM_CHFEV_Enum; +#else +typedef enum +{ + TM_CHFEV_OFF = 0x00000000, /*!< TM channel Filter off */ + TM_CHFEV_2 = 0x00000001, /*!< TM channel Filter 2 event counter Setting */ + TM_CHFEV_4 = 0x00000002, /*!< TM channel Filter 4 event counter Setting */ + TM_CHFEV_8 = 0x00000003, /*!< TM channel Filter 8 event counter Setting */ + TM_CHFEV_12 = 0x00000004, /*!< TM channel Filter 12 event counter Setting */ + TM_CHFEV_16 = 0x00000005 /*!< TM channel Filter 16 event counter Setting */ +} TM_CHFEV_Enum; +#endif +#endif +/** + * @brief Enumeration of TM fDTS clock divider. + */ +typedef enum +{ + TM_CKDIV_OFF = 0x0000, /*!< fDTS = fCLKIN */ + TM_CKDIV_2 = 0x0100, /*!< fDTS = fCLKIN / 2 */ + TM_CKDIV_4 = 0x0200, /*!< fDTS = fCLKIN / 4 */ + #if (LIBCFG_TM_652XX_V1 || LIBCFG_TM_CKDIV_8) + TM_CKDIV_8 = 0x0300, /*!< fDTS = fCLKIN / 8 */ + #endif +} TM_CKDIV_Enum; +#if 0 +/** + * @brief Enumeration of TM ETI input prescaler. + */ +typedef enum +{ + TM_ETIPSC_OFF = 0x00000000, /*!< ETI prescaler off */ + TM_ETIPSC_2 = 0x00001000, /*!< ETIP frequency divided by 2 */ + TM_ETIPSC_4 = 0x00002000, /*!< ETIP frequency divided by 4 */ + TM_ETIPSC_8 = 0x00003000 /*!< ETIP frequency divided by 8 */ +} TM_ETIPSC_Enum; +/** + * @brief Enumeration of TM ETI input polarity. + */ +typedef enum +{ + TM_ETIPOL_NONINVERTED = 0x00000000, /*!< TM ETI polarity is active high or rising edge */ + TM_ETIPOL_INVERTED = 0x00010000 /*!< TM ETI polarity is active low or falling edge */ +} TM_ETIPOL_Enum; +#endif +/** + * @brief Enumeration of TM slave trigger input selection. + */ +typedef enum +{ + TM_TRSEL_UEVG = 0x0, /*!< Software trigger by setting UEVG bit */ + TM_TRSEL_TI0S0 = 0x1, /*!< Filtered channel 0 input */ + TM_TRSEL_TI1S1 = 0x2, /*!< Filtered channel 1 input */ + TM_TRSEL_ETIF = 0x3, /*!< External Trigger input */ + TM_TRSEL_TI0BED = 0x8, /*!< Trigger input 0 both edge detector */ +#if (LIBCFG_TM_NO_ITI == 1) + #define IS_TRSEL_ITI0(x) (0) + #define IS_TRSEL_ITI1(x) (0) + #define IS_TRSEL_ITI2(x) (0) +#else + TM_TRSEL_ITI0 = 0x9, /*!< Internal trigger input 0 */ + TM_TRSEL_ITI1 = 0xA, /*!< Internal trigger input 1 */ + TM_TRSEL_ITI2 = 0xB /*!< Internal trigger input 2 */ + #define IS_TRSEL_ITI0(x) (x == TM_TRSEL_ITI0) + #define IS_TRSEL_ITI1(x) (x == TM_TRSEL_ITI1) + #define IS_TRSEL_ITI2(x) (x == TM_TRSEL_ITI2) +#endif +} TM_TRSEL_Enum; +/** + * @brief Enumeration of TM slave mode selection. + */ +typedef enum +{ + TM_SMSEL_DISABLE = 0x0000, /*!< The prescaler is clocked directly by the internal clock */ + TM_SMSEL_DECODER1 = 0x0100, /*!< Counter counts up/down on CH0 edge depending on CH1 level */ + TM_SMSEL_DECODER2 = 0x0200, /*!< Counter counts up/down on CH1 edge depending on CH0 level */ + TM_SMSEL_DECODER3 = 0x0300, /*!< Counter counts up/down on both CH0 & CH1 edges depending on the + level of the other input */ + TM_SMSEL_RESTART = 0x0400, /*!< Slave restart mode */ + TM_SMSEL_PAUSE = 0x0500, /*!< Slave pause mode */ + TM_SMSEL_TRIGGER = 0x0600, /*!< Slave trigger mode */ + TM_SMSEL_STIED = 0x0700, /*!< Rising edge of the selected trigger(STI) clock the counter */ + #if (LIBCFG_TM_652XX_V1) + TM_SMSEL_DECODER4 = 0x0800, /*!< Pluse/Direction mode(Counter counts on Ch0, Count up/down on Ch1 */ + #endif +} TM_SMSEL_Enum; +/** + * @brief Enumeration of TM master mode selection. + */ +typedef enum +{ + TM_MMSEL_RESET = 0x00000000, /*!< Send trigger signal when S/W setting UEVG or slave restart */ + TM_MMSEL_ENABLE = 0x00010000, /*!< The counter enable signal is used as trigger output. */ + TM_MMSEL_UPDATE = 0x00020000, /*!< The update event is used as trigger output. */ + TM_MMSEL_CH0CC = 0x00030000, /*!< Channel 0 capture or compare match occurred as trigger output. */ + TM_MMSEL_CH0OREF = 0x00040000, /*!< The CH0OREF signal is used as trigger output. */ + TM_MMSEL_CH1OREF = 0x00050000, /*!< The CH1OREF signal is used as trigger output. */ + TM_MMSEL_CH2OREF = 0x00060000, /*!< The CH2OREF signal is used as trigger output. */ + TM_MMSEL_CH3OREF = 0x00070000, /*!< The CH3OREF signal is used as trigger output. */ + #if (LIBCFG_TM_652XX_V1) + TM_MMSEL_VCLK = 0x000C0000 /*!< The VCLK signal is used as trigger output. */ + #endif + #if (LIBCFG_PWM_8_CHANNEL) + TM_MMSEL_CH4OREF = 0x00080000, /*!< The CH4OREF signal is used as trigger output. */ + TM_MMSEL_CH5OREF = 0x00090000, /*!< The CH5OREF signal is used as trigger output. */ + TM_MMSEL_CH6OREF = 0x000A0000, /*!< The CH6OREF signal is used as trigger output. */ + TM_MMSEL_CH7OREF = 0x000B0000 /*!< The CH7OREF signal is used as trigger output. */ + #endif +} TM_MMSEL_Enum; +#if (LIBCFG_PDMA) +/** + * @brief Enumeration of TM channel Capture / Compare PDMA selection. + */ +typedef enum +{ + TM_CHCCDS_CHCCEV = 0, /*!< Send CHx PDMA request when channel capture/compare event occurs */ + TM_CHCCDS_UEV /*!< Send CHx PDMA request when update event occurs */ +} TM_CHCCDS_Enum; +#endif +/** + * @brief Definition of TM timebase init structure. + */ +typedef struct +{ + u16 CounterReload; /*!< Period (Value for CRR register) */ +#if(LIBCFG_TM_PRESCALER_8BIT) + u8 Prescaler; /*!< Prescaler (Value for PSCR register) */ +#else + u16 Prescaler; /*!< Prescaler (Value for PSCR register) */ +#endif + u8 RepetitionCounter; /*!< Repetition counter */ + TM_CNT_MODE_Enum CounterMode; /*!< Counter mode refer to \ref TM_CNT_MODE_Enum */ + TM_PSC_RLD_Enum PSCReloadTime; /*!< Prescaler reload mode refer to \ref TM_PSC_RLD_Enum */ +} TM_TimeBaseInitTypeDef; +/** + * @brief Definition of TM channel output init structure. + */ +typedef struct +{ + TM_CH_Enum Channel; /*!< Channel selection refer to \ref TM_CH_Enum */ + TM_OM_Enum OutputMode; /*!< Channel output mode selection refer to \ref TM_OM_Enum */ + TM_CHCTL_Enum Control; /*!< CHxO output state refer to \ref TM_CHCTL_Enum */ + TM_CHCTL_Enum ControlN; /*!< CHxO output state refer to \ref TM_CHCTL_Enum */ + TM_CHP_Enum Polarity; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + TM_CHP_Enum PolarityN; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + MCTM_OIS_Enum IdleState; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + MCTM_OIS_Enum IdleStateN; /*!< CHxO polarity refer to \ref TM_CHP_Enum */ + u16 Compare; /*!< Value for CHxCCR register */ + u16 AsymmetricCompare; /*!< Value for CHxACR register */ +} TM_OutputInitTypeDef; +/** + * @brief Definition of TM channel input init structure. + */ +typedef struct +{ + TM_CH_Enum Channel; /*!< Channel selection refer to \ref TM_CH_Enum */ + TM_CHP_Enum Polarity; /*!< Channel input polarity refer to \ref TM_CHP_Enum */ + TM_CHCCS_Enum Selection; /*!< Channel capture source selection refer to \ref TM_CHCCS_Enum */ + TM_CHPSC_Enum Prescaler; /*!< Channel Capture prescaler refer to \ref TM_CHPSC_Enum */ + #if (LIBCFG_TM_652XX_V1) + TM_CHFDIV_Enum Fsampling; /*!< Digital filter Fsampling Frequency, it must fDTS/1 ~ fDTS/64 */ + #if (LIBCFG_TM_TIFN_5BIT) + u8 Event; /*!< Digital filter N-event counter Setting, it must be 0 ~ 31 */ + #else + TM_CHFEV_Enum Event; /*!< Digital filter N-event counter Setting, it must be 0, 2, 4, 8, 12, 16 */ + #endif + #else + u8 Filter; /*!< Digital filter Configuration, it must between 0x0 ~ 0xF. */ + #endif +} TM_CaptureInitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Constants TM exported constants + * @{ + */ + +/** @defgroup TM_INT Definitions of TM_INT + * @{ + */ +#define TM_INT_CH0CC 0x0001 /*!< Channel 0 capture/compare interrupt */ +#define TM_INT_CH1CC 0x0002 /*!< Channel 1 capture/compare interrupt */ +#define TM_INT_CH2CC 0x0004 /*!< Channel 2 capture/compare interrupt */ +#define TM_INT_CH3CC 0x0008 /*!< Channel 3 capture/compare interrupt */ +#if (LIBCFG_PWM_8_CHANNEL) +#define TM_INT_CH4CC 0x10000000ul /*!< Channel 4 compare interrupt */ +#define TM_INT_CH5CC 0x20000000ul /*!< Channel 5 compare interrupt */ +#define TM_INT_CH6CC 0x40000000ul /*!< Channel 6 compare interrupt */ +#define TM_INT_CH7CC 0x80000000ul /*!< Channel 7 compare interrupt */ +#endif +#define TM_INT_UEV 0x0100 /*!< Update interrupt */ +#define TM_INT_UEV2 0x0200 /*!< Update interrupt 2 */ +#define TM_INT_TEV 0x0400 /*!< Trigger interrupt */ +#define TM_INT_BRKEV 0x0800 /*!< Break interrupt */ + +#if (LIBCFG_TM_652XX_V1) +#define MCTM_INT_CH0CD 0x100000 /*!< Channel 0 Count-Down compare interrupt */ +#define MCTM_INT_CH1CD 0x200000 /*!< Channel 1 Count-Down compare interrupt */ +#define MCTM_INT_CH2CD 0x400000 /*!< Channel 2 Count-Down compare interrupt */ +#define MCTM_INT_CH3CD 0x800000 /*!< Channel 3 Count-Down compare interrupt */ + +#define TM_INT_VC 0x1000 /*!< Quadrature Decoder VCLK interrupt */ +#define TM_INT_QC 0x2000 /*!< Quadrature Decoder CLKPULSE interrupt */ +#define TM_INT_PE 0x4000 /*!< Quadrature Decoder Phase Error interrupt */ +#define TM_INT_DC 0x8000 /*!< Quadrature Decoder Direction Change interrupt */ + +#define MCTM_INT_OVER 0x2000 /*!< Counter overflow interrupt */ +#define MCTM_INT_UNDER 0x4000 /*!< Counter underflow Interrupt */ +#if (LIBCFG_TM_65232) +#define MCTM_INT_RECCDIF 0x8000 /*!< CCIF or CDIF Interrupt flag control by REPR */ +#endif + +#endif +/** + * @} + */ + +#if (LIBCFG_PDMA) +/** @defgroup TM_PDMA Definitions of TM_PDMA + * @{ + */ +#define TM_PDMA_CH0CC 0x00010000 /*!< Channel 0 capture/compare PDMA request */ +#define TM_PDMA_CH1CC 0x00020000 /*!< Channel 1 capture/compare PDMA request */ +#define TM_PDMA_CH2CC 0x00040000 /*!< Channel 2 capture/compare PDMA request */ +#define TM_PDMA_CH3CC 0x00080000 /*!< Channel 3 capture/compare PDMA request */ +#define TM_PDMA_UEV 0x01000000 /*!< Update PDMA request */ +#define TM_PDMA_UEV2 0x02000000 /*!< Update 2 PDMA request */ +#define TM_PDMA_TEV 0x04000000 /*!< Trigger PDMA request */ +/** + * @} + */ +#endif + +/** @defgroup TM_EVENT Definitions of TM_EVENT + * @{ + */ +#define TM_EVENT_CH0CC 0x0001 /*!< Channel 0 capture/compare event */ +#define TM_EVENT_CH1CC 0x0002 /*!< Channel 1 capture/compare event */ +#define TM_EVENT_CH2CC 0x0004 /*!< Channel 2 capture/compare event */ +#define TM_EVENT_CH3CC 0x0008 /*!< Channel 3 capture/compare event */ +#if (LIBCFG_PWM_8_CHANNEL) +#define TM_EVENT_CH4CC 0x10000000ul /*!< Channel 4 compare event */ +#define TM_EVENT_CH5CC 0x20000000ul /*!< Channel 5 compare event */ +#define TM_EVENT_CH6CC 0x40000000ul /*!< Channel 6 compare event */ +#define TM_EVENT_CH7CC 0x80000000ul /*!< Channel 7 compare event */ +#endif +#define TM_EVENT_UEV 0x0100 /*!< Update event */ +#define TM_EVENT_UEV2 0x0200 /*!< Update event 2 */ +#define TM_EVENT_TEV 0x0400 /*!< Trigger event */ +#define TM_EVENT_BRKEV 0x0800 /*!< Break event */ +/** + * @} + */ + +/** @defgroup TM_FLAG Definitions of TM_FLAG + * @{ + */ +#define TM_FLAG_CH0CC 0x0001 /*!< Channel 0 capture/compare flag */ +#define TM_FLAG_CH1CC 0x0002 /*!< Channel 1 capture/compare flag */ +#define TM_FLAG_CH2CC 0x0004 /*!< Channel 2 capture/compare flag */ +#define TM_FLAG_CH3CC 0x0008 /*!< Channel 3 capture/compare flag */ +#if (LIBCFG_PWM_8_CHANNEL) +#define TM_FLAG_CH4CC 0x10000000ul /*!< Channel 4 compare flag */ +#define TM_FLAG_CH5CC 0x20000000ul /*!< Channel 5 compare flag */ +#define TM_FLAG_CH6CC 0x40000000ul /*!< Channel 6 compare flag */ +#define TM_FLAG_CH7CC 0x80000000ul /*!< Channel 7 compare flag */ +#endif +#define TM_FLAG_CH0OC 0x0010 /*!< Channel 0 over capture flag */ +#define TM_FLAG_CH1OC 0x0020 /*!< Channel 1 over capture flag */ +#define TM_FLAG_CH2OC 0x0040 /*!< Channel 2 over capture flag */ +#define TM_FLAG_CH3OC 0x0080 /*!< Channel 3 over capture flag */ +#define TM_FLAG_UEV 0x0100 /*!< Update flag */ +#define TM_FLAG_UEV2 0x0200 /*!< Update 2 flag */ +#define TM_FLAG_TEV 0x0400 /*!< Trigger flag */ +#define TM_FLAG_BRK0 0x0800 /*!< Break 0 flag */ +#define TM_FLAG_BRK1 0x1000 /*!< Break 1 flag */ +/** + * @} + */ + +/** @defgroup TM_Check_Parameter Check parameter + * @{ + */ + +/** + * @brief Used to check parameter of the TMx. + */ +#define IS_TM(x) (IS_GPTM0(x) || IS_GPTM1(x) || IS_MCTM0(x) || IS_PWM0(x) || IS_PWM1(x) || IS_PWM2(x) || IS_SCTM(x)) +#if (!LIBCFG_NO_GPTM0) +#define IS_GPTM0(x) (x == HT_GPTM0) +#else +#define IS_GPTM0(x) (0) +#endif + +#if (LIBCFG_GPTM1) +#define IS_GPTM1(x) (x == HT_GPTM1) +#else +#define IS_GPTM1(x) (0) +#endif + +#if (LIBCFG_MCTM0) +#define IS_MCTM0(x) (x == HT_MCTM0) +#else +#define IS_MCTM0(x) (0) +#endif + +#if (LIBCFG_PWM0) +#define IS_PWM0(x) (x == HT_PWM0) +#else +#define IS_PWM0(x) (0) +#endif + +#if (LIBCFG_PWM1) +#define IS_PWM1(x) (x == HT_PWM1) +#else +#define IS_PWM1(x) (0) +#endif + +#if (LIBCFG_PWM2) +#define IS_PWM2(x) (x == HT_PWM2) +#else +#define IS_PWM2(x) (0) +#endif + +#define IS_SCTM(x) (IS_SCTM0(x) || IS_SCTM1(x) || IS_SCTM2(x) || IS_SCTM3(x)) + +#define IS_SCTM0(x) (0) +#define IS_SCTM1(x) (0) +#define IS_SCTM2(x) (0) +#define IS_SCTM3(x) (0) + +#if (LIBCFG_SCTM0) +#undef IS_SCTM0 +#define IS_SCTM0(x) (x == HT_SCTM0) +#endif + +#if (LIBCFG_SCTM1) +#undef IS_SCTM1 +#define IS_SCTM1(x) (x == HT_SCTM1) +#endif + +#if (LIBCFG_SCTM2) +#undef IS_SCTM2 +#define IS_SCTM2(x) (x == HT_SCTM2) +#endif + +#if (LIBCFG_SCTM3) +#undef IS_SCTM3 +#define IS_SCTM3(x) (x == HT_SCTM3) +#endif + +/** + * @brief Used to check parameter of the output compare mode. + */ +#define IS_TM_OM_CMP(x) (((x) == TM_OM_MATCH_NOCHANGE) || \ + ((x) == TM_OM_MATCH_INACTIVE) || \ + ((x) == TM_OM_MATCH_ACTIVE) || \ + ((x) == TM_OM_MATCH_TOGGLE) || \ + ((x) == TM_OM_PWM1) || \ + ((x) == TM_OM_PWM2)) +/** + * @brief Used to check parameter of the output mode. + */ +#define IS_TM_OM(x) (((x) == TM_OM_MATCH_NOCHANGE) || \ + ((x) == TM_OM_MATCH_INACTIVE) || \ + ((x) == TM_OM_MATCH_ACTIVE) || \ + ((x) == TM_OM_MATCH_TOGGLE) || \ + ((x) == TM_OM_PWM1) || \ + ((x) == TM_OM_PWM2) || \ + ((x) == TM_OM_FORCED_INACTIVE) || \ + ((x) == TM_OM_FORCED_ACTIVE) || \ + ((x) == TM_OM_ASYMMETRIC_PWM1) || \ + ((x) == TM_OM_ASYMMETRIC_PWM2)) + +#define IS_TM_OM_NOASYM(x) (((x) == TM_OM_MATCH_NOCHANGE) || \ + ((x) == TM_OM_MATCH_INACTIVE) || \ + ((x) == TM_OM_MATCH_ACTIVE) || \ + ((x) == TM_OM_MATCH_TOGGLE) || \ + ((x) == TM_OM_PWM1) || \ + ((x) == TM_OM_PWM2) || \ + ((x) == TM_OM_FORCED_INACTIVE) || \ + ((x) == TM_OM_FORCED_ACTIVE)) +/** + * @brief Used to check parameter of the channel. + */ +#define IS_TM_CH_0(x) (x == TM_CH_0) +#define IS_TM_CH_1(x) (x == TM_CH_1) +#define IS_TM_CH_2(x) (x == TM_CH_2) +#define IS_TM_CH_3(x) (x == TM_CH_3) +#if (LIBCFG_PWM_8_CHANNEL) +#define IS_TM_CH_4(x) (x == TM_CH_4) +#define IS_TM_CH_5(x) (x == TM_CH_5) +#define IS_TM_CH_6(x) (x == TM_CH_6) +#define IS_TM_CH_7(x) (x == TM_CH_7) +#else +#define IS_TM_CH_4(x) (0) +#define IS_TM_CH_5(x) (0) +#define IS_TM_CH_6(x) (0) +#define IS_TM_CH_7(x) (0) +#endif +#define IS_TM_CH(x) (IS_TM_CH_0(x) || IS_TM_CH_1(x) || \ + IS_TM_CH_2(x) || IS_TM_CH_3(x) || \ + IS_TM_CH_4(x) || IS_TM_CH_5(x) || \ + IS_TM_CH_6(x) || IS_TM_CH_7(x) ) + +/** + * @brief Used to check parameter of the channel for PWM input function. + */ +#define IS_TM_CH_PWMI(x) (((x) == TM_CH_0) || ((x) == TM_CH_1)) +/** + * @brief Used to check parameter of the clock divider. + */ +#define IS_TM_CKDIV_OFF(x) (x == TM_CKDIV_OFF) +#define IS_TM_CKDIV_2(x) (x == TM_CKDIV_2) +#define IS_TM_CKDIV_4(x) (x == TM_CKDIV_4) + +#if (LIBCFG_TM_CKDIV_8) +#define IS_TM_CKDIV_8(x) (x == TM_CKDIV_8) +#else +#define IS_TM_CKDIV_8(x) (0) +#endif + +#define IS_TM_CKDIV(x) (IS_TM_CKDIV_OFF(x) || \ + IS_TM_CKDIV_2(x) || \ + IS_TM_CKDIV_4(x) || \ + IS_TM_CKDIV_8(x)) +/** + * @brief Used to check parameter of the counter mode. + */ +#define IS_TM_CNT_MODE(x) ((x == TM_CNT_MODE_UP) || \ + (x == TM_CNT_MODE_CA1) || \ + (x == TM_CNT_MODE_CA2) || \ + (x == TM_CNT_MODE_CA3) || \ + (x == TM_CNT_MODE_DOWN)) +/** + * @brief Used to check parameter of the channel polarity. + */ +#define IS_TM_CHP(x) ((x == TM_CHP_NONINVERTED) || (x == TM_CHP_INVERTED)) +/** + * @brief Used to check parameter of the channel control. + */ +#define IS_TM_CHCTL(x) ((x == TM_CHCTL_DISABLE) || (x == TM_CHCTL_ENABLE)) +/** + * @brief Used to check parameter of the channel capture / compare PDMA selection. + */ +#define IS_TM_CHCCDS(x) ((x == TM_CHCCDS_CHCCEV) || (x == TM_CHCCDS_UEV)) +/** + * @brief Used to check parameter of the channel input selection. + */ +#define IS_TM_CHCCS(x) ((x == TM_CHCCS_DIRECT) || \ + (x == TM_CHCCS_INDIRECT) || \ + (x == TM_CHCCS_TRCED)) +/** + * @brief Used to check parameter of the channel capture prescaler. + */ +#define IS_TM_CHPSC(x) ((x == TM_CHPSC_OFF) || \ + (x == TM_CHPSC_2) || \ + (x == TM_CHPSC_4) || \ + (x == TM_CHPSC_8)) +#if 0 +/** + * @brief Used to check parameter of the ETI prescaler. + */ +#define IS_TM_ETIPSC(x) ((x == TM_ETIPSC_OFF) || \ + (x == TM_ETIPSC_2) || \ + (x == TM_ETIPSC_4) || \ + (x == TM_ETIPSC_8)) +#endif +/** + * @brief Used to check parameter of the TM interrupt. + */ +#define IS_TM_INT(x) (((x & 0xFF0F10F0) == 0x0) && (x != 0)) +/** + * @brief Used to check parameter of the TM PDMA request. + */ +#define IS_TM_PDMA(x) (((x & 0xFAF0FFFF) == 0x0) && (x != 0)) +/** + * @brief Used to check parameter of the TM interrupt for \ref TM_GetIntStatus function. + */ +#define IS_TM_INT_CH0CC(x) (x == TM_INT_CH0CC) +#define IS_TM_INT_CH1CC(x) (x == TM_INT_CH1CC) +#define IS_TM_INT_CH2CC(x) (x == TM_INT_CH2CC) +#define IS_TM_INT_CH3CC(x) (x == TM_INT_CH3CC) +#if (LIBCFG_PWM_8_CHANNEL) +#define IS_TM_INT_CH4CC(x) (x == TM_INT_CH4CC) +#define IS_TM_INT_CH5CC(x) (x == TM_INT_CH5CC) +#define IS_TM_INT_CH6CC(x) (x == TM_INT_CH6CC) +#define IS_TM_INT_CH7CC(x) (x == TM_INT_CH7CC) +#else +#define IS_TM_INT_CH4CC(x) (0) +#define IS_TM_INT_CH5CC(x) (0) +#define IS_TM_INT_CH6CC(x) (0) +#define IS_TM_INT_CH7CC(x) (0) +#endif +#define IS_TM_INT_UEV(x) (x == TM_INT_UEV) +#define IS_TM_INT_UEV2(x) (x == TM_INT_UEV2) +#define IS_TM_INT_TEV(x) (x == TM_INT_TEV) +#define IS_TM_INT_BRKEV(x) (x == TM_INT_BRKEV) +#define IS_TM_GET_INT(x) (IS_TM_INT_CH0CC(x) || \ + IS_TM_INT_CH1CC(x) || \ + IS_TM_INT_CH2CC(x) || \ + IS_TM_INT_CH3CC(x) || \ + IS_TM_INT_CH4CC(x) || \ + IS_TM_INT_CH5CC(x) || \ + IS_TM_INT_CH6CC(x) || \ + IS_TM_INT_CH7CC(x) || \ + IS_TM_INT_UEV(x) || \ + IS_TM_INT_UEV2(x) || \ + IS_TM_INT_TEV(x) || \ + IS_TM_INT_BRKEV(x)) + +/** + * @brief Used to check parameter of the TM STI selection. + */ +#define IS_TM_TRSEL(x) ((x == TM_TRSEL_UEVG) || \ + (x == TM_TRSEL_TI0S0) || \ + (x == TM_TRSEL_TI1S1) || \ + (x == TM_TRSEL_ETIF) || \ + (x == TM_TRSEL_TI0BED) || \ + IS_TRSEL_ITI0(x) || \ + IS_TRSEL_ITI1(x) || \ + IS_TRSEL_ITI2(x)) +/** + * @brief Used to check parameter of the ITI. + */ +#if (LIBCFG_TM_NO_ITI == 1) +#else +#define IS_TM_ITI(x) ((x == TM_TRSEL_ITI0) || (x == TM_TRSEL_ITI1) || (x == TM_TRSEL_ITI2)) +#endif +/** + * @brief Used to check parameter of the TM_TRSEL for \ref TM_ChExternalClockConfig function. + */ +#define IS_TM_TRSEL_CH(x) ((x == TM_TRSEL_TI0S0) || (x == TM_TRSEL_TI1S1) || \ + (x == TM_TRSEL_TI0BED)) +/** + * @brief Used to check parameter of the TM ETI polarity. + */ +#define IS_TM_ETIPOL(x) ((x == TM_ETIPOL_NONINVERTED) || (x == TM_ETIPOL_INVERTED)) +/** + * @brief Used to check parameter of the TM prescaler reload time. + */ +#define IS_TM_PSC_RLD(x) ((x == TM_PSC_RLD_UPDATE) || (x == TM_PSC_RLD_IMMEDIATE)) +/** + * @brief Used to check parameter of the forced action. + */ +#define IS_TM_OM_FORCED(x) ((x == TM_OM_FORCED_ACTIVE) || (x == TM_OM_FORCED_INACTIVE)) +/** + * @brief Used to check parameter of the decoder mode. + */ +#define IS_TM_SMSEL_DECODER(x) ((x == TM_SMSEL_DECODER1) || (x == TM_SMSEL_DECODER2) || \ + (x == TM_SMSEL_DECODER3)) +/** + * @brief Used to check parameter of the event. + */ +#define IS_TM_EVENT(x) (((x & 0xFFFFFAF0) == 0x0000) && (x != 0x0000)) +/** + * @brief Used to check parameter of the TM master mode selection. + */ +#define IS_TM_MMSEL_RESET(x) (x == TM_MMSEL_RESET) +#define IS_TM_MMSEL_ENABLE(x) (x == TM_MMSEL_ENABLE) +#define IS_TM_MMSEL_UPDATE(x) (x == TM_MMSEL_UPDATE) +#define IS_TM_MMSEL_CH0CC(x) (x == TM_MMSEL_CH0CC) +#define IS_TM_MMSEL_CH0OREF(x) (x == TM_MMSEL_CH0OREF) +#define IS_TM_MMSEL_CH1OREF(x) (x == TM_MMSEL_CH1OREF) +#define IS_TM_MMSEL_CH2OREF(x) (x == TM_MMSEL_CH2OREF) +#define IS_TM_MMSEL_CH3OREF(x) (x == TM_MMSEL_CH3OREF) +#if (LIBCFG_PWM_8_CHANNEL) +#define IS_TM_MMSEL_CH4OREF(x) (x == TM_MMSEL_CH4OREF) +#define IS_TM_MMSEL_CH5OREF(x) (x == TM_MMSEL_CH5OREF) +#define IS_TM_MMSEL_CH6OREF(x) (x == TM_MMSEL_CH6OREF) +#define IS_TM_MMSEL_CH7OREF(x) (x == TM_MMSEL_CH7OREF) +#else +#define IS_TM_MMSEL_CH4OREF(x) (0) +#define IS_TM_MMSEL_CH5OREF(x) (0) +#define IS_TM_MMSEL_CH6OREF(x) (0) +#define IS_TM_MMSEL_CH7OREF(x) (0) +#endif +#define IS_TM_MMSEL(x) (IS_TM_MMSEL_RESET(x) || \ + IS_TM_MMSEL_ENABLE(x) || \ + IS_TM_MMSEL_UPDATE(x) || \ + IS_TM_MMSEL_CH0CC(x) || \ + IS_TM_MMSEL_CH0OREF(x) || \ + IS_TM_MMSEL_CH1OREF(x) || \ + IS_TM_MMSEL_CH2OREF(x) || \ + IS_TM_MMSEL_CH3OREF(x) || \ + IS_TM_MMSEL_CH4OREF(x) || \ + IS_TM_MMSEL_CH5OREF(x) || \ + IS_TM_MMSEL_CH6OREF(x) || \ + IS_TM_MMSEL_CH7OREF(x)) + +/** + * @brief Used to check parameter of the TM slave mode. + */ +#define IS_TM_SLAVE_MODE(x) ((x == TM_SMSEL_RESTART) || (x == TM_SMSEL_PAUSE) || \ + (x == TM_SMSEL_TRIGGER) || (x == TM_SMSEL_STIED)) +/** + * @brief Used to check parameter of the TM flag. + */ +#define IS_TM_FLAG_CH0CC(x) (x == TM_FLAG_CH0CC) +#define IS_TM_FLAG_CH1CC(x) (x == TM_FLAG_CH1CC) +#define IS_TM_FLAG_CH2CC(x) (x == TM_FLAG_CH2CC) +#define IS_TM_FLAG_CH3CC(x) (x == TM_FLAG_CH3CC) +#if (LIBCFG_PWM_8_CHANNEL) +#define IS_TM_FLAG_CH4CC(x) (x == TM_FLAG_CH4CC) +#define IS_TM_FLAG_CH5CC(x) (x == TM_FLAG_CH5CC) +#define IS_TM_FLAG_CH6CC(x) (x == TM_FLAG_CH6CC) +#define IS_TM_FLAG_CH7CC(x) (x == TM_FLAG_CH7CC) +#else +#define IS_TM_FLAG_CH4CC(x) (0) +#define IS_TM_FLAG_CH5CC(x) (0) +#define IS_TM_FLAG_CH6CC(x) (0) +#define IS_TM_FLAG_CH7CC(x) (0) +#endif +#define IS_TM_FLAG_CH0OC(x) (x == TM_FLAG_CH0OC) +#define IS_TM_FLAG_CH1OC(x) (x == TM_FLAG_CH1OC) +#define IS_TM_FLAG_CH2OC(x) (x == TM_FLAG_CH2OC) +#define IS_TM_FLAG_CH3OC(x) (x == TM_FLAG_CH3OC) +#define IS_TM_FLAG_UEV(x) (x == TM_FLAG_UEV) +#define IS_TM_FLAG_UEV2(x) (x == TM_FLAG_UEV2) +#define IS_TM_FLAG_TEV(x) (x == TM_FLAG_TEV) +#define IS_TM_FLAG_BRK0(x) (x == TM_FLAG_BRK0) +#define IS_TM_FLAG_BRK1(x) (x == TM_FLAG_BRK1) +#define IS_TM_FLAG(x) (IS_TM_FLAG_CH0CC(x) || \ + IS_TM_FLAG_CH1CC(x) || \ + IS_TM_FLAG_CH2CC(x) || \ + IS_TM_FLAG_CH3CC(x) || \ + IS_TM_FLAG_CH4CC(x) || \ + IS_TM_FLAG_CH5CC(x) || \ + IS_TM_FLAG_CH6CC(x) || \ + IS_TM_FLAG_CH7CC(x) || \ + IS_TM_FLAG_CH0OC(x) || \ + IS_TM_FLAG_CH1OC(x) || \ + IS_TM_FLAG_CH2OC(x) || \ + IS_TM_FLAG_CH3OC(x) || \ + IS_TM_FLAG_UEV(x) || \ + IS_TM_FLAG_UEV2(x) || \ + IS_TM_FLAG_TEV(x) || \ + IS_TM_FLAG_BRK0(x) || \ + IS_TM_FLAG_BRK1(x)) + +/** + * @brief Used to check parameter of the TM flag for \ref TM_ClearFlag function. + */ +#define IS_TM_FLAG_CLR(x) (((x & 0xFFFFFA00) == 0) && (x != 0)) +/** + * @brief Used to check value of TM digital filter. + */ +#if (LIBCFG_TM_652XX_V1) +#define IS_TM_FILTER(x) (x <= 0xFF) +#else +#define IS_TM_FILTER(x) (x <= 0xF) +#endif + +/** + * @} + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Functions TM exported functions + * @{ + */ +#define TM_SetCaptureCompare0(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_0, Cmp) +#define TM_SetCaptureCompare1(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_1, Cmp) +#define TM_SetCaptureCompare2(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_2, Cmp) +#define TM_SetCaptureCompare3(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_3, Cmp) +#if (LIBCFG_PWM_8_CHANNEL) +#define TM_SetCaptureCompare4(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_4, Cmp) +#define TM_SetCaptureCompare5(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_5, Cmp) +#define TM_SetCaptureCompare6(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_6, Cmp) +#define TM_SetCaptureCompare7(TMx, Cmp) TM_SetCaptureCompare(TMx, TM_CH_7, Cmp) +#endif + +#define TM_ForcedOREF0(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_0, ForcedAction) +#define TM_ForcedOREF1(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_1, ForcedAction) +#define TM_ForcedOREF2(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_2, ForcedAction) +#define TM_ForcedOREF3(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_3, ForcedAction) +#if (LIBCFG_PWM_8_CHANNEL) +#define TM_ForcedOREF4(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_4, ForcedAction) +#define TM_ForcedOREF5(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_5, ForcedAction) +#define TM_ForcedOREF6(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_6, ForcedAction) +#define TM_ForcedOREF7(TMx, ForcedAction) TM_ForcedOREF(TMx, TM_CH_7, ForcedAction) +#endif + +#define TM_SetAsymmetricCompare0(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_0, Cmp) +#define TM_SetAsymmetricCompare1(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_1, Cmp) +#define TM_SetAsymmetricCompare2(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_2, Cmp) +#define TM_SetAsymmetricCompare3(TMx, Cmp) TM_SetAsymmetricCompare(TMx, TM_CH_3, Cmp) + +#define TM_GetCaptureCompare0(TMx) TM_GetCaptureCompare(TMx, TM_CH_0) +#define TM_GetCaptureCompare1(TMx) TM_GetCaptureCompare(TMx, TM_CH_1) +#define TM_GetCaptureCompare2(TMx) TM_GetCaptureCompare(TMx, TM_CH_2) +#define TM_GetCaptureCompare3(TMx) TM_GetCaptureCompare(TMx, TM_CH_3) +#if (LIBCFG_PWM_8_CHANNEL) +#define TM_GetCaptureCompare4(TMx) TM_GetCaptureCompare(TMx, TM_CH_4) +#define TM_GetCaptureCompare5(TMx) TM_GetCaptureCompare(TMx, TM_CH_5) +#define TM_GetCaptureCompare6(TMx) TM_GetCaptureCompare(TMx, TM_CH_6) +#define TM_GetCaptureCompare7(TMx) TM_GetCaptureCompare(TMx, TM_CH_7) +#endif + +void TM_DeInit(HT_TM_TypeDef* TMx); +void TM_TimeBaseInit(HT_TM_TypeDef* TMx, TM_TimeBaseInitTypeDef* TimeBaseInit); +void TM_OutputInit(HT_TM_TypeDef* TMx, TM_OutputInitTypeDef* OutInit); +void TM_CaptureInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit); +void TM_PwmInputInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit); +void TM_TimeBaseStructInit(TM_TimeBaseInitTypeDef* TimeBaseInit); +void TM_OutputStructInit(TM_OutputInitTypeDef* OutInit); +void TM_CaptureStructInit(TM_CaptureInitTypeDef* CapInit); +void TM_Cmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +#if (LIBCFG_TM_NO_ITI == 1) +#else +void TM_ItiExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Iti); +#endif +void TM_ChExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel, TM_CHP_Enum Pol, u8 Filter); +#if 0 // M0+ not supported +void TM_EtiExternalClockConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter); +void TM_EtiConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter); +#endif +void TM_PrescalerConfig(HT_TM_TypeDef* TMx, u16 Psc, TM_PSC_RLD_Enum PscReloadTime); +void TM_CounterModeConfig(HT_TM_TypeDef* TMx, TM_CNT_MODE_Enum Mod); +void TM_StiConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel); +void TM_DecoderConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum DecoderMod, TM_CHP_Enum CH0P, TM_CHP_Enum CH1P); + +void TM_ForcedOREF(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, TM_OM_Enum ForcedAction); +void TM_CRRPreloadCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_CHCCRPreloadConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState); +void TM_ClearOREFConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState); +void TM_ChPolarityConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHP_Enum Pol); + +void TM_ImmActiveConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState); +void TM_ChannelConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control); + +void TM_OutputModeConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_OM_Enum Mod); +void TM_UpdateCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_UEVG_IntConfig(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_HallInterfaceCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_SinglePulseModeCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_MMSELConfig(HT_TM_TypeDef* TMx, TM_MMSEL_Enum Sel); +void TM_SlaveModeConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum Sel); +void TM_TimSyncCmd(HT_TM_TypeDef* TMx, ControlStatus NewState); +void TM_SetCounter(HT_TM_TypeDef* TMx, u16 Counter); +void TM_SetCounterReload(HT_TM_TypeDef* TMx, u16 Reload); +void TM_SetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp); +void TM_SetAsymmetricCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp); + +void TM_CHPSCConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHPSC_Enum Psc); +void TM_CKDIVConfig(HT_TM_TypeDef* TMx, TM_CKDIV_Enum Div); +u32 TM_GetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n); +u32 TM_GetCounter(HT_TM_TypeDef* TMx); +u32 TM_GetPrescaler(HT_TM_TypeDef* TMx); +void TM_GenerateEvent(HT_TM_TypeDef* TMx, u32 TM_EVENT); +FlagStatus TM_GetFlagStatus(HT_TM_TypeDef* TMx, u32 TM_FLAG); +void TM_ClearFlag(HT_TM_TypeDef* TMx, u32 TM_FLAG); +void TM_IntConfig(HT_TM_TypeDef* TMx, u32 TM_INT, ControlStatus NewState); +FlagStatus TM_GetIntStatus(HT_TM_TypeDef* TMx, u32 TM_INT); +void TM_ClearIntPendingBit(HT_TM_TypeDef* TMx, u32 TM_INT); +void TM_InternalClockConfig(HT_TM_TypeDef* TMx); + +#if (LIBCFG_PDMA) +void TM_CHCCDSConfig(HT_TM_TypeDef* TMx, TM_CHCCDS_Enum Selection); +void TM_PDMAConfig(HT_TM_TypeDef* TMx, u32 TM_PDMA, ControlStatus NewState); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm_type.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm_type.h new file mode 100644 index 0000000000..a6ef678b37 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_tm_type.h @@ -0,0 +1,129 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_tm_type.h + * @version $Rev:: 7319 $ + * @date $Date:: 2023-10-28 #$ + * @brief The header file of the TM library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_TM_TYPE_H +#define __HT32F5XXXX_TM_TYPE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup TM + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Types TM exported types + * @{ + */ +/** + * @brief Enumeration of TM channel. + */ +typedef enum +{ + TM_CH_0 = 0, /*!< TM channel 0 */ + TM_CH_1, /*!< TM channel 1 */ + TM_CH_2, /*!< TM channel 2 */ + TM_CH_3, /*!< TM channel 3 */ +#if (LIBCFG_PWM_8_CHANNEL) + TM_CH_4, /*!< TM channel 4 */ + TM_CH_5, /*!< TM channel 5 */ + TM_CH_6, /*!< TM channel 6 */ + TM_CH_7, /*!< TM channel 7 */ +#endif +} TM_CH_Enum; +/** + * @brief Enumeration of TM channel control. + */ +typedef enum +{ + TM_CHCTL_DISABLE = 0, /*!< TM channel disable */ + TM_CHCTL_ENABLE /*!< TM channel enable */ +} TM_CHCTL_Enum; +/** + * @brief Enumeration of TM channel polarity. + */ +typedef enum +{ + TM_CHP_NONINVERTED = 0, /*!< TM channel polarity is active high or rising edge */ + TM_CHP_INVERTED /*!< TM channel polarity is active low or falling edge */ +} TM_CHP_Enum; +/** + * @brief Enumeration of MCTM channel output idle state. + */ +typedef enum +{ + MCTM_OIS_LOW = 0, /*!< MCTM channel output low when CHMOE equal to 0 */ + MCTM_OIS_HIGH /*!< MCTM channel output high when CHMOE equal to 0 */ +} MCTM_OIS_Enum; +/** + * @brief Enumeration of MCTM COMUS. + */ +typedef enum +{ + MCTM_COMUS_STIOFF = 0, /*!< MCTM capture/compare control bits are updated by + setting the UEV2G bit only */ + MCTM_COMUS_STION /*!< MCTM capture/compare control bits are updated by both + setting the UEV2G bit or when a rising edge occurs on STI */ +} MCTM_COMUS_Enum; +#if (LIBCFG_MCTM_UEV1DIS) +/** + * @brief Enumeration of MCTM update event1 disasble. + */ +typedef enum +{ + MCTM_UEV1UD = 0x00000004, /*!< MCTM update event 1 rquest by overflow disable control */ + MCTM_UEV1OD = 0x00000008, /*!< MCTM update event 1 rquest by underflow disable control */ +} MCTM_UEV1DIS_Enum; +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usart.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usart.h new file mode 100644 index 0000000000..bb0d75fe15 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usart.h @@ -0,0 +1,499 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_usart.h + * @version $Rev:: 7107 $ + * @date $Date:: 2023-08-08 #$ + * @brief The header file of the USART library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_USART_H +#define __HT32F5XXXX_USART_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup USART + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Types USART exported types + * @{ + */ +/* Definition of USART Init Structure ---------------------------------------------------------------------*/ +typedef struct +{ + u32 USART_BaudRate; + u16 USART_WordLength; + u16 USART_StopBits; + u16 USART_Parity; + u32 USART_Mode; +} USART_InitTypeDef; + +typedef struct +{ + u16 USART_ClockEnable; + u16 USART_ClockPhase; + u16 USART_ClockPolarity; + u16 USART_TransferSelectMode; +} USART_SynClock_InitTypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Constants USART exported constants + * @{ + */ + +#define USART_CMD_TX (0) +#define USART_CMD_RX (1) + +#define USART_CMD_OUT (0) +#define USART_CMD_IN (1) + +/* USART Word Length ---------------------------------------------------------------------------------------*/ +/** @defgroup USART_Word_Length Definitions of USART word length + * @{ + */ +#define USART_WORDLENGTH_7B ((u32)0x00000000) +#define USART_WORDLENGTH_8B ((u32)0x00000100) +#define USART_WORDLENGTH_9B ((u32)0x00000200) + +#define IS_USART_WORD_LENGTH(LENGTH) ((LENGTH == USART_WORDLENGTH_9B) || \ + (LENGTH == USART_WORDLENGTH_8B) || \ + (LENGTH == USART_WORDLENGTH_7B)) +/** + * @} + */ + +/* USART Stop Bits -----------------------------------------------------------------------------------------*/ +/** @defgroup USART_Stop_Bit Definitions of USART stop bit + * @{ + */ +#define USART_STOPBITS_1 ((u32)0x00000000) +#define USART_STOPBITS_2 ((u32)0x00000400) + + +#define IS_USART_STOPBITS(STOPBITS) ((STOPBITS == USART_STOPBITS_1) || \ + (STOPBITS == USART_STOPBITS_2)) +/** + * @} + */ + +/* USART Parity --------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Parity Definitions of USART parity + * @{ + */ +#define USART_PARITY_NO ((u32)0x00000000) +#define USART_PARITY_EVEN ((u32)0x00001800) +#define USART_PARITY_ODD ((u32)0x00000800) +#define USART_PARITY_MARK ((u32)0x00002800) +#define USART_PARITY_SPACE ((u32)0x00003800) + +#define IS_USART_PARITY(PARITY) ((PARITY == USART_PARITY_NO) || \ + (PARITY == USART_PARITY_EVEN) || \ + (PARITY == USART_PARITY_ODD)) +/** + * @} + */ + +/* USART Mode ----------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Mode Definitions of USART mode + * @{ + */ +#define USART_MODE_NORMAL ((u32)0x00000000) +#define USART_MODE_IRDA ((u32)0x00000001) +#define USART_MODE_RS485 ((u32)0x00000002) +#define USART_MODE_SYNCHRONOUS ((u32)0x00000003) +#if (LIBCFG_USART_LIN) +#define USART_MODE_LIN ((u32)0x00010000) +#define IS_MODE_LIN(x) (x == USART_MODE_LIN) +#else +#define IS_MODE_LIN(x) (0) +#endif +#if (LIBCFG_USART_SINGLE_WIRE) +#define USART_MODE_SINGLE_WIRE ((u32)0x00010001) +#define IS_MODE_SINGLE_WIRE(x) (x == USART_MODE_SINGLE_WIRE) +#else +#define IS_MODE_SINGLE_WIRE(x) (0) +#endif +#define IS_USART_MODE(MODE) ((MODE == USART_MODE_NORMAL) || \ + (MODE == USART_MODE_IRDA) || \ + (MODE == USART_MODE_RS485) || \ + (MODE == USART_MODE_SYNCHRONOUS) || \ + IS_MODE_LIN(MODE) || \ + IS_MODE_SINGLE_WIRE(MODE)) +/** + * @} + */ + +/* USART Transfer Select Mode ------------------------------------------------------------------------------*/ +/** @defgroup USART_LSB Definitions of USART LSB + * @{ + */ +#define USART_LSB_FIRST ((u32)0x00000000) +#define USART_MSB_FIRST ((u32)0x00000004) + +#define IS_USART_TRANSFER_MODE(TMODE) ((TMODE == USART_LSB_FIRST) || \ + (TMODE == USART_MSB_FIRST)) +/** + * @} + */ + + +/* USART Synchronous Clock ---------------------------------------------------------------------------------*/ +/** @defgroup USART_Synchronous_Clock Definitions of USART synchronous clock + * @{ + */ +#define USART_SYN_CLOCK_DISABLE ((u32)0x00000000) +#define USART_SYN_CLOCK_ENABLE ((u32)0x00000001) + +#define IS_USART_SYNCHRONOUS_CLOCK(SYNCLOCK) ((SYNCLOCK == USART_SYN_CLOCK_DISABLE) || \ + (SYNCLOCK == USART_SYN_CLOCK_ENABLE)) +/** + * @} + */ + +/* USART Synchronous Clock Phase ---------------------------------------------------------------------------*/ +/** @defgroup USART_Synchronous_Clock_Phase Definitions of USART Synchronous clock phase + * @{ + */ +#define USART_SYN_CLOCK_PHASE_FIRST ((u32)0x00000000) +#define USART_SYN_CLOCK_PHASE_SECOND ((u32)0x00000004) + +#define IS_USART_SYNCHRONOUS_PHASE(PHASE) ((PHASE == USART_SYN_CLOCK_PHASE_FIRST) || \ + (PHASE == USART_SYN_CLOCK_PHASE_SECOND)) +/** + * @} + */ + +/* USART Clock Polarity ------------------------------------------------------------------------------------*/ +/** @defgroup USART_Clock_Polarity Definitions of USART clock polarity + * @{ + */ +#define USART_SYN_CLOCK_POLARITY_LOW ((u32)0x00000000) +#define USART_SYN_CLOCK_POLARITY_HIGH ((u32)0x00000008) + +#define IS_USART_SYNCHRONOUS_POLARITY(POLARITY) ((POLARITY == USART_SYN_CLOCK_POLARITY_LOW) || \ + (POLARITY == USART_SYN_CLOCK_POLARITY_HIGH)) +/** + * @} + */ + +/* USART IrDA ---------------------------------------------------------------------------------------------*/ +/** @defgroup USART_IrDA Definitions of USART IrDA + * @{ + */ +#define USART_IRDA_LOWPOWER ((u32)0x00000002) +#define USART_IRDA_NORMAL ((u32)0xFFFFFFFD) + +#define IS_USART_IRDA_MODE(MODE) ((MODE == USART_IRDA_LOWPOWER) || \ + (MODE == USART_IRDA_NORMAL)) + +#define USART_IRDA_TX ((u32)0x00000004) +#define USART_IRDA_RX ((u32)0xFFFFFFFB) + +#define IS_USART_IRDA_DIRECTION(DIRECTION) ((DIRECTION == USART_IRDA_TX) || \ + (DIRECTION == USART_IRDA_RX)) +/** + * @} + */ + +#define IS_USART_TL(x) (IS_USART_RXTL(x) || IS_USART_TXTL(x)) + +/* USART Rx FIFO Interrupt Trigger Level -------------------------------------------------------------------*/ +/** @defgroup USART_RX_FIFO_Trigger_Level Definitions of USART Rx FIFO interrupts + * @{ + */ +#define USART_RXTL_01 ((u32)0x00000000) +#define USART_RXTL_02 ((u32)0x00000010) +#define USART_RXTL_04 ((u32)0x00000020) +#define USART_RXTL_06 ((u32)0x00000030) + +#define IS_USART_RXTL(RXTL) ((RXTL == USART_RXTL_01) || \ + (RXTL == USART_RXTL_02) || \ + (RXTL == USART_RXTL_04) || \ + (RXTL == USART_RXTL_06)) +/** + * @} + */ + +/* USART Tx FIFO Interrupt Trigger Level -------------------------------------------------------------------*/ +/** @defgroup USART_TX_FIFO_Trigger_Level Definitions of USART Tx FIFO interrupts + * @{ + */ +#define USART_TXTL_00 ((u32)0x00000000) +#define USART_TXTL_02 ((u32)0x00000010) +#define USART_TXTL_04 ((u32)0x00000020) +#define USART_TXTL_06 ((u32)0x00000030) + +#define IS_USART_TXTL(TXTL) ((TXTL == USART_TXTL_00) || \ + (TXTL == USART_TXTL_02) || \ + (TXTL == USART_TXTL_04) || \ + (TXTL == USART_TXTL_06)) +/** + * @} + */ + +/* USART Interrupt definition ------------------------------------------------------------------------------*/ +/** @defgroup USART_Interrupt_Enable Definitions of USART interrupt Enable bits + * @{ + */ +#define USART_INT_RXDR ((u32)0x00000001) +#define USART_INT_TXDE ((u32)0x00000002) +#define USART_INT_TXC ((u32)0x00000004) +#define USART_INT_OE ((u32)0x00000008) +#define USART_INT_PE ((u32)0x00000010) +#define USART_INT_FE ((u32)0x00000020) +#define USART_INT_BI ((u32)0x00000040) +#define USART_INT_RSADD ((u32)0x00000080) +#define USART_INT_TOUT ((u32)0x00000100) +#define USART_INT_CTS ((u32)0x00000200) +#if (LIBCFG_USART_LIN) +#define USART_INT_LBD ((u32)0x00000400) +#endif + +#if (LIBCFG_USART_LIN) +#define IS_USART_INT(INT) ((((INT) & 0xFFFFF800) == 0) && ((INT) != 0)) +#else +#define IS_USART_INT(INT) ((((INT) & 0xFFFFFC00) == 0) && ((INT) != 0)) +#endif +/** + * @} + */ + +/* USART Flags ---------------------------------------------------------------------------------------------*/ +/** @defgroup USART_Flag Definitions of USART flags + * @{ + */ +#define USART_FLAG_RXDNE ((u32)0x00000001) +#define USART_FLAG_OE ((u32)0x00000002) +#define USART_FLAG_PE ((u32)0x00000004) +#define USART_FLAG_FE ((u32)0x00000008) +#define USART_FLAG_BI ((u32)0x00000010) +#define USART_FLAG_RXDR ((u32)0x00000020) +#define USART_FLAG_TOUT ((u32)0x00000040) +#define USART_FLAG_TXDE ((u32)0x00000080) +#define USART_FLAG_TXC ((u32)0x00000100) +#define USART_FLAG_RSADD ((u32)0x00000200) +#define USART_FLAG_CTSC ((u32)0x00000400) +#define USART_FLAG_CTSS ((u32)0x00000800) +#if (LIBCFG_USART_LIN) +#define USART_FLAG_LBD ((u32)0x00001000) +#define IS_FLAG_LBD(x) (x == USART_FLAG_LBD) +#else +#define IS_FLAG_LBD(x) (0) +#endif + +#define IS_USART_FLAG(FLAG) ((FLAG == USART_FLAG_RXDNE) || (FLAG == USART_FLAG_OE) || \ + (FLAG == USART_FLAG_PE) || (FLAG == USART_FLAG_FE) || \ + (FLAG == USART_FLAG_BI) || (FLAG == USART_FLAG_RXDR) || \ + (FLAG == USART_FLAG_TOUT) || (FLAG == USART_FLAG_TXDE) || \ + (FLAG == USART_FLAG_TXC) || (FLAG == USART_FLAG_RSADD) || \ + (FLAG == USART_FLAG_CTSC) || (FLAG == USART_FLAG_CTSS) || \ + IS_FLAG_LBD(FLAG)) + +#define IS_USART_CLEAR_FLAG(FLAG) ((FLAG == USART_FLAG_OE) || (FLAG == USART_FLAG_PE) || \ + (FLAG == USART_FLAG_FE) || (FLAG == USART_FLAG_BI) || \ + (FLAG == USART_FLAG_TOUT) || (FLAG == USART_FLAG_RSADD) || \ + (FLAG == USART_FLAG_CTSC) || IS_FLAG_LBD(FLAG)) +/** + * @} + */ + +/* USART RS485 definition ----------------------------------------------------------------------------------*/ +/** @defgroup USART_RS485 Definitions of USART RS485 + * @{ + */ +#define USART_RS485POLARITY_LOW ((u32)0x00000001) +#define USART_RS485POLARITY_HIGH ((u32)0xFFFFFFFE) + +#define IS_USART_RS485_POLARITY(POLARITY) ((POLARITY == USART_RS485POLARITY_LOW) || \ + (POLARITY == USART_RS485POLARITY_HIGH)) +/** + * @} + */ + +/* USART LIN definition -----------------------------------------------------------------------------------*/ +/** @defgroup USART_LIN Definitions of USART LIN + * @{ + */ +#if (LIBCFG_USART_LIN) +#define USART_LINSENDBREAK ((u32)0x00020000) + +#define USART_LINLENGTH_10BIT ((u32)0xFFFBFFFF) +#define USART_LINLENGTH_11BIT ((u32)0x00040000) + +#define IS_USART_LINLENGTH(LENGTH) ((LENGTH == USART_LINLENGTH_10BIT) || \ + (LENGTH == USART_LINLENGTH_11BIT)) +#endif +/** + * @} + */ + +#define USART_FIFO_TX ((u32)0x00000001) +#define USART_FIFO_RX ((u32)0x00000002) + +#define IS_USART_FIFO_DIRECTION(DIRECTION) ((DIRECTION == USART_FIFO_TX) || \ + (DIRECTION == USART_FIFO_RX)) + +#define USART_STICK_LOW ((u32)0x00001000) +#define USART_STICK_HIGH ((u32)0xFFFFEFFF) + +#define IS_USART_STICK_PARITY(PARITY) ((PARITY == USART_STICK_LOW) || (PARITY == USART_STICK_HIGH)) + +#if (LIBCFG_PDMA) +#define USART_PDMAREQ_TX ((u32)0x00000040) +#define USART_PDMAREQ_RX ((u32)0x00000080) + +#define IS_USART_PDMA_REQ(REQ) (((REQ & 0xFFFFFF3F) == 0x0) && (REQ != 0x0)) +#endif + +#define IS_USART(x) (IS_USART0(x) || \ + IS_USART1(x) || \ + IS_UART0(x) || \ + IS_UART1(x) || \ + IS_UART2(x) || \ + IS_UART3(x)) +#if (LIBCFG_NO_USART0) +#define IS_USART0(x) (0) +#else +#define IS_USART0(x) (x == HT_USART0) +#endif +#define IS_UART0(x) (x == HT_UART0) +#if (LIBCFG_USART1) +#define IS_USART1(x) (x == HT_USART1) +#else +#define IS_USART1(x) (0) +#endif +#if (LIBCFG_UART1) +#define IS_UART1(x) (x == HT_UART1) +#else +#define IS_UART1(x) (0) +#endif +#if (LIBCFG_UART2) +#define IS_UART2(x) (x == HT_UART2) +#else +#define IS_UART2(x) (0) +#endif +#if (LIBCFG_UART3) +#define IS_UART3(x) (x == HT_UART3) +#else +#define IS_UART3(x) (0) +#endif +#define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE > 0) && (BAUDRATE < 0x0044AA21)) +#define IS_USART_DATA(DATA) (DATA <= 0x1FF) +#define IS_USART_GUARD_TIME(TIME) (TIME <= 0xFF) +#define IS_USART_IRDA_PRESCALER(PRESCALER) (PRESCALER <= 0xFF) +#define IS_USART_TIMEOUT(TIMEOUT) (TIMEOUT <= 0x7F) +#define IS_USART_ADDRESS_MATCH_VALUE(VALUE) (VALUE <= 0xFF) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Functions USART exported functions + * @{ + */ +#define USART_TxCmd(USARTx, NewState) USART_TxRxCmd(USARTx, USART_CMD_TX, NewState) +#define USART_RxCmd(USARTx, NewState) USART_TxRxCmd(USARTx, USART_CMD_RX, NewState) + +#define USART_TxPDMACmd(USARTx, NewState) USART_PDMACmd(USARTx, USART_PDMAREQ_TX, NewState) +#define USART_RxPDMACmd(USARTx, NewState) USART_PDMACmd(USARTx, USART_PDMAREQ_RX, NewState) + +#define USART_RXTLConfig(USARTx, USART_tl) USART_TXRXTLConfig(USARTx, USART_CMD_RX, USART_tl) +#define USART_TXTLConfig(USARTx, USART_tl) USART_TXRXTLConfig(USARTx, USART_CMD_TX, USART_tl) + +#define USART_IrDAInvtOutputCmd(USARTx, NewState) USART_IrDAInvtCmd(USARTx, USART_CMD_OUT, NewState) +#define USART_IrDAInvtInputCmd(USARTx, NewState) USART_IrDAInvtCmd(USARTx, USART_CMD_IN, NewState) + +void USART_DeInit(HT_USART_TypeDef* USARTx); +void USART_Init(HT_USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStructure); +void USART_StructInit(USART_InitTypeDef* USART_InitStructure); +void USART_SendData(HT_USART_TypeDef* USARTx, u16 Data); +u16 USART_ReceiveData(HT_USART_TypeDef* USARTx); +FlagStatus USART_GetFlagStatus(HT_USART_TypeDef* USARTx, u32 USART_FLAG_x); +FlagStatus USART_GetIntStatus(HT_USART_TypeDef* USARTx, u32 USART_FLAG_x); +void USART_ClearFlag(HT_USART_TypeDef* USARTx, u32 USART_Flag); +void USART_IntConfig(HT_USART_TypeDef* USARTx, u32 USART_INT_x, ControlStatus NewState); +void USART_TxRxCmd(HT_USART_TypeDef* USARTx,u32 TxRx, ControlStatus NewState); +#if (LIBCFG_PDMA) +void USART_PDMACmd(HT_USART_TypeDef* USARTx, u32 USART_PDMAREQ, ControlStatus NewState); +#endif +void USART_ForceBreakCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_StickParityCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_StickParityConfig(HT_USART_TypeDef* USARTx, u32 USART_StickParity); + +void USART_SetGuardTime(HT_USART_TypeDef* USARTx, u32 USART_GuardTime); +void USART_TXRXTLConfig(HT_USART_TypeDef* USARTx, u32 TxRx, u32 USART_tl); +void USART_SetTimeOutValue(HT_USART_TypeDef* USARTx, u32 USART_TimeOut); +void USART_FIFOReset(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection); +u8 USART_GetFIFOStatus(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection); +void USART_HardwareFlowControlCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); + +void USART_IrDACmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_IrDAConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDAMode); +void USART_SetIrDAPrescaler(HT_USART_TypeDef* USARTx, u32 USART_IrDAPrescaler); +void USART_IrDADirectionConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDADirection); +void USART_IrDAInvtCmd(HT_USART_TypeDef* USARTx, u32 inout, ControlStatus NewState); + +void USART_RS485TxEnablePolarityConfig(HT_USART_TypeDef* USARTx, u32 USART_RS485Polarity); +void USART_RS485NMMCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_RS485AADCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState); +void USART_SetAddressMatchValue(HT_USART_TypeDef* USARTx, u32 USART_AddressMatchValue); + +void USART_SynClockInit(HT_USART_TypeDef* USARTx, USART_SynClock_InitTypeDef* USART_SynClock_InitStruct); +void USART_SynClockStructInit(USART_SynClock_InitTypeDef* USART_SynClock_InitStruct); + +#if (LIBCFG_USART_LIN) +void USART_LIN_SendBreak(HT_USART_TypeDef* USARTx); +void USART_LIN_LengthSelect(HT_USART_TypeDef* USARTx, u32 USART_LIN_Length); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbd.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbd.h new file mode 100644 index 0000000000..c9ebd0e408 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbd.h @@ -0,0 +1,346 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_usbd.h + * @version $Rev:: 6559 $ + * @date $Date:: 2022-12-18 #$ + * @brief The header file of the USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_USBD_H +#define __HT32F5XXXX_USBD_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +#if (LIBCFG_USBD_V2) +#include "ht32f5xxxx_02_usbdconf.h" +#else +#include "ht32f5xxxx_01_usbdconf.h" +#endif +#include "ht32f5xxxx_usbdinit.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup USBDevice USB Device + * @brief USB Device driver modules + * @{ + */ + + +/* Settings ------------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Settings USB Device settings + * @{ + */ +#if (LIBCFG_USBD_V2) +#define MAX_EP_NUM (10) +#else +#define MAX_EP_NUM (8) +#endif +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Types USB Device exported types + * @{ + */ +/* USB Endpoint number */ +typedef enum +{ + USBD_EPT0 = 0, + USBD_EPT1 = 1, + USBD_EPT2 = 2, + USBD_EPT3 = 3, + USBD_EPT4 = 4, + USBD_EPT5 = 5, + USBD_EPT6 = 6, + USBD_EPT7 = 7, + #if (LIBCFG_USBD_V2) + USBD_EPT8 = 8, + USBD_EPT9 = 9, + #endif + USBD_NOEPT = -1, +} USBD_EPTn_Enum; + +typedef enum +{ + USBD_TCR_0 = 0, + USBD_TCR_1 = 16, +} USBD_TCR_Enum; + +typedef enum +{ + USBD_NAK = 0, + USBD_ACK = 1 +} USBD_Handshake_Enum; + +/* Endpoint CFGR Register */ +typedef struct _EPTCFGR_BIT +{ + vu32 EPBUFA: 10; + vu32 EPLEN : 10; + vu32 _RES0 : 3; + vu32 SDBS : 1; + vu32 EPADR : 4; + vu32 EPDIR : 1; + vu32 EPTYPE: 1; + vu32 _RES1 : 1; + vu32 EPEN : 1; +} USBD_EPTCFGR_Bit; + +typedef union _EPTCFGR_TYPEDEF +{ + USBD_EPTCFGR_Bit bits; + u32 word; +} USBD_EPTCFGR_TypeDef; + +/* Endpoint CFGR and IER Register */ +typedef struct +{ + USBD_EPTCFGR_TypeDef CFGR; + u32 IER; +} USBD_EPTInit_TypeDef; + +/* Endpoint 0 ~ MAX_EP_NUM */ +typedef struct +{ + u32 uInterruptMask; + USBD_EPTInit_TypeDef ept[MAX_EP_NUM]; +} USBD_Driver_TypeDef; +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Constants USB Device exported constants + * @{ + */ + +/* USB Interrupt Enable Register (USBIER) */ +#define UGIE ((u32)0x00000001) /*!< USB global Interrupt Enable */ +#define SOFIE ((u32)0x00000002) /*!< Start Of Frame Interrupt Enable */ +#define URSTIE ((u32)0x00000004) /*!< USB Reset Interrupt Enable */ +#define RSMIE ((u32)0x00000008) /*!< Resume Interrupt Enable */ +#define SUSPIE ((u32)0x00000010) /*!< Suspend Interrupt Enable */ +#define ESOFIE ((u32)0x00000020) /*!< Expected Start Of Frame Interrupt Enable */ +#define FRESIE ((u32)0x00000040) /*!< Force USB Reset Control Interrupt Enable */ +#define EP0IE ((u32)0x00000100) /*!< Endpoint 0 Interrupt Enable */ +#define EP1IE ((u32)0x00000200) /*!< Endpoint 1 Interrupt Enable */ +#define EP2IE ((u32)0x00000400) /*!< Endpoint 2 Interrupt Enable */ +#define EP3IE ((u32)0x00000800) /*!< Endpoint 3 Interrupt Enable */ +#define EP4IE ((u32)0x00001000) /*!< Endpoint 4 Interrupt Enable */ +#define EP5IE ((u32)0x00002000) /*!< Endpoint 5 Interrupt Enable */ +#define EP6IE ((u32)0x00004000) /*!< Endpoint 6 Interrupt Enable */ +#define EP7IE ((u32)0x00008000) /*!< Endpoint 7 Interrupt Enable */ + +/* USB Interrupt Status Register (USBISR) */ +#define SOFIF ((u32)0x00000002) /*!< Start Of Frame Interrupt Flag */ +#define URSTIF ((u32)0x00000004) /*!< USB Reset Interrupt Flag */ +#define RSMIF ((u32)0x00000008) /*!< Resume Interrupt Flag */ +#define SUSPIF ((u32)0x00000010) /*!< Suspend Interrupt Flag */ +#define ESOFIF ((u32)0x00000020) /*!< Expected Start Of Frame Interrupt Flag */ +#define FRESIF ((u32)0x00000040) /*!< Force USB Reset Control Interrupt Flag */ +#define EP0IF ((u32)0x00000100) /*!< Endpoint 0 Interrupt flag */ +#define EP1IF ((u32)0x00000200) /*!< Endpoint 1 Interrupt flag */ +#define EP2IF ((u32)0x00000400) /*!< Endpoint 2 Interrupt flag */ +#define EP3IF ((u32)0x00000800) /*!< Endpoint 3 Interrupt flag */ +#define EP4IF ((u32)0x00001000) /*!< Endpoint 4 Interrupt flag */ +#define EP5IF ((u32)0x00002000) /*!< Endpoint 5 Interrupt flag */ +#define EP6IF ((u32)0x00004000) /*!< Endpoint 6 Interrupt flag */ +#define EP7IF ((u32)0x00008000) /*!< Endpoint 7 Interrupt flag */ +#if (LIBCFG_USBD_V2) +#define EP8IF ((u32)0x00010000) /*!< Endpoint 8 Interrupt flag */ +#define EP9IF ((u32)0x00020000) /*!< Endpoint 9 Interrupt flag */ +#define EPnIF ((u32)0x0003FF00) /*!< Endpoint n Interrupt flag */ +#else +#define EPnIF ((u32)0x0000FF00) /*!< Endpoint n Interrupt flag */ +#endif + + +/* USB Endpoint n Interrupt Enable Register (USBEPnIER) */ +#define OTRXIE ((u32)0x00000001) /*!< OUT Token Received Interrupt Enable */ +#define ODRXIE ((u32)0x00000002) /*!< OUT Data Received Interrupt Enable */ +#define ODOVIE ((u32)0x00000004) /*!< OUT Data Buffer Overrun Interrupt Enable */ +#define ITRXIE ((u32)0x00000008) /*!< IN Token Received Interrupt Enable */ +#define IDTXIE ((u32)0x00000010) /*!< IN Data Transmitted Interrupt Enable */ +#define NAKIE ((u32)0x00000020) /*!< NAK Transmitted Interrupt Enable */ +#define STLIE ((u32)0x00000040) /*!< STALL Transmitted Interrupt Enable */ +#define UERIE ((u32)0x00000080) /*!< USB Error Interrupt Enable */ +#define STRXIE ((u32)0x00000100) /*!< SETUP Token Received Interrupt Enable */ +#define SDRXIE ((u32)0x00000200) /*!< SETUP Data Received Interrupt Enable */ +#define SDERIE ((u32)0x00000400) /*!< SETUP Data Error Interrupt Enable */ +#define ZLRXIE ((u32)0x00000800) /*!< Zero Length Data Received Interrupt Enable */ + +/* USB Endpoint n Interrupt Status Register (USBEPnISR) */ +#define OTRXIF ((u32)0x00000001) /*!< OUT Token Received Interrupt Flag */ +#define ODRXIF ((u32)0x00000002) /*!< OUT Data Received Interrupt Flag */ +#define ODOVIF ((u32)0x00000004) /*!< OUT Data Buffer Overrun Interrupt Flag */ +#define ITRXIF ((u32)0x00000008) /*!< IN Token Received Interrupt Flag */ +#define IDTXIF ((u32)0x00000010) /*!< IN Data Transmitted Interrupt Flag */ +#define NAKIF ((u32)0x00000020) /*!< NAK Transmitted Interrupt Flag */ +#define STLIF ((u32)0x00000040) /*!< STALL Transmitted Interrupt Flag */ +#define UERIF ((u32)0x00000080) /*!< USB Error Interrupt Flag */ +#define STRXIF ((u32)0x00000100) /*!< SETUP Token Received Interrupt Flag */ +#define SDRXIF ((u32)0x00000200) /*!< SETUP Data Received Interrupt Flag */ +#define SDERIF ((u32)0x00000400) /*!< SETUP Data Error Interrupt Flag */ +#define ZLRXIF ((u32)0x00000800) /*!< Zero Length Data Received Interrupt Flag */ + +/* USB Endpoint n Control and Status Register (USBEPnCSR) */ +#define DTGTX ((u32)0x00000001) /*!< Data Toggle Status, for IN transfer */ +#define NAKTX ((u32)0x00000002) /*!< NAK Status, for IN transfer */ +#define STLTX ((u32)0x00000004) /*!< STALL Status, for IN transfer */ +#define DTGRX ((u32)0x00000008) /*!< Data Toggle Status, for OUT transfer */ +#define NAKRX ((u32)0x00000010) /*!< NAK Status, for OUT transfer */ +#define STLRX ((u32)0x00000020) /*!< STALL Status, for OUT transfer */ + +/* For USBD_EPTGetTranssferCount function */ +#define USBD_CNTB0 (USBD_TCR_0) +#define USBD_CNTB1 (USBD_TCR_1) +#define USBD_CNTIN (USBD_TCR_0) +#define USBD_CNTOUT (USBD_TCR_1) +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Macro USB Device exported macro + * @{ + */ +/* API macro for USB Core - Global event and operation */ +#define API_USB_INIT(driver) (USBD_Init(driver)) +#define API_USB_DEINIT() (USBD_DeInit()) +#define API_USB_POWER_UP(driver, power) (USBD_PowerUp(driver, power)) +#define API_USB_POWER_OFF() (USBD_PowerOff()) +#define API_USB_POWER_ON() (USBD_PowerOn()) +#define API_USB_REMOTE_WAKEUP() (USBD_RemoteWakeup()) +#define API_USB_READ_SETUP(buffer) (USBD_ReadSETUPData((u32 *)(buffer))) +#define API_USB_SET_ADDR(addr) (USBD_SetAddress(addr)) +#define API_USB_GET_CTRL_IN_LEN() (USBD_EPTGetBufferLen(USBD_EPT0)) +#define API_USB_ENABLE_INT(flag) (USBD_EnableINT(flag)) +#define API_USB_GET_INT() (USBD_GetINT()) +#define API_USB_GET_EPT_NUM(flag) (USBD_GetEPTnINTNumber(flag)) +#define API_USB_IS_SETUP_INT(flag) (flag & SDRXIF) +#define API_USB_CLR_SETUP_INT() (USBD_EPTClearINT(USBD_EPT0, SDRXIF)) +#define API_USB_IS_RESET_INT(flag) (flag & URSTIF) +#define API_USB_CLR_RESET_INT() (USBD_ClearINT(URSTIF)) +#define API_USB_IS_SOF_INT(flag) (flag & SOFIF) +#define API_USB_CLR_SOF_INT() (USBD_ClearINT(SOFIF)) +#define API_USB_IS_FRES_INT(flag) (flag & FRESIF) +#define API_USB_CLR_FRES_INT() (USBD_ClearINT(FRESIF)) +#define API_USB_IS_RESUME_INT(flag) (flag & RSMIF) +#define API_USB_CLR_RESUME_INT() (USBD_ClearINT(RSMIF)) +#define API_USB_IS_SUSPEND_INT(flag) (flag & SUSPIF) +#define API_USB_CLR_SUSPEND_INT() (USBD_ClearINT(SUSPIF)) +#define API_USB_IS_EPTn_INT(flag, EPTn) (flag & (EP0IF << EPTn)) +#define API_USB_CLR_EPTn_INT(EPTn) (USBD_ClearINT(EP0IF << EPTn)) + +/* API macro for USB Core - Endpoint event and operation */ +#define API_USB_EPTn_INIT(EPTn, driver) (USBD_EPTInit(EPTn, driver)) +#define API_USB_EPTn_RESET(EPTn) (USBD_EPTReset(EPTn)) +#define API_USB_EPTn_SEND_STALL(EPTn) (USBD_EPTSendSTALL(EPTn)) +#define API_USB_EPTn_GET_INT(EPTn) (USBD_EPTGetINT(EPTn)) +#define API_USB_EPTn_IS_IN_INT(flag) (flag & IDTXIF) +#define API_USB_EPTn_CLR_IN_INT(EPTn) (USBD_EPTClearINT(EPTn, IDTXIF)) +#define API_USB_EPTn_IS_OUT_INT(flag) (flag & ODRXIF) +#define API_USB_EPTn_CLR_OUT_INT(EPTn) (USBD_EPTClearINT(EPTn, ODRXIF)) +#define API_USB_EPTn_IS_INT(flag) (flag & (ODRXIF | IDTXIF)) +#define API_USB_EPTn_CLR_INT(EPTn) (USBD_EPTClearINT(EPTn, (ODRXIF | IDTXIF))) +#define API_USB_EPTn_GET_HALT(EPTn) (USBD_EPTGetHalt(EPTn)) +#define API_USB_EPTn_SET_HALT(EPTn) (USBD_EPTSetHalt(EPTn)) +#define API_USB_EPTn_CLR_HALT(EPTn) (USBD_EPTClearHalt(EPTn)) +#define API_USB_EPTn_WAIT_STALL_SENT(EPTn) (USBD_EPTWaitSTALLSent(EPTn)) +#define API_USB_EPTn_CLR_DTG(EPTn) (USBD_EPTClearDTG(EPTn)) +#define API_USB_EPTn_GET_BUFFLEN(EPTn) (USBD_EPTGetBufferLen(EPTn)) +#define API_USB_EPTn_GET_CNT(EPTn, type) (USBD_EPTGetTransferCount(EPTn, type)) +#define API_USB_EPTn_WRITE_IN(EPTn, from, len) (USBD_EPTWriteINData(EPTn, from, len)) +#define API_USB_EPTn_READ_OUT(EPTn, to, len) (USBD_EPTReadOUTData(EPTn, to, len)) +#define API_USB_EPTn_READ_MEM(EPTn, to, len) (USBD_EPTReadMemory(EPTn, to, len)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Functions USB Device exported functions + * @{ + */ +void USBD_Init(u32 *pDriver); +void USBD_PreInit(USBD_Driver_TypeDef *pDriver); +void USBD_DPpullupCmd(ControlStatus NewState); +void USBD_DPWakeUpCmd(ControlStatus NewState); +void USBD_DeInit(void); +void USBD_PowerUp(u32 *pDriver, u32 uIsSelfPowered); +void USBD_PowerOff(void); +void USBD_PowerOn(void); +void USBD_SRAMResetConditionCmd(ControlStatus NewState); +void USBD_DisableDefaultPull(void); +void USBD_RemoteWakeup(void); +void USBD_ReadSETUPData(u32 *pBuffer); +void USBD_SetAddress(u32 address); +void USBD_EnableINT(u32 INTFlag); +void USBD_DisableINT(u32 INTFlag); +u32 USBD_GetINT(void); +void USBD_ClearINT(u32 INTFlag); +USBD_EPTn_Enum USBD_GetEPTnINTNumber(u32 INTFlag); + +void USBD_EPTInit(USBD_EPTn_Enum USBD_EPTn, u32 *pDriver); +void USBD_EPTReset(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTEnableINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag); +u32 USBD_EPTGetINT(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTClearINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag); +void USBD_EPTSendSTALL(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetHalt(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTSetHalt(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTClearHalt(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTWaitSTALLSent(USBD_EPTn_Enum USBD_EPTn); +void USBD_EPTClearDTG(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetBuffer0Addr(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetBuffer1Addr(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetBufferLen(USBD_EPTn_Enum USBD_EPTn); +u32 USBD_EPTGetTransferCount(USBD_EPTn_Enum USBD_EPTn, USBD_TCR_Enum USBD_TCR_0or1); +u32 USBD_EPTWriteINData(USBD_EPTn_Enum USBD_EPTn, u32 *pFrom, u32 len); +u32 USBD_EPTReadOUTData(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +u32 USBD_EPTReadMemory(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdchk.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdchk.h new file mode 100644 index 0000000000..d4d1625cef --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdchk.h @@ -0,0 +1,706 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_usbdchk.h + * @version $Rev:: 5656 $ + * @date $Date:: 2021-11-24 #$ + * @brief The header file of the USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_USBDCHK_H +#define __HT32F5XXXX_USBDCHK_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup USBDevice + * @{ + */ + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint 0 ~ 7 and checking */ +/* !!! DO NOT MODIFY !!! */ +/*----------------------------------------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP0LEN != 8 && _EP0LEN != 16 && _EP0LEN != 32 && _EP0LEN != 64) + #error "USB Buffer Length (EPLEN) of Control Endpoint0 must be 8, 16, 32, or 64 bytes." +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration and checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP1_ENABLE == 1) + #if (_EP1_TYPR == EP_TYPE_BULK) + #if (_EP1LEN != 8 && _EP1LEN != 16 && _EP1LEN != 32 && _EP1LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint1 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP1LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint1 must be less than 64 bytes." + #endif + #if (_EP1LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint1 cannot be 0 byte." + #endif + #if ((_EP1LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint1 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP2_ENABLE == 1) + #if (_EP2_TYPR == EP_TYPE_BULK) + #if (_EP2LEN != 8 && _EP2LEN != 16 && _EP2LEN != 32 && _EP2LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint2 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP2LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint2 must be less than 64 bytes." + #endif + #if (_EP2LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint2 cannot be 0 byte." + #endif + #if ((_EP2LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint2 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP3_ENABLE == 1) + #if (_EP3_TYPR == EP_TYPE_BULK) + #if (_EP3LEN != 8 && _EP3LEN != 16 && _EP3LEN != 32 && _EP3LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint3 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP3LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint3 must be less than 64 bytes." + #endif + #if (_EP3LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint3 cannot be 0 byte." + #endif + #if ((_EP3LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint3 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint8 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP8_ENABLE == 1) + #if (_EP8_TYPR == EP_TYPE_BULK) + #if (_EP8LEN != 8 && _EP8LEN != 16 && _EP8LEN != 32 && _EP8LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint8 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP8LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint8 must be less than 64 bytes." + #endif + #if (_EP8LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint8 cannot be 0 byte." + #endif + #if ((_EP8LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint8 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint9 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP9_ENABLE == 1) + #if (_EP9_TYPR == EP_TYPE_BULK) + #if (_EP9LEN != 8 && _EP9LEN != 16 && _EP9LEN != 32 && _EP9LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint9 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP9LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint9 must be less than 64 bytes." + #endif + #if (_EP9LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint9 cannot be 0 byte." + #endif + #if ((_EP9LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint9 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP4_ENABLE == 1) + #if (_EP4_TYPR == EP_TYPE_BULK) + #if (_EP4LEN != 8 && _EP4LEN != 16 && _EP4LEN != 32 && _EP4LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP4_TYPR == EP_TYPE_INT) + #if (_EP4LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP4_TYPR == EP_TYPE_ISO) + #if (_EP4LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP4LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint4 cannot be 0 byte." + #endif + #if ((_EP4LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint4 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP5_ENABLE == 1) + #if (_EP5_TYPR == EP_TYPE_BULK) + #if (_EP5LEN != 8 && _EP5LEN != 16 && _EP5LEN != 32 && _EP5LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP5_TYPR == EP_TYPE_INT) + #if (_EP5LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP5_TYPR == EP_TYPE_ISO) + #if (_EP5LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP5LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint5 cannot be 0 byte." + #endif + #if ((_EP5LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint5 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP6_ENABLE == 1) + #if (_EP6_TYPR == EP_TYPE_BULK) + #if (_EP6LEN != 8 && _EP6LEN != 16 && _EP6LEN != 32 && _EP6LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP6_TYPR == EP_TYPE_INT) + #if (_EP6LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP6_TYPR == EP_TYPE_ISO) + #if (_EP6LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP6LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint6 cannot be 0 byte." + #endif + #if ((_EP6LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint6 must be a multiple of 4 (word-aligned)." + #endif +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 checking */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP7_ENABLE == 1) + #if (_EP7_TYPR == EP_TYPE_BULK) + #if (_EP7LEN != 8 && _EP7LEN != 16 && _EP7LEN != 32 && _EP7LEN != 64) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be 8, 16, 32, or 64 bytes under Bulk transfer." + #endif + #endif + #if (_EP7_TYPR == EP_TYPE_INT) + #if (_EP7LEN > 64) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be less than 64 bytes under Interrupt transfer." + #endif + #endif + #if (_EP7_TYPR == EP_TYPE_ISO) + #if (_EP7LEN > 1023) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be less than 1023 bytes under Isochronous transfer." + #endif + #endif + #if (_EP7LEN == 0) + #error "USB Buffer Length (EPLEN) of Endpoint7 cannot be 0 byte." + #endif + #if ((_EP7LEN & 0x3) != 0x0) + #error "USB Buffer Length (EPLEN) of Endpoint7 must be a multiple of 4 (word-aligned)." + #endif +#endif + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Check the endpoint address */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (_EP1_ENABLE == 1) + #if (_EP1_CFG_EPADR == 0) + #error "The address of Endpoint1 (EPADR) cannot be 0." + #endif + #if (_EP2_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint8." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP1_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint1 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP2_ENABLE == 1) + #if (_EP2_CFG_EPADR == 0) + #error "The address of Endpoint2 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint8." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP2_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint2 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP3_ENABLE == 1) + #if (_EP3_CFG_EPADR == 0) + #error "The address of Endpoint3 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint8." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP3_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint3 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP4_ENABLE == 1) + #if (_EP4_CFG_EPADR == 0) + #error "The address of Endpoint4 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint8." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP4_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint4 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP5_ENABLE == 1) + #if (_EP5_CFG_EPADR == 0) + #error "The address of Endpoint5 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint8." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP5_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint5 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP6_ENABLE == 1) + #if (_EP6_CFG_EPADR == 0) + #error "The address of Endpoint6 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint8." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP6_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint6 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP7_ENABLE == 1) + #if (_EP7_CFG_EPADR == 0) + #error "The address of Endpoint1 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint8." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP7_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint7 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP8_ENABLE == 1) + #if (_EP8_CFG_EPADR == 0) + #error "The address of Endpoint8 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP9_ENABLE == 1) + #if (_EP8_CFG_EPADR == _EP9_CFG_EPADR) + #error "The address of Endpoint8 (EPADR) conflicts with Endpoint9." + #endif + #endif +#endif + +#if (_EP9_ENABLE == 1) + #if (_EP9_CFG_EPADR == 0) + #error "The address of Endpoint9 (EPADR) cannot be 0." + #endif + #if (_EP1_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP1_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint1." + #endif + #endif + #if (_EP2_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP2_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint2." + #endif + #endif + #if (_EP3_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP3_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint3." + #endif + #endif + #if (_EP4_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP4_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint4." + #endif + #endif + #if (_EP5_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP5_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint5." + #endif + #endif + #if (_EP6_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP6_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint6." + #endif + #endif + #if (_EP7_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP7_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint7." + #endif + #endif + #if (_EP8_ENABLE == 1) + #if (_EP9_CFG_EPADR == _EP8_CFG_EPADR) + #error "The address of Endpoint9 (EPADR) conflicts with Endpoint8." + #endif + #endif +#endif + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Check Buffer size */ +/*----------------------------------------------------------------------------------------------------------*/ +#if ((_EP0LEN_T + _EP1LEN + _EP2LEN + _EP3LEN + _EP4LEN_T + _EP5LEN_T + _EP6LEN_T + _EP7LEN_T + _EP8LEN + _EP9LEN) > 1024) + #error "Total buffer size of Endpoint 0 ~ 7 (or 0 ~ 9) must be less than 1024 bytes." +#endif + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdinit.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdinit.h new file mode 100644 index 0000000000..97184ef903 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_usbdinit.h @@ -0,0 +1,330 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_usbdinit.h + * @version $Rev:: 5656 $ + * @date $Date:: 2021-11-24 #$ + * @brief The header file of the USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_USBDINIT_H +#define __HT32F5XXXX_USBDINIT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32_retarget_usbdconf.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup USBDevice + * @{ + */ + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint 0 ~ 7 Configuration */ +/* !!! DO NOT MODIFY !!! */ +/*----------------------------------------------------------------------------------------------------------*/ + +#define EP_TYPE_ISO (1) +#define EP_TYPE_BULK (2) +#define EP_TYPE_INT (3) + +#ifndef _UIER_ALL + #define _UIER_ALL _UIER +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP0_CFG_EPEN (1UL) +#define _EP0STADR (HT_USB_SRAM_BASE + 0x8) +#define _EP0INTADR (_EP0STADR) +#define _EP0OUTTADR (_EP0STADR + _EP0LEN) +#define _EP0_CFG ((_EP0_CFG_EPEN << 31) | \ + (_EP0LEN << 10) | \ + (_EP0STADR & EPBUFA_MASK)) +#define _EP0LEN_T (_EP0LEN * 2) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP1STADR (_EP0STADR + (_EP0LEN * 2)) + +#if (_EP1_ENABLE == 1) + #define _EP1LEN (_EP1LEN_TMP) +#else + #define _EP1LEN (0) +#endif + +#if (_EP1_CFG_EPEN_TMP == 1) + #define _EP1_CFG_EPEN (1UL) +#else + #define _EP1_CFG_EPEN (0UL) +#endif + +#define _EP1_CFG ((_EP1_CFG_EPEN << 31) | \ + (_EP1_CFG_EPDIR << 28) | \ + (_EP1_CFG_EPADR << 24) | \ + (_EP1LEN << 10) | \ + (_EP1STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP2STADR (_EP1STADR + _EP1LEN) + +#if (_EP2_ENABLE == 1) + #define _EP2LEN (_EP2LEN_TMP) +#else + #define _EP2LEN (0) +#endif + +#if (_EP2_CFG_EPEN_TMP == 1) + #define _EP2_CFG_EPEN (1UL) +#else + #define _EP2_CFG_EPEN (0UL) +#endif + +#define _EP2_CFG ((_EP2_CFG_EPEN << 31) | \ + (_EP2_CFG_EPDIR << 28) | \ + (_EP2_CFG_EPADR << 24) | \ + (_EP2LEN << 10) | \ + (_EP2STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP3STADR (_EP2STADR + _EP2LEN) + +#if (_EP3_ENABLE == 1) + #define _EP3LEN (_EP3LEN_TMP) +#else + #define _EP3LEN (0) +#endif + +#if (_EP3_CFG_EPEN_TMP == 1) + #define _EP3_CFG_EPEN (1UL) +#else + #define _EP3_CFG_EPEN (0UL) +#endif + +#define _EP3_CFG ((_EP3_CFG_EPEN << 31) | \ + (_EP3_CFG_EPDIR << 28) | \ + (_EP3_CFG_EPADR << 24) | \ + (_EP3LEN << 10) | \ + (_EP3STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP4STADR (_EP3STADR + _EP3LEN) + +#if (_EP4_ENABLE == 1) + #define _EP4LEN (_EP4LEN_TMP) + #define _EP4LEN_T (_EP4LEN_TMP * (_EP4_CFG_SDBS + 1)) +#else + #define _EP4LEN (0) + #define _EP4LEN_T (0) +#endif +#if (_EP4_TYPR == EP_TYPE_ISO) + #define _EP4_CFG_EPTYPE (1) +#else + #define _EP4_CFG_EPTYPE (0) +#endif + +#if (_EP4_CFG_EPEN_TMP == 1) + #define _EP4_CFG_EPEN (1UL) +#else + #define _EP4_CFG_EPEN (0UL) +#endif + +#define _EP4_CFG ((_EP4_CFG_EPEN << 31) | \ + (_EP4_CFG_EPTYPE << 29) | \ + (_EP4_CFG_EPDIR << 28) | \ + (_EP4_CFG_EPADR << 24) | \ + (_EP4_CFG_SDBS << 23) | \ + (_EP4LEN << 10) | \ + (_EP4STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP5STADR (_EP4STADR + _EP4LEN_T) + +#if (_EP5_ENABLE == 1) + #define _EP5LEN (_EP5LEN_TMP) + #define _EP5LEN_T (_EP5LEN_TMP * (_EP5_CFG_SDBS + 1)) +#else + #define _EP5LEN (0) + #define _EP5LEN_T (0) +#endif +#if (_EP5_TYPR == EP_TYPE_ISO) + #define _EP5_CFG_EPTYPE (1) +#else + #define _EP5_CFG_EPTYPE (0) +#endif + +#if (_EP5_CFG_EPEN_TMP == 1) + #define _EP5_CFG_EPEN (1UL) +#else + #define _EP5_CFG_EPEN (0UL) +#endif + +#define _EP5_CFG ((_EP5_CFG_EPEN << 31) | \ + (_EP5_CFG_EPTYPE << 29) | \ + (_EP5_CFG_EPDIR << 28) | \ + (_EP5_CFG_EPADR << 24) | \ + (_EP5_CFG_SDBS << 23) | \ + (_EP5LEN << 10) | \ + (_EP5STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP6STADR (_EP5STADR + _EP5LEN_T) + +#if (_EP6_ENABLE == 1) + #define _EP6LEN (_EP6LEN_TMP) + #define _EP6LEN_T (_EP6LEN_TMP * (_EP6_CFG_SDBS + 1)) +#else + #define _EP6LEN (0) + #define _EP6LEN_T (0) +#endif +#if (_EP6_TYPR == EP_TYPE_ISO) + #define _EP6_CFG_EPTYPE (1) +#else + #define _EP6_CFG_EPTYPE (0) +#endif + +#if (_EP6_CFG_EPEN_TMP == 1) + #define _EP6_CFG_EPEN (1UL) +#else + #define _EP6_CFG_EPEN (0UL) +#endif + +#define _EP6_CFG ((_EP6_CFG_EPEN << 31) | \ + (_EP6_CFG_EPTYPE << 29) | \ + (_EP6_CFG_EPDIR << 28) | \ + (_EP6_CFG_EPADR << 24) | \ + (_EP6_CFG_SDBS << 23) | \ + (_EP6LEN << 10) | \ + (_EP6STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP7STADR (_EP6STADR + _EP6LEN_T) + +#if (_EP7_ENABLE == 1) + #define _EP7LEN (_EP7LEN_TMP) + #define _EP7LEN_T (_EP7LEN_TMP * (_EP7_CFG_SDBS + 1)) +#else + #define _EP7LEN (0) + #define _EP7LEN_T (0) +#endif +#if (_EP7_TYPR == EP_TYPE_ISO) + #define _EP7_CFG_EPTYPE (1) +#else + #define _EP7_CFG_EPTYPE (0) +#endif + +#if (_EP7_CFG_EPEN_TMP == 1) + #define _EP7_CFG_EPEN (1UL) +#else + #define _EP7_CFG_EPEN (0UL) +#endif + +#define _EP7_CFG ((_EP7_CFG_EPEN << 31) | \ + (_EP7_CFG_EPTYPE << 29) | \ + (_EP7_CFG_EPDIR << 28) | \ + (_EP7_CFG_EPADR << 24) | \ + (_EP7_CFG_SDBS << 23) | \ + (_EP7LEN << 10) | \ + (_EP7STADR & EPBUFA_MASK)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint8 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP8STADR (_EP7STADR + _EP7LEN_T) + +#if (_EP8_ENABLE == 1) + #define _EP8LEN (_EP8LEN_TMP) +#else + #define _EP8LEN (0) +#endif + +#if (_EP8_CFG_EPEN_TMP == 1) + #define _EP8_CFG_EPEN (1UL) +#else + #define _EP8_CFG_EPEN (0UL) +#endif + +#define _EP8_CFG ((_EP8_CFG_EPEN << 31) | \ + (_EP8_CFG_EPDIR << 28) | \ + (_EP8_CFG_EPADR << 24) | \ + (_EP8LEN << 10) | \ + (_EP8STADR & EPBUFA_MASK)) + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint9 Configuration */ +/*----------------------------------------------------------------------------------------------------------*/ +#define _EP9STADR (_EP8STADR + _EP8LEN) + +#if (_EP9_ENABLE == 1) + #define _EP9LEN (_EP9LEN_TMP) +#else + #define _EP9LEN (0) +#endif + +#if (_EP9_CFG_EPEN_TMP == 1) + #define _EP9_CFG_EPEN (1UL) +#else + #define _EP9_CFG_EPEN (0UL) +#endif + +#define _EP9_CFG ((_EP9_CFG_EPEN << 31) | \ + (_EP9_CFG_EPDIR << 28) | \ + (_EP9_CFG_EPADR << 24) | \ + (_EP9LEN << 10) | \ + (_EP9STADR & EPBUFA_MASK)) + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_wdt.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_wdt.h new file mode 100644 index 0000000000..ae5fdd1c5e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f5xxxx_wdt.h @@ -0,0 +1,149 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_wdt.h + * @version $Rev:: 1704 $ + * @date $Date:: 2017-08-17 #$ + * @brief The header file of the WDT library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F5XXXX_WDT_H +#define __HT32F5XXXX_WDT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup WDT + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Exported_Constants WDT exported constants + * @{ + */ + +/* WDT prescaler */ +#define WDT_PRESCALER_1 ((u16)0x0000) +#define WDT_PRESCALER_2 ((u16)0x1000) +#define WDT_PRESCALER_4 ((u16)0x2000) +#define WDT_PRESCALER_8 ((u16)0x3000) +#define WDT_PRESCALER_16 ((u16)0x4000) +#define WDT_PRESCALER_32 ((u16)0x5000) +#define WDT_PRESCALER_64 ((u16)0x6000) +#define WDT_PRESCALER_128 ((u16)0x7000) + +#define IS_WDT_PRESCALER(PRESCALER) ((PRESCALER == WDT_PRESCALER_1) || \ + (PRESCALER == WDT_PRESCALER_2) || \ + (PRESCALER == WDT_PRESCALER_4) || \ + (PRESCALER == WDT_PRESCALER_8) || \ + (PRESCALER == WDT_PRESCALER_16) || \ + (PRESCALER == WDT_PRESCALER_32) || \ + (PRESCALER == WDT_PRESCALER_64) || \ + (PRESCALER == WDT_PRESCALER_128)) + + +/* WDT runs or halts in sleep and deep sleep1 mode */ +/* WDT WDTSHLT mask */ +#define MODE0_WDTSHLT_BOTH ((u32)0x00000000) +#define MODE0_WDTSHLT_SLEEP ((u32)0x00004000) +#define MODE0_WDTSHLT_HALT ((u32)0x00008000) + +#define IS_WDT_WDTSHLT_MODE(WDT_Mode) ((WDT_Mode == MODE0_WDTSHLT_BOTH) || \ + (WDT_Mode == MODE0_WDTSHLT_SLEEP) || \ + (WDT_Mode == MODE0_WDTSHLT_HALT)) + + + +/* WDT Flag */ +#define WDT_FLAG_UNDERFLOW ((u32)0x00000001) +#define WDT_FLAG_ERROR ((u32)0x00000002) + + +#define IS_WDT_FLAG(WDT_FLAG) ((WDT_FLAG == WDT_FLAG_UNDERFLOW) || \ + (WDT_FLAG == WDT_FLAG_ERROR)) + + +#define IS_WDT_RELOAD(WDTV) ((WDTV <= 0xFFF)) + +#define IS_WDT_DELTA(WDTD) ((WDTD <= 0xFFF)) + +#if (LIBCFG_LSE) +/* WDT Source Select */ +#define WDT_SOURCE_LSI ((u32)0x00000000) +#define WDT_SOURCE_LSE ((u32)0x00000001) + + +#define IS_WDT_SOURCE_SELECT(WDT_SOURCE) ((WDT_SOURCE == WDT_SOURCE_LSI) || \ + (WDT_SOURCE == WDT_SOURCE_LSE)) +#endif +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Exported_Functions WDT exported functions + * @{ + */ +void WDT_DeInit(void); +void WDT_Cmd(ControlStatus NewState); +void WDT_HaltConfig(u32 WDT_Mode); +void WDT_ResetCmd(ControlStatus NewState); +void WDT_ProtectCmd(ControlStatus NewState); +void WDT_SetReloadValue(u16 WDTV); +u16 WDT_GetReloadValue(void); +void WDT_SetDeltaValue(u16 WDTD); +u16 WDT_GetDeltaValue(void); +void WDT_SetPrescaler(u16 WDT_PRESCALER); +u8 WDT_GetPrescaler(void); +void WDT_Restart(void); +FlagStatus WDT_GetFlagStatus (u32 WDT_FLAG); +void WDT_LockCmd(ControlStatus NewState); +#if (LIBCFG_LSE) +void WDT_SourceConfig(u32 WDT_SOURCE); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61141_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61141_libcfg.h new file mode 100644 index 0000000000..030674e28b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61141_libcfg.h @@ -0,0 +1,76 @@ +/*********************************************************************************************************//** + * @file ht32f61141_libcfg.h + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F61141_LIBCFG_H +#define __HT32F61141_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F61141) +#define USE_MEM_HT32F61141 +#endif + +#define LIBCFG_MAX_SPEED (48000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F61141 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 16) + #define LIBCFG_CHIPNAME (0x61141) +#endif + +#define LIBCFG_NO_ADC (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CRC (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_LSE (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_NO_USART0 (1) +#define LIBCFG_PWRCU_WAKEUP_V01 (1) +#define LIBCFG_PWRCU_WAKEUP1 (1) +#define LIBCFG_PWRCU_PORF (1) +#define LIBCFG_PWRCU_VREG (1) +#define LIBCFG_PWRCU_VREG_2V5 (1) +#define LIBCFG_SCI0 (1) +#define LIBCFG_SCI1 (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_USBD (1) +#define LIBCFG_USBD_V2 (1) + + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61244_45_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61244_45_libcfg.h new file mode 100644 index 0000000000..b7ed32e296 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f61244_45_libcfg.h @@ -0,0 +1,73 @@ +/*********************************************************************************************************//** + * @file ht32f61244_45_libcfg.h + * @version $Rev:: 6719 $ + * @date $Date:: 2023-02-08 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F61244_45_LIBCFG_H +#define __HT32F61244_45_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F61244) && !defined(USE_MEM_HT32F61245) +#define USE_MEM_HT32F61245 +#endif + +#define LIBCFG_MAX_SPEED (48000000) + +#define LIBCFG_FLASH_PAGESIZE (512) + +#ifdef USE_MEM_HT32F61244 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x61244) +#endif + +#ifdef USE_MEM_HT32F61245 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x61245) +#endif + +#define LIBCFG_BFTM1 (1) +#define LIBCFG_DACDUAL16 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPIOD (1) +#define LIBCFG_MIDI (1) +#define LIBCFG_NO_USART0 (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_QSPI (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_ADC_CH12_15 (1) +#define LIBCFG_CKCU_NO_AUTO_TRIM (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) +#define LIBCFG_PWRCU_V15_READY_SOURCE (1) +#define LIBCFG_TM_NO_ITI (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65230_40_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65230_40_libcfg.h new file mode 100644 index 0000000000..bbf4192d74 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65230_40_libcfg.h @@ -0,0 +1,92 @@ +/*********************************************************************************************************//** + * @file ht32f65230_40_libcfg.h + * @version $Rev:: 7184 $ + * @date $Date:: 2023-08-31 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F65230_40_LIBCFG_H +#define __HT32F65230_40_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F65240) && !defined(USE_MEM_HT32F65230) +#define USE_MEM_HT32F65240 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F65230 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 32) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x65230) +#endif + +#ifdef USE_MEM_HT32F65240 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x65240) +#endif + +#define LIBCFG_ADC1 (1) +#define LIBCFG_ADC_SAMPLE_TIME_BY_CH (1) +#define LIBCFG_ADC_TRIG_DELAY (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_NO_ADCPRE_DIV1 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CMP (1) +#define LIBCFG_CMP2 (1) +#define LIBCFG_CMP_NOSCALER_SRC (1) +#define LIBCFG_CMP_65x_VER (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_EXTI_4_9_GROUP (1) +#define LIBCFG_FMC_BRANCHCACHE (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPTM_GIRQ (1) +#define LIBCFG_LSE (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_MCTM_UEV1DIS (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_OPA (1) +#define LIBCFG_OPA1 (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_PDMA_CH3FIX (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_TM_652XX_V1 (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_NO_PORF (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65232_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65232_libcfg.h new file mode 100644 index 0000000000..8787c99413 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65232_libcfg.h @@ -0,0 +1,90 @@ +/*********************************************************************************************************//** + * @file ht32f65232_libcfg.h + * @version $Rev:: 6932 $ + * @date $Date:: 2023-05-11 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F65232_LIBCFG_H +#define __HT32F65232_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F65232) +#define USE_MEM_HT32F65232 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F65232 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 31) + #define LIBCFG_RAM_SIZE (1024 * 4) + #define LIBCFG_CHIPNAME (0x65232) +#endif + +#define LIBCFG_ADC_SAMPLE_TIME_BY_CH (1) +#define LIBCFG_ADC_TRIG_SRC_V2 (1) +#define LIBCFG_ADC_TRIG_DELAY (1) +#define LIBCFG_ADC_CH_65232 (1) +#define LIBCFG_AFIO_SCTM_MODE9 (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_NO_ADCPRE_DIV1 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CMP (1) +#define LIBCFG_CMP_NOSCALER_SRC (1) +#define LIBCFG_CMP_65x_VER (1) +#define LIBCFG_CMP_POS_INPUT_SEL_V2 (1) +#define LIBCFG_CMP_CO (1) +#define LIBCFG_CMP_SCALER_8BIT (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_EXTI_4_9_GROUP (1) +#define LIBCFG_FMC_BRANCHCACHE (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_GPTM_GIRQ (1) +#define LIBCFG_MCTM0 (1) +#define LIBCFG_MCTM_UEV1DIS (1) +#define LIBCFG_PWRCU_NO_PD_MODE (1) +#define LIBCFG_PWRCU_NO_PDF (1) +#define LIBCFG_PWRCU_NO_VDDPORF (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_OPA (1) +#define LIBCFG_OPA_V2 (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_TM_652XX_V1 (1) +#define LIBCFG_TM_65232 (1) +#define LIBCFG_TM_TIFN_5BIT (1) +#define LIBCFG_PWRCU_VDD_5V (1) +#define LIBCFG_PWRCU_NO_PORF (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_adc.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_adc.h new file mode 100644 index 0000000000..0b0313fc40 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_adc.h @@ -0,0 +1,417 @@ +/*********************************************************************************************************//** + * @file ht32f65xxx_66xxx_adc.h + * @version $Rev:: 7058 $ + * @date $Date:: 2023-07-27 #$ + * @brief The header file of the ADC library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F65XXX_66XXX_ADC_H +#define __HT32F65XXX_66XXX_ADC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup ADC + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Exported_Constants ADC exported constants + * @{ + */ +#if (LIBCFG_ADC1) +#define IS_ADC(x) ((x == HT_ADC0) || (x == HT_ADC1)) +#else +#define IS_ADC(x) (x == HT_ADC0) +#endif + +#define ONE_SHOT_MODE (0x00000000) +#define CONTINUOUS_MODE (0x00000002) +#define DISCONTINUOUS_MODE (0x00000003) + +#define IS_ADC_CONVERSION_MODE(REGULAR_MODE) (((REGULAR_MODE) == ONE_SHOT_MODE) || \ + ((REGULAR_MODE) == CONTINUOUS_MODE) || \ + ((REGULAR_MODE) == DISCONTINUOUS_MODE)) + +#define IS_ADC_HP_CONVERSION_MODE(HP_MODE) (((HP_MODE) == ONE_SHOT_MODE) || \ + ((HP_MODE) == CONTINUOUS_MODE) || \ + ((HP_MODE) == DISCONTINUOUS_MODE)) + +#define DUAL_INDEPENDENT (0x00000000) +#define DUAL_CASCADE_REGULAR (0x00000001) +#define DUAL_CASCADE_REGULAR_H_PRIORITY (0x00000003) + +#define IS_ADC_DUAL_MODE(DUAL_MODE) (((DUAL_MODE) == DUAL_INDEPENDENT) || \ + ((DUAL_MODE) == DUAL_CASCADE_REGULAR) || \ + ((DUAL_MODE) == DUAL_CASCADE_REGULAR_H_PRIORITY)) + +#if (LIBCFG_ADC_CH_65232) +#define ADC_CH_0 (0) +#define ADC_CH_1 (1) +#define ADC_CH_2 (2) +#define ADC_CH_3 (3) +#define ADC_CH_4 (4) +#define ADC_CH_5 (5) +#define ADC_CH_6 (6) +#define ADC_CH_7 (7) +#define ADC_CH_8 (8) +#define ADC_CH_9 (9) +#define ADC_CH_10 (10) +#define ADC_CH_11 (11) +#define ADC_CH_OPA0 (12) +#define ADC_CH_GND_VREF (13) +#define ADC_CH_VDD_VREF (14) + +#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7) || \ + ((CHANNEL) == ADC_CH_8) || ((CHANNEL) == ADC_CH_9) || \ + ((CHANNEL) == ADC_CH_10) || ((CHANNEL) == ADC_CH_11) || \ + ((CHANNEL) == ADC_CH_OPA0) || \ + ((CHANNEL) == ADC_CH_GND_VREF) || ((CHANNEL) == ADC_CH_VDD_VREF)) + +#define IS_ADC_INPUT_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7) || \ + ((CHANNEL) == ADC_CH_OPA0)) +#else +#define ADC_CH_0 (0) +#define ADC_CH_1 (1) +#define ADC_CH_2 (2) +#define ADC_CH_3 (3) +#define ADC_CH_4 (4) +#define ADC_CH_5 (5) +#define ADC_CH_6 (6) +#define ADC_CH_7 (7) +#define ADC_CH_OPA0 (8) +#define ADC_CH_OPA1 (9) +#define ADC_CH_GND_VREF (12) +#define ADC_CH_VDD_VREF (13) + +#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7) || \ + ((CHANNEL) == ADC_CH_OPA0) || ((CHANNEL) == ADC_CH_OPA1) || \ + ((CHANNEL) == ADC_CH_GND_VREF) || ((CHANNEL) == ADC_CH_VDD_VREF)) + +#define IS_ADC_INPUT_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CH_0) || ((CHANNEL) == ADC_CH_1) || \ + ((CHANNEL) == ADC_CH_2) || ((CHANNEL) == ADC_CH_3) || \ + ((CHANNEL) == ADC_CH_4) || ((CHANNEL) == ADC_CH_5) || \ + ((CHANNEL) == ADC_CH_6) || ((CHANNEL) == ADC_CH_7) || \ + ((CHANNEL) == ADC_CH_OPA0) || ((CHANNEL) == ADC_CH_OPA1)) +#endif + + +#define ADC_TRIG_SOFTWARE (1UL << 0) + +#define ADC_TRIG_MCTM0_MTO ((1UL << 2) | (0UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH0O ((1UL << 2) | (1UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH1O ((1UL << 2) | (2UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH2O ((1UL << 2) | (3UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH3O ((1UL << 2) | (4UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH0MEV ((1UL << 2) | (0x18UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH0DEV ((1UL << 2) | (0x28UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH0MDEV ((1UL << 2) | (0x38UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH1MEV ((1UL << 2) | (0x19UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH1DEV ((1UL << 2) | (0x29UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH1MDEV ((1UL << 2) | (0x39UL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH2MEV ((1UL << 2) | (0x1AUL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH2DEV ((1UL << 2) | (0x2AUL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH2MDEV ((1UL << 2) | (0x3AUL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH3MEV ((1UL << 2) | (0x1BUL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH3DEV ((1UL << 2) | (0x2BUL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CH3MDEV ((1UL << 2) | (0x3BUL << 24) | (0UL << 16)) + +#define IS_ADC_TRIG_MCTM0_CHALL(REGTRIG) (0) + +#if (LIBCFG_ADC_TRIG_SRC_V2) +#define ADC_TRIG_MCTM0_CHALLMEV ((1UL << 2) | (0x1CUL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CHALLDEV ((1UL << 2) | (0x2CUL << 24) | (0UL << 16)) +#define ADC_TRIG_MCTM0_CHALLMDEV ((1UL << 2) | (0x3CUL << 24) | (0UL << 16)) + +#undef IS_ADC_TRIG_MCTM0_CHALL +#define IS_ADC_TRIG_MCTM0_CHALL(REGTRIG) ((REGTRIG == ADC_TRIG_MCTM0_CHALLMEV) || \ + (REGTRIG == ADC_TRIG_MCTM0_CHALLDEV) || \ + (REGTRIG == ADC_TRIG_MCTM0_CHALLMDEV)) +#endif + +#define ADC_TRIG_CMP0 ((1UL << 4) | (0UL << 20)) +#define ADC_TRIG_CMP1 ((1UL << 4) | (1UL << 20)) +#define ADC_TRIG_CMP2 ((1UL << 4) | (2UL << 20)) + +#define ADC_TRIG_BFTM0 ((1UL << 3) | (0UL << 22) | (0UL << 19)) +#define ADC_TRIG_BFTM1 ((1UL << 3) | (0UL << 22) | (1UL << 19)) + +#define ADC_TRIG_GPTM0_MTO ((1UL << 2) | (0UL << 24) | (1UL << 16)) +#define ADC_TRIG_GPTM0_CH0O ((1UL << 2) | (1UL << 24) | (1UL << 16)) +#define ADC_TRIG_GPTM0_CH1O ((1UL << 2) | (2UL << 24) | (1UL << 16)) +#define ADC_TRIG_GPTM0_CH2O ((1UL << 2) | (3UL << 24) | (1UL << 16)) +#define ADC_TRIG_GPTM0_CH3O ((1UL << 2) | (4UL << 24) | (1UL << 16)) + +#define ADC_TRIG_EXTI_0 ((1UL << 1) | ( 0UL << 8)) +#define ADC_TRIG_EXTI_1 ((1UL << 1) | ( 1UL << 8)) +#define ADC_TRIG_EXTI_2 ((1UL << 1) | ( 2UL << 8)) +#define ADC_TRIG_EXTI_3 ((1UL << 1) | ( 3UL << 8)) +#define ADC_TRIG_EXTI_4 ((1UL << 1) | ( 4UL << 8)) +#define ADC_TRIG_EXTI_5 ((1UL << 1) | ( 5UL << 8)) +#define ADC_TRIG_EXTI_6 ((1UL << 1) | ( 6UL << 8)) +#define ADC_TRIG_EXTI_7 ((1UL << 1) | ( 7UL << 8)) +#define ADC_TRIG_EXTI_8 ((1UL << 1) | ( 8UL << 8)) +#define ADC_TRIG_EXTI_9 ((1UL << 1) | ( 9UL << 8)) +#define ADC_TRIG_EXTI_10 ((1UL << 1) | (10UL << 8)) +#define ADC_TRIG_EXTI_11 ((1UL << 1) | (11UL << 8)) +#define ADC_TRIG_EXTI_12 ((1UL << 1) | (12UL << 8)) +#define ADC_TRIG_EXTI_13 ((1UL << 1) | (13UL << 8)) +#define ADC_TRIG_EXTI_14 ((1UL << 1) | (14UL << 8)) +#define ADC_TRIG_EXTI_15 ((1UL << 1) | (15UL << 8)) + +#define IS_ADC_TRIG(REGTRIG) (((REGTRIG) == ADC_TRIG_GPTM0_MTO) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH0O) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH1O) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH2O) || \ + ((REGTRIG) == ADC_TRIG_GPTM0_CH3O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_MTO) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH0O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH1O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH2O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH3O) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH0MEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH0DEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH0MDEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH1MEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH1DEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH1MDEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH2MEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH2DEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH2MDEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH3MEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH3DEV) || \ + ((REGTRIG) == ADC_TRIG_MCTM0_CH3MDEV) || \ + (IS_ADC_TRIG_MCTM0_CHALL(REGTRIG)) || \ + ((REGTRIG) == ADC_TRIG_BFTM0) || \ + ((REGTRIG) == ADC_TRIG_BFTM1) || \ + ((REGTRIG) == ADC_TRIG_CMP0) || \ + ((REGTRIG) == ADC_TRIG_CMP1) || \ + ((REGTRIG) == ADC_TRIG_CMP2) || \ + ((REGTRIG) == ADC_TRIG_EXTI_0) || \ + ((REGTRIG) == ADC_TRIG_EXTI_1) || \ + ((REGTRIG) == ADC_TRIG_EXTI_2) || \ + ((REGTRIG) == ADC_TRIG_EXTI_3) || \ + ((REGTRIG) == ADC_TRIG_EXTI_4) || \ + ((REGTRIG) == ADC_TRIG_EXTI_5) || \ + ((REGTRIG) == ADC_TRIG_EXTI_6) || \ + ((REGTRIG) == ADC_TRIG_EXTI_7) || \ + ((REGTRIG) == ADC_TRIG_EXTI_8) || \ + ((REGTRIG) == ADC_TRIG_EXTI_9) || \ + ((REGTRIG) == ADC_TRIG_EXTI_10) || \ + ((REGTRIG) == ADC_TRIG_EXTI_11) || \ + ((REGTRIG) == ADC_TRIG_EXTI_12) || \ + ((REGTRIG) == ADC_TRIG_EXTI_13) || \ + ((REGTRIG) == ADC_TRIG_EXTI_14) || \ + ((REGTRIG) == ADC_TRIG_EXTI_15) || \ + ((REGTRIG) == ADC_TRIG_SOFTWARE)) + + +#define ADC_INT_SINGLE_EOC (0x00000001) +#define ADC_INT_SUB_GROUP_EOC (0x00000002) +#define ADC_INT_CYCLE_EOC (0x00000004) +#define ADC_INT_HP_SINGLE_EOC (0x00000100) +#define ADC_INT_HP_SUB_GROUP_EOC (0x00000200) +#define ADC_INT_HP_CYCLE_EOC (0x00000400) +#define ADC_INT_AWD_LOWER (0x00010000) +#define ADC_INT_AWD_UPPER (0x00020000) +#define ADC_INT_DATA_OVERWRITE (0x01000000) +#define ADC_INT_HP_DATA_OVERWRITE (0x02000000) + +#define IS_ADC_INT(INT) ((((INT) & 0xFCFCFF88) == 0) && ((INT) != 0)) + + +#define ADC_FLAG_SINGLE_EOC (0x00000001) +#define ADC_FLAG_SUB_GROUP_EOC (0x00000002) +#define ADC_FLAG_CYCLE_EOC (0x00000004) +#define ADC_FLAG_HP_SINGLE_EOC (0x00000100) +#define ADC_FLAG_HP_SUB_GROUP_EOC (0x00000200) +#define ADC_FLAG_HP_CYCLE_EOC (0x00000400) +#define ADC_FLAG_AWD_LOWER (0x00010000) +#define ADC_FLAG_AWD_UPPER (0x00020000) +#define ADC_FLAG_DATA_OVERWRITE (0x01000000) +#define ADC_FLAG_HP_DATA_OVERWRITE (0x02000000) + +#define IS_ADC_FLAG(FLAG) ((((FLAG) & 0xFCFCFF88) == 0) && ((FLAG) != 0)) + + +#define ADC_REGULAR_DATA0 (0) +#define ADC_REGULAR_DATA1 (1) +#define ADC_REGULAR_DATA2 (2) +#define ADC_REGULAR_DATA3 (3) +#define ADC_REGULAR_DATA4 (4) +#define ADC_REGULAR_DATA5 (5) +#define ADC_REGULAR_DATA6 (6) +#define ADC_REGULAR_DATA7 (7) + +#define IS_ADC_REGULAR_DATA(DATA) ((DATA) < 8) + + +#define ADC_HP_DATA0 (0) +#define ADC_HP_DATA1 (1) +#define ADC_HP_DATA2 (2) +#define ADC_HP_DATA3 (3) + +#define IS_ADC_HP_DATA(DATA) ((DATA) < 4) + + +#define ADC_AWD_DISABLE (u8)0x00 +#define ADC_AWD_ALL_LOWER (u8)0x05 +#define ADC_AWD_ALL_UPPER (u8)0x06 +#define ADC_AWD_ALL_LOWER_UPPER (u8)0x07 +#define ADC_AWD_SINGLE_LOWER (u8)0x01 +#define ADC_AWD_SINGLE_UPPER (u8)0x02 +#define ADC_AWD_SINGLE_LOWER_UPPER (u8)0x03 + +#define IS_ADC_AWD(AWD) (((AWD) == ADC_AWD_DISABLE) || \ + ((AWD) == ADC_AWD_ALL_LOWER) || \ + ((AWD) == ADC_AWD_ALL_UPPER) || \ + ((AWD) == ADC_AWD_ALL_LOWER_UPPER) || \ + ((AWD) == ADC_AWD_SINGLE_LOWER) || \ + ((AWD) == ADC_AWD_SINGLE_UPPER) || \ + ((AWD) == ADC_AWD_SINGLE_LOWER_UPPER)) + +#define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) < 4096) + +#define ADC_PDMA_REGULAR_SINGLE (0x00000001) +#define ADC_PDMA_REGULAR_SUBGROUP (0x00000002) +#define ADC_PDMA_REGULAR_CYCLE (0x00000004) + +#define ADC_PDMA_HP_SINGLE (0x00000100) +#define ADC_PDMA_HP_SUBGROUP (0x00000200) +#define ADC_PDMA_HP_CYCLE (0x00000400) + +#define IS_ADC_PDMA(PDMA) (((PDMA) == ADC_PDMA_REGULAR_SINGLE) || \ + ((PDMA) == ADC_PDMA_REGULAR_SUBGROUP) || \ + ((PDMA) == ADC_PDMA_REGULAR_CYCLE) || \ + ((PDMA) == ADC_PDMA_HP_SINGLE) || \ + ((PDMA) == ADC_PDMA_HP_SUBGROUP) || \ + ((PDMA) == ADC_PDMA_HP_CYCLE)) + + +#define IS_ADC_INPUT_SAMPLING_TIME(TIME) ((TIME) <= 255) + +#define IS_ADC_OFFSET(OFFSET) ((OFFSET) < 4096) + +#define IS_ADC_REGULAR_RANK(RANK) ((RANK) < 8) + +#define IS_ADC_HP_RANK(RANK) ((RANK) < 4) + +#define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 1) && ((LENGTH) <= 8)) +#define IS_ADC_REGULAR_SUB_LENGTH(SUB_LENGTH) (((SUB_LENGTH) >= 1) && ((SUB_LENGTH) <= 8)) + +#define IS_ADC_HP_LENGTH(LENGTH) (((LENGTH) >= 1) && ((LENGTH) <= 4)) +#define IS_ADC_HP_SUB_LENGTH(SUB_LENGTH) (((SUB_LENGTH) >= 1) && ((SUB_LENGTH) <= 4)) + +#define IS_ADC_TRIG_DELAY(DELAY) ((DELAY) < 256) + +typedef enum +{ + ADC_ALIGN_RIGHT = (0 << 14), + ADC_ALIGN_LEFT = (1 << 14), +} ADC_ALIGN_Enum; + +#define IS_ADC_ALIGN(ALIGN) (((ALIGN) == ADC_ALIGN_RIGHT) || ((ALIGN) == ADC_ALIGN_LEFT)) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Exported_Functions ADC exported functions + * @{ + */ +void ADC_DeInit(HT_ADC_TypeDef* HT_ADCn); +void ADC_Reset(HT_ADC_TypeDef* HT_ADCn); +void ADC_Cmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); +#if (LIBCFG_ADC1) +void ADC_DualModeConfig(HT_ADC_TypeDef* HT_ADCn, u32 DUAL_X, u8 HDelayTime, u8 DelayTime); +#endif + +void ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock); +void ADC_RegularGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength); +void ADC_RegularTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x); + +void ADC_HPChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock); +void ADC_HPGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength); +void ADC_HPTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x); + +void ADC_ChannelDataAlign(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ADC_ALIGN_Enum ADC_ALIGN_x); +void ADC_ChannelOffsetValue(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u16 OffsetValue); +void ADC_ChannelOffsetCmd(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ControlStatus NewState); + +#if (LIBCFG_ADC_TRIG_DELAY) +void ADC_TrigDelayConfig(HT_ADC_TypeDef* HT_ADCn, u8 HDelayTime, u8 DelayTime); +#endif + +void ADC_SoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); +void ADC_HPSoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState); + +u16 ADC_GetConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_REGULAR_DATAn); +u16 ADC_GetHPConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_HP_DATAn); + +void ADC_IntConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x, ControlStatus NewState); +FlagStatus ADC_GetIntStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x); +void ADC_ClearIntPendingBit(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x); +FlagStatus ADC_GetFlagStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_FLAG_x); + +void ADC_AWDConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_AWD_x); +void ADC_AWDSingleChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n); +void ADC_AWDThresholdsConfig(HT_ADC_TypeDef* HT_ADCn, u16 UPPER, u16 LOWER); + +void ADC_PDMAConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_PDMA_x, ControlStatus NewState); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_opa.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_opa.h new file mode 100644 index 0000000000..f8cfc6cca8 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_opa.h @@ -0,0 +1,215 @@ +/*********************************************************************************************************//** + * @file ht32f65xxx_66xxx_opa.h + * @version $Rev:: 6911 $ + * @date $Date:: 2023-05-10 #$ + * @brief The header file of the OPA library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F65XXX_66XXX_OPA_H +#define __HT32F65XXX_66XXX_OPA_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup OPA + * @{ + */ + + +/* Exported types ------------------------------------------------------------------------------------------*/ +#if (LIBCFG_OPA_V2) +/** @defgroup OPA_Exported_Types OPA exported types + * @{ + */ +/** + * @brief Definition of CMP init structure. + */ +typedef struct +{ + u32 OPA_ScalerEnable; + u32 OPA_ExternalPinEnable; + #if (LIBCFG_OPA_PGA) + u32 OPA_PGAEnable; + u32 OPA_UnitGainEnable; + u32 OPA_PGAGain; + #endif +} OPA_InitTypeDef; +/** + * @brief Enumeration of OPA PGA Gain. + */ +typedef enum +{ + /* OPnPGA = 1, OPnDACEN = 0 */ + PGA_GAIN_6 = 0x0, + PGA_GAIN_8 = 0x1, + PGA_GAIN_12 = 0x2, + PGA_GAIN_16 = 0x3, + PGA_GAIN_24 = 0x4, + PGA_GAIN_32 = 0x5, + PGA_GAIN_48 = 0x6, + PGA_GAIN_64 = 0x7, + + /* OPnPGA = 1, OPnDACEN = 1 */ + PGA_GAIN_5 = 0x0, + PGA_GAIN_7 = 0x1, + PGA_GAIN_11 = 0x2, + PGA_GAIN_15 = 0x3, + PGA_GAIN_23 = 0x4, + PGA_GAIN_31 = 0x5, + PGA_GAIN_47 = 0x6, + PGA_GAIN_63 = 0x7, +} OPA_PGA_Enum; +/** + * @} + */ +#endif + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup OPA_Exported_Constants OPA exported constants + * @{ + */ +#define OPA_UNPROTECT_KEY (0x9C3A) + +#if (LIBCFG_OPA1) +#define IS_OPA1(PERIPH) (PERIPH == HT_OPA1) +#else +#define IS_OPA1(PERIPH) (0) +#endif +#define IS_OPA(PERIPH) ((PERIPH == HT_OPA0) || IS_OPA1(PERIPH)) + +#if (LIBCFG_OPA_V2) +/* Definitions of OPA DAC Enable Bit */ +#define OPA_SCALER_ENABLE ((u32)0x00000100) +#define OPA_SCALER_DISABLE ((u32)0x00000000) + +/* Definitions of OPA External Pin Enable Bit */ +#define OPA_ExternalPin_ENABLE ((u32)0x00000008) +#define OPA_ExternalPin_DISABLE ((u32)0x00000000) + +/* Definitions of OPA PGA Enable Bit */ +#define OPA_PGA_ENABLE ((u32)0x00000004) +#define OPA_PGA_DISABLE ((u32)0x00000000) + +/* Definitions of OPA UnitGain Enable Bit */ +#define OPA_UNITGAIN_ENABLE ((u32)0x00000002) +#define OPA_UNITGAIN_DISABLE ((u32)0x00000000) + +/* Definitions of OPA Output Status */ +#define OPA_OUTPUT_HIGH ((u32)0x00000080) +#define OPA_OUTPUT_LOW ((u32)0x00000000) + +#define OPA_NORMAL_MODE (0) +#define OPA_OFFSET_CALIBRATION_MODE (1) + +#define OPA_INPUT_OFFSET_INN (0) +#define OPA_INPUT_OFFSET_INP (1) + +/** + * @brief Used to check parameter of the OPAx. + */ +#define IS_OPA_ScalerEnable(x) ((x == OPA_SCALER_ENABLE) || (x == OPA_SCALER_DISABLE)) + +#define IS_OPA_ExtPinEnable(x) ((x == OPA_ExternalPin_ENABLE) || (x == OPA_ExternalPin_DISABLE)) + +#define IS_OPA_PGAEnable(x) ((x == OPA_PGA_ENABLE) || (x == OPA_PGA_DISABLE)) + +#define IS_OPA_UnitGainEnable(x) ((x == OPA_UNITGAIN_ENABLE) || (x == OPA_UNITGAIN_DISABLE)) + +#define IS_OPA_PGA_SEL(SEL) ((SEL == PGA_GAIN_5) || (SEL == PGA_GAIN_6) || \ + (SEL == PGA_GAIN_7) || (SEL == PGA_GAIN_8) || \ + (SEL == PGA_GAIN_11) || (SEL == PGA_GAIN_12) || \ + (SEL == PGA_GAIN_15) || (SEL == PGA_GAIN_16) || \ + (SEL == PGA_GAIN_23) || (SEL == PGA_GAIN_24) || \ + (SEL == PGA_GAIN_31) || (SEL == PGA_GAIN_32) || \ + (SEL == PGA_GAIN_47) || (SEL == PGA_GAIN_48) || \ + (SEL == PGA_GAIN_63) || (SEL == PGA_GAIN_64)) + +#define IS_OPA_OFMMODE(MODE) ((MODE == OPA_OFFSET_CALIBRATION_MODE) || \ + (MODE == OPA_NORMAL_MODE)) + +#define IS_OPA_INPUTOFFSET_SEL(SEL) ((SEL == OPA_INPUT_OFFSET_INN) || \ + (SEL == OPA_INPUT_OFFSET_INP)) + +/* Check the OPA Scaler Value */ +#define IS_OPA_SCALER_VALUE(x) (x <= 0x3FF) + +/* Check the OPA Input Offset Value */ +#define IS_OPA_INPUTOFFSET_VALUE(x) (x <= 0x1F) +#endif +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup OPA_Exported_Functions OPA exported functions + * @{ + */ +void OPA_DeInit(void); +void OPA_Cmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState); +void OPA_SetUnProtectKey(u32 uUnProtectKey); +void OPA_ProtectConfig(HT_OPA_TypeDef* HT_OPAn); +void OPA_UnprotectConfig(HT_OPA_TypeDef* HT_OPAn); + +#if (LIBCFG_OPA_V2) +void OPA_Init(HT_OPA_TypeDef* HT_OPAn, OPA_InitTypeDef* OPA_InitStruct); +void OPA_StructInit(OPA_InitTypeDef* OPA_InitStruct); +void OPA_ExternalInputCmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState); +#if (LIBCFG_OPA_PGA) +void OPA_UnitGainCmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState); +void OPA_PGACmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState); +void OPA_PGAGain(HT_OPA_TypeDef* HT_OPAn, u8 bGAIN_SEL); +#endif +void OPA_ScalerCmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState); +void OPA_SetScalerValue(HT_OPA_TypeDef* HT_OPAn, u32 Scaler_Value); +FlagStatus OPA_GetOutputStatus(HT_OPA_TypeDef* HT_OPAn); +void OPA_OFMMode(HT_OPA_TypeDef* HT_OPAn, u8 bMODE); +void OPA_OFM_InputOffsetReferenceSelect(HT_OPA_TypeDef* HT_OPAn, u8 bSEL); +void OPA_SetInputOffsetVoltage(HT_OPA_TypeDef* HT_OPAn, u8 bData); +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_pga.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_pga.h new file mode 100644 index 0000000000..c72336c2fa --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f65xxx_66xxx_pga.h @@ -0,0 +1,62 @@ +/*********************************************************************************************************//** + * @file ht32f65xxx_66xxx_pga.h + * @version $Rev:: 6915 $ + * @date $Date:: 2023-05-10 #$ + * @brief The header file of the PGA library (temporary file, not finish/support yet). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F65XXX_66XXX_PGA_H +#define __HT32F65XXX_66XXX_PGA_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup PGA + * @{ + */ + + + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66242_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66242_libcfg.h new file mode 100644 index 0000000000..953106da19 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66242_libcfg.h @@ -0,0 +1,52 @@ +/*********************************************************************************************************//** + * @file ht32f66242_libcfg.h + * @version $Rev:: 7184 $ + * @date $Date:: 2023-08-31 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F66242_LIBCFG_H +#define __HT32F66242_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F66242) +#define USE_MEM_HT32F66242 +#endif + +#define LIBCFG_MAX_SPEED (80000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F66242 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x66242) +#endif + +#define LIBCFG_ADC_NO_OFFSET_REG (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_PDMA (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66246_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66246_libcfg.h new file mode 100644 index 0000000000..90a37a1703 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66246_libcfg.h @@ -0,0 +1,52 @@ +/*********************************************************************************************************//** + * @file ht32f66246_libcfg.h + * @version $Rev:: 7184 $ + * @date $Date:: 2023-08-31 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F66246_LIBCFG_H +#define __HT32F66246_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F66246) +#define USE_MEM_HT32F66246 +#endif + +#define LIBCFG_MAX_SPEED (80000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F66246 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 63) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x66246) +#endif + +#define LIBCFG_ADC_NO_OFFSET_REG (1) +#define LIBCFG_GPIOC (1) +#define LIBCFG_NO_PWRCU_TEST_REG (1) +#define LIBCFG_PDMA (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_cordic.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_cordic.h new file mode 100644 index 0000000000..1c25b4c036 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_cordic.h @@ -0,0 +1,62 @@ +/*********************************************************************************************************//** + * @file ht32f66xxx_cordic.h + * @version $Rev:: 6915 $ + * @date $Date:: 2023-05-10 #$ + * @brief The header file of the CORDIC library (temporary file, not finish/support yet). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F66XXX_CORDIC_H +#define __HT32F66XXX_CORDIC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup CORDIC + * @{ + */ + + + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_pid.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_pid.h new file mode 100644 index 0000000000..c47671643c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f66xxx_pid.h @@ -0,0 +1,62 @@ +/*********************************************************************************************************//** + * @file ht32f66xxx_pid.h + * @version $Rev:: 6915 $ + * @date $Date:: 2023-05-10 #$ + * @brief The header file of the PID library (temporary file, not finish/support yet). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F66XXX_PID_H +#define __HT32F66XXX_PID_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @addtogroup PID + * @{ + */ + + + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f67041_51_libcfg.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f67041_51_libcfg.h new file mode 100644 index 0000000000..b72fe2659b --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/inc/ht32f67041_51_libcfg.h @@ -0,0 +1,78 @@ +/*********************************************************************************************************//** + * @file ht32f67041_51_libcfg.h + * @version $Rev:: 6923 $ + * @date $Date:: 2023-05-10 #$ + * @brief The library configuration file. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32F67041_51_LIBCFG_H +#define __HT32F67041_51_LIBCFG_H + +/* Settings ------------------------------------------------------------------------------------------------*/ + +#if !defined(USE_MEM_HT32F67041) && !defined(USE_MEM_HT32F67051) +#define USE_MEM_HT32F67051 +#endif + +#define LIBCFG_MAX_SPEED (60000000) + +#define LIBCFG_FLASH_PAGESIZE (1024) + +#ifdef USE_MEM_HT32F67041 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 64) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x67041) +#endif + +#ifdef USE_MEM_HT32F67051 + #define LIBCFG_FLASH_SIZE (LIBCFG_FLASH_PAGESIZE * 127) + #define LIBCFG_RAM_SIZE (1024 * 8) + #define LIBCFG_CHIPNAME (0x67051) +#endif + +#define LIBCFG_ADC_CH8_11 (1) +#define LIBCFG_ADC_IVREF (1) +#define LIBCFG_ADC_MVDDA (1) +#define LIBCFG_AES (1) +#define LIBCFG_BFTM1 (1) +#define LIBCFG_CKCU_ATM_V01 (1) +#define LIBCFG_CKCU_PLLSRCDIV (1) +#define LIBCFG_CKCU_REFCLK_EXT_PIN (1) +#define LIBCFG_CKCU_SYS_CK_60M (1) +#define LIBCFG_CRC (1) +#define LIBCFG_DIV (1) +#define LIBCFG_FMC_PREFETCH (1) +#define LIBCFG_FMC_WAIT_STATE_2 (1) +#define LIBCFG_I2C1 (1) +#define LIBCFG_LSE (1) +#define LIBCFG_PDMA (1) +#define LIBCFG_SCTM0 (1) +#define LIBCFG_SCTM1 (1) +#define LIBCFG_SCTM2 (1) +#define LIBCFG_SCTM3 (1) +#define LIBCFG_NO_USART0 (1) +#define LIBCFG_SPI1 (1) +#define LIBCFG_UART1 (1) +#define LIBCFG_PWRCU_VDD_2V0_3V6 (1) + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_cm0plus_misc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_cm0plus_misc.c new file mode 100644 index 0000000000..91fc97ab99 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_cm0plus_misc.c @@ -0,0 +1,243 @@ +/*********************************************************************************************************//** + * @file ht32_cm0plus_misc.c + * @version $Rev:: 5377 $ + * @date $Date:: 2021-05-26 #$ + * @brief This file provides all the miscellaneous firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32_cm0plus_misc.h" +#include "ht32_div.c" +#include "ht32_rand.c" +#ifdef HTCFG_TIME_IPSEL +#include "ht32_time.c" +#endif + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup MISC MISC + * @brief MISC driver modules + * @{ + */ + + +/* Private definitions -------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Private_Define MISC private definitions + * @{ + */ +#define AIRCR_VECTKEY_MASK ((u32)0x05FA0000) +#define CTRL_TICKINT_SET ((u32)0x00000002) +#define CTRL_TICKINT_RESET ((u32)0xFFFFFFFD) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup MISC_Exported_Functions MISC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Set the vector table location and Offset. + * @param NVIC_VectTable: Specify if the vector table is in FLASH or RAM. + * This parameter can be one of the following values: + * @arg NVIC_VECTTABLE_RAM + * @arg NVIC_VECTTABLE_FLASH + * @param NVIC_Offset: Vector Table base offset field. + * This value must be a multiple of 0x100. + * @retval None + ***********************************************************************************************************/ +void NVIC_SetVectorTable(u32 NVIC_VectTable, u32 NVIC_Offset) +{ + /* Check the parameters */ + Assert_Param(IS_NVIC_VECTTABLE(NVIC_VectTable)); + Assert_Param(IS_NVIC_OFFSET(NVIC_Offset)); + + SCB->VTOR = NVIC_VectTable | (NVIC_Offset & (u32)0x1FFFFF80); +} + +/*********************************************************************************************************//** + * @brief Select which low power mode to execute to the system. + * @param NVIC_LowPowerMode: Specify the new low power mode to execute to the system. + * This parameter can be one of the following values: + * @arg NVIC_LOWPOWER_SEVONPEND + * @arg NVIC_LOWPOWER_SLEEPDEEP + * @arg NVIC_LOWPOWER_SLEEPONEXIT + * @param NewState: new state of low power condition. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void NVIC_LowPowerConfig(u8 NVIC_LowPowerMode, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_NVIC_LOWPOWER(NVIC_LowPowerMode)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCB->SCR |= NVIC_LowPowerMode; + } + else + { + SCB->SCR &= (u32)(~(u32)NVIC_LowPowerMode); + } +} + +/*********************************************************************************************************//** + * @brief Set the pending bit for a system handler. + * @param SystemHandler: Specify the system handler pending bit to be set. + * This parameter can be one of the following values: + * @arg SYSTEMHANDLER_NMI + * @arg SYSTEMHANDLER_PSV + * @arg SYSTEMHANDLER_SYSTICK + * @retval None + ***********************************************************************************************************/ +void NVIC_SetPendingSystemHandler(u32 SystemHandler) +{ + /* Check the parameters */ + Assert_Param(IS_NVIC_SYSTEMHANDLER(SystemHandler)); + + /* Set the corresponding System Handler pending bit */ + SCB->ICSR |= SystemHandler; +} + +/*********************************************************************************************************//** + * @brief Configure the SysTick clock source. + * @param SysTick_ClockSource: Specify the SysTick clock source. + * This parameter can be one of the following values: + * @arg SYSTICK_SRC_STCLK : External reference clock is selected as SysTick clock source. + * @arg SYSTICK_SRC_FCLK : AHB clock is selected as SysTick clock source. + * @retval None + ***********************************************************************************************************/ +void SYSTICK_ClockSourceConfig(u32 SysTick_ClockSource) +{ + /* Check the parameters */ + Assert_Param(IS_SYSTICK_CLOCK_SOURCE(SysTick_ClockSource)); + + if (SysTick_ClockSource == SYSTICK_SRC_FCLK) + { + SysTick->CTRL |= SYSTICK_SRC_FCLK; + } + else + { + SysTick->CTRL &= SYSTICK_SRC_STCLK; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SysTick counter. + * @param SysTick_Counter: new state of the SysTick counter. + * This parameter can be one of the following values: + * @arg SYSTICK_COUNTER_DISABLE : Disable counter + * @arg SYSTICK_COUNTER_ENABLE : Enable counter + * @arg SYSTICK_COUNTER_CLEAR : Clear counter value to 0 + * @retval None + ***********************************************************************************************************/ +void SYSTICK_CounterCmd(u32 SysTick_Counter) +{ + /* Check the parameters */ + Assert_Param(IS_SYSTICK_COUNTER(SysTick_Counter)); + + if (SysTick_Counter == SYSTICK_COUNTER_CLEAR) + { + SysTick->VAL = SYSTICK_COUNTER_CLEAR; + } + else + { + if (SysTick_Counter == SYSTICK_COUNTER_ENABLE) + { + SysTick->CTRL |= SYSTICK_COUNTER_ENABLE; + } + else + { + SysTick->CTRL &= SYSTICK_COUNTER_DISABLE; + } + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the SysTick Interrupt. + * @param NewState: new state of the SysTick Interrupt. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void SYSTICK_IntConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SysTick->CTRL |= CTRL_TICKINT_SET; + } + else + { + SysTick->CTRL &= CTRL_TICKINT_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Set SysTick counter reload value. + * @param SysTick_Reload: SysTick reload new value. + * This parameter must be a number between 1 and 0xFFFFFF. + * @retval None + ***********************************************************************************************************/ +void SYSTICK_SetReloadValue(u32 SysTick_Reload) +{ + /* Check the parameters */ + Assert_Param(IS_SYSTICK_RELOAD(SysTick_Reload)); + + SysTick->LOAD = SysTick_Reload; +} + +/*********************************************************************************************************//** + * @brief Reverse bits. + * @param in: Input data + * @retval uRBIT + ***********************************************************************************************************/ +u32 RBIT(u32 in) +{ + u32 uRBIT = 0; + s32 i; + + for(i = 31; i >=0; i--) + { + uRBIT |= ((in & 0x1) << i); + in = in >> 1; + } + + return uRBIT; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_div.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_div.c new file mode 100644 index 0000000000..37403e1d5e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_div.c @@ -0,0 +1,55 @@ +/*********************************************************************************************************//** + * @file ht32_div.c + * @version $Rev:: 220 $ + * @date $Date:: 2016-02-16 #$ + * @brief The division assembly. + ************************************************************************************************************* +* @attention +* +* Firmware Disclaimer Information +* +* 1. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the +* proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and +* other intellectual property laws. +* +* 2. The customer hereby acknowledges and agrees that the program technical documentation, including the +* code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties +* other than HOLTEK and the customer. +* +* 3. The program technical documentation, including the code, is provided "as is" and for customer reference +* only. After delivery by HOLTEK, the customer shall use the program technical documentation, including +* the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including +* the warranties of merchantability, satisfactory quality and fitness for a particular purpose. +* +*

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +#include "ht32.h" + +/* Global variables ----------------------------------------------------------------------------------------*/ +//__ALIGN4 static uc32 Data[] = +__ALIGN4 static u32 Data[] = +{ +0x09032200, 0xD32C428B, 0x428B0A03, 0x2300D311, 0xE04E469C, 0x430B4603, 0x2200D43C, 0x428B0843, +0x0903D331, 0xD31C428B, 0x428B0A03, 0x4694D301, 0x09C3E03F, 0xD301428B, 0x1AC001CB, 0x09834152, +0xD301428B, 0x1AC0018B, 0x09434152, 0xD301428B, 0x1AC0014B, 0x09034152, 0xD301428B, 0x1AC0010B, +0x08C34152, 0xD301428B, 0x1AC000CB, 0x08834152, 0xD301428B, 0x1AC0008B, 0x08434152, 0xD301428B, +0x1AC0004B, 0x1A414152, 0x4601D200, 0x46104152, 0xE05D4770, 0xD0000FCA, 0x10034249, 0x4240D300, +0x22004053, 0x0903469C, 0xD32D428B, 0x428B0A03, 0x22FCD312, 0xBA120189, 0x428B0A03, 0x0189D30C, +0x428B1192, 0x0189D308, 0x428B1192, 0x0189D304, 0x1192D03A, 0x0989E000, 0x428B09C3, 0x01CBD301, +0x41521AC0, 0x428B0983, 0x018BD301, 0x41521AC0, 0x428B0943, 0x014BD301, 0x41521AC0, 0x428B0903, +0x010BD301, 0x41521AC0, 0x428B08C3, 0x00CBD301, 0x41521AC0, 0x428B0883, 0x008BD301, 0x41521AC0, +0x0843D2D9, 0xD301428B, 0x1AC0004B, 0x1A414152, 0x4601D200, 0x41524663, 0x4610105B, 0x4240D301, +0xD5002B00, 0x47704249, 0x105B4663, 0x4240D300, 0x2000B501, 0x46C046C0, 0x0000BD02 +}; + +u32 (*UDIV32)(u32, u32); +s32 (*SDIV32)(s32, s32); + +void DIV32_Init(void) +{ + u32 fptr = (u32)Data; + UDIV32 = (u32 (*)(u32, u32))(fptr + 0x1); + SDIV32 = (s32 (*)(s32, s32))(fptr + 0x15); +} diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_rand.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_rand.c new file mode 100644 index 0000000000..435766bb0e --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_rand.c @@ -0,0 +1,81 @@ +/*********************************************************************************************************//** + * @file ht32_rand.c + * @version $Rev:: 2069 $ + * @date $Date:: 2017-11-07 #$ + * @brief The rundom number function. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include + +/* Global variables ----------------------------------------------------------------------------------------*/ +__ALIGN4 static uc32 RandData[] = +{ + 0x4946b5ff, 0x6a4cb087, 0x6b0c9404, 0x6a4c9403, + 0x042d2503, 0x624c432c, 0x4d416b0c, 0x630c432c, + 0x68394f40, 0x2580463c, 0x402926f9, 0x1b890236, + 0x021e6039, 0x04114316, 0x0619430e, 0x607e430e, + 0x43160216, 0x4316041a, 0x60a6430e, 0x62212117, + 0x22014934, 0x630a3140, 0x432b6823, 0x4e326023, + 0x93056873, 0x685c4b31, 0x4c319406, 0x605c6074, + 0x69dd69f4, 0x43136b4b, 0x4a2a634b, 0x68533280, + 0xd5fc075b, 0x463a6b3b, 0x0f1b071b, 0x6b7b9302, + 0x071b6bbf, 0x073f0f1b, 0x97010f3f, 0x07176bd2, + 0x680a0f3f, 0x071746bc, 0x97000f3f, 0x0717684a, + 0x688a0f3f, 0x071246be, 0x0f1268c9, 0x68074e1a, + 0x042d69f6, 0x193419be, 0x4d181964, 0x69ed6004, + 0x011b9e02, 0x431e9f01, 0x023b042d, 0x46671964, + 0x432b033d, 0x431e9f00, 0x431e043b, 0x053b4677, + 0x0612431e, 0x07094316, 0x9a08430e, 0x18891931, + 0x48096001, 0x60419905, 0x99064808, 0x48036041, + 0x62419904, 0x63019903, 0xbdf0b00b, 0x40088000, + 0x01000040, 0x40010000, 0x400b0000, 0x400b2000, + 0x0000ffff +}; + +__ALIGN4 static uc32 RandData2[] = +{ + 0x4604b510, 0x18406800, 0x46216020, 0x68084a03, + 0x4a034350, 0x60081880, 0xbd100840, 0x41c64e6d, + 0x00003039 +}; + +typedef void (*Randinit_TypeDef) (u32 *, u32, u32, u32); +u32 (*Rand_Get)(u32 *, u32); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/*********************************************************************************************************//** + * @brief Rand init. + * @param uSeed + * @param uCount + * @param a + * @param b + * @retval none + ***********************************************************************************************************/ +void Rand_Init(u32 *uSeed, u32 uCount, u32 a, u32 b) +{ + Randinit_TypeDef Randinit = (Randinit_TypeDef)((u32)RandData | 0x1); + Rand_Get = (u32 (*)(u32 *, u32))((u32)RandData2 | 0x1); + Randinit(uSeed, uCount, a, b); +} diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget.c new file mode 100644 index 0000000000..5ffe762c9d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget.c @@ -0,0 +1,413 @@ +/*********************************************************************************************************//** + * @file ht32_retarget.c + * @version $Rev:: 6977 $ + * @date $Date:: 2023-06-07 #$ + * @brief Retarget layer for target-dependent low level functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_board.h" + +#if defined (__CC_ARM) + #pragma import(__use_no_semihosting_swi) +#endif + +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #ifndef __MICROLIB + __asm(".global __use_no_semihosting"); + #endif +#endif + +#if (_RETARGET == 1) +#include + +#if defined (__CC_ARM) + #include +#endif + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup RETARGET Retarget + * @brief Retarget related functions + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup RETARGET_Private_Define Retarget private definitions + * @{ + */ + +#if (RETARGET_PORT == RETARGET_ITM) +#define ITM_PORT8(n) (*((vu8 *)(0xE0000000 + 4 * n))) +#define ITM_PORT16(n) (*((vu16 *)(0xE0000000 + 4 * n))) +#define ITM_PORT32(n) (*((vu32 *)(0xE0000000 + 4 * n))) + +#define DEMCR (*((vu32 *)(0xE000EDFC))) +#define TRCENA (0x01000000) +volatile int32_t ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* For Keil MDK-ARM only */ +#endif +/** + * @} + */ + +/* Global variables ----------------------------------------------------------------------------------------*/ +/** @defgroup RETARGET_Global_Variable Retarget global variables + * @{ + */ +#if defined (__CC_ARM) +struct __FILE { int handle; /* Add whatever you need here */ }; +FILE __stdout; +FILE __stdin; +#endif + +#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #ifndef __MICROLIB + FILE __stdout; + FILE __stdin; + FILE __stderr; + #endif +#endif + +#if defined (__SES_ARM) && defined(__SEGGER_RTL_VERSION) +struct __SEGGER_RTL_FILE_impl { // NOTE: Provides implementation for FILE + int stub; // only needed so impl has size != 0. +}; +static FILE __SEGGER_RTL_stdin_file = { 0 }; // stdin reads from UART +static FILE __SEGGER_RTL_stdout_file = { 0 }; // stdout writes to UART +static FILE __SEGGER_RTL_stderr_file = { 0 }; // stderr writes to UART + +FILE *stdin = &__SEGGER_RTL_stdin_file; // NOTE: Provide implementation of stdin for RTL. +FILE *stdout = &__SEGGER_RTL_stdout_file; // NOTE: Provide implementation of stdout for RTL. +FILE *stderr = &__SEGGER_RTL_stderr_file; // NOTE: Provide implementation of stderr for RTL. + +static int _stdin_ungot = EOF; +#endif +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup RETARGET_Exported_Functions Retarget exported functions + * @{ + */ + +void RETARGET_Configuration(void) +{ +#ifdef RETARGET_IS_UART + /* !!! NOTICE !!! + Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below in this function. + */ + USART_InitTypeDef USART_InitStructure; + #ifdef RETARGET_UxART_BAUDRATE + USART_InitStructure.USART_BaudRate = RETARGET_UxART_BAUDRATE; + #else + USART_InitStructure.USART_BaudRate = 115200; + #endif + USART_InitStructure.USART_WordLength = USART_WORDLENGTH_8B; + USART_InitStructure.USART_StopBits = USART_STOPBITS_1; + USART_InitStructure.USART_Parity = USART_PARITY_NO; + USART_InitStructure.USART_Mode = USART_MODE_NORMAL; + + #ifdef RETARGET_COM_PORT + HT32F_DVB_COMInit(RETARGET_COM_PORT, &USART_InitStructure); + #else + { /* Enable peripheral clock of UxART */ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + CKCUClock.Bit.RETARGET_UxART_IPN = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + } + + USART_Init(RETARGET_USART_PORT, &USART_InitStructure); + USART_TxCmd(RETARGET_USART_PORT, ENABLE); + USART_RxCmd(RETARGET_USART_PORT, ENABLE); + #if (RETARGET_INT_MODE == 1) + NVIC_EnableIRQ(RETARGET_UART_IRQn); + #endif + #endif +#endif + +#if (RETARGET_PORT == RETARGET_ITM) + CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }}; + CKCUClock.Bit.AFIO = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + CKCU_MCUDBGConfig(CKCU_DBG_TRACE_ON, ENABLE); + AFIO_GPxConfig(TRACESWO_GPIO_ID, TRACESWO_AFIO_PIN, TRACESWO_AFIO_MODE); +#endif + +#ifdef NON_USB_IN_APP + SERIAL_USBDInit(); +#endif +} + +int __backspace(FILE *stream) +{ + if (stream == 0) // Remove the compiler warning + { + } + return 0; +} + +/* + Keil and IAR before 9.20 share fputc() to implement printf +*/ +int fputc (int ch, FILE *f) +{ + #if 0 + if (f == 0) // Remove the compiler warning + { + } + #endif + #if (RETARGET_PORT == RETARGET_ITM) + if (DEMCR & TRCENA) + { + while (ITM_PORT32(0) == 0); + ITM_PORT8(0) = ch; + } + return (ch); + #else + #ifdef AUTO_RETURN + if (ch == '\n') + { + SERIAL_PutChar('\r'); + } + #endif + return (SERIAL_PutChar(ch)); + #endif +} + +#if defined (__ICCARM__) +#if (__VER__ > 9010000) +/* + IAR's version after 9.20 use write to implement printf +*/ +int __write(int Handle, + const unsigned char * Buf, + int Bufsize) +{ + size_t nChars = 0; + if (Handle == -1) + { + return 0; + } + /* Check for stdout and stderr + (only necessary if FILE descriptors are enabled.) */ + if (Handle != 1 && Handle != 2) + { + return -1; + } + for (/*Empty */; Bufsize > 0; --Bufsize) + { + SERIAL_PutChar(*Buf++); + ++nChars; + } + return nChars; +} +#endif +int __read(int Handle, unsigned char *Buf, size_t BufSize) +{ + #if (RETARGET_PORT != RETARGET_ITM) + int nChars = 0; + + if (Handle != 0) + { + return -1; + } + + for (/* Empty */; BufSize > 0; --BufSize) + { + unsigned char c = NULL; + c = SERIAL_GetChar(); + if (c == 0) + break; + *Buf++ = c; + ++nChars; + } + #endif + return nChars; +} + +#elif defined(__SES_ARM) +#if defined(__SEGGER_RTL_VERSION) +/* + SES's version after 6.20 use RTL to implement printf. +*/ +/*********************************************************************************************************//** + * @brief Get character from standard input.. + * @retval Character received. + ************************************************************************************************************/ +static char _stdin_getc(void) { + unsigned char c; + + if (_stdin_ungot != EOF) { + c = _stdin_ungot; + _stdin_ungot = EOF; + } else { + c = SERIAL_GetChar(); + } + return c; +} + +/*********************************************************************************************************//** + * @brief Get file status. + * @param Pointer to file. + * @retval -1: Failure, stream is not a valid file. 0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_stat(FILE *stream) { + if (stream == stdin || stream == stdout || stream == stderr) { + return 0; // NOTE: stdin, stdout, and stderr are assumed to be valid. + } else { + return EOF; + } +} + +/*********************************************************************************************************//** + * @brief Get stream buffer size. + * @param stream: Pointer to file. + * @retval Nonzero number of characters to use for buffered I/O; for unbuffered I/O, return 1. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_bufsize(FILE *stream) { + (void)stream; + return 1; +} + +/*********************************************************************************************************//** + * @brief Read data from file. + * @param stream: Pointer to file to read from. + * @param s: Pointer to object that receives the input. + * @param len: Number of characters to read from file. + * @retval -1: Failure, stream is not a valid file. >0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_read(FILE *stream, char *s, unsigned len) { + int c; + + if (stream == stdin) { + c = 0; + while (len > 0) { + *s = _stdin_getc(); + ++s; + ++c; + --len; + } + } else { + c = EOF; + } + return c; +} + +/*********************************************************************************************************//** + * @brief Write data to file. + * @param stream: Pointer to file to write to. + * @param s:Pointer to object to write to file. + * @param len:Number of characters to write to the file. + * @retval -1: Failure, stream is not a valid file. >0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_write(FILE *stream, const char *s, unsigned len) { + if ((stream == stdout) || (stream == stderr)) { + //BSP_UART_WriteBlocking(_UART_Port, (const unsigned char*) s, len); + for (/*Empty */; len > 0; --len) + { + SERIAL_PutChar(*s++); + } + return len; + } else { + return EOF; + } +} + +/*********************************************************************************************************//** + * @brief ush character back to stream. + * @param stream: Pointer to file to push back to. + * @param c: Character to push back. + * @retval -1: Failure, stream is not a valid file. >0: Success, stream is a valid file. + ***********************************************************************************************************/ +int __SEGGER_RTL_X_file_unget(FILE *stream, int c) { + if (stream == stdin) { + if (c != EOF && _stdin_ungot == EOF) { + _stdin_ungot = c; + } else { + c = EOF; + } + } else { + c = EOF; + } + return c; +} +#endif +#else +int fgetc (FILE *f) +{ + #if 0 + if (f == 0) // Remove the compiler warning + { + } + #endif + #if (RETARGET_PORT == RETARGET_ITM) + /* For Keil MDK-ARM only */ + while (ITM_CheckChar() == 0); + return (ITM_ReceiveChar()); + #else + return (SERIAL_GetChar()); + #endif +} +#endif + +void _ttywrch(int ch) +{ + #if (RETARGET_PORT == RETARGET_ITM) + if (DEMCR & TRCENA) + { + while (ITM_PORT32(0) == 0); + ITM_PORT8(0) = ch; + } + #else + SERIAL_PutChar(ch); + #endif +} +#endif + +void _sys_exit(int return_code) +{ + if (return_code == 0) // Remove the compiler warning + { + } + +label: goto label; /* endless loop */ +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget_desc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget_desc.c new file mode 100644 index 0000000000..b8fec7bee6 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_retarget_desc.c @@ -0,0 +1,272 @@ +/*********************************************************************************************************//** + * @file ht32_retarget_desc.c + * @version $Rev:: 783 $ + * @date $Date:: 2016-06-10 #$ + * @brief The The USB Descriptor of retarget. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Includes ------------------------------------------------------------------------------------------------*/ + +#define DESC_LEN_CONFN_T (u16)(DESC_LEN_CONFN) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Device descriptor setting +// USB Specification Release number (bcdUSB) +// <0x0200=> USB 2.0 +// <0x0110=> USB 1.1 +// <0x0100=> USB 1.0 +// USB Class code (assigned by the USB-IF) +// <0x00=> Use class information in the Interface Descriptors (0x00) +// <0x02=> Communications and CDC Control (CDC, 0x02) +// <0xDC=> Diagnostic Device (0xDC) +// <0xEF=> Miscellaneous (0xEF) +// <0xFF=> Vendor Specific (0xFF) +// USB Subclass code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Protocol code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Vendor ID <0x0-0xFFFF:1> +// USB Product ID <0x0-0xFFFF:1> +// USB Device Version <0x0-0xFFFF:1> +// USB String descriptor - Manufacturer +// USB String descriptor - Product +// USB String descriptor - Device serial number +// USB Number of possible configurations <0-255:1> +#define DESC_BCDUSB (0x0110) +#define DESC_BDEVCLASS (0x00) +#define DESC_BDEVSUBCLASS (0x00) +#define DESC_BDEVPROTOCOL (0x00) +#define DESC_IDVENDOR (0x04D9) +#define DESC_IDPRODUCT (0x8008) +#define DESC_BCDDEVICE (0x0100) +#define DESC_IMANUFACTURE (1) +#define DESC_IPRODUCT (1) +#define DESC_ISERIALNUM (1) +#define DESC_INUMCONFN (1) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (DESC_BDEVCLASS == 0x0 & DESC_BDEVSUBCLASS != 0x0) +#error "DESC_BDEVSUBCLASS must be reset to zero when the DESC_BDEVCLASS is equal to zero." +#endif +#define DESC_WMAXPACKETSIZE0 (_EP0LEN) +#define DESC_STR_MAN (1 * DESC_IMANUFACTURE) +#define DESC_STR_PRD (2 * DESC_IPRODUCT) +#define DESC_STR_SER (3 * DESC_ISERIALNUM) +#define DESC_NUM_STRING (1 + 3) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_DeviceDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Device descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_DEV, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_01_DEV, // bDescriptorType 1 DEVICE Descriptor Type + DESC_H2B(DESC_BCDUSB), // bcdUSB 2 USB Specification Release Number + DESC_BDEVCLASS, // bDeviceClass 1 Class code (assigned by the USB-IF) + DESC_BDEVSUBCLASS, // bDeviceSubClass 1 Subclass code (assigned by the USB-IF) + DESC_BDEVPROTOCOL, // bDeviceProtocol 1 Protocol code (assigned by the USB-IF) + DESC_WMAXPACKETSIZE0, // wMaxPacketSize0 1 Maximum packet size for endpoint zero + DESC_H2B(DESC_IDVENDOR), // idVendor 2 Vendor ID (assigned by USB-IF) + DESC_H2B(DESC_IDPRODUCT), // idProduct 2 Product ID (assigned by manufacturer) + DESC_H2B(DESC_BCDDEVICE), // bcdDevice 2 Device release number + DESC_STR_MAN, // iManufacturer 1 Index of string descriptor (Manufacturer) + DESC_STR_PRD, // iProduct 1 Index of string descriptor (Product) + DESC_STR_SER, // iSerialNumber 1 Index of string descriptor (Serial Number) + DESC_INUMCONFN, // iNumConfigurations 1 Number of possible configuration +}; + + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Configuration descriptor setting +// Self-powered +// Bit 6 of bmAttributes +// Remote Wakeup +// Bit 5 of bmAttributes +// USB Device maximum power (mA) < 2-512:2> +#define DESC_BMATTR_SELF_POWER (0) +#define DESC_BMATTR_REMOTE_WAKEUP (0) +#define DESC_BMAXPOWER (100) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#define DESC_BMATTRIBUTES (0x80 | (DESC_BMATTR_SELF_POWER << 6) | (DESC_BMATTR_REMOTE_WAKEUP << 5)) +#define DESC_TOTAL_LEN DESC_H2B((DESC_LEN_CONFN_T + RETARGET_DLEN)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_ConfnDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Configuration descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_CONFN, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_02_CONFN, // bDescriptorType 1 CONFIGURATION Descriptor Type + DESC_TOTAL_LEN, // wTotalLength 2 Total length of data returned for this configuration + RETARGET_INF, // bNumberInterface 1 Number of interfaces supported by this configuration + 0x01, // bConfigurationValue 1 Value to use as an argument to the SetConfiguration() + 0x00, // iConfiguration 1 Index of string descriptor describing this configuration + DESC_BMATTRIBUTES, // bmAttributes 1 Configuration characteristics + // D6: Self-powered, D5: RemoteWakeup + DESC_POWER(DESC_BMAXPOWER), // bMaxPower 1 Maximum power consumption of the USB device (2 mA units) + + #ifdef RETARGET_IS_USB + #include "ht32_retarget_desc.h" + #endif + +}; + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB String Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_StringDescLANGID[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* LANGID (Index = 0) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(1), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_H2B(0x0409), // wLANGID[0] 2 LANGID code zero +}; + +#if (DESC_IMANUFACTURE == 1) +__ALIGN4 static uc8 guUSB_StringDescManufacture[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Manufacture (Index = 1) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(6), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('H'), // bString N UNICODE encoded string + DESC_CHAR('O'), + DESC_CHAR('L'), + DESC_CHAR('T'), + DESC_CHAR('E'), + DESC_CHAR('K'), +}; +#endif + +#if (DESC_IPRODUCT == 1) +__ALIGN4 static uc8 guUSB_StringDescProduct[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Product (Index = 2) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(7), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('U'), // bString N UNICODE encoded string + DESC_CHAR('S'), + DESC_CHAR('B'), + DESC_CHAR('-'), + DESC_CHAR('V'), + DESC_CHAR('C'), + DESC_CHAR('P'), +}; +#endif + + +#if (DESC_ISERIALNUM == 1) +__ALIGN4 static uc8 guUSB_StringDescSerialNum[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Serial Number (Index = 3) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(12), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('S'), // bString N UNICODE encoded string + DESC_CHAR('N'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('1'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), +}; +#endif + +uc8 *gpStringDesc[DESC_NUM_STRING] = +{ + + guUSB_StringDescLANGID, + + #if (DESC_IMANUFACTURE == 1) + guUSB_StringDescManufacture, + #else + NULL, + #endif + + #if (DESC_IPRODUCT == 1) + guUSB_StringDescProduct, + #else + NULL, + #endif + + #if (DESC_ISERIALNUM == 1) + guUSB_StringDescSerialNum + #else + NULL, + #endif + +}; + +/*********************************************************************************************************//** + * @brief USB Descriptor pointer initialization. + * @param pDesc: pointer of USBDCore_Desc_TypeDef + * @retval None + ***********************************************************************************************************/ +void USBDDesc_Init(USBDCore_Desc_TypeDef *pDesc) +{ + pDesc->pDeviceDesc = guUSB_DeviceDesc; + pDesc->pConfnDesc = guUSB_ConfnDesc; + pDesc->ppStringDesc = gpStringDesc; + pDesc->uStringDescNumber = DESC_NUM_STRING; + + return; +} diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_serial.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_serial.c new file mode 100644 index 0000000000..a1f642f393 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_serial.c @@ -0,0 +1,555 @@ +/*********************************************************************************************************//** + * @file ht32_serial.c + * @version $Rev:: 6490 $ + * @date $Date:: 2022-11-25 #$ + * @brief This file provides all the Low level serial routines for HT32. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_board.h" + +#if (_RETARGET == 1) + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup SERIAL SERIAL + * @brief Serial related functions + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Exported_Functions Serial exported functions + * @{ + */ + +#ifdef RETARGET_IS_UART + +#if (RETARGET_INT_MODE == 1) +__ALIGN4 static u8 uSerialBuffer[RETARGET_INT_BUFFER_SIZE]; +static vu32 uReadIndex; +static vu32 uWriteIndex; + +#define IS_BUFFER_FULL(LEN) (((uWriteIndex + LEN) >= RETARGET_INT_BUFFER_SIZE) ? ((uWriteIndex + LEN - RETARGET_INT_BUFFER_SIZE) == uReadIndex) : ((uWriteIndex + LEN) == uReadIndex)) +#define IS_BUFFER_EMPTY() (uReadIndex == uWriteIndex) +#define BUFFER_FREE_LEN() ((uWriteIndex >= uReadIndex) ? (RETARGET_INT_BUFFER_SIZE - uWriteIndex + uReadIndex - 1) : (uReadIndex - uWriteIndex - 1)) + +/*********************************************************************************************************//** + * @brief UART IRQ handler. + * @retval None + ************************************************************************************************************/ +void RETARGET_UART_IRQHandler(void) +{ + if (((RETARGET_USART_PORT->SR) & USART_FLAG_TXDE)) + { + if (IS_BUFFER_EMPTY()) + { + RETARGET_USART_PORT->IER &= ~USART_INT_TXDE; + } + else + { + RETARGET_USART_PORT->DR = uSerialBuffer[uReadIndex++]; + if (uReadIndex == RETARGET_INT_BUFFER_SIZE) + { + uReadIndex = 0; + } + } + } + +} +#endif + +/*********************************************************************************************************//** + * @brief Put char to USART. + * @param ch: The char put to USART. + * @retval The char put to USART. + ************************************************************************************************************/ +u32 SERIAL_PutChar(u32 ch) +{ +#if (RETARGET_INT_MODE == 1) + + while (IS_BUFFER_FULL(1)); + + uSerialBuffer[uWriteIndex++] = ch; + if (uWriteIndex == RETARGET_INT_BUFFER_SIZE) + { + uWriteIndex = 0; + } + RETARGET_USART_PORT->IER |= USART_INT_TXDE; + +#else + + RETARGET_USART_PORT->DR = (u8)ch; + while ((RETARGET_USART_PORT->SR & USART_FLAG_TXC) == RESET) + { + } + +#endif + + return ch; +} + +/*********************************************************************************************************//** + * @brief Get char from USART. + * @retval The char got from USART. + ************************************************************************************************************/ +u32 SERIAL_GetChar(void) +{ + while (USART_GetFlagStatus(RETARGET_USART_PORT, USART_FLAG_RXDR) == RESET) + { + } + return USART_ReceiveData(RETARGET_USART_PORT); +} + +#endif + + +#ifdef RETARGET_IS_USB +/* Private types -------------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_TypesDefinitions Serial private types definitions + * @{ + */ +typedef struct _VCP_LINE_CODING +{ + u32 dwDTERate; //Bit rate; + u8 bCharFormat; //Stop bits: + //0 = 1 Stop bit + //1 = 1.5 Stop bit + //2 = 2 Stop bit + u8 bParityType; //parity: + //0 = None + //1 = Odd + //2 = Even + //3 = Mark + //4 = Space + u8 bDataBits; //Number of data bits (7, 8, 9) +} USBDClass_VCP_LINE_CODING; +/** + * @} + */ + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_Define Serial private definitions + * @{ + */ +#define CLASS_REQ_20_SET_LINE_CODING (0x20) +#define CLASS_REQ_21_GET_LINE_CODING (0x21) +#define CLASS_REQ_22_SET_CONTROL_LINE_STATE (0x22) + +#ifndef RETARGET_TXBUFFER_SIZE + #define RETARGET_TXBUFFER_SIZE (1) +#endif + +#define RETARGET_USB_MODE_BLOCK (0) +#define RETARGET_USB_MODE_NONBLOCK (1) +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_Macro Serial private macros + * @{ + */ +#define IS_BUFFER_FULL(LEN) (((uWriteIndex + LEN) >= RETARGET_BUFFER_SIZE) ? ((uWriteIndex + LEN - RETARGET_BUFFER_SIZE) == uReadIndex) : ((uWriteIndex + LEN) == uReadIndex)) +#define IS_BUFFER_EMPTY() (uReadIndex == uWriteIndex) +#define BUFFER_FREE_LEN() ((uWriteIndex >= uReadIndex) ? (RETARGET_BUFFER_SIZE - uWriteIndex + uReadIndex - 1) : (uReadIndex - uWriteIndex - 1)) +/** + * @} + */ + +/* Private variables ---------------------------------------------------------------------------------------*/ +/** @defgroup SERIAL_Private_Variable Serial private variables + * @{ + */ +static USBDClass_VCP_LINE_CODING USBDClassVCPLineCoding; +__ALIGN4 static u8 uSerialBuffer[RETARGET_BUFFER_SIZE]; +static vu32 uReadIndex; +static vu32 uWriteIndex; +static vu32 uDTRState = 0; +static vu32 gIsINEmpty = TRUE; + +static u32 TxCount = 0; +__ALIGN4 static u8 TxBuffer[RETARGET_TXBUFFER_SIZE]; +/** + * @} + */ + +#if (RETARGET_RX_EPT == RETARGET_TX_EPT) + #error USB Endpoint of retarget Rx and Tx must different. Please check RETARGET_RX_EPT/RETARGET_TX_EPT "ht32_retarget_usbdconf.h". +#endif + +#if (RETARGET_CTRL_EPT == RETARGET_TX_EPT) + #error USB Endpoint of retarget Control and Tx must different. Please check RETARGET_CTRL_EPT/RETARGET_TX_EPT "ht32_retarget_usbdconf.h". +#endif + +#if (RETARGET_CTRL_EPT == RETARGET_RX_EPT) + #error USB Endpoint of retarget Control and Rx must different. Please check RETARGET_CTRL_EPT/RETARGET_RX_EPT "ht32_retarget_usbdconf.h". +#endif + +#ifdef _RERATGET1_ERR + #error Endpoint 1 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET2_ERR + #error Endpoint 2 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET3_ERR + #error Endpoint 3 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET4_ERR + #error Endpoint 4 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET5_ERR + #error Endpoint 5 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET6_ERR + #error Endpoint 6 already used by other USB class. Retarget can not overwrite it. +#endif + +#ifdef _RERATGET7_ERR + #error Endpoint 7 already used by other USB class. Retarget can not overwrite it. +#endif + +/*********************************************************************************************************//** + * @brief Put char to USB. + * @param ch: The char put to USB. + * @retval The char put to USB. + ************************************************************************************************************/ +u32 SERIAL_PutChar(u32 ch) +{ + #if (RETARGET_TXBUFFER_SIZE > 63) + #error RETARGET_TXBUFFER_SIZE shall less than 63 (define in ht32fxxxxx_conf.h). + #endif + + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_BLOCK) + while (uDTRState == 0); /* Wait until user open the virtual COM port by PC UI such as Hyper Terminal */ + #elif (RETARGET_USB_MODE == RETARGET_USB_MODE_NONBLOCK) + if (uDTRState == 0) /* Drop data if USB or terminal software is not ready */ + { + return ch; + } + #endif + + TxBuffer[TxCount++] = ch; + + if (TxCount == RETARGET_TXBUFFER_SIZE) + { + TxCount = 0; + + while (gIsINEmpty == FALSE) + { + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_NONBLOCK) + if (uDTRState == 0) + { + return ch; + } + #endif + } + + gIsINEmpty = FALSE; + USBDCore_EPTWriteINData((USBD_EPTn_Enum)RETARGET_TX_EPT, (u32 *)&TxBuffer, RETARGET_TXBUFFER_SIZE); + } + + return ch; +} + +/*********************************************************************************************************//** + * @brief Get char from USB. + * @retval The char got from USB. + ************************************************************************************************************/ +u32 SERIAL_GetChar(void) +{ + u32 value = 0; + + while (IS_BUFFER_EMPTY()); + value = uSerialBuffer[uReadIndex++]; + if (uReadIndex == RETARGET_BUFFER_SIZE) + { + uReadIndex = 0; + } + + return value; +} + +/*********************************************************************************************************//** + * @brief Flush the Tx Buffer + * @retval None + ************************************************************************************************************/ +void SERIAL_Flush(void) +{ + do + { + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_NONBLOCK) + if (uDTRState == 0) + { + return; + } + #endif + } while (USBDCore_EPTGetTransferCount((USBD_EPTn_Enum)RETARGET_TX_EPT, USBD_TCR_0)); + + gIsINEmpty = FALSE; + USBDCore_EPTWriteINData((USBD_EPTn_Enum)RETARGET_TX_EPT, (u32 *)&TxBuffer, TxCount); + TxCount = 0; +} + +#ifdef NON_USB_IN_APP +#include "ht32_retarget_desc.c" +__ALIGN4 USBDCore_TypeDef gUSBCore; +USBD_Driver_TypeDef gUSBDriver; + +/*********************************************************************************************************//** + * @brief This function handles USB interrupt. + * @retval None + ************************************************************************************************************/ +void USB_IRQHandler(void) +{ + USBDCore_IRQHandler(&gUSBCore); +} + +/*********************************************************************************************************//** + * @brief USB Class initialization. + * @param pClass: pointer of USBDCore_Class_TypeDef + * @retval None + ************************************************************************************************************/ +void USBDClass_Init(USBDCore_Class_TypeDef *pClass) +{ + pClass->CallBack_ClassRequest = SERIAL_USBDClass_Request; + pClass->CallBack_EPTn[RETARGET_RX_EPT] = SERIAL_USBDClass_RXHandler; + pClass->CallBack_EPTn[RETARGET_TX_EPT] = SERIAL_USBDClass_TXHandler; + return; +} + +#if (LIBCFG_CKCU_USB_PLL) +/*********************************************************************************************************//** + * @brief Configure USB PLL + * @retval None + ************************************************************************************************************/ +void USBPLL_Configuration(void) +{ + if ((HT_CKCU->GCCR & (1 << 11)) == 0) + { + CKCU_HSICmd(ENABLE); + } + + { /* USB PLL configuration */ + + /* !!! NOTICE !!! + Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below in this function. + */ + CKCU_PLLInitTypeDef PLLInit; + + PLLInit.ClockSource = CKCU_PLLSRC_HSI; + #if (LIBCFG_CKCU_USB_PLL_96M) + PLLInit.CFG = CKCU_USBPLL_8M_96M; + #else + PLLInit.CFG = CKCU_USBPLL_8M_48M; + #endif + PLLInit.BYPASSCmd = DISABLE; + CKCU_USBPLLInit(&PLLInit); + } + + CKCU_USBPLLCmd(ENABLE); + + while (CKCU_GetClockReadyStatus(CKCU_FLAG_USBPLLRDY) == RESET); + CKCU_USBClockConfig(CKCU_CKUSBPLL); +} +#endif + +#if (LIBCFG_PWRCU_VREG) +/*********************************************************************************************************//** + * @brief Configure USB Voltage + * @retval None + ************************************************************************************************************/ +void USBVRG_Configuration(void) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }}; + CKCUClock.Bit.BKP = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + /* !!! NOTICE !!! + USB LDO should be enabled (PWRCU_VREG_ENABLE) if the MCU VDD > 3.6 V. + */ + PWRCU_VREGConfig(PWRCU_VREG_BYPASS); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure USB for retarget. + * @retval None + ************************************************************************************************************/ +void SERIAL_USBDInit(void) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + CKCUClock.Bit.USBD = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + #if (LIBCFG_CKCU_USB_PLL) + USBPLL_Configuration(); + #endif + + #if (LIBCFG_PWRCU_VREG) + USBVRG_Configuration(); /* Voltage of USB setting */ + #endif + + /* !!! NOTICE !!! + Must turn on if the USB clock source is from HSI (PLL clock Source) + */ + #if (RETARGET_HSI_ATM) + CKCU_HSIAutoTrimClkConfig(CKCU_ATC_USB); + CKCU_HSIAutoTrimCmd(ENABLE); + #endif + + gUSBCore.pDriver = (u32 *)&gUSBDriver; /* Initiate memory pointer of USB driver */ + USBDDesc_Init(&gUSBCore.Device.Desc); /* Initiate memory pointer of descriptor */ + USBDClass_Init(&gUSBCore.Class); /* Initiate USB Class layer */ + USBDCore_Init(&gUSBCore); /* Initiate USB Core layer */ + NVIC_EnableIRQ(USB_IRQn); /* Enable USB device interrupt */ + USBD_DPpullupCmd(ENABLE); + + #if (RETARGET_USB_MODE == RETARGET_USB_MODE_BLOCK) + USBDCore_MainRoutine(&gUSBCore); /* USB core main routine */ + while (USBDCore_GetStatus() != USB_STATE_CONFIGURED); + #else + gUSBCore.Info.CurrentFeature.Bits.bSelfPowered = TRUE; + USBDCore_MainRoutine(&gUSBCore); /* USB core main routine */ + #endif +} +#endif + +/*********************************************************************************************************//** + * @brief USB Device Class Request for USB retarget + * @param pDev: pointer of USB Device + * @retval None + ************************************************************************************************************/ +void SERIAL_USBDClass_Request(USBDCore_Device_TypeDef *pDev) +{ + u8 USBCmd = *((u8 *)(&(pDev->Request.bRequest))); + u16 len = *((u16 *)(&(pDev->Request.wLength))); + u32 inf = pDev->Request.wIndex; + u32 uIsCmdOK = 0; + + if (inf != 11) + { + return; + } + + if (USBCmd == CLASS_REQ_22_SET_CONTROL_LINE_STATE) + { + if (len == 0) + { + uDTRState = pDev->Request.wValueL & 0x1; + pDev->Transfer.pData = 0; + pDev->Transfer.sByteLength = 0; + pDev->Transfer.Action = USB_ACTION_DATAOUT; + } + } + else + { + if (USBCmd == CLASS_REQ_20_SET_LINE_CODING) + { + pDev->Transfer.Action = USB_ACTION_DATAOUT; + uIsCmdOK = 1; + } + else if (USBCmd == CLASS_REQ_21_GET_LINE_CODING) + { + pDev->Transfer.Action = USB_ACTION_DATAIN; + uIsCmdOK = 1; + } + + if (uIsCmdOK == 1) + { + pDev->Transfer.pData = (uc8*)&USBDClassVCPLineCoding; + pDev->Transfer.sByteLength = (sizeof(USBDClassVCPLineCoding) > pDev->Request.wLength) ? (pDev->Request.wLength) : (sizeof(USBDClassVCPLineCoding)); + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Received handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None +************************************************************************************************************/ +void SERIAL_USBDClass_RXHandler(USBD_EPTn_Enum EPTn) +{ + u32 uLen; + u32 uFreeLen = BUFFER_FREE_LEN(); + u8 uTempBuffer[64]; + u32 i; + + /* Read Receive data */ + uLen = USBDCore_EPTReadOUTData(EPTn, (u32*)uTempBuffer, 64); + + if (uLen > uFreeLen) + { + uLen = uFreeLen; + } + + for (i = 0; i < uLen; i++) + { + uSerialBuffer[uWriteIndex++] = uTempBuffer[i]; + if (uWriteIndex == RETARGET_BUFFER_SIZE) + { + uWriteIndex = 0; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Tx handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None +************************************************************************************************************/ +void SERIAL_USBDClass_TXHandler(USBD_EPTn_Enum EPTn) +{ + gIsINEmpty = TRUE; + return; +} + +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_time.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_time.c new file mode 100644 index 0000000000..a84bbb61ac --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32_time.c @@ -0,0 +1,185 @@ +/*********************************************************************************************************//** + * @file ht32_time.c + * @version $Rev:: 6461 $ + * @date $Date:: 2022-11-18 #$ + * @brief The time functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_time.h" + +/* + Tick Range: 0 ~ 2^32 / HTCFG_TIME_TICKHZ (maximum tick time) + Interrupt Time: _HTCFG_TIME_OVERFLOW_VALUE / (HTCFG_TIME_TICKHZ * HTCFG_TIME_MULTIPLE) Second (not apply for BFTM) + + Example: 32-bit BFTM with 48 MHz Timer Clock + HTCFG_TIME_TICKHZ = HTCFG_TIME_CLKSRC = 48000000 + Tick Range: 0 ~ 2^32 / 48000000 = 0 ~ 89.478485 Second (maximum tick time, return to 0 every 89.478485 Second) + BFTM do not use interrupt + + Example: 16-bit SCTM with 1 us tick + HTCFG_TIME_TICKHZ = 1000000 (Hz) + HTCFG_TIME_MULTIPLE = 1 (1 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 1000000 = 0 ~ 4294 Second = 0 ~ 71.58 Minute (maximum tick time, return to 0 every 71.58 Minute) + Interrupt Time: 65536 / (1000000 * 1) = 65.536 ms (Trigger interrupt every 65.536 ms) + + Example: 16-bit SCTM with 10 us tick + HTCFG_TIME_TICKHZ = 100000 (Hz) + HTCFG_TIME_MULTIPLE = 4 (4 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 100000 = 0 ~ 42949 Second = 0 ~ 715.82 Minute = 11.93 Hour (maximum tick time, return to 0 every 11.93 Hour) + Interrupt Time: 65536 / (100000 * 4) = 163.84 ms (Trigger interrupt every 163.84 ms) + + Example: 16-bit GPTM with 1 ms tick + HTCFG_TIME_TICKHZ = 1000 (Hz) + HTCFG_TIME_MULTIPLE = 4 (4 Timer Count = 1 Tick) + Tick Range: 0 ~ 2^32 / 1000 = 0 ~ 4294967 Second = 0 ~ 49.7 Day (maximum tick time, return to 0 every 49.7 Day) + Interrupt Time: 65536 / (1000 * 4) = 16.384 Second (Trigger interrupt every 16.384 Second) +*/ + +/* Private constants ---------------------------------------------------------------------------------------*/ +#define _HTCFG_TIME_CKCU_PCLK STRCAT2(CKCU_PCLK_, HTCFG_TIME_IPN) + +#if (IS_IPN_TM(HTCFG_TIME_IPN)) +// SCTM/PWM/GPTM/MCTM +#define _HTCFG_TIME_IRQn STRCAT2(HTCFG_TIME_IPN, _IRQn) +#define _HTCFG_TIME_IRQHandler STRCAT2(HTCFG_TIME_IPN, _IRQHandler) +#define _HTCFG_TIME_CLKDIV (HTCFG_TIME_CLKSRC / HTCFG_TIME_TICKHZ / HTCFG_TIME_MULTIPLE) +#define _HTCFG_TIME_OVERFLOW_VALUE (65536) // 16-bit = 2^16 + +#if (_HTCFG_TIME_CLKDIV <= 0) + #error "_HTCFG_TIME_CLKDIV is not correct (must >= 1)!" +#endif + +#if (_HTCFG_TIME_CLKDIV > 65536) + #error "_HTCFG_TIME_CLKDIV is not correct (must <= 65536)!" +#endif + +#if ((_HTCFG_TIME_CLKDIV * HTCFG_TIME_MULTIPLE) != (HTCFG_TIME_CLKSRC / HTCFG_TIME_TICKHZ)) + #error "_HTCFG_TIME_CLKDIV is not correct (must be integer)!" +#endif +#endif + +/* Private variables ---------------------------------------------------------------------------------------*/ +#if (IS_IPN_TM(HTCFG_TIME_IPN)) +u32 gTotalTick = 0x00000000; +u8 gIsTimeInt = FALSE; +#endif + +/* Global functions ----------------------------------------------------------------------------------------*/ +/*********************************************************************************************************//** + * @brief Time Init function. + * @retval None + ***********************************************************************************************************/ +void Time_Init(void) +{ + { /* Enable peripheral clock */ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }}; + CKCUClock.Bit.HTCFG_TIME_IPN = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + } + + #if (LIBCFG_CKCU_NO_APB_PRESCALER == 0) + CKCU_SetPeripPrescaler(_HTCFG_TIME_CKCU_PCLK, (CKCU_APBCLKPRE_TypeDef)HTCFG_TIME_PCLK_DIV); + #endif + + #if (IS_IPN_TM(HTCFG_TIME_IPN)) + + { /* Time base configuration */ + /* !!! NOTICE !!! + Notice that the local variable (structure) did not have an initial value. + Please confirm that there are no missing members in the parameter settings below in this function. + */ + TM_TimeBaseInitTypeDef TimeBaseInit; + + TimeBaseInit.Prescaler = _HTCFG_TIME_CLKDIV - 1; + TimeBaseInit.CounterReload = _HTCFG_TIME_OVERFLOW_VALUE -1; + TimeBaseInit.RepetitionCounter = 0; + TimeBaseInit.CounterMode = TM_CNT_MODE_UP; + TimeBaseInit.PSCReloadTime = TM_PSC_RLD_IMMEDIATE; + TM_TimeBaseInit(_HTCFG_TIME_PORT, &TimeBaseInit); + + /* Clear Update Event Interrupt flag since the "TM_TimeBaseInit()" writes the UEV1G bit */ + TM_ClearFlag(_HTCFG_TIME_PORT, TM_FLAG_UEV); + } + + /* Enable Update Event interrupt */ + TM_IntConfig(_HTCFG_TIME_PORT, TM_INT_UEV, ENABLE); + NVIC_EnableIRQ(_HTCFG_TIME_IRQn); + + TM_SetCounter(_HTCFG_TIME_PORT, 0x0000); + TM_Cmd(_HTCFG_TIME_PORT, ENABLE); + + #else + + BFTM_SetCounter(_HTCFG_TIME_PORT, 0x00000000); + BFTM_EnaCmd(_HTCFG_TIME_PORT, ENABLE); + #endif +} + +/*********************************************************************************************************//** + * @brief Time delay function. + * @param uDelayTick: Delay count based on tick. + * @retval None + ***********************************************************************************************************/ +void Time_Delay(u32 uDelayTick) +{ + u32 uCurrent; + u32 uStart = Time_GetTick(); + + do + { + uCurrent = Time_GetTick(); + } while (TIME_TICKDIFF(uStart, uCurrent) < uDelayTick); +} + +#if (IS_IPN_TM(HTCFG_TIME_IPN)) +/*********************************************************************************************************//** + * @brief Gets the current time tick. + * @retval Time Tick + ***********************************************************************************************************/ +u32 Time_GetTick(void) +{ + u32 uCount = GET_CNT(); + + if (gIsTimeInt == TRUE) + { + gIsTimeInt = FALSE; + uCount = GET_CNT(); + gTotalTick += (_HTCFG_TIME_OVERFLOW_VALUE / HTCFG_TIME_MULTIPLE); + } + + return (gTotalTick + (uCount / HTCFG_TIME_MULTIPLE)); +} + +/*********************************************************************************************************//** + * @brief This function handles Timer interrupt. + * @retval None + ************************************************************************************************************/ +void _HTCFG_TIME_IRQHandler(void) +{ + TM_ClearFlag(_HTCFG_TIME_PORT, TM_INT_UEV); + + gIsTimeInt = TRUE; +} +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_adc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_adc.c new file mode 100644 index 0000000000..d244507c11 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_adc.c @@ -0,0 +1,603 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_adc.c + * @version $Rev:: 7366 $ + * @date $Date:: 2023-12-06 #$ + * @brief This file provides all the ADC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_adc.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup ADC ADC + * @brief ADC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Private_Define ADC private definitions + * @{ + */ +#define ADC_ENABLE_BIT (0x00000080) +#define ADC_SOFTWARE_RESET (0x00000040) +#define LST_SEQ_SET (0x0000001F) +#define TCR_SC_SET (0x00000001) + +#define HLST_SEQ_SET (0x0000001F) +#define HTCR_SC_SET (0x00000001) + +#define ADC_VREF_MVDDAEN (0x00000100) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup ADC_Exported_Functions ADC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the HT_ADCn peripheral registers to their default reset values. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_DeInit(HT_ADC_TypeDef* HT_ADCn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + if (HT_ADCn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.ADC0 = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Reset ADC. + * @param HT_ADCn: is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_Reset(HT_ADC_TypeDef* HT_ADCn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + HT_ADCn->CR |= ADC_SOFTWARE_RESET; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_Cmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->CR |= ADC_ENABLE_BIT; + } + else + { + HT_ADCn->CR &= ~(ADC_ENABLE_BIT); + } +} + +/*********************************************************************************************************//** + * @brief Configure conversion mode and length of list queue for regular group. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_MODE: ADC Cyclic Conversion Mode. + * This parameter can be one of the following values: + * @arg ONE_SHOT_MODE : + * @arg CONTINUOUS_MODE : + * @arg DISCONTINUOUS_MODE : + * @param Length: must between 1 ~ 8 + * @param SubLength: must between 1 ~ 8, only valid for DISCONTINUOUS_MODE. + * @retval None + ************************************************************************************************************/ +void ADC_RegularGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CONVERSION_MODE(ADC_MODE)); + Assert_Param(IS_ADC_REGULAR_LENGTH(Length)); + #if (LIBCFG_ADC_NO_DISCON_MODE == 0) + if (ADC_MODE == DISCONTINUOUS_MODE) + { + Assert_Param(IS_ADC_REGULAR_SUB_LENGTH(SubLength)); + } + #endif + + #if (LIBCFG_ADC_NO_DISCON_MODE) + /* Config cyclic conversion mode and length of list queue for regular group */ + HT_ADCn->CR = ((u32)(Length - 1) << 8) | ADC_MODE | (HT_ADCn->CR & ADC_ENABLE_BIT); + #else + /* Config cyclic conversion mode and length of list queue and sub length for regular group */ + HT_ADCn->CR = ((u32)(SubLength - 1) << 16) | ((u32)(Length - 1) << 8) | ADC_MODE | (HT_ADCn->CR & ADC_ENABLE_BIT); + #endif +} + +/*********************************************************************************************************//** + * @brief Configure the corresponding rank in the sequencer for the regular channel + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel n selected, n must between 0 ~ m (m represent the maximum external ADC input channel). + * @arg ADC_CH_DAC0_CH0 : ADC DAC0_CH0 selected + * @arg ADC_CH_DAC0_CH1 : ADC DAC0_CH1 selected + * @arg ADC_CH_DAC1_CH0 : ADC DAC1_CH0 selected + * @arg ADC_CH_DAC1_CH1 : ADC DAC1_CH1 selected + * @arg ADC_CH_IVREF : ADC Internal VREF selected + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @arg ADC_CH_MVDDA : ADC MVDDA selected + * @param Rank: The rank in the regular group sequencer. + * This parameter must be between 0 to 7. + * @param ...: Null parameter for API compatibility. + * @retval None + ************************************************************************************************************/ +void ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, ...) +{ + u32 tmpreg1, tmpreg2; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_REGULAR_RANK(Rank)); + + /* Get the old register value */ + tmpreg1 = HT_ADCn->LST[Rank >> 2]; + /* Calculate the mask to clear */ + tmpreg2 = LST_SEQ_SET << (8 * (Rank & 0x3)); + /* Clear the old SEQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (u32)ADC_CH_n << (8 * (Rank & 0x3)); + /* Set the SEQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + HT_ADCn->LST[Rank >> 2] = tmpreg1; +} + +/*********************************************************************************************************//** + * @brief Configure the ADC trigger source for regular channels conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_TRIG_x: + * This parameter can be one of the following values: + * @arg ADC_TRIG_SOFTWARE : S/W trigger + * @arg ADC_TRIG_EXTI_n : where n can be 0 ~ 15 + * @arg ADC_TRIG_MCTMn_MTO : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_GPTMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_TRIG_BFTMn : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_MTO : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH0O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH1O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH2O : where n can be 0 ~ 1 + * @arg ADC_TRIG_PWMn_CH3O : where n can be 0 ~ 1 + * @arg ADC_TRIG_CMPn : where n can be 0 ~ 1 + * @retval None + ************************************************************************************************************/ +void ADC_RegularTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_TRIG(ADC_TRIG_x)); + + /* Config external trigger conversion source of regular group */ + #if (LIBCFG_ADC_SW_TRIGGER_ONLY == 0) + HT_ADCn->TCR = ADC_TRIG_x & 0x0000001F; + #endif + HT_ADCn->TSR = ADC_TRIG_x & (~0x0000001F); +} + +/*********************************************************************************************************//** + * @brief Configure the sampling time for the ADC input channel. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param SampleClock: must between 0 ~ 255. + * @retval None + ************************************************************************************************************/ +void ADC_SamplingTimeConfig(HT_ADC_TypeDef* HT_ADCn, u8 SampleClock) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + /* config sampling clock of ADC input channel */ + HT_ADCn->STR = SampleClock; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable software start of the regular channel conversion of the selected ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_SoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Start Conversion */ + if (NewState != DISABLE) + { + HT_ADCn->TSR |= TCR_SC_SET; + } + else + { + HT_ADCn->TSR &= ~TCR_SC_SET; + } +} + +/*********************************************************************************************************//** + * @brief Return the result of ADC regular channel conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_REGULAR_DATAn: where n can be 0 ~ 7 + * @retval The Value of data conversion. + ************************************************************************************************************/ +u16 ADC_GetConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_REGULAR_DATAn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_REGULAR_DATA(ADC_REGULAR_DATAn)); + + return ((u16)HT_ADCn->DR[ADC_REGULAR_DATAn]); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC interrupts. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the ADC interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_IntConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->IER |= ADC_INT_x; + } + else + { + HT_ADCn->IER &= ~ADC_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC interrupt has occurred. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetIntStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + if ((HT_ADCn->ISR & ADC_INT_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Clear the ADC interrupt pending bits. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt pending bits to be cleared. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_ClearIntPendingBit(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + HT_ADCn->ICLR = ADC_INT_x; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC flag has been set. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_FLAG_x: Specify the flag to check. + * This parameter can be any combination of the following values: + * @arg ADC_FLAG_SINGLE_EOC : + * @arg ADC_FLAG_SUB_GROUP_EOC : + * @arg ADC_FLAG_CYCLE_EOC : + * @arg ADC_FLAG_DATA_OVERWRITE : + * @arg ADC_FLAG_AWD_LOWER : + * @arg ADC_FLAG_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetFlagStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_FLAG_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_FLAG(ADC_FLAG_x)); + + if ((HT_ADCn->IRAW & ADC_FLAG_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +#if (LIBCFG_ADC_NO_WDT == 0) +/*********************************************************************************************************//** + * @brief Enable or Disable Lower/Upper threshold warning of the analog watchdog on single/all channels. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_AWD_x: + * This parameter can be any combination of the following values: + * @arg ADC_AWD_DISABLE : + * @arg ADC_AWD_ALL_LOWER : + * @arg ADC_AWD_ALL_UPPER : + * @arg ADC_AWD_ALL_LOWER_UPPER : + * @arg ADC_AWD_SINGLE_LOWER : + * @arg ADC_AWD_SINGLE_UPPER : + * @arg ADC_AWD_SINGLE_LOWER_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_AWDConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_AWD_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_AWD(ADC_AWD_x)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFFFF8) | ADC_AWD_x; +} + +/*********************************************************************************************************//** + * @brief Configure the analog watchdog that guards single channel. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: where n must between 0 ~ m (m represent the maximum external ADC input channel). + * @retval None + ************************************************************************************************************/ +void ADC_AWDSingleChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INPUT_CHANNEL(ADC_CH_n)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFF0FF) | ((u32)ADC_CH_n << 8); +} + +/*********************************************************************************************************//** + * @brief Configure the high and low thresholds of the analog watchdog. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param UPPER: must between 0x0000 ~ 0x0FFF + * @param LOWER: must between 0x0000 ~ 0x0FFF + * @retval None + ************************************************************************************************************/ +void ADC_AWDThresholdsConfig(HT_ADC_TypeDef* HT_ADCn, u16 UPPER, u16 LOWER) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_THRESHOLD(UPPER)); + Assert_Param(IS_ADC_THRESHOLD(LOWER)); + + HT_ADCn->WTR = (UPPER << 16) | LOWER; +} +#endif + +#if (LIBCFG_PDMA) +/*********************************************************************************************************//** + * @brief Enable or Disable the specified PDMA request. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_PDMA_x: Specify the ADC PDMA request that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_PDMA_REGULAR_SINGLE : + * @arg ADC_PDMA_REGULAR_SUBGROUP : + * @arg ADC_PDMA_REGULAR_CYCLE : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_PDMAConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_PDMA_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_PDMA(ADC_PDMA_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->PDMAR |= ADC_PDMA_x; + } + else + { + HT_ADCn->PDMAR &= ~ADC_PDMA_x; + } +} +#endif + +#if (LIBCFG_ADC_IVREF) +/*********************************************************************************************************//** + * @brief Enable or Disable the VREF. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_VREFCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->VREFCR |= 0x00000001; + } + else + { + HT_ADCn->VREFCR &= ~(0x00000001); + } +} + +/*********************************************************************************************************//** + * @brief Configure the VREF output voltage. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_VREF_x: + * This parameter can be one of the following value: + * @arg ADC_VREF_1V215 : + * @arg ADC_VREF_2V0 : + * @arg ADC_VREF_2V5 : + * @arg ADC_VREF_2V7 : + * For the 5 V version (LIBCFG_ADC_IVREF_LEVEL_TYPE2): + * @arg ADC_VREF_2V5 : + * @arg ADC_VREF_3V0 : + * @arg ADC_VREF_4V0 : + * @arg ADC_VREF_4V5 : + * @retval None + ************************************************************************************************************/ +void ADC_VREFConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_VREF_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_VREF_SEL(ADC_VREF_x)); + + HT_ADCn->VREFCR = (HT_ADCn->VREFCR & ~(3ul << 4)) | (ADC_VREF_x); +} +#endif + +#if (LIBCFG_ADC_VREFBUF) +/*********************************************************************************************************//** + * @brief Enable or Disable the VREF output. When enable, the VREF provides a stable voltage output to the ADVREFP pin (ADC reference positive voltage). + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_VREFOutputCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* !!! NOTICE !!! + The ADCREFP pin should not be connected to an external voltage when the VREF output is enabled. + */ + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->VREFCR |= 0x00000002; + } + else + { + HT_ADCn->VREFCR &= ~(0x00000002); + } +} +#endif + +#if (LIBCFG_ADC_MVDDA) +/*********************************************************************************************************//** + * @brief Enable or Disable the power of MVDDA (VDDA/2) + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_MVDDACmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->VREFCR |= ADC_VREF_MVDDAEN; + } + else + { + HT_ADCn->VREFCR &= ~(ADC_VREF_MVDDAEN); + } +} + +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_aes.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_aes.c new file mode 100644 index 0000000000..133889a258 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_aes.c @@ -0,0 +1,552 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_aes.c + * @version $Rev:: 7390 $ + * @date $Date:: 2023-12-12 #$ + * @brief This file provides all the ADC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_aes.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup AES AES + * @brief AES driver modules + * @{ + */ + + +/* Global variables ----------------------------------------------------------------------------------------*/ +u32 *gpu32OutputBuff; +u32 gu32OutputIndex = 0; + +u32 *gpu32InputBuff; +u32 gu32InputSize = 0; +u32 gu32InputIndex = 0; + +/* Private functions ---------------------------------------------------------------------------------------*/ +static void _AES_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup AES_Exported_Functions AES exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the AES peripheral registers to their default reset values. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AES_DeInit(HT_AES_TypeDef* HT_AESn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + if (HT_AESn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.AES = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Flush the FIFO. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AES_FIFOFlush(HT_AES_TypeDef* HT_AESn) +{ + AES_Cmd(HT_AESn, DISABLE); + HT_AESn->CR |= AES_FLUSH_ENABLE; + AES_Cmd(HT_AESn, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified AES. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void AES_Cmd(HT_AES_TypeDef* HT_AESn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_AESn->CR |= AES_ENABLE; + } + else + { + HT_AESn->CR &= ~AES_ENABLE; + } +} + +/*********************************************************************************************************//** + * @brief Start the AES key. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AES_StartKey(HT_AES_TypeDef* HT_AESn) +{ + HT_AESn->CR |= (1 << 4); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where AES is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void _AES_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_KEY_SIZE(AES_InitStruct->AES_KeySize)); + Assert_Param(IS_AES_DIR(AES_InitStruct->AES_Dir)); + Assert_Param(IS_AES_MODE(AES_InitStruct->AES_Mode)); + Assert_Param(IS_AES_SWAP(AES_InitStruct->AES_Swap)); + + HT_AESn->CR = (HT_AESn->CR & 0xFFFFFE81) | AES_InitStruct->AES_KeySize | + AES_InitStruct->AES_Dir | AES_InitStruct->AES_Mode | + AES_InitStruct->AES_Swap; + + AES_Cmd(HT_AESn, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral on ECB mode according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where AES is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void AES_ECB_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + AES_InitStruct->AES_Mode = AES_MODE_ECB; + _AES_Init(HT_AESn, AES_InitStruct); + + AES_IntConfig(HT_AESn, AES_IER_OFINTEN, ENABLE); + NVIC_EnableIRQ(AES_IRQn); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral on CBC mode according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where AES is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void AES_CBC_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + AES_InitStruct->AES_Mode = AES_MODE_CBC; + _AES_Init(HT_AESn, AES_InitStruct); + + AES_IntConfig(HT_AESn, AES_IER_OFINTEN, ENABLE); + NVIC_EnableIRQ(AES_IRQn); +} + +/*********************************************************************************************************//** + * @brief Initialize the AES peripheral on CTR mode according to the specified parameters in the AES_InitStruct. + * @param HT_AESn: where HT_AESn is the selected AES peripheral. + * @param AES_InitStruct: pointer to a AES_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void AES_CTR_Init(HT_AES_TypeDef* HT_AESn, AES_InitTypeDef* AES_InitStruct) +{ + AES_InitStruct->AES_Mode = AES_MODE_CTR; + _AES_Init(HT_AESn, AES_InitStruct); + + AES_IntConfig(HT_AESn, AES_IER_OFINTEN, ENABLE); + NVIC_EnableIRQ(AES_IRQn); +} + +/*********************************************************************************************************//** + * @brief Check whether the specified AES status has been set. + * @param HT_AESn: where HT_AESn is the selected AES peripheral. + * @param AES_SR_x: specify the flag to be check. + * This parameter can be one of the following values: + * @arg AES_SR_IFEMPTY : AES Input FIFO is Empty + * @arg AES_SR_IFNFULL : AES Input FIFO is not Full + * @arg AES_SR_OFNEMPTY : AES Output FIFO is not Empty + * @arg AES_SR_OFFULL : AES Output FIFO is Full + * @arg AES_SR_BUSY : AES is busy when AES is in encrypt/decrypt action and key expansion + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus AES_GetStatus(HT_AES_TypeDef* HT_AESn, u32 AES_SR_x) +{ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_STATUS(AES_SR_x)); + + if ((HT_AESn->SR & AES_SR_x) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the AES PDMA interface. + * @param HT_AESn: where HT_AESn is the selected HT_AESn peripheral. + * @param AES_PDMA_xFDMAEN: specify the AES FIFO DMA to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg AES_PDMA_IFDMAEN : input FIFO PDMA + * @arg AES_PDMA_OFDMAEN : Output FIFO PDMA + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void AES_PDMACmd(HT_AES_TypeDef* HT_AESn, u32 AES_PDMA_xFDMAEN, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_AESn->PDMAR |= AES_PDMA_xFDMAEN; + } + else + { + HT_AESn->PDMAR &= ~AES_PDMA_xFDMAEN; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified AES interrupt has occurred. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param AES_INTSR_x: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * @arg AES_INTSR_IFINT : + * @arg AES_INTSR_OFINT : + * @return SET or RESET + ************************************************************************************************************/ +FlagStatus AES_GetIntStatus(HT_AES_TypeDef* HT_AESn, u32 AES_INTSR_x) +{ + FlagStatus Status; + u32 aes_isr = HT_AESn->ISR; + u32 aes_ier = HT_AESn->IER; + + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_INTSR(AES_INTSR_x)); + + Status = (FlagStatus)(aes_isr & aes_ier); + if ((Status & AES_INTSR_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified AES interrupts. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param AES_IER_x: Specify the AES interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg AES_IER_IFINTEN : + * @arg AES_IER_OFINTEN : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void AES_IntConfig(HT_AES_TypeDef* HT_AESn, u32 AES_IER_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_AES(HT_AESn)); + Assert_Param(IS_AES_IER(AES_IER_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_AESn->IER |= AES_IER_x; + } + else + { + HT_AESn->IER &= ~AES_IER_x; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified AES Input data. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param AES_Data: Data input + * @retval None + ************************************************************************************************************/ +void AES_SetInputData(HT_AES_TypeDef* HT_AESn, uc32 AES_Data) +{ + Assert_Param(IS_AES(HT_AESn)); + #if (LIBCFG_AES_SWAP) + HT_AESn->DINR = __REV(AES_Data); + #else + HT_AESn->DINR = AES_Data; + #endif +} + +/*********************************************************************************************************//** + * @brief Get the specified AES output data. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @retval Output Data + ************************************************************************************************************/ +u32 AES_GetOutputData(HT_AES_TypeDef* HT_AESn) +{ + Assert_Param(IS_AES(HT_AESn)); + #if (LIBCFG_AES_SWAP) + return __REV(HT_AESn->DOUTR); + #else + return HT_AESn->DOUTR; + #endif +} + +/*********************************************************************************************************//** + * @brief Set the specified AES key table. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param Key: Key table + * @param keySize: Key table's size + * @retval None + ************************************************************************************************************/ +void AES_SetKeyTable(HT_AES_TypeDef* HT_AESn, u32 *Key, u32 keySize) +{ + u32 i; + u32 uCRTemp = HT_AESn->CR & (~(0x00000060UL)); + if (keySize == 128/8) + { + uCRTemp |= AES_KEYSIZE_128B; + } + #if (LIBCFG_AES_KEYSIZE_256B) + else if (keySize == 192/8) + { + uCRTemp |= AES_KEYSIZE_192B; + } + else if (keySize == 256/8) + { + uCRTemp |= AES_KEYSIZE_256B; + } + #endif + else + { + return; + } + HT_AESn->CR = uCRTemp; + + for (i = 0; i < keySize; i += 4) + { + #if (LIBCFG_AES_SWAP) + HT_AESn->KEYR[i >> 2] = __REV(*&Key[i]); + #else + HT_AESn->KEYR[i >> 2] = *&Key[i]; + #endif + } + + AES_StartKey(HT_AES); +} + +/*********************************************************************************************************//** + * @brief Set the specified AES Vector table. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @param Vector: + * @retval None + ************************************************************************************************************/ +void AES_SetVectorTable(HT_AES_TypeDef* HT_AESn, u32 *Vector) +{ + int i; + Assert_Param(IS_AES(HT_AESn)); + + for (i = 0; i < 16; i += 4) + { + #if (LIBCFG_AES_SWAP) + HT_AESn->IVR[i >> 2] = __REV(*&Vector[i]); + #else + HT_AESn->IVR[i >> 2] = *&Vector[i]; + #endif + } +} + +/*********************************************************************************************************//** + * @brief AES Crypt Data + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param dir: Crypt Data's direction + * @param iv: initial vector table + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus _AES_CryptData(HT_AES_TypeDef* HT_AESn, + AES_DIR_Enum dir, + u32 *iv, + u32 length, + u32 *inputData, + u32 *outputData) +{ + /*AES Data blocks 16 byte */ + if ((length % 16) != 0) + { + /* Data size can not be divisible by 16. */ + return ERROR; + } + + /*Set inital Vector */ + if (iv != NULL) + { + AES_SetVectorTable(HT_AESn, iv); + } + + /*FIFO Flush */ + AES_FIFOFlush(HT_AES); + + /*Set direction */ + HT_AESn->CR = (HT_AESn->CR & 0xFFFFFFFD) | dir; + + /*Create input/output data */ + gpu32InputBuff = inputData; + gpu32OutputBuff = outputData; + + /*Init Index */ + gu32OutputIndex = 0; + gu32InputSize = length/4; + + /*Set input data */ + AES_IntConfig(HT_AES, AES_IER_IFINTEN, ENABLE); + + /*Waitting for conversion */ + while (AES_GetStatus(HT_AES, AES_SR_OFNEMPTY)); + return SUCCESS; +} + +#if 0 +/*********************************************************************************************************//** + * @brief AES Crypt Data on ECB mode + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param dir: Crypt Data's direction + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus AES_ECB_CryptData(HT_AES_TypeDef* HT_AESn, + AES_DIR_Enum dir, + u32 length, + u32 *inputData, + u32 *outputData) +{ + return _AES_CryptData(HT_AESn, + dir, + NULL, + length, + inputData, + outputData); +} + +/*********************************************************************************************************//** + * @brief AES Crypt Data on CBC mode + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param dir: Crypt Data's direction + * @param iv: initial vector table + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus AES_CBC_CryptData(HT_AES_TypeDef* HT_AESn, + AES_DIR_Enum dir, + u32 *iv, + u32 length, + u32 *inputData, + u32 *outputData) +{ + return _AES_CryptData(HT_AESn, + dir, + iv, + length, + inputData, + outputData); +} + +/*********************************************************************************************************//** + * @brief AES Crypt Data on CTR mode + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals + * @param iv: initial vector table + * @param length: data size + * @param inputData: InputData + * @param outputData: Output Data + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus AES_CTR_CryptData(HT_AES_TypeDef* HT_AESn, + u32 *iv, + u32 length, + u32 *inputData, + u32 *outputData) +{ + return _AES_CryptData(HT_AESn, + AES_DIR_ENCRYPT, + iv, + length, + inputData, + outputData); +} +#endif + +/*********************************************************************************************************//** + * @brief This function handles AES Core interrupt. + * @param HT_AESn: where HT_AESn is the selected AES from the AES peripherals. + * @retval None + ************************************************************************************************************/ +void AESCore_IRQHandler(HT_AES_TypeDef* HT_AESn) +{ + if (AES_GetIntStatus(HT_AES, AES_INTSR_OFINT)) + { + gpu32OutputBuff[gu32OutputIndex++] = AES_GetOutputData(HT_AES); + } + if (AES_GetIntStatus(HT_AES, AES_INTSR_IFINT)) + { + if (gu32InputIndex < gu32InputSize) + { + AES_SetInputData(HT_AES, gpu32InputBuff[gu32InputIndex]); + gu32InputIndex++; + } + else + { + AES_IntConfig(HT_AES, AES_IER_IFINTEN, DISABLE); + gu32InputIndex = 0; + } + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_bftm.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_bftm.c new file mode 100644 index 0000000000..db0ad91c0f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_bftm.c @@ -0,0 +1,242 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_bftm.c + * @version $Rev:: 6393 $ + * @date $Date:: 2022-10-27 #$ + * @brief This file provides all the BFTM firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_bftm.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup BFTM BFTM + * @brief BFTM driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup BFTM_Exported_Functions BFTM exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the specified BFTM registers to their default values. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval None + ************************************************************************************************************/ +void BFTM_DeInit(HT_BFTM_TypeDef* HT_BFTMn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + if (HT_BFTMn == HT_BFTM0) + { + RSTCUReset.Bit.BFTM0 = 1; + } + #if (LIBCFG_BFTM1) + else if (HT_BFTMn == HT_BFTM1) + { + RSTCUReset.Bit.BFTM1 = 1; + } + #endif + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void BFTM_EnaCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_BFTMn->CR |= (1UL << 2); + } + else + { + HT_BFTMn->CR &= ~(1UL << 2); + } +} + +/*********************************************************************************************************//** + * @brief Configure the CMP register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param uCompare: Specify a value to the CMP register. + * @retval None + ************************************************************************************************************/ +void BFTM_SetCompare(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCompare) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + HT_BFTMn->CMP = uCompare; +} + +/*********************************************************************************************************//** + * @brief Get the CMP register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval The value of the CMP register + ************************************************************************************************************/ +u32 BFTM_GetCompare(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + return HT_BFTMn->CMP; +} + +/*********************************************************************************************************//** + * @brief Set the CNTR register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param uCounter: Specify a new value to the CNTR register. + * @retval None + ************************************************************************************************************/ +void BFTM_SetCounter(HT_BFTM_TypeDef* HT_BFTMn, BFTM_DataTypeDef uCounter) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + HT_BFTMn->CNTR = uCounter; +} + +/*********************************************************************************************************//** + * @brief Get the CNTR register value of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval The value of the CNTR register + ************************************************************************************************************/ +u32 BFTM_GetCounter(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + return HT_BFTMn->CNTR; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the one shot mode of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void BFTM_OneShotModeCmd(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_BFTMn->CR |= (1UL << 1); + } + else + { + HT_BFTMn->CR &= ~(1UL << 1); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified BFTM interrupt. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void BFTM_IntConfig(HT_BFTM_TypeDef* HT_BFTMn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_BFTMn->CR |= BFTM_INT_MATCH; + } + else + { + HT_BFTMn->CR &= ~BFTM_INT_MATCH; + } +} + +/*********************************************************************************************************//** + * @brief Get the flag status of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus BFTM_GetFlagStatus(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + if (HT_BFTMn->SR & BFTM_FLAG_MATCH) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the interrupt flag of the specified BFTM. + * @param HT_BFTMn: where the HT_BFTMn is the selected BFTM from the BFTM peripherals. + * @retval None + ************************************************************************************************************/ +void BFTM_ClearFlag(HT_BFTM_TypeDef* HT_BFTMn) +{ + /* Check the parameters */ + Assert_Param(IS_BFTM(HT_BFTMn)); + + HT_BFTMn->SR &= ~BFTM_FLAG_MATCH; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_can.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_can.c new file mode 100644 index 0000000000..22fca5ab02 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_can.c @@ -0,0 +1,1029 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_can.c + * @version $Rev:: 7187 $ + * @date $Date:: 2023-08-31 #$ + * @brief This file provides all the CAN firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_can.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CAN CAN + * @brief CAN driver modules + * @{ + */ + +/* Private types -------------------------------------------------------------------------------------------*/ +typedef enum +{ + IF0_NUM = 0, + IF1_NUM, + IF_TOTAL_NUM +} CANIF_NUMBER_Enum; + + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static CANIF_NUMBER_Enum GetFreeIF(HT_CAN_TypeDef *CANx); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CAN_Exported_Functions CAN exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the specified CAN registers to their default values. + * @param CANx: where the CANx is the selected CAN from the CAN peripherals. + * @retval None + ************************************************************************************************************/ +void CAN_DeInit(HT_CAN_TypeDef* CANx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + /* Check the parameters */ + Assert_Param(IS_CAN(CANx)); + + if (CANx == HT_CAN0) + { + RSTCUReset.Bit.CAN0 = 1; + } + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief This function is used to set CAN to enter initialization mode and enable access bit timing + * register.After bit timing configuration ready, user must call CAN_LeaveInitMode() + * to leave initialization mode and lock bit timing register to let new configuration + * take effect. + * @param CANx: The pointer to CAN module base address. + * @retval None + ***********************************************************************************************************/ +void CAN_EnterInitMode(HT_CAN_TypeDef *CANx) +{ + CANx->CR |= CAN_CR_INIT_Msk; + CANx->CR |= CAN_CR_CCE_Msk; +} + +/*********************************************************************************************************//** + * @brief Leave initialization mode + * @param CANx: The pointer to CAN module base address. + * @retval None + ***********************************************************************************************************/ +void CAN_LeaveInitMode(HT_CAN_TypeDef *CANx) +{ + CANx->CR &= (~(CAN_CR_INIT_Msk | CAN_CR_CCE_Msk)); + + while(CANx->CR & CAN_CR_INIT_Msk); /* Check INIT bit is released */ +} + +/*********************************************************************************************************//** + * @brief This function is used to Wait message into message buffer in basic mode. Please notice the + * function is polling NEWDAT bit of MCR register by while loop and it is used in basic mode. + * @param CANx: The pointer to CAN module base address. + * @retval None + ***********************************************************************************************************/ +void CAN_WaitMsg(HT_CAN_TypeDef *CANx) +{ + CANx->SR = 0x0; /* clr status */ + + while(1) + { + if(CANx->IF1.MCR & CAN_IF_MCR_NEWDAT_Msk) /* check new data */ + { + /*DEBUG_PRINTF("New Data IN\n");*/ + break; + } + if(CANx->SR & CAN_SR_RXOK_Msk) + { + /*DEBUG_PRINTF("Rx OK\n");*/ + } + if(CANx->SR & CAN_SR_LEC_Msk) + { + /*DEBUG_PRINTF("Error\n");*/ + } + } +} + +/*********************************************************************************************************//** + * @brief Get current bit rate + * @param CANx: The pointer to CAN module base address. + * @retval Current Bit-Rate (kilo bit per second) + ***********************************************************************************************************/ +u32 CAN_GetCANBitRate(HT_CAN_TypeDef *CANx) +{ + u32 wTseg1, wTseg2; + u32 wBpr; + + wTseg1 = (CANx->BTR & CAN_BTR_TSEG0_Msk) >> CAN_BTR_TSEG0_Pos; + wTseg2 = (CANx->BTR & CAN_BTR_TSEG1_Msk) >> CAN_BTR_TSEG1_Pos; + wBpr = CANx->BTR & CAN_BTR_BRP_Msk; + wBpr |= CANx->BRPER << 6; + + return (SystemCoreClock / (wBpr + 1) / (wTseg1 + wTseg2 + 3)); +} + +/**********************************************************************************************************//** + * @brief Switch the CAN into test mode. + * @param CANx: The pointer to CAN module base address. + * @param u8TestMask Specifies the configuration in test modes + * @arg CAN_TEST_BASIC_Msk : Enable basic mode of test mode + * @arg CAN_TEST_SILENT_Msk : Enable silent mode of test mode + * @arg CAN_TEST_LBACK_Msk : Enable Loop Back Mode of test mode + * @arg CAN_TEST_TX0_Msk/CAN_TEST_TX1_Msk: Control CAN_TX pin bit field + * @retval None + ***********************************************************************************************************/ +void CAN_EnterTestMode(HT_CAN_TypeDef *CANx, u32 u8TestMask) +{ + CANx->CR |= CAN_CR_TEST_Msk; + CANx->TR = u8TestMask; +} + +/*********************************************************************************************************//** + * @brief Leave the test mode + * @param CANx: The pointer to CAN module base address. + * @retval None + ***********************************************************************************************************/ +void CAN_LeaveTestMode(HT_CAN_TypeDef *CANx) +{ + CANx->CR |= CAN_CR_TEST_Msk; + CANx->TR &= ~(CAN_TEST_LBACK_Msk | CAN_TEST_SILENT_Msk | CAN_TEST_BASIC_Msk); + CANx->CR &= (~CAN_CR_TEST_Msk); +} + +/*********************************************************************************************************//** + * @brief Get the waiting status of a received message. + * @param CANx: The pointer to CAN module base address. + * @param MsgObj: Specifies the Message object number, from 0 to 31. 0 No message object has new data. + ***********************************************************************************************************/ +u32 CAN_IsNewDataReceived(HT_CAN_TypeDef *CANx, u32 MsgObj) +{ + MsgObj--; + return (MsgObj < 16 ? CANx->NDR0 & (1 << MsgObj) : CANx->NDR1 & (1 << (MsgObj - 16))); +} + +/*********************************************************************************************************//** + * @brief The function is used to Send CAN message in BASIC mode of test mode. Before call the API, + * the user should be call CAN_EnterTestMode(CAN_TEST_BASIC) and let CAN controller enter + * basic mode of test mode. Please notice IF0 Registers used as Tx Buffer in basic mode. + * @param CANx: The pointer to CAN module base address. + * @param pCanMsg: Pointer to the message structure containing data to transmit. + * @retval TRUE: Transmission OK, FALSE: Check busy flag of interface 0 is timeout + ***********************************************************************************************************/ +s32 CAN_BasicSendMsg(HT_CAN_TypeDef *CANx, STR_CANMSG_T_TypeDef* pCanMsg) +{ + u32 i = 0; + while(CANx->IF0.CREQ & CAN_IF_CREQ_BUSY_Msk); + + CANx->SR &= (~CAN_SR_TXOK_Msk); + + if(pCanMsg->IdType == CAN_STD_ID) + { + /* standard ID*/ + CANx->IF0.ARB0 = 0; + CANx->IF0.ARB1 = (((pCanMsg->Id) & 0x7FF) << 2) ; + } + else + { + /* extended ID*/ + CANx->IF0.ARB0 = (pCanMsg->Id) & 0xFFFF; + CANx->IF0.ARB1 = ((pCanMsg->Id) & 0x1FFF0000) >> 16 | CAN_IF_ARB1_XTD_Msk; + } + + if(pCanMsg->FrameType) + CANx->IF0.ARB1 |= CAN_IF_ARB1_DIR_Msk; + else + CANx->IF0.ARB1 &= (~CAN_IF_ARB1_DIR_Msk); + + CANx->IF0.MCR = (CANx->IF0.MCR & (~CAN_IF_MCR_DLC_Msk)) | pCanMsg->DLC; + CANx->IF0.DA0R = ((u16)pCanMsg->Data[1] << 8) | pCanMsg->Data[0]; + CANx->IF0.DA1R = ((u16)pCanMsg->Data[3] << 8) | pCanMsg->Data[2]; + CANx->IF0.DB0R = ((u16)pCanMsg->Data[5] << 8) | pCanMsg->Data[4]; + CANx->IF0.DB1R = ((u16)pCanMsg->Data[7] << 8) | pCanMsg->Data[6]; + + /* request transmission*/ + CANx->IF0.CREQ &= (~CAN_IF_CREQ_BUSY_Msk); + if(CANx->IF0.CREQ & CAN_IF_CREQ_BUSY_Msk) + { + return FALSE; + } + + CANx->IF0.CREQ |= CAN_IF_CREQ_BUSY_Msk; /* Sending */ + + for(i = 0; i < 0xFFFFF; i++) + { + if((CANx->IF0.CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) + break; + } + + if(i >= 0xFFFFFFF) + { + return FALSE; + } + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Get a message information in BASIC mode. + * @param CANx: The pointer to CAN module base address. + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @retval FALSE: No any message received, TRUE: Receive a message success. + ***********************************************************************************************************/ +s32 CAN_BasicReceiveMsg(HT_CAN_TypeDef *CANx, STR_CANMSG_T_TypeDef* pCanMsg) +{ + if((CANx->IF1.MCR & CAN_IF_MCR_NEWDAT_Msk) == 0) /* In basic mode, receive data always save in IF1 */ + { + return FALSE; + } + + CANx->SR &= (~CAN_SR_RXOK_Msk); + + CANx->IF1.CMASK = CAN_IF_CMASK_ARB_Msk + | CAN_IF_CMASK_CONTROL_Msk + | CAN_IF_CMASK_DATAA_Msk + | CAN_IF_CMASK_DATAB_Msk; + + if((CANx->IF1.MASK1 & CAN_IF_ARB1_XTD_Msk) == 0) + { + /* standard ID*/ + pCanMsg->IdType = CAN_STD_ID; + pCanMsg->Id = (CANx->IF1.MASK1 >> 2) & 0x07FF; + } + else + { + /* extended ID*/ + pCanMsg->IdType = CAN_EXT_ID; + pCanMsg->Id = (CANx->IF1.ARB1 & 0x1FFF) << 16; + pCanMsg->Id |= (u32)CANx->IF1.ARB0; + } + + pCanMsg->FrameType = !((CANx->IF1.ARB1 & CAN_IF_ARB1_DIR_Msk) >> CAN_IF_ARB1_DIR_Pos); + + pCanMsg->DLC = CANx->IF1.MCR & CAN_IF_MCR_DLC_Msk; + pCanMsg->Data[0] = CANx->IF1.DA0R & CAN_IF_DAT_A0_DATA0_Msk; + pCanMsg->Data[1] = (CANx->IF1.DA0R & CAN_IF_DAT_A0_DATA1_Msk) >> CAN_IF_DAT_A0_DATA1_Pos; + pCanMsg->Data[2] = CANx->IF1.DA1R & CAN_IF_DAT_A1_DATA2_Msk; + pCanMsg->Data[3] = (CANx->IF1.DA1R & CAN_IF_DAT_A1_DATA3_Msk) >> CAN_IF_DAT_A1_DATA3_Pos; + pCanMsg->Data[4] = CANx->IF1.DB0R & CAN_IF_DAT_B0_DATA4_Msk; + pCanMsg->Data[5] = (CANx->IF1.DB0R & CAN_IF_DAT_B0_DATA5_Msk) >> CAN_IF_DAT_B0_DATA5_Pos; + pCanMsg->Data[6] = CANx->IF1.DB1R & CAN_IF_DAT_B1_DATA6_Msk; + pCanMsg->Data[7] = (CANx->IF1.DB1R & CAN_IF_DAT_B1_DATA7_Msk) >> CAN_IF_DAT_B1_DATA7_Pos; + + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Set Rx message object + * @param CANx: The pointer to CAN module base address. + * @param MsgObj: Specifies the Message object number, from 0 to 31. + * @arg CAN_STD_ID (standard ID, 11-bit) + * @arg CAN_EXT_ID (extended ID, 29-bit) + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @retval TRUE: SUCCESS, FALSE: No useful interface. + ***********************************************************************************************************/ +s32 CAN_SetRxMsgObj(HT_CAN_TypeDef *CANx, u32 MsgObj, STR_CANMSG_R_TypeDef* pCanMsg) +{ + u32 u8MsgIfNum = 0; + + if((u8MsgIfNum = GetFreeIF(CANx)) == 2) /* Check Free Interface for configure */ + { + return FALSE; + } + + if (u8MsgIfNum == 1) + { + /* Command Setting */ + CANx->IF1.CMASK = CAN_IF_CMASK_WRRD_Msk | CAN_IF_CMASK_MASK_Msk | CAN_IF_CMASK_ARB_Msk | + CAN_IF_CMASK_CONTROL_Msk | CAN_IF_CMASK_DATAA_Msk | CAN_IF_CMASK_DATAB_Msk; + + if(pCanMsg->IdType == CAN_STD_ID) /* According STD/EXT ID format,Configure Mask and Arbitration register */ + { + CANx->IF1.ARB0 = 0; + CANx->IF1.ARB1 = CAN_IF_ARB1_MSGVAL_Msk | (pCanMsg->Id & 0x7FF) << 2; + CANx->IF1.MASK0 = pCanMsg->MASK0; + CANx->IF1.MASK1 = pCanMsg->MASK1; + } + else + { + CANx->IF1.ARB0 = pCanMsg->Id & 0xFFFF; + CANx->IF1.ARB1 = CAN_IF_ARB1_MSGVAL_Msk | CAN_IF_ARB1_XTD_Msk | (pCanMsg->Id & 0x1FFF0000) >> 16; + } + + CANx->IF1.MCR |= CAN_IF_MCR_RXIE_Msk | pCanMsg->MCR ; + + if(pCanMsg->UMASK) + { + CANx->IF1.MCR |= CAN_IF_MCR_UMASK_Msk; + CANx->IF1.MASK0 = pCanMsg->MASK0; + CANx->IF1.MASK1 = pCanMsg->MASK1; + } + + if(pCanMsg->RMTEN) + CANx->IF1.MCR |= CAN_IF_MCR_RMTEN_Msk; + else + CANx->IF1.MCR &= (~CAN_IF_MCR_RMTEN_Msk); + + if(pCanMsg->EOB) + CANx->IF1.MCR |= CAN_IF_MCR_EOB_Msk; + else + CANx->IF1.MCR &= (~CAN_IF_MCR_EOB_Msk); + + CANx->IF1.MCR &= (~CAN_IF_MCR_INTPND_Msk); + CANx->IF1.MCR &= (~CAN_IF_MCR_NEWDAT_Msk); + CANx->IF1.DA0R = 0; + CANx->IF1.DA1R = 0; + CANx->IF1.DB0R = 0; + CANx->IF1.DB1R = 0; + CANx->IF1.CREQ = MsgObj+1; + } + else + { + /* Command Setting */ + CANx->IF0.CMASK = CAN_IF_CMASK_WRRD_Msk | CAN_IF_CMASK_MASK_Msk | CAN_IF_CMASK_ARB_Msk | + CAN_IF_CMASK_CONTROL_Msk | CAN_IF_CMASK_DATAA_Msk | CAN_IF_CMASK_DATAB_Msk; + + if(pCanMsg->IdType == CAN_STD_ID) /* According STD/EXT ID format,Configure Mask and Arbitration register */ + { + CANx->IF0.ARB0 = 0; + CANx->IF0.ARB1 = CAN_IF_ARB1_MSGVAL_Msk | (pCanMsg->Id & 0x7FF) << 2; + CANx->IF0.MASK0 = pCanMsg->MASK0; + CANx->IF0.MASK1 = pCanMsg->MASK1; + } + else + { + CANx->IF0.ARB0 = pCanMsg->Id & 0xFFFF; + CANx->IF0.ARB1 = CAN_IF_ARB1_MSGVAL_Msk | CAN_IF_ARB1_XTD_Msk | (pCanMsg->Id & 0x1FFF0000) >> 16; + } + + CANx->IF0.MCR |= CAN_IF_MCR_RXIE_Msk | pCanMsg->MCR ; + + if(pCanMsg->UMASK) + { + CANx->IF0.MCR |= CAN_IF_MCR_UMASK_Msk; + CANx->IF0.MASK0 = pCanMsg->MASK0; + CANx->IF0.MASK1 = pCanMsg->MASK1; + } + + if(pCanMsg->RMTEN) + CANx->IF0.MCR |= CAN_IF_MCR_RMTEN_Msk; + else + CANx->IF0.MCR &= (~CAN_IF_MCR_RMTEN_Msk); + + if(pCanMsg->EOB) + CANx->IF0.MCR |= CAN_IF_MCR_EOB_Msk; + else + CANx->IF0.MCR &= (~CAN_IF_MCR_EOB_Msk); + + CANx->IF0.MCR &= (~CAN_IF_MCR_INTPND_Msk); + CANx->IF0.MCR &= (~CAN_IF_MCR_NEWDAT_Msk); + CANx->IF0.DA0R = 0; + CANx->IF0.DA1R = 0; + CANx->IF0.DB0R = 0; + CANx->IF0.DB1R = 0; + CANx->IF0.CREQ = MsgObj+1; + } + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Gets the message + * @param CANx: The pointer to CAN module base address. + * @param MsgObj: Specifies the Message object number, from 0 to 31. + * @param Release: Specifies the message release indicator. + * @arg TRUE : the message object is released when getting the data. + * @arg FALSE: the message object is not released. + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @retval TRUE Success, FALSE No any message received + ***********************************************************************************************************/ +s32 CAN_ReadMsgObj(HT_CAN_TypeDef *CANx, u32 MsgObj, u32 Release, STR_CANMSG_T_TypeDef* pCanMsg) +{ + u32 u8MsgIfNum = 0; + + if(!CAN_IsNewDataReceived(CANx, MsgObj)) + { + return FALSE; + } + + if((u8MsgIfNum = GetFreeIF(CANx)) == 2) /* Check Free Interface for configure */ + { + return FALSE; + } + + CANx->SR &= (~CAN_SR_RXOK_Msk); + + if (u8MsgIfNum == 1) + { + /* read the message contents*/ + CANx->IF1.CMASK = CAN_IF_CMASK_MASK_Msk + | CAN_IF_CMASK_ARB_Msk + | CAN_IF_CMASK_CONTROL_Msk + | CAN_IF_CMASK_CLRINTPND_Msk + | (Release ? CAN_IF_CMASK_TXRQSTNEWDAT_Msk : 0) + | CAN_IF_CMASK_DATAA_Msk + | CAN_IF_CMASK_DATAB_Msk; + + CANx->IF1.CREQ = MsgObj; + + while(CANx->IF1.CREQ & CAN_IF_CREQ_BUSY_Msk) + { + /*Wait*/ + } + + if((CANx->IF1.ARB1 & CAN_IF_ARB1_XTD_Msk) == 0) + { + /* standard ID*/ + pCanMsg->IdType = CAN_STD_ID; + pCanMsg->Id = (CANx->IF1.ARB1 & CAN_IF_ARB1_ID_Msk) >> 2; + } + else + { + /* extended ID*/ + pCanMsg->IdType = CAN_EXT_ID; + pCanMsg->Id = (CANx->IF1.ARB1 & 0x1FFF) << 16 ; + pCanMsg->Id |= CANx->IF1.ARB0; + } + pCanMsg->MCR = CANx->IF1.MCR; + pCanMsg->DLC = CANx->IF1.MCR & CAN_IF_MCR_DLC_Msk; + pCanMsg->EOB = CANx->IF1.MCR & CAN_IF_MCR_EOB_Msk; + pCanMsg->Data[0] = CANx->IF1.DA0R & CAN_IF_DAT_A0_DATA0_Msk; + pCanMsg->Data[1] = (CANx->IF1.DA0R & CAN_IF_DAT_A0_DATA1_Msk) >> CAN_IF_DAT_A0_DATA1_Pos; + pCanMsg->Data[2] = CANx->IF1.DA1R & CAN_IF_DAT_A1_DATA2_Msk; + pCanMsg->Data[3] = (CANx->IF1.DA1R & CAN_IF_DAT_A1_DATA3_Msk) >> CAN_IF_DAT_A1_DATA3_Pos; + pCanMsg->Data[4] = CANx->IF1.DB0R & CAN_IF_DAT_B0_DATA4_Msk; + pCanMsg->Data[5] = (CANx->IF1.DB0R & CAN_IF_DAT_B0_DATA5_Msk) >> CAN_IF_DAT_B0_DATA5_Pos; + pCanMsg->Data[6] = CANx->IF1.DB1R & CAN_IF_DAT_B1_DATA6_Msk; + pCanMsg->Data[7] = (CANx->IF1.DB1R & CAN_IF_DAT_B1_DATA7_Msk) >> CAN_IF_DAT_B1_DATA7_Pos; + } + else + { + /* read the message contents*/ + CANx->IF0.CMASK = CAN_IF_CMASK_MASK_Msk + | CAN_IF_CMASK_ARB_Msk + | CAN_IF_CMASK_CONTROL_Msk + | CAN_IF_CMASK_CLRINTPND_Msk + | (Release ? CAN_IF_CMASK_TXRQSTNEWDAT_Msk : 0) + | CAN_IF_CMASK_DATAA_Msk + | CAN_IF_CMASK_DATAB_Msk; + + CANx->IF0.CREQ = MsgObj; + + while(CANx->IF0.CREQ & CAN_IF_CREQ_BUSY_Msk) + { + /*Wait*/ + } + + if((CANx->IF0.ARB1 & CAN_IF_ARB1_XTD_Msk) == 0) + { + /* standard ID*/ + pCanMsg->IdType = CAN_STD_ID; + pCanMsg->Id = (CANx->IF0.ARB1 & CAN_IF_ARB1_ID_Msk) >> 2; + } + else + { + /* extended ID*/ + pCanMsg->IdType = CAN_EXT_ID; + pCanMsg->Id = (CANx->IF0.ARB1 & 0x1FFF) << 16; + pCanMsg->Id |= CANx->IF0.ARB0; + } + + pCanMsg->MCR = CANx->IF0.MCR; + pCanMsg->DLC = CANx->IF0.MCR & CAN_IF_MCR_DLC_Msk; + pCanMsg->EOB = CANx->IF0.MCR & CAN_IF_MCR_EOB_Msk; + pCanMsg->Data[0] = CANx->IF0.DA0R & CAN_IF_DAT_A0_DATA0_Msk; + pCanMsg->Data[1] = (CANx->IF0.DA0R & CAN_IF_DAT_A0_DATA1_Msk) >> CAN_IF_DAT_A0_DATA1_Pos; + pCanMsg->Data[2] = CANx->IF0.DA1R & CAN_IF_DAT_A1_DATA2_Msk; + pCanMsg->Data[3] = (CANx->IF0.DA1R & CAN_IF_DAT_A1_DATA3_Msk) >> CAN_IF_DAT_A1_DATA3_Pos; + pCanMsg->Data[4] = CANx->IF0.DB0R & CAN_IF_DAT_B0_DATA4_Msk; + pCanMsg->Data[5] = (CANx->IF0.DB0R & CAN_IF_DAT_B0_DATA5_Msk) >> CAN_IF_DAT_B0_DATA5_Pos; + pCanMsg->Data[6] = CANx->IF0.DB1R & CAN_IF_DAT_B1_DATA6_Msk; + pCanMsg->Data[7] = (CANx->IF0.DB1R & CAN_IF_DAT_B1_DATA7_Msk) >> CAN_IF_DAT_B1_DATA7_Pos; + } + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Set bus baud-rate. + * @param CANx: The pointer to CAN module base address. + * @param wBaudRate: The target CAN baud-rate. The range of u32BaudRate is 1~1000KHz. + * @retval CurrentBitRate: Real baud-rate value. + ***********************************************************************************************************/ +u32 CAN_SetBaudRate(HT_CAN_TypeDef *CANx, u32 wBaudRate) +{ + u32 wTseg0, wTseg1; + u32 wBrp; + u32 wValue; + + CAN_EnterInitMode(CANx); + + SystemCoreClockUpdate(); + + wTseg0 = 2; + wTseg1 = 1; + + wValue = SystemCoreClock / wBaudRate; + + while(1) + { + if(((wValue % (wTseg0 + wTseg1 + 3)) == 0)) + break; + if(wTseg1 < 7) + wTseg1++; + + if((wValue % (wTseg0 + wTseg1 + 3)) == 0) + break; + if(wTseg0 < 15) + wTseg0++; + else + { + wTseg0 = 2; + wTseg1 = 1; + break; + } + } + + wBrp = SystemCoreClock / (wBaudRate) / (wTseg0 + wTseg1 + 3) - 1; + + wValue = ((u32)wTseg1 << CAN_BTR_TSEG1_Pos) | ((u32)wTseg0 << CAN_BTR_TSEG0_Pos) | + (wBrp & CAN_BTR_BRP_Msk) | (CANx->BTR & CAN_BTR_SJW_Msk); + CANx->BTR = wValue; + CANx->BRPER = (wBrp >> 6) & 0x0F; + + CAN_LeaveInitMode(CANx); + + return (CAN_GetCANBitRate(CANx)); +} + +/*********************************************************************************************************//** + * @brief The function is used to disable all CAN interrupt. + * @param CANx: The pointer to CAN module base address. + * @retval None + ***********************************************************************************************************/ +void CAN_Close(HT_CAN_TypeDef *CANx) +{ + CAN_DisableInt(CANx, (CAN_CR_IE_Msk | CAN_CR_SIE_Msk | CAN_CR_EIE_Msk)); +} + +/*********************************************************************************************************//** + * @brief Set CAN operation mode and target baud-rate. + * @param CANx: The pointer to CAN module base address. + * @param wBaudRate The target CAN baud-rate. The range of u32BaudRate is 1~1000KHz. + * @param wMode The CAN operation mode. + * @arg CAN_NORMAL_MODE : Normal operation. + * @arg CAN_BASIC_MODE : Basic operation. + * @arg CAN_SILENT_MODE : Silent operation. + * @arg CAN_LBACK_MODE : Loop Back operation. + * @arg CAN_LBS_MODE : Loop Back combined with Silent operation. + * @retval u32CurrentBitRate Real baud-rate value. + ***********************************************************************************************************/ +u32 CAN_Open(HT_CAN_TypeDef *CANx, u32 wBaudRate, u32 wMode) +{ + u32 CurrentBitRate; + + CurrentBitRate = CAN_SetBaudRate(CANx, wBaudRate); + + if(wMode) + CAN_EnterTestMode(CANx, wMode); + + return CurrentBitRate; +} + +/*********************************************************************************************************//** + * @brief The function is used to configure a transmit object. + * @param CANx: The pointer to CAN module base address. + * @param MsgNum: Specifies the Message object number, from 0 to 31. + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @retval FALSE No useful interface, TRUE Config message object success. + ***********************************************************************************************************/ +s32 CAN_SetTxMsg(HT_CAN_TypeDef *CANx, u32 MsgNum , STR_CANMSG_T_TypeDef* pCanMsg) +{ + u32 MsgIfNum = 0; + u32 i = 0; + + while((MsgIfNum = GetFreeIF(CANx)) == 2) + { + i++; + if(i > 0x10000000) + return FALSE; + } + + /* update the contents needed for transmission*/ + if(MsgIfNum ==0) + { + CANx->IF0.CMASK = 0xF3; /* CAN_CMASK_WRRD_Msk | CAN_CMASK_MASK_Msk | CAN_CMASK_ARB_Msk + | CAN_CMASK_CONTROL_Msk | CAN_CMASK_DATAA_Msk | CAN_CMASK_DATAB_Msk ; */ + + if(pCanMsg->IdType == CAN_STD_ID) + { + /* standard ID*/ + CANx->IF0.ARB0 = 0; + CANx->IF0.ARB1 = (((pCanMsg->Id) & 0x7FF) << 2) | CAN_IF_ARB1_DIR_Msk | CAN_IF_ARB1_MSGVAL_Msk; + } + else + { + /* extended ID*/ + CANx->IF0.ARB0 = (pCanMsg->Id) & 0xFFFF; + CANx->IF0.ARB1 = ((pCanMsg->Id) & 0x1FFF0000) >> 16 | CAN_IF_ARB1_DIR_Msk + | CAN_IF_ARB1_XTD_Msk | CAN_IF_ARB1_MSGVAL_Msk; + } + + if(pCanMsg->FrameType) + CANx->IF0.ARB1 |= CAN_IF_ARB1_DIR_Msk; + else + CANx->IF0.ARB1 &= (~CAN_IF_ARB1_DIR_Msk); + + CANx->IF0.DA0R = ((u16)pCanMsg->Data[1] << 8) | pCanMsg->Data[0]; + CANx->IF0.DA1R = ((u16)pCanMsg->Data[3] << 8) | pCanMsg->Data[2]; + CANx->IF0.DB0R = ((u16)pCanMsg->Data[5] << 8) | pCanMsg->Data[4]; + CANx->IF0.DB1R = ((u16)pCanMsg->Data[7] << 8) | pCanMsg->Data[6]; + CANx->IF0.MCR = 0; + if(pCanMsg->RMTEN) + CANx->IF0.MCR |= CAN_IF_MCR_RMTEN_Msk; + else + CANx->IF0.MCR &= (~CAN_IF_MCR_RMTEN_Msk); + if(pCanMsg->EOB) + CANx->IF0.MCR |= CAN_IF_MCR_EOB_Msk; + else + CANx->IF0.MCR &= (~CAN_IF_MCR_EOB_Msk); + + CANx->IF0.MCR |= CAN_IF_MCR_NEWDAT_Msk | pCanMsg->DLC | CAN_IF_MCR_TXIE_Msk ; + CANx->IF0.CREQ = MsgNum +1; + } + else + { + CANx->IF1.CMASK = 0xF3; /* CAN_CMASK_WRRD_Msk | CAN_CMASK_MASK_Msk | CAN_CMASK_ARB_Msk + | CAN_CMASK_CONTROL_Msk | CAN_CMASK_DATAA_Msk | CAN_CMASK_DATAB_Msk ; */ + + if(pCanMsg->IdType == CAN_STD_ID) + { + /* standard ID*/ + CANx->IF1.ARB0 = 0; + CANx->IF1.ARB1 = (((pCanMsg->Id) & 0x7FF) << 2) | CAN_IF_ARB1_DIR_Msk | CAN_IF_ARB1_MSGVAL_Msk; + } + else + { + /* extended ID*/ + CANx->IF1.ARB0 = (pCanMsg->Id) & 0xFFFF; + CANx->IF1.ARB1 = ((pCanMsg->Id) & 0x1FFF0000) >> 16 | CAN_IF_ARB1_DIR_Msk + | CAN_IF_ARB1_XTD_Msk | CAN_IF_ARB1_MSGVAL_Msk; + } + + if(pCanMsg->FrameType) + CANx->IF1.ARB1 |= CAN_IF_ARB1_DIR_Msk; + else + CANx->IF1.ARB1 &= (~CAN_IF_ARB1_DIR_Msk); + + CANx->IF1.DA0R = ((u16)pCanMsg->Data[1] << 8) | pCanMsg->Data[0]; + CANx->IF1.DA1R = ((u16)pCanMsg->Data[3] << 8) | pCanMsg->Data[2]; + CANx->IF1.DB0R = ((u16)pCanMsg->Data[5] << 8) | pCanMsg->Data[4]; + CANx->IF1.DB1R = ((u16)pCanMsg->Data[7] << 8) | pCanMsg->Data[6]; + + CANx->IF1.MCR = 0; + + if(pCanMsg->RMTEN) + CANx->IF1.MCR |= CAN_IF_MCR_RMTEN_Msk; + else + CANx->IF1.MCR &= (~CAN_IF_MCR_RMTEN_Msk); + + if(pCanMsg->EOB) + CANx->IF1.MCR |= CAN_IF_MCR_EOB_Msk; + else + CANx->IF1.MCR &= (~CAN_IF_MCR_EOB_Msk); + + CANx->IF1.MCR |= CAN_IF_MCR_NEWDAT_Msk | pCanMsg->DLC | CAN_IF_MCR_TXIE_Msk ; + CANx->IF1.CREQ = MsgNum +1; + } + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Set transmit request bit. + * If a transmission is requested by programming bit TxRqst/NewDat (IFn_CMASK[2]), the TxRqst + * (IFn_MCON[8]) will be ignored. + * @param CANx: The pointer to CAN module base address. + * @param u32MsgNum: Specifies the Message object number, from 0 to 31. + * @retval TRUE: Start transmit message. + ***********************************************************************************************************/ +s32 CAN_TriggerTxMsg(HT_CAN_TypeDef *CANx, u32 u32MsgNum) +{ + CANx->SR &= (~CAN_SR_TXOK_Msk); + + /* read the message contents*/ + CANx->IF1.CMASK = CAN_IF_CMASK_CLRINTPND_Msk + | CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + + CANx->IF1.CREQ = u32MsgNum+1; + + while(CANx->IF1.CREQ & CAN_IF_CREQ_BUSY_Msk) + { + /*Wait*/ + } + CANx->IF0.CMASK = CAN_IF_CMASK_WRRD_Msk | CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + CANx->IF0.CREQ = u32MsgNum+1; + + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Enable CAN interrupt. + * The application software has two possibilities to follow the source of a message interrupt. + * First, it can follow the IntId in the Interrupt Register and second it can poll the Interrupt Pending Register. + * @param CANx: The pointer to CAN module base address. + * @param u32Mask: Interrupt Mask. + * @arg CAN_CR_IE_Msk : Module interrupt enable. + * @arg CAN_CR_SIE_Msk: Status change interrupt enable. + * @arg CAN_CR_EIE_Msk: Error interrupt enable. + * @retval None + ***********************************************************************************************************/ +void CAN_EnableInt(HT_CAN_TypeDef *CANx, u32 u32Mask) +{ + CAN_EnterInitMode(CANx); + + CANx->CR = (CANx->CR & 0xF1) | ((u32Mask & CAN_CR_IE_Msk) ? CAN_CR_IE_Msk : 0) + | ((u32Mask & CAN_CR_SIE_Msk) ? CAN_CR_SIE_Msk : 0) + | ((u32Mask & CAN_CR_EIE_Msk) ? CAN_CR_EIE_Msk : 0); + + + CAN_LeaveInitMode(CANx); +} + +/*********************************************************************************************************//** + * @brief Disable CAN interrupt. + * @param CANx: The pointer to CAN module base address. + * @param Mask: Interrupt Mask. (CAN_CR_IE_Msk / CAN_CR_SIE_Msk / CAN_CR_EIE_Msk). + * @retval None + ***********************************************************************************************************/ +void CAN_DisableInt(HT_CAN_TypeDef *CANx, u32 Mask) +{ + CAN_EnterInitMode(CANx); + + CANx->CR = CANx->CR & ~(CAN_CR_IE_Msk | ((Mask & CAN_CR_SIE_Msk) ? CAN_CR_SIE_Msk : 0) + | ((Mask & CAN_CR_EIE_Msk) ? CAN_CR_EIE_Msk : 0)); + + CAN_LeaveInitMode(CANx); +} + + +/*********************************************************************************************************//** + * @brief The function is used to configure a receive message object. + * @param CANx: The pointer to CAN module base address. + * @param MsgNum: Specifies the Message object number, from 0 to 31. + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @arg CAN_STD_ID: The 11-bit identifier. + * @arg CAN_EXT_ID: The 29-bit identifier. + * @retval FALSE No useful interface, TRUE Configure a receive message object success. + ***********************************************************************************************************/ +s32 CAN_SetRxMsg(HT_CAN_TypeDef *CANx, u32 MsgNum , STR_CANMSG_R_TypeDef* pCanMsg) +{ + u32 TimeOutCount = 0; + + while(CAN_SetRxMsgObj(CANx, MsgNum, pCanMsg) == FALSE) + { + TimeOutCount++; + + if(TimeOutCount >= 0x10000000) return FALSE; + } + + return TRUE; +} + +/*********************************************************************************************************//** + * @brief The function is used to configure several receive message objects. + * The Interface Registers avoid conflict between the CPU accesses to the Message RAM and CAN message + * reception and transmission by buffering the data to be transferred. + * @param CANx: The pointer to CAN module base address. + * @param MsgNum: The starting MSG RAM number(0 ~ 31). + * @param MsgCount: the number of MSG RAM of the FIFO. + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @arg CAN_STD_ID: The 11-bit identifier. + * @arg CAN_EXT_ID: The 29-bit identifier. + * @retval FALSE No useful interface, TRUE Configure receive message objects success. + ***********************************************************************************************************/ +s32 CAN_SetMultiRxMsg(HT_CAN_TypeDef *CANx, u32 MsgNum , u32 MsgCount, STR_CANMSG_R_TypeDef* pCanMsg) +{ + u32 i = 0; + u32 TimeOutCount; + + for(i = 1; i < MsgCount+1; i++) + { + TimeOutCount = 0; + pCanMsg->EOB = 0; + + if(i == MsgCount) + pCanMsg->EOB=1; + + while(CAN_SetRxMsgObj(CANx, MsgNum, pCanMsg) == FALSE) + { + TimeOutCount++; + + if(TimeOutCount >= 0x10000000) + return FALSE; + } + MsgNum ++; + } + + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Send CAN message. + * @param CANx: The pointer to CAN module base address. + * @param MsgNum: Specifies the Message object number, from 0 to 31. + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @retval FALSE: 1. When operation in basic mode: Transmit message time out. + * 2. When operation in normal mode: No useful interface. + * TRUE: Transmit Message success. + ***********************************************************************************************************/ +s32 CAN_Transmit(HT_CAN_TypeDef *CANx, u32 MsgNum , STR_CANMSG_T_TypeDef* pCanMsg) +{ + if((CANx->CR & CAN_CR_TEST_Msk) && (CANx->TR & CAN_TEST_BASIC_Msk)) + { + return (CAN_BasicSendMsg(CANx, pCanMsg)); + } + else + { + if(CAN_SetTxMsg(CANx, MsgNum, pCanMsg) == FALSE) + return FALSE; + + CANx->SR &= (~CAN_SR_TXOK_Msk); + + /* read the message contents*/ + CANx->IF1.CMASK = CAN_IF_CMASK_CLRINTPND_Msk + | CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + + CANx->IF1.CREQ = MsgNum+1; + + while(CANx->IF1.CREQ & CAN_IF_CREQ_BUSY_Msk) + { + /*Wait*/ + } + CANx->IF0.CMASK = CAN_IF_CMASK_WRRD_Msk | CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + CANx->IF0.CREQ = MsgNum+1; + } + + return TRUE; +} + +/*********************************************************************************************************//** + * @brief Gets the message, if received. + * The Interface Registers avoid conflict between the CPU accesses to the Message RAM and CAN message + * reception and transmission by buffering the data to be transferred. + * @param CANx: The pointer to CAN module base address. + * @param MsgNum: Specifies the Message object number, from 0 to 31. + * @param pCanMsg: Pointer to the message structure where received data is copied. + * @retval FALSE: No any message received, TRUE: Receive Message success. + ***********************************************************************************************************/ +s32 CAN_Receive(HT_CAN_TypeDef *CANx, u32 MsgNum , STR_CANMSG_T_TypeDef* pCanMsg) +{ + if((CANx->CR & CAN_CR_TEST_Msk) && (CANx->TR & CAN_TEST_BASIC_Msk)) + { + return (CAN_BasicReceiveMsg(CANx, pCanMsg)); + } + else + { + return CAN_ReadMsgObj(CANx, MsgNum, TRUE, pCanMsg); + } +} + +/*********************************************************************************************************//** + * @brief Clear interrupt pending bit. + * @param CANx: The pointer to CAN module base address. + * @param MsgNum: Specifies the Message object number, from 0 to 31. + * @retval None + ***********************************************************************************************************/ +void CAN_CLR_INT_PENDING_BIT(HT_CAN_TypeDef *CANx, u32 MsgNum) +{ + u32 u32IFBusyCount = 0; + + while(u32IFBusyCount < 0x10000000) + { + if((CANx->IF0.CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) + { + CANx->IF0.CMASK = CAN_IF_CMASK_CLRINTPND_Msk | CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + CANx->IF0.CREQ = MsgNum+1; + break; + } + else if((CANx->IF1.CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) + { + CANx->IF1.CMASK = CAN_IF_CMASK_CLRINTPND_Msk | CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + CANx->IF1.CREQ = MsgNum+1; + break; + } + + u32IFBusyCount++; + } +} + +/*********************************************************************************************************//** + * @brief The function is used to configure Mask as the message object. + * @param CANx: The pointer to CAN module base address. + * @param MsgObj: Specifies the Message object number, from 0 to 31. + * @param MaskMsg: Pointer to the message structure where received data is copied. + * @arg CAN_STD_ID: The 11-bit identifier. + * @arg CAN_EXT_ID: The 29-bit identifier. + * @retval FALSE No useful interface, TRUE Configure a receive message object success. + ***********************************************************************************************************/ +s32 CAN_MsgObjMaskConfig(HT_CAN_TypeDef *CANx, u32 MsgObj, STR_CANMSG_R_TypeDef* MaskMsg) +{ + if(MaskMsg->IdType == CAN_STD_ID) + { + /* standard ID*/ + CANx->IF0.ARB0 = 0; + CANx->IF0.ARB1 = (((MaskMsg->Id) & 0x7FF) << 2) | CAN_IF_ARB1_MSGVAL_Msk ; + + /* Set the Mask Standard ID(11-bit) for IFn Mask Register is used for acceptance filtering*/ + CANx->IF0.MASK0 = 0; + CANx->IF0.MASK1 = ((MaskMsg->Id & 0x7FF) << 2) ; + } + else + { + /* extended ID*/ + CANx->IF0.ARB0 = (MaskMsg->Id) & 0xFFFF; + CANx->IF0.ARB1 = ((MaskMsg->Id) & 0x1FFF0000) >> 16 | CAN_IF_ARB1_DIR_Msk + | CAN_IF_ARB1_XTD_Msk | CAN_IF_ARB1_MSGVAL_Msk; + /* Set the Mask Extended ID(29-bit) for IFn Mask Register is used for acceptance filtering*/ + CANx->IF0.MASK0 = (MaskMsg->Id) & 0xFFFF; + CANx->IF0.MASK1 = ((MaskMsg->Id) & 0x1FFF0000) >> 16 ; + } + + if(MaskMsg->u8Xtd) + CANx->IF0.MASK1 |= CAN_IF_MASK1_MXTD_Msk; /* The extended identifier bit (IDE) is used for acceptance filtering */ + else + CANx->IF0.MASK1 &= (~CAN_IF_MASK1_MXTD_Msk); /* The extended identifier bit (IDE) has no effect on the acceptance filtering */ + + if(MaskMsg->u8Dir) + CANx->IF0.MASK1 |= CAN_IF_MASK1_MDIR_Msk; /* The message direction bit (Dir) is used for acceptance filtering */ + else + CANx->IF0.MASK1 &= (~CAN_IF_MASK1_MDIR_Msk); /* The message direction bit (Dir) has no effect on the acceptance filtering */ + + CANx->IF0.MCR |= CAN_IF_MCR_UMASK_Msk; /* Use Mask (Msk28-0, MXtd, and MDir) for acceptance filtering */ + + /* Update the contents needed for transmission*/ + CANx->IF0.CMASK = CAN_IF_CMASK_WRRD_Msk /* Transfer data from the selected Message Buffer Registers to the Message Object addressed */ + | CAN_IF_CMASK_MASK_Msk; /* Transfer Identifier Mask + MDir + MXtd to Message Object */ + + CANx->IF0.DA0R = 0; + CANx->IF0.DA1R = 0; + CANx->IF0.DB0R = 0; + CANx->IF0.DB1R = 0; + + /* Set the Message Object in the Message RAM is selected for data transfer */ + CANx->IF0.CREQ = 1 + MsgObj; + + return TRUE; +} + +/* Private functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CAN_Private_Functions CAN private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Check if SmartCard slot is presented. + * @param CANx: The pointer to CAN module base address. +* @retval Free IF number. IF0_NUM or IF1_NUM or IF_TOTAL_NUM (No IF is free) + ***********************************************************************************************************/ +static CANIF_NUMBER_Enum GetFreeIF(HT_CAN_TypeDef *CANx) +{ + if((CANx->IF0.CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) + return IF0_NUM; + else if((CANx->IF1.CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) + return IF1_NUM; + else + return IF_TOTAL_NUM; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ckcu.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ckcu.c new file mode 100644 index 0000000000..9238830a04 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ckcu.c @@ -0,0 +1,1105 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_ckcu.c + * @version $Rev:: 7322 $ + * @date $Date:: 2023-10-28 #$ + * @brief This file provides all the Clock Control Unit firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_ckcu.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CKCU CKCU + * @brief CKCU driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Private_Define CKCU private definitions + * @{ + */ + +/* GCFGR bit field definition */ +#define CKCU_POS_CKOUTSRC 0 +#define CKCU_MASK_CKOUTSRC ((u32)0x7 << CKCU_POS_CKOUTSRC) + +#define CKCU_POS_PLLSRC 8 +#define CKCU_MASK_PLLSRC ((u32)0x1 << CKCU_POS_PLLSRC) + +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_POS_USBPLLSRC 9 +#define CKCU_MASK_USBPLLSRC ((u32)0x1 << CKCU_POS_USBPLLSRC) + +#define CKCU_POS_USBSRC 10 +#define CKCU_MASK_USBSRC ((u32)0x1 << CKCU_POS_USBSRC) +#endif + +#define CKCU_POS_CKREFPRE 11 +#define CKCU_MASK_CKREFPRE ((u32)0x1F << CKCU_POS_CKREFPRE) + +/* GCCR bit field definition */ +#define CKCU_POS_SW 0 +#define CKCU_MASK_SW ((u32)0x7 << CKCU_POS_SW) + +#if (LIBCFG_CKCU_USB_PLL) +#define CKCU_POS_USBPLLEN 3 +#define CKCU_MASK_USBPLLEN ((u32)0x1 << CKCU_POS_USBPLLEN) +#endif + +#define CKCU_POS_PLLEN 9 +#define CKCU_MASK_PLLEN ((u32)0x1 << CKCU_POS_PLLEN) + +#define CKCU_POS_HSEEN 10 +#define CKCU_MASK_HSEEN ((u32)0x1 << CKCU_POS_HSEEN) + +#define CKCU_POS_HSIEN 11 +#define CKCU_MASK_HSIEN ((u32)0x1 << CKCU_POS_HSIEN) + +#define CKCU_POS_CKMEN 16 +#define CKCU_MASK_CKMEN ((u32)0x1 << CKCU_POS_CKMEN) + +#define CKCU_POS_PSRCEN 17 +#define CKCU_MASK_PSRCEN ((u32)0x1 << CKCU_POS_PSRCEN) + +/* PLLCFGR bit field definition */ +#define CKCU_POS_POTD 21 +#define CKCU_MASK_POTD ((u32)0x3 << CKCU_POS_POTD) + +#define CKCU_POS_PFBD 23 +#define CKCU_MASK_PFBD ((u32)0x0F << CKCU_POS_PFBD) + +/* PLLCR bit field definition */ +#define CKCU_POS_PLLBYPASS 31 +#define CKCU_MASK_PLLBYPASS ((u32)0x1 << CKCU_POS_PLLBYPASS) + +/* APBCFGR bit field definition */ +#define CKCU_POS_ADC0DIV 16 +#define CKCU_MASK_ADC0DIV ((u32)0x7 << CKCU_POS_ADC0DIV) + +#if (LIBCFG_ADC1) +#define CKCU_POS_ADC1DIV 20 +#define CKCU_MASK_ADC1DIV ((u32)0x7 << CKCU_POS_ADC1DIV) +#endif + +#if (LIBCFG_CKCU_LCD_SRC) +#define CKCU_POS_LCDSRC 4 +#define CKCU_MASK_LCDSRC ((u32)0x3 << CKCU_POS_LCDSRC) +#endif + +#if (LIBCFG_LCD) +#define CKCU_POS_LCDDIV 8 +#define CKCU_MASK_LCDDIV ((u32)0x7 << CKCU_POS_LCDDIV) +#endif + +#if (LIBCFG_CKCU_MCTM_SRC) +#define CKCU_POS_MCTMCSEL 8 +#define CKCU_MASK_MCTMCSEL ((u32)0x1 << CKCU_POS_MCTMCSEL) +#endif + +#if (LIBCFG_MIDI) +#define CKCU_POS_MIDIDIV 24 +#define CKCU_MASK_MIDIDIV ((u32)0x7 << CKCU_POS_MIDIDIV) +#endif + +/* CKST bit field definition */ +#define CKCU_POS_PLLST 8 +#define CKCU_MASK_PLLST ((u32)0xF << CKCU_POS_PLLST) + +#define CKCU_POS_HSEST 16 +#define CKCU_MASK_HSEST ((u32)0x3 << CKCU_POS_HSEST) + +#define CKCU_POS_HSIST 24 +#define CKCU_MASK_HSIST ((u32)0x7 << CKCU_POS_HSIST) + +#define CKCU_POS_CKSWST 0 +#define CKCU_MASK_CKSWST ((u32)0x7 << CKCU_POS_CKSWST) + +/* LPCR bit field definition */ +#define CKCU_POS_BKISO 0 +#define CKCU_MASK_BKISO ((u32)0x1 << CKCU_POS_BKISO) + +/* HSICR bit field definition */ +#define CKCU_POS_TRIMEN (0) +#define CKCU_MASK_TRIMEN ((u32)0x1 << CKCU_POS_TRIMEN) + +#define CKCU_POS_ATCEN (1) +#define CKCU_MASK_ATCEN ((u32)0x1 << CKCU_POS_ATCEN) + +#define CKCU_POS_REFCLKSEL (5) +#define CKCU_MASK_REFCLKSEL ((u32)0x3 << CKCU_POS_REFCLKSEL) + +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup CKCU_Private_Macro CKCU private macros + * @{ + */ +#define CKCU_BF_WRITE(Reg, Mask, Pos, WriteValue) (Reg = ((Reg & ~((u32)Mask)) | ((u32)WriteValue << Pos))) +#define CKCU_BF_READ(Reg, Mask, Pos) ((Reg & (u32)Mask) >> Pos) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup CKCU_Exported_Functions CKCU exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CKCU registers to the reset values. + * @retval None + ************************************************************************************************************/ +void CKCU_DeInit(void) +{ + /* Reset system clock */ + CKCU_HSICmd(ENABLE); + while (CKCU_GetClockReadyStatus(CKCU_FLAG_HSIRDY) == RESET); + CKCU_SysClockConfig(CKCU_SW_HSI); + + #if (LIBCFG_CKCU_USB_PLL) + HT_CKCU->GCFGR = 0x00000302; /* Reset value of GCFGR */ + #else + HT_CKCU->GCFGR = 0x00000102; /* Reset value of GCFGR */ + #endif + HT_CKCU->GCCR = 0x00000803; /* Reset value of GCCR */ + HT_CKCU->GCIR = 0x000000FF; /* Clear all interrupt flags */ + + #if (!LIBCFG_NO_PLL) + HT_CKCU->PLLCR = 0; /* Reset value of PLLCR */ + #endif + HT_CKCU->AHBCFGR = 0; /* Reset value of AHBCFGR */ + HT_CKCU->AHBCCR = 0x00000065; /* Reset value of AHBCCR */ + #if (!LIBCFG_NO_ADC) + HT_CKCU->APBCFGR = 0x00010000; /* Reset value of APBCFGR */ + #endif + HT_CKCU->APBCCR0 = 0; /* Reset value of APBCCR0 */ + HT_CKCU->APBCCR1 = 0; /* Reset value of APBCCR1 */ + #if (!LIBCFG_CKCU_NO_APB_PRESCALER) + HT_CKCU->APBPCSR0 = 0; /* Reset value of APBPCSR0 */ + HT_CKCU->APBPCSR1 = 0; /* Reset value of APBPCSR1 */ + #endif + #if (!LIBCFG_CKCU_NO_AUTO_TRIM) + HT_CKCU->HSICR = 0; /* Reset value of HSICR */ + #endif + #if ((!LIBCFG_CKCU_NO_APB_PRESCALER) && (LIBCFG_PWM0 || LIBCFG_PWM1 || LIBCFG_MIDI || LIBCFG_DAC0 || LIBCFG_DAC1 || LIBCFG_DACDUAL16 || LIBCFG_LCD || LIBCFG_LEDC || LIBCFG_TKEY)) + HT_CKCU->APBPCSR2 = 0; /* Reset value of APBPCSR2 */ + #endif + #if (LIBCFG_CKCU_HSIRDYCR) + HT_CKCU->HSIRDYCR = 0; /* Reset value of HSIRDYCR */ + #endif + #if (!LIBCFG_CKCU_NO_LPCR) + HT_CKCU->LPCR = 0; /* Reset value of LPCR */ + #endif + HT_CKCU->MCUDBGCR = 0; /* Reset value of MCUDBGCR */ +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the external high speed oscillator (HSE). + * @note HSE can not be stopped if it is used by system clock or PLL. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_HSECmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_HSEEN, CKCU_POS_HSEEN, Cmd); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the internal high speed oscillator (HSI). + * @note HSI can not be stopped if it is used by system clock or PLL. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_HSICmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_HSIEN, CKCU_POS_HSIEN, Cmd); +} + +#if (!LIBCFG_NO_PLL) +/*********************************************************************************************************//** + * @brief Enable or Disable the PLL clock. + * @note PLL can not be stopped if it is used by system clock or CK_REF. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_PLLCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_PLLEN, CKCU_POS_PLLEN, Cmd); +} +#endif + +#if (LIBCFG_CKCU_USB_PLL) +/*********************************************************************************************************//** + * @brief Enable or Disable the USBPLL clock. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_USBPLLCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_USBPLLEN, CKCU_POS_USBPLLEN, Cmd); +} +#endif + +/*********************************************************************************************************//** + * @brief Wait for HSE is ready to be used. + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus CKCU_WaitHSEReady(void) +{ + u32 ReadyCnt = 0; + + /* Wait until HSE is ready or time-out occurred */ + while (CKCU_GetClockReadyStatus(CKCU_FLAG_HSERDY) != SET) + { + if (++ReadyCnt >= HSE_READY_TIME) + { + return ERROR; + } + } + + return SUCCESS; +} + +/*********************************************************************************************************//** + * @brief Check whether the specific clock ready flag is set or not. + * @param CKCU_FLAG: specify the clock ready flag. + * This parameter can be one of the following values: + * @arg CKCU_FLAG_USBPLLRDY : USB PLL ready flag + * @arg CKCU_FLAG_PLLRDY : PLL ready flag + * @arg CKCU_FLAG_HSERDY : HSE ready flag + * @arg CKCU_FLAG_HSIRDY : HSI ready flag + * @arg CKCU_FLAG_LSERDY : LSE ready flag + * @arg CKCU_FLAG_LSIRDY : LSI ready flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CKCU_GetClockReadyStatus(u32 CKCU_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_FLAG(CKCU_FLAG)); + + if (HT_CKCU->GCSR & CKCU_FLAG) + { + return SET; + } + else + { + return RESET; + } +} + +#if (!LIBCFG_NO_PLL) +/*********************************************************************************************************//** + * @brief This function is used to configure PLL. + * @param PLL_InitStruct: pointer to CKCU_PLLInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_PLLInit(CKCU_PLLInitTypeDef *PLL_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_PLL_CLKSRC(PLL_InitStruct->ClockSource)); + Assert_Param(IS_CONTROL_STATUS(PLL_InitStruct->BYPASSCmd)); + Assert_Param(IS_PLL_CFG(PLL_InitStruct->CFG)); + + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_PLLSRC, CKCU_POS_PLLSRC, PLL_InitStruct->ClockSource); + CKCU_BF_WRITE(HT_CKCU->PLLCR, CKCU_MASK_PLLBYPASS, CKCU_POS_PLLBYPASS, PLL_InitStruct->BYPASSCmd); + HT_CKCU->PLLCFGR = (HT_CKCU->PLLCFGR & 0x0000FFFF) | PLL_InitStruct->CFG; +} +#endif + +#if (LIBCFG_CKCU_USB_PLL) +/*********************************************************************************************************//** + * @brief This function is used to configure USBPLL. + * @param USBPLL_InitStruct: pointer to CKCU_PLLInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_USBPLLInit(CKCU_PLLInitTypeDef *USBPLL_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_PLL_CLKSRC(USBPLL_InitStruct->ClockSource)); + Assert_Param(IS_USBPLL_CFG(USBPLL_InitStruct->CFG)); + + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_USBPLLSRC, CKCU_POS_USBPLLSRC, USBPLL_InitStruct->ClockSource); + HT_CKCU->PLLCFGR = (HT_CKCU->PLLCFGR & 0xFFFF0000) | USBPLL_InitStruct->CFG; +} + +/*********************************************************************************************************//** + * @brief Configure the CK_USB clock source. + * @param USBSRC: specify the USB clock source. + * This parameter can be one of the following values: + * @arg CKCU_CKPLL : CK_USB = CK_PLL + * @arg CKCU_CKUSBPLL : CK_USB = CK_USBPLL + * @retval None + ************************************************************************************************************/ +void CKCU_USBClockConfig(CKCU_USBSRC_TypeDef USBSRC) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_USBSRC, CKCU_POS_USBSRC, USBSRC); +} +#endif + +#if (LIBCFG_CKCU_LCD_SRC) +/*********************************************************************************************************//** + * @brief Configure LCD clock source. + * @param LCDSRC: Specify LCD clock source. + * This parameter can be one of the following values: + * @arg CKCU_LCDSRC_LSI : + * @arg CKCU_LCDSRC_LSE : + * @arg CKCU_LCDSRC_HSI : + * @arg CKCU_LCDSRC_HSE : + * @retval None + ************************************************************************************************************/ +void CKCU_LCDClockConfig(CKCU_LCDSRC_TypeDef LCDSRC) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_LCDSRC, CKCU_POS_LCDSRC, LCDSRC); +} +#endif + +#if (LIBCFG_CKCU_MCTM_SRC) +/*********************************************************************************************************//** + * @brief Configure the MCTM clock source. + * @param CKCU_MCTMSRC_x: specify the MCTM clock source. + * This parameter can be one of the following values: + * @arg CKCU_MCTMSRC_AHB : CK_MCTM = CK_AHB + * @arg CKCU_MCTMSRC_USBPLL : CK_MCTM = CK_USBPLL + * @retval None + ************************************************************************************************************/ +void CKCU_MCTMClockConfig(CKCU_MCTMSRC_TypeDef CKCU_MCTMSRC_x) +{ + Assert_Param(IS_MCTM_SRC(CKCU_MCTMSRC_x)); + CKCU_BF_WRITE(HT_CKCU->APBCFGR, CKCU_MASK_MCTMCSEL, CKCU_POS_MCTMCSEL, CKCU_MCTMSRC_x); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure the CK_SYS source. + * @param CLKSRC: specify the system clock source. + * This parameter can be one of the following values: + * @arg CKCU_SW_PLL : PLL is selected as CK_SYS + * @arg CKCU_SW_HSE : HSE is selected as CK_SYS + * @arg CKCU_SW_HSI : HSI is selected as CK_SYS + * @arg CKCU_SW_LSE : LSE is selected as CK_SYS + * @arg CKCU_SW_LSI : LSI is selected as CK_SYS + * @retval None + ************************************************************************************************************/ +ErrStatus CKCU_SysClockConfig(CKCU_SW_TypeDef CLKSRC) +{ + u32 cnt = 0xFF; + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_SW, CKCU_POS_SW, CLKSRC); + + /* Wait until new system clock source is applied or time-out */ + while (--cnt) + { + if (CKCU_GetSysClockSource() == (u32)CLKSRC) + { + return SUCCESS; + } + } + + return ERROR; +} + +/*********************************************************************************************************//** + * @brief Return the source clock which is used as system clock. + * @retval The source clock used as system clock. + * 0x01: PLL is selected as system clock + * 0x02: HSE is selected as system clock + * 0x03: HSI is selected as system clock + * 0x06: LSE is selected as system clock + * 0x07: LSI is selected as system clock + ************************************************************************************************************/ +u32 CKCU_GetSysClockSource(void) +{ + return ((u32)CKCU_BF_READ(HT_CKCU->CKST, CKCU_MASK_CKSWST, CKCU_POS_CKSWST)); +} + +/*********************************************************************************************************//** + * @brief Configure the CK_AHB prescaler. + * @param HCLKPRE: specify the value of divider. + * This parameter can be one of the following values: + * @arg CKCU_SYSCLK_DIV1 : HCLK = CK_SYS + * @arg CKCU_SYSCLK_DIV2 : HCLK = CK_SYS / 2 + * @arg CKCU_SYSCLK_DIV4 : HCLK = CK_SYS / 4 + * @arg CKCU_SYSCLK_DIV8 : HCLK = CK_SYS / 8 + * @arg CKCU_SYSCLK_DIV16 : HCLK = CK_SYS / 16 + * @arg CKCU_SYSCLK_DIV32 : HCLK = CK_SYS / 32 + * @retval None + ************************************************************************************************************/ +void CKCU_SetHCLKPrescaler(CKCU_SYSCLKDIV_TypeDef HCLKPRE) +{ + HT_CKCU->AHBCFGR = HCLKPRE; +} + +/*********************************************************************************************************//** + * @brief Configure the CK_REF prescaler. + * @param CKREFPRE: specify the value of divider. + * This parameter can be: CKCU_CKREFPRE_DIV2 to CKCU_CKREFPRE_DIV64 (CK_REF = CK_PLL / (2 * (N + 1)), N = 0 ~ 31) + * @retval None + ************************************************************************************************************/ +void CKCU_SetCKREFPrescaler(CKCU_CKREFPRE_TypeDef CKREFPRE) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_CKREFPRE, CKCU_POS_CKREFPRE, CKREFPRE); +} + +#if (!LIBCFG_NO_ADC) +/*********************************************************************************************************//** + * @brief Configure the CK_ADCn prescaler. + * @param CKCU_ADCPRE_ADCn: specify the ADCn. + * @param CKCU_ADCPRE_DIVn: specify the prescaler value. + * This parameter can be one of the following values: + * @arg CKCU_ADCPRE_DIV1 : CK_ADC = HCLK / 1 + * @arg CKCU_ADCPRE_DIV2 : CK_ADC = HCLK / 2 + * @arg CKCU_ADCPRE_DIV3 : CK_ADC = HCLK / 3 + * @arg CKCU_ADCPRE_DIV4 : CK_ADC = HCLK / 4 + * @arg CKCU_ADCPRE_DIV8 : CK_ADC = HCLK / 8 + * @arg CKCU_ADCPRE_DIV16 : CK_ADC = HCLK / 16 + * @arg CKCU_ADCPRE_DIV32 : CK_ADC = HCLK / 32 + * @arg CKCU_ADCPRE_DIV64 : CK_ADC = HCLK / 64 + * @retval None + ************************************************************************************************************/ +void CKCU_SetADCnPrescaler(CKCU_ADCPRE_ADCn_TypeDef CKCU_ADCPRE_ADCn, CKCU_ADCPRE_TypeDef CKCU_ADCPRE_DIVn) +{ + HT_CKCU->APBCFGR = (HT_CKCU->APBCFGR & (~(0x07 << CKCU_ADCPRE_ADCn))) | (CKCU_ADCPRE_DIVn << CKCU_ADCPRE_ADCn); +} +#endif + +#if (LIBCFG_LCD) +/*********************************************************************************************************//** + * @brief Configure LCD clock prescaler. + * @param LCDCPS: Specify LCD clock prescaler. + * This parameter can be one of the following values: + * @arg CKCU_LCDPRE_DIV1 : + * @arg CKCU_LCDPRE_DIV2 : + * @arg CKCU_LCDPRE_DIV4 : + * @arg CKCU_LCDPRE_DIV8 : + * @arg CKCU_LCDPRE_DIV16 : + * @retval None + ************************************************************************************************************/ +void CKCU_SetLCDPrescaler(CKCU_LCDPRE_TypeDef LCDPRE) +{ + CKCU_BF_WRITE(HT_CKCU->APBCFGR, CKCU_MASK_LCDDIV, CKCU_POS_LCDDIV, LCDPRE); +} +#endif + +#if (LIBCFG_MIDI) +/*********************************************************************************************************//** + * @brief Configure the CK_MIDI prescaler. + * @param MIDIPRE: specify the value of divider. + * This parameter can be: + * @arg CKCU_MIDIPRE_DIV8 : CK_MIDI = HCLK / 8 + * @arg CKCU_MIDIPRE_DIV9 : CK_MIDI = HCLK / 9 + * @arg CKCU_MIDIPRE_DIV11 : CK_MIDI = HCLK / 11 + * @arg CKCU_MIDIPRE_DIV13 : CK_MIDI = HCLK / 13 + * @arg CKCU_MIDIPRE_DIV16 : CK_MIDI = HCLK / 16 + * @retval None + ************************************************************************************************************/ +void CKCU_SetMIDIPrescaler(CKCU_MIDIPRE_TypeDef MIDIPRE) +{ + CKCU_BF_WRITE(HT_CKCU->APBCFGR, CKCU_MASK_MIDIDIV, CKCU_POS_MIDIDIV, MIDIPRE); +} +#endif + +/*********************************************************************************************************//** + * @brief Return the frequency of the different clocks. + * @param CKCU_Clk: pointer to CKCU_ClocksTypeDef structure to get the clocks frequency. + * @retval None + ************************************************************************************************************/ +void CKCU_GetClocksFrequency(CKCU_ClocksTypeDef* CKCU_Clk) +{ + u32 div; + u32 SystemCoreClockSrc = (HT_CKCU->CKST) & 7UL; +#if (!LIBCFG_NO_PLL) + CKCU_Clk->PLL_Freq = CKCU_GetPLLFrequency(); +#endif + /* Get system frequency */ + switch (SystemCoreClockSrc) + { +#if (!LIBCFG_NO_PLL) + case CKCU_SW_PLL: + CKCU_Clk->SYSCK_Freq = CKCU_Clk->PLL_Freq; + break; +#endif + case CKCU_SW_HSE: + CKCU_Clk->SYSCK_Freq = HSE_VALUE; + break; + case CKCU_SW_HSI: + CKCU_Clk->SYSCK_Freq = HSI_VALUE; + break; + #if (LIBCFG_LSE) + case CKCU_SW_LSE: + CKCU_Clk->SYSCK_Freq = LSE_VALUE; + break; + #endif + case CKCU_SW_LSI: + CKCU_Clk->SYSCK_Freq = LSI_VALUE; + break; + default: + CKCU_Clk->SYSCK_Freq = 0; + break; + } + + /* Get HCLK frequency */ + div = HT_CKCU->AHBCFGR; + CKCU_Clk->HCLK_Freq = (div >= 5) ? ((CKCU_Clk->SYSCK_Freq) >> 5) : ((CKCU_Clk->SYSCK_Freq) >> div); + + /* Get ADC frequency */ + #if (LIBCFG_NO_ADC) + #else + #if (HT32_LIB_ENABLE_GET_CK_ADC) + div = CKCU_BF_READ(HT_CKCU->APBCFGR, CKCU_MASK_ADC0DIV, CKCU_POS_ADC0DIV); + CKCU_Clk->ADC0_Freq = (div == 7) ? ((CKCU_Clk->HCLK_Freq) / 3) : ((CKCU_Clk->HCLK_Freq) >> div); + #if (LIBCFG_ADC1) + div = CKCU_BF_READ(HT_CKCU->APBCFGR, CKCU_MASK_ADC1DIV, CKCU_POS_ADC1DIV); + CKCU_Clk->ADC1_Freq = (div == 7) ? ((CKCU_Clk->HCLK_Freq) / 3) : ((CKCU_Clk->HCLK_Freq) >> div); + #endif + #endif + #endif +} + +#if (!LIBCFG_NO_PLL) +/*********************************************************************************************************//** + * @brief Return the frequency of the PLL. + * @retval PLL Frequency + ************************************************************************************************************/ +u32 CKCU_GetPLLFrequency(void) +{ + u32 pllNO, pllNF, ClockSrc; + u32 CKCU_BB_PLLSRC = CKCU_BF_READ(HT_CKCU->GCFGR, CKCU_MASK_PLLSRC, CKCU_POS_PLLSRC); + u32 CKCU_BB_PLLBYPASS = CKCU_BF_READ(HT_CKCU->PLLCR, CKCU_MASK_PLLBYPASS, CKCU_POS_PLLBYPASS); + u32 CKCU_BB_PLLEN = CKCU_BF_READ(HT_CKCU->GCCR, CKCU_MASK_PLLEN, CKCU_POS_PLLEN); + /* Get PLL frequency */ + if (CKCU_BB_PLLEN == DISABLE) + { + return 0; + } + + ClockSrc = (CKCU_BB_PLLSRC == CKCU_PLLSRC_HSE) ? HSE_VALUE : HSI_VALUE; + + #if (LIBCFG_CKCU_PLLSRCDIV) + { + u32 PllSourceClockDiv = (HT_CKCU->PLLCFGR >> 28) & 1UL; + ClockSrc = ClockSrc >> PllSourceClockDiv; + } + #endif + + if (CKCU_BB_PLLBYPASS == ENABLE) + { + return ClockSrc; + } + + pllNF = CKCU_BF_READ(HT_CKCU->PLLCFGR, CKCU_MASK_PFBD, CKCU_POS_PFBD); + if (pllNF == 0) + pllNF = 16; + + pllNO = CKCU_BF_READ(HT_CKCU->PLLCFGR, CKCU_MASK_POTD, CKCU_POS_POTD); + + return ((ClockSrc * pllNF) >> pllNO); +} +#endif + +#if (!LIBCFG_CKCU_NO_APB_PRESCALER) +/*********************************************************************************************************//** + * @brief Configure the APB peripheral prescaler. + * @param Perip: specify the APB peripheral. + * This parameter can be: + * @arg CKCU_PCLK_I2C0, CKCU_PCLK_I2C1, CKCU_PCLK_I2C2, + * CKCU_PCLK_SPI0, CKCU_PCLK_SPI1, + * CKCU_PCLK_CAN0, + * CKCU_PCLK_BFTM0, CKCU_PCLK_BFTM1, + * CKCU_PCLK_MCTM0, + * CKCU_PCLK_GPTM0, CKCU_PCLK_GPTM1, + * CKCU_PCLK_USART0, CKCU_PCLK_USART1, + * CKCU_PCLK_UART0, CKCU_PCLK_UART1, CKCU_PCLK_UART2, CKCU_PCLK_UART3 + * CKCU_PCLK_AFIO, CKCU_PCLK_EXTI, CKCU_PCLK_ADC, CKCU_PCLK_CMP, CKCU_PCLK_OPA + * CKCU_PCLK_WDTR, CKCU_PCLK_BKPR, + * CKCU_PCLK_SCI0, CKCU_PCLK_SCI1, + * CKCU_PCLK_I2S, + * CKCU_PCLK_SCTM0, CKCU_PCLK_SCTM1, CKCU_PCLK_SCTM2, CKCU_PCLK_SCTM3 + * CKCU_PCLK_PWM0, CKCU_PCLK_PWM1 + * CKCU_PCLK_AFE, CKCU_PCLK_DAC0, CKCU_PCLK_DAC1, CKCU_PCLK_MIDI + * CKCU_PCLK_LEDC, CKCU_PCLK_TKEY + * @param PCLKPrescaler: specify the value of prescaler. + * This parameter can be: + * @arg CKCU_APBCLKPRE_DIV1: specific peripheral clock = PCLK / 1 (inapplicable to BKPRCLK) + * @arg CKCU_APBCLKPRE_DIV2: specific peripheral clock = PCLK / 2 (inapplicable to BKPRCLK) + * @arg CKCU_APBCLKPRE_DIV4: specific peripheral clock = PCLK / 4 + * @arg CKCU_APBCLKPRE_DIV8: specific peripheral clock = PCLK / 8 + * @arg CKCU_APBCLKPRE_DIV16: specific peripheral clock = PCLK / 16 (BKPRCLK only) + * @arg CKCU_APBCLKPRE_DIV32: specific peripheral clock = PCLK / 32 (BKPRCLK only) + * @retval None + ************************************************************************************************************/ +void CKCU_SetPeripPrescaler(CKCU_PeripPrescaler_TypeDef Perip, CKCU_APBCLKPRE_TypeDef PCLKPrescaler) +{ + u32 *PCSR = (u32 *)((&HT_CKCU->APBPCSR0) + (Perip >> CKCU_APBPCSR_OFFSET)); + u32 Prescaler = PCLKPrescaler; + if (Perip == CKCU_PCLK_BKPR) + { + Prescaler -= 2; + } + Perip &= 0x0000001F; + CKCU_BF_WRITE(*PCSR, (3UL << Perip), Perip, Prescaler); +} +#endif + +/*********************************************************************************************************//** + * @brief Return the operating frequency of the specific APB peripheral. + * @param Perip: specify the APB peripheral. + * This parameter can be: + * @arg CKCU_PCLK_I2C0, CKCU_PCLK_I2C1, CKCU_PCLK_I2C2, + * CKCU_PCLK_SPI0, CKCU_PCLK_SPI1, + * CKCU_PCLK_CAN0, + * CKCU_PCLK_BFTM0, CKCU_PCLK_BFTM1, + * CKCU_PCLK_MCTM0, + * CKCU_PCLK_GPTM0, CKCU_PCLK_GPTM1, + * CKCU_PCLK_USART0, CKCU_PCLK_USART1, + * CKCU_PCLK_UART0, CKCU_PCLK_UART1, CKCU_PCLK_UART2, CKCU_PCLK_UART3 + * CKCU_PCLK_AFIO, CKCU_PCLK_EXTI, CKCU_PCLK_ADC0, CKCU_PCLK_ADC1, CKCU_PCLK_CMP, CKCU_PCLK_OPA + * CKCU_PCLK_WDTR, CKCU_PCLK_BKPR, + * CKCU_PCLK_SCI0, CKCU_PCLK_SCI1, + * CKCU_PCLK_I2S, + * CKCU_PCLK_PWM0, CKCU_PCLK_PWM1 + * CKCU_PCLK_AFE, CKCU_PCLK_DAC0, CKCU_PCLK_DAC1, CKCU_PCLK_MIDI + * CKCU_PCLK_LEDC, CKCU_PCLK_TKEY + * @retval Frequency in Hz + ************************************************************************************************************/ +u32 CKCU_GetPeripFrequency(CKCU_PeripPrescaler_TypeDef Perip) +{ + CKCU_ClocksTypeDef Clock; + u32 PCLKPrescaler = 0; + #if (!LIBCFG_CKCU_NO_APB_PRESCALER) + u32 *PCSR = (u32 *)(&HT_CKCU->APBPCSR0 + (Perip >> CKCU_APBPCSR_OFFSET)); + + if (Perip == CKCU_PCLK_BKPR) + { + PCLKPrescaler = 2; + } + + Perip &= 0x0000001F; + PCLKPrescaler += CKCU_BF_READ(*PCSR, (3UL << Perip), Perip); + + #endif + CKCU_GetClocksFrequency(&Clock); + return (Clock.HCLK_Freq >> (PCLKPrescaler)); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the HSE Clock Monitor function. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_CKMCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_CKMEN, CKCU_POS_CKMEN, Cmd); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the power saving wakeup RC clock. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_PSRCWKUPCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BF_WRITE(HT_CKCU->GCCR, CKCU_MASK_PSRCEN, CKCU_POS_PSRCEN, Cmd); +} + +/*********************************************************************************************************//** + * @brief Select the output clock source through the CKOUT pin. + * @param CKOUTInit: pointer to CKCU_CKOUTInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_CKOUTConfig(CKCU_CKOUTInitTypeDef *CKOUTInit) +{ + CKCU_BF_WRITE(HT_CKCU->GCFGR, CKCU_MASK_CKOUTSRC, CKCU_POS_CKOUTSRC, CKOUTInit->CKOUTSRC); +} + +/*********************************************************************************************************//** + * @brief Check whether the specific CKCU interrupt has occurred or not. + * @param CKCU_INT: specify the CKCU interrupt source. + * This parameter can be any combination of the following values: + * @arg CKCU_INT_CKS: HSE clock failure interrupt flag (NMI) + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CKCU_GetIntStatus(u32 CKCU_INT) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_INT_FLAG(CKCU_INT)); + + if (HT_CKCU->GCIR & CKCU_INT) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the CKCU interrupt flag. + * @param CKCU_INT: specify the CKCU interrupt flag to clear. + * This parameter can be any combination of the following values: + * @arg CKCU_INT_CKS : HSE clock failure interrupt flag (NMI) + * @retval None + ************************************************************************************************************/ +void CKCU_ClearIntFlag(u32 CKCU_INT) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_INT_FLAG(CKCU_INT)); + + HT_CKCU->GCIR |= CKCU_INT; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specific CKCU interrupts. + * @param CKCU_INT: specify the CKCU interrupt source which is enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CKCU_INT_CKSIE : HSE clock failure interrupt (NMI) + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_IntConfig(u32 CKCU_INT, ControlStatus Cmd) +{ + u32 tmp1 = HT_CKCU->GCIR; + + /* Check the parameters */ + Assert_Param(IS_CKCU_INT(CKCU_INT)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + tmp1 |= CKCU_INT; + } + else + { + tmp1 &= ~CKCU_INT; + } + + /* Note: CKCU interrupt flags will be cleared by writing "1" */ + tmp1 &= ~0x00000001; + HT_CKCU->GCIR = tmp1; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the AHB peripheral clock during SLEEP mode. + * @param CKCU_CLK: specify the clock which is enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CKCU_AHBEN_SLEEP_FMC, CKCU_AHBEN_SLEEP_SRAM, CKCU_AHBEN_SLEEP_BM, CKCU_AHBEN_SLEEP_APB0, + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_SleepClockConfig(u32 CKCU_CLK, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_SLEEP_AHB(CKCU_CLK)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + HT_CKCU->AHBCCR |= CKCU_CLK; + } + else + { + HT_CKCU->AHBCCR &= ~CKCU_CLK; + } +} + +#if (!LIBCFG_NO_PLL) +/*********************************************************************************************************//** + * @brief Check if PLL clock used by the specific target source or not. + * @param Target: specify the target clock. + * This parameter can be one of the following values: + * @arg CKCU_PLLST_SYSCK : Is PLL used by system clock + * @arg CKCU_PLLST_USB : Is PLL used by USB + * @arg CKCU_PLLST_REFCK : Is PLL used by CK_REF + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_IS_PLL_USED(CKCU_PLLST_TypeDef Target) +{ + if ((HT_CKCU->CKST >> CKCU_POS_PLLST) & (u32)Target) + { + return TRUE; + } + else + { + return FALSE; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Check HSI clock used by the specific target source or not. + * @param Target: specify the target clock. + * This parameter can be one of the following values: + * @arg CKCU_HSIST_SYSCK : Is HSI used by system clock + * @arg CKCU_HSIST_PLL : Is HSI used by PLL + * @arg CKCU_HSIST_CKM : Is HSI used by clock monitor + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_IS_HSI_USED(CKCU_HSIST_TypeDef Target) +{ + if ((HT_CKCU->CKST >> CKCU_POS_HSIST) & (u32)Target) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/*********************************************************************************************************//** + * @brief Check HSE clock used by the specific target source or not. + * @param Target: specify the target clock. + * This parameter can be one of the following values: + * @arg CKCU_HSEST_SYSCK : Is HSE used by system clock + * @arg CKCU_HSEST_PLL : Is HSE used by PLL + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_IS_HSE_USED(CKCU_HSEST_TypeDef Target) +{ + if ((HT_CKCU->CKST >> CKCU_POS_HSEST) & (u32)Target) + { + return TRUE; + } + else + { + return FALSE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specific debug function. + * @param CKCU_DBGx: specify the debug functions to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CKCU_DBG_SLEEP, CKCU_DBG_DEEPSLEEP1, CKCU_DBG_DEEPSLEEP2, CKCU_DBG_POWERDOWN, + * CKCU_DBG_MCTM0_HALT, + * CKCU_DBG_GPTM0_HALT, CKCU_DBG_GPTM1_HALT, + * CKCU_DBG_SCTM0_HALT, CKCU_DBG_SCTM1_HALT, CKCU_DBG_SCTM2_HALT, CKCU_DBG_SCTM3_HALT, + * CKCU_DBG_BFTM0_HALT, CKCU_DBG_BFTM1_HALT, + * CKCU_DBG_USART0_HALT, CKCU_DBG_USART1_HALT, + * CKCU_DBG_UART0_HALT, CKCU_DBG_UART1_HALT, CKCU_DBG_UART2_HALT, CKCU_DBG_UART3_HALT, + * CKCU_DBG_SPI0_HALT, CKCU_DBG_SPI1_HALT, CKCU_DBG_QSPI_HALT, + * CKCU_DBG_I2C0_HALT, CKCU_DBG_I2C1_HALT, CKCU_DBG_I2C2_HALT, + * CKCU_DBG_CAN0_HALT + * CKCU_DBG_SCI0_HALT, CKCU_DBG_SCI1_HALT, + * CKCU_DBG_WDT_HALT, + * CKCU_DBG_PWM0_HALT, CKCU_DBG_PWM1_HALT, CKCU_DBG_PWM2_HALT, + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_MCUDBGConfig(u32 CKCU_DBGx, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CKCU_DBG(CKCU_DBGx)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + HT_CKCU->MCUDBGCR |= CKCU_DBGx; + } + else + { + HT_CKCU->MCUDBGCR &= ~CKCU_DBGx; + } +} + +#if (!LIBCFG_CKCU_NO_LPCR) +/*********************************************************************************************************//** + * @brief Enable or Disable the Backup domain isolation control. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_BKISOCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + /* DISABLE: Backup domain is isolated */ + CKCU_BF_WRITE(HT_CKCU->LPCR, CKCU_MASK_BKISO, CKCU_POS_BKISO, !Cmd); +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the peripheral clock. + * @param Clock: specify the peripheral clock enable bits. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_PeripClockConfig(CKCU_PeripClockConfig_TypeDef Clock, ControlStatus Cmd) +{ + u32 uAHBCCR; + u32 uAPBCCR0; + u32 uAPBCCR1; + + uAHBCCR = HT_CKCU->AHBCCR; + uAPBCCR0 = HT_CKCU->APBCCR0; + uAPBCCR1 = HT_CKCU->APBCCR1; + + uAHBCCR &= ~(Clock.Reg[0]); + uAPBCCR0 &= ~(Clock.Reg[1]); + uAPBCCR1 &= ~(Clock.Reg[2]); + + if (Cmd != DISABLE) + { + uAHBCCR |= Clock.Reg[0]; + uAPBCCR0 |= Clock.Reg[1]; + uAPBCCR1 |= Clock.Reg[2]; + } + + HT_CKCU->AHBCCR = uAHBCCR; + HT_CKCU->APBCCR0 = uAPBCCR0; + HT_CKCU->APBCCR1 = uAPBCCR1; +} + +#if (((LIBCFG_LSE) || (LIBCFG_USBD)) && (!LIBCFG_CKCU_NO_AUTO_TRIM)) +/*********************************************************************************************************//** + * @brief Configure the reference clock of HSI auto-trim function. + * @param CLKSRC: specify the clock source. + * This parameter can be: + * @arg CKCU_ATC_LSE: LSE is selected as reference clock + * @arg CKCU_ATC_USB: USB is selected as reference clock + * @arg CKCU_ATC_CKIN: External pin (CKIN) is selected as reference clock + * @retval None + ************************************************************************************************************/ +void CKCU_HSIAutoTrimClkConfig(CKCU_ATC_TypeDef CLKSRC) +{ + CKCU_BF_WRITE(HT_CKCU->HSICR, CKCU_MASK_REFCLKSEL, CKCU_POS_REFCLKSEL, CLKSRC); +} + +#if (LIBCFG_CKCU_ATM_V01) +/*********************************************************************************************************//** + * @brief Initialize the ATC according to the specified parameters in the ATC_InitStruct. + * @param ATC_InitStruct: pointer to a CKCU_ATCInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CKCU_ATCInit(CKCU_ATCInitTypeDef* ATC_InitStruct) +{ + HT_CKCU->HSICR &= 0xFFFFFFF3; + HT_CKCU->HSICR |= (u32)ATC_InitStruct->SearchAlgorithm | (u32)ATC_InitStruct->FrqTolerance; +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the HSI auto-trim function. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CKCU_HSIAutoTrimCmd(ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + CKCU_BF_WRITE(HT_CKCU->HSICR, CKCU_MASK_TRIMEN, CKCU_POS_TRIMEN, Cmd); + CKCU_BF_WRITE(HT_CKCU->HSICR, CKCU_MASK_ATCEN, CKCU_POS_ATCEN, Cmd); +} + +/*********************************************************************************************************//** + * @brief Check Auto Trim is ready or not. + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool CKCU_HSIAutoTrimIsReady(void) +{ +#if (LIBCFG_CKCU_AUTO_TRIM_LEGACY) + u32 lower_bound, upper_bound, i; + static u32 ATCR = 0; + + if ((HT_CKCU->HSICR & (3ul << 5)) == 0) + { + lower_bound = 7812 - 19; + upper_bound = 7812 + 19; + } + else + { + lower_bound = 8000 - 20; + upper_bound = 8000 + 20; + } + + SystemCoreClockUpdate(); + for (i = SystemCoreClock / 8000; i > 0; i--){}; + ATCR += HT_CKCU->HSIATCR; + ATCR /= 2; + + if ((ATCR >= lower_bound) && (ATCR <= upper_bound)) + { + ATCR = 0; + return TRUE; + } + else + { + return FALSE; + } + +#else + return (HT_CKCU->HSICR & 0x80) ? TRUE : FALSE; +#endif +} +#endif + +#if (LIBCFG_CKCU_HSIRDYCR) +/*********************************************************************************************************//** + * @brief Set HSI Ready Counter Value. + * @param Value: 0x0~0x1F. + * @retval None + ************************************************************************************************************/ +void CKCU_Set_HSIReadyCounter(u8 Value) +{ + /* Check the parameters */ + Assert_Param(IS_COUNTER_VALUE(Value)); + + HT_CKCU->HSIRDYCR = ((HT_CKCU->HSIRDYCR) & (~(0x1F))) | Value; +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_cmp.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_cmp.c new file mode 100644 index 0000000000..10f4b9dded --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_cmp.c @@ -0,0 +1,336 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_cmp.c + * @version $Rev:: 6932 $ + * @date $Date:: 2023-05-11 #$ + * @brief This file provides all the CMP firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_cmp.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CMP CMP + * @brief CMP driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CMP_Exported_Functions CMP exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CMP0 and CMP1 peripheral registers to their default reset values. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @retval None + ************************************************************************************************************/ +void CMP_DeInit(HT_CMP_TypeDef* HT_CMPn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + if (HT_CMPn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.CMP = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Unprotect the selected comparator configuration before setting the Comparator Control Register. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @retval None + ************************************************************************************************************/ +void CMP_UnprotectConfig(HT_CMP_TypeDef* HT_CMPn) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + + /* Set the unlock code corresponding to selected comparator */ + HT_CMPn->CR = CMP_PROTECT_KEY; +} + +/*********************************************************************************************************//** + * @brief Initialize the CMP peripheral according to the specified parameters in the CMP_InitStruct. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_InitStruct: pointer to a CMP_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CMP_Init(HT_CMP_TypeDef* HT_CMPn, CMP_InitTypeDef* CMP_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_Wakeup_Set(CMP_InitStruct->CMP_Wakeup)); + Assert_Param(IS_CMP_OutputSelection(CMP_InitStruct->CMP_OutputSelection)); + Assert_Param(IS_CMP_ScalerSource(CMP_InitStruct->CMP_ScalerSource)); + Assert_Param(IS_CMP_ScalerOutputBuf(CMP_InitStruct->CMP_ScalerOutputBuf)); + Assert_Param(IS_CMP_ScalerEnable(CMP_InitStruct->CMP_ScalerEnable)); + Assert_Param(IS_CMP_CoutSynchronized(CMP_InitStruct->CMP_CoutSync)); + Assert_Param(IS_CMP_OutputPol_Set(CMP_InitStruct->CMP_OutputPol)); + #if (LIBCFG_CMP_65x_VER) + Assert_Param(IS_CMP_InputSelection(CMP_InitStruct->CMP_InputSelection)); + #endif + Assert_Param(IS_CMP_InvInputSelection(CMP_InitStruct->CMP_InvInputSelection)); + Assert_Param(IS_CMP_Hysteresis_Set(CMP_InitStruct->CMP_Hysteresis)); + Assert_Param(IS_CMP_Speed_Set(CMP_InitStruct->CMP_Speed)); + + HT_CMPn->CR |= CMP_InitStruct->CMP_Wakeup | CMP_InitStruct->CMP_OutputSelection | CMP_InitStruct->CMP_ScalerSource | \ + CMP_InitStruct->CMP_ScalerOutputBuf | CMP_InitStruct->CMP_ScalerEnable | CMP_InitStruct->CMP_CoutSync | \ + CMP_InitStruct->CMP_OutputPol | CMP_InitStruct->CMP_InvInputSelection | CMP_InitStruct->CMP_Hysteresis | \ + CMP_InitStruct->CMP_Speed; + + #if (LIBCFG_CMP_65x_VER) + HT_CMPn->CI = CMP_InitStruct->CMP_InputSelection; + #endif +} + +/*********************************************************************************************************//** + * @brief Fill each CMP_InitStruct member with its default value. + * @param CMP_InitStruct: pointer to an CMP_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CMP_StructInit(CMP_InitTypeDef* CMP_InitStruct) +{ + /* CMP_InitStruct members default value */ + CMP_InitStruct->CMP_Wakeup = CMP_WUP_DISABLE; + CMP_InitStruct->CMP_OutputSelection = CMP_TRIG_NONE; + #if (LIBCFG_CMP_NOSCALER_SRC) + CMP_InitStruct->CMP_ScalerSource = 0; + #else + CMP_InitStruct->CMP_ScalerSource = CMP_SCALER_SRC_VDDA; + #endif + CMP_InitStruct->CMP_ScalerOutputBuf = CMP_SCALER_OBUF_DISABLE; + CMP_InitStruct->CMP_ScalerEnable = CMP_SCALER_DISABLE; + CMP_InitStruct->CMP_CoutSync = CMP_ASYNC_OUTPUT; + CMP_InitStruct->CMP_OutputPol = CMP_NONINV_OUTPUT; + CMP_InitStruct->CMP_InvInputSelection = CMP_EXTERNAL_CN_IN; + CMP_InitStruct->CMP_Hysteresis = CMP_NO_HYSTERESIS; + CMP_InitStruct->CMP_Speed = CMP_LOW_SPEED; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP peripheral. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CMP_Cmd(HT_CMP_TypeDef* HT_CMPn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CMPn->CR |= CMP_ENABLE; + } + else + { + HT_CMPn->CR &= ~(u32)CMP_ENABLE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP interrupts. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_INT_x: specify the CMP interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CMP_INT_RE : CMP rising edge interrupt + * @arg CMP_INT_FE : CMP falling edge interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CMP_IntConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_INT(CMP_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CMPn->IER |= CMP_INT_x; + } + else + { + HT_CMPn->IER &= ~CMP_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified CMP edge detection. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_xE_Detect: specify the CMP edge detection that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg CMP_RE_Detect : CMP rising edge detection + * @arg CMP_FE_Detect : CMP falling edge detection + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void CMP_EdgeDetectConfig(HT_CMP_TypeDef* HT_CMPn, u32 CMP_xE_Detect, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_EdgeDetect(CMP_xE_Detect)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_CMPn->TFR = (HT_CMPn->TFR | CMP_xE_Detect) & 0xfffffffc; + } + else + { + HT_CMPn->TFR = (HT_CMPn->TFR & (~CMP_xE_Detect)) & 0xfffffffc; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified CM flag has been set. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_FLAG_x: specify the flag to be checked. + * This parameter can be any combination of the following values: + * @arg CMP_FLAG_RE : CMP rising edge flag + * @arg CMP_FLAG_FE : CMP falling edge flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CMP_GetFlagStatus(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_FLAG(CMP_FLAG_x)); + + if ((HT_CMPn->TFR & CMP_FLAG_x) != 0) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear flags of the specified CMP. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param CMP_FLAG_x: specify the flag to be checked. + * This parameter can be any combination of the following values: + * @arg CMP_FLAG_RE : CMP rising edge flag + * @arg CMP_FLAG_FE : CMP falling edge flag + * @retval None + ************************************************************************************************************/ +void CMP_ClearFlag(HT_CMP_TypeDef* HT_CMPn, u32 CMP_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_FLAG(CMP_FLAG_x)); + + /* Clear the flags */ + HT_CMPn->TFR = (HT_CMPn->TFR & 0xfffffffc) | CMP_FLAG_x; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Get the output status of the specified CMP. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus CMP_GetOutputStatus(HT_CMP_TypeDef* HT_CMPn) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + + if ((HT_CMPn-> CR & CMP_OUTPUT_HIGH) != 0) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified reference value in the data register of the scaler. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param Scaler_Value: value to be loaded in the selected data register + * @retval None + ************************************************************************************************************/ +void CMP_SetScalerValue(HT_CMP_TypeDef* HT_CMPn, u8 Scaler_Value) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_SCALER_VALUE(Scaler_Value)); + + /* Set the scaler reference value register */ + HT_CMPn->VALR = (u32)Scaler_Value; +} + +#if (LIBCFG_CMP_CO) +/*********************************************************************************************************//** + * @brief Select the synchronous source with the CMPnO signal. + * @param HT_CMPn: where HT_CMPn is the selected CMP from the CMP peripherals. + * @param uCOUTSEL: Comparator Sync Output Select. + * This parameter can be one of the following value: + * @arg CMP_SYNCOUT_CMPnO : + * @arg CMP_SYNCOUT_MCTM_CH0O : + * @arg CMP_SYNCOUT_MCTM_CH0NO : + * @arg CMP_SYNCOUT_MCTM_CH1O : + * @arg CMP_SYNCOUT_MCTM_CH1NO : + * @arg CMP_SYNCOUT_MCTM_CH2O : + * @arg CMP_SYNCOUT_MCTM_CH2NO : + * @arg CMP_SYNCOUT_MCTM_CH3O : + * @arg CMP_SYNCOUT_MCTM_CH3OB : + * @retval None + ************************************************************************************************************/ +void CMP_Output_SyncSource_Select(HT_CMP_TypeDef* HT_CMPn, CMP_SYNCOUT_Enum CMP_SYNCOUT_x) +{ + /* Check the parameters */ + Assert_Param(IS_CMP(HT_CMPn)); + Assert_Param(IS_CMP_SYNC_SOURCE(CMP_SYNCOUT_x)); + + HT_CMPn->CO = (HT_CMPn->CO & 0xFFFFFFF0) | CMP_SYNCOUT_x; +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_crc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_crc.c new file mode 100644 index 0000000000..04da829194 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_crc.c @@ -0,0 +1,190 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_crc.c + * @version $Rev:: 5483 $ + * @date $Date:: 2021-07-19 #$ + * @brief This file provides all the CRC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_crc.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CRC CRC + * @brief CRC driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup CRC_Exported_Functions CRC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the CRC peripheral registers to their default reset values. + * @param HT_CRCn: where CRC is the selected CRC peripheral. + * @retval None + ************************************************************************************************************/ +void CRC_DeInit(HT_CRC_TypeDef* HT_CRCn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + if (HT_CRCn == NULL) // Remove the compiler warning + { + } + + RSTCUReset.Bit.CRC = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the CRC peripheral according to the specified parameters in the CRC_InitStruct. + * @param HT_CRCn: Selected CRC peripheral. + * @param CRC_InitStruct: pointer to a CRC_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void CRC_Init(HT_CRC_TypeDef* HT_CRCn, CRC_InitTypeDef* CRC_InitStruct) +{ + u32 uCRValue; + HT_CRCn->SDR = CRC_InitStruct->uSeed; + switch (CRC_InitStruct->Mode) + { + case CRC_CCITT_POLY: + { + uCRValue = CRC_CCITT_POLY | CRC_NORMAL_WR | CRC_NORMAL_SUM; + break; + } + case CRC_16_POLY: + { + uCRValue = CRC_16_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM; + break; + } + case CRC_32_POLY: + { + uCRValue = CRC_32_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM | CRC_CMPL_SUM; + break; + } + case CRC_USER_DEFINE: + default: + { + uCRValue = CRC_InitStruct->uCR; + break; + } + } + + HT_CRCn->CR = uCRValue; +} + +/*********************************************************************************************************//** + * @brief Get the CRC checksum from the given data + * @param HT_CRCn: Selected CRC peripheral. + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ***********************************************************************************************************/ +u32 CRC_Process(HT_CRC_TypeDef* HT_CRCn, u8 *buffer, u32 length) +{ + while (length--) + { + wb(&HT_CRCn->DR, *buffer++); // byte write + } + + return (HT_CRCn->CSR); +} + +/*********************************************************************************************************//** + * @brief Get the CRC-CCITT checksum from the given data + * @param seed: CRC initial data + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ************************************************************************************************************/ +u16 CRC_CCITT(u16 seed, u8 *buffer, u32 length) +{ + /* CRC-CCITT poly: 0x1021 */ + HT_CRC->SDR = seed; + HT_CRC->CR = CRC_CCITT_POLY | CRC_NORMAL_WR | CRC_NORMAL_SUM; + + while (length--) + { + wb(&HT_CRC->DR, *buffer++); // byte write + } + + return (u16)(HT_CRC->CSR); +} + +/*********************************************************************************************************//** + * @brief Get the CRC-16 checksum from the given data + * @param seed: CRC initial data + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ************************************************************************************************************/ +u16 CRC_16(u16 seed, u8 *buffer, u32 length) +{ + /* CRC-16 poly: 0x8005 */ + HT_CRC->SDR = seed; + HT_CRC->CR = CRC_16_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM; + + while (length--) + { + wb(&HT_CRC->DR, *buffer++); // byte write + } + + return (u16)(HT_CRC->CSR); +} + +/*********************************************************************************************************//** + * @brief Get the CRC-32 checksum from the given data + * @param seed: CRC initial data + * @param buffer: pointer to the given data to be calculated + * @param length: data length in byte + * @retval The checksum value + ************************************************************************************************************/ +u32 CRC_32(u32 seed, u8 *buffer, u32 length) +{ + /* CRC-32 poly: 0x04C11DB7 */ + HT_CRC->SDR = seed; + HT_CRC->CR = CRC_32_POLY | CRC_BIT_RVS_WR | CRC_BIT_RVS_SUM | CRC_BYTE_RVS_SUM | CRC_CMPL_SUM; + + while (length--) + { + wb(&HT_CRC->DR, *buffer++); // byte write + } + + return (HT_CRC->CSR); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac.c new file mode 100644 index 0000000000..e209d4c1a0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac.c @@ -0,0 +1,249 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_dac.c + * @version $Rev:: 7081 $ + * @date $Date:: 2023-08-01 #$ + * @brief This file provides all the DAC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_dac.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup DAC DAC + * @brief DAC driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup DAC_Exported_Functions DAC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the HT_DACn peripheral registers to their default reset values. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @retval None + ************************************************************************************************************/ +void DAC_DeInit(HT_DAC_TypeDef* HT_DACn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + + if (HT_DACn == HT_DAC0) + { + RSTCUReset.Bit.DAC0 = 1; + } + #if (LIBCFG_DAC1) + else if (HT_DACn == HT_DAC1) + { + RSTCUReset.Bit.DAC1 = 1; + } + #endif + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure the DAC conversion mode. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @param ModeSel: specify the conversion mode + * This parameter can be one of the following values: + * @arg ASYNC_MODE : asynchronous conversion mode + * @arg SYNC_MODE : synchronous conversion mode + * @retval None + ************************************************************************************************************/ +void DAC_ModeConfig(HT_DAC_TypeDef* HT_DACn, u8 ModeSel) +{ + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + Assert_Param(IS_DAC_CONVERSION_MODE(ModeSel)); + + HT_DACn->CFGR = ModeSel; +} + +/*********************************************************************************************************//** + * @brief Configure the specified DAC channel reference voltage. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @param DAC_Ch: the DAC channel to configure +* This parameter can be one of the following values: +* @arg DAC_CH0 : DAC channel 0 +* @arg DAC_CH1 : DAC channel 1 + * @param RefSel: DAC reference voltage source + * This parameter can be one of the following values: + * @arg DAC_REFERENCE_VDDA : VDDA + * @arg DAC_REFERENCE_VREF : VREF + * @retval None + ************************************************************************************************************/ +void DAC_ReferenceConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 RefSel) +{ + HT_DACCH_TypeDef *DACnCH = (HT_DACCH_TypeDef *)((u32)&HT_DACn->DACCH0 + DAC_Ch * 8 * 4); + + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + Assert_Param(IS_DAC_CHANNEL(DAC_Ch)); + Assert_Param(IS_DAC_REFERENCE(RefSel)); + + DACnCH->CR = (DACnCH->CR & ~(3UL << 14)) | RefSel; +} + +/*********************************************************************************************************//** + * @brief Configure the specified DAC channel resolution. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @param DAC_Ch: the DAC channel to configure +* This parameter can be one of the following values: +* @arg DAC_CH0 : DAC channel 0 +* @arg DAC_CH1 : DAC channel 1 + * @param ResoSel: DAC Channel Resolution + * This parameter can be one of the following values: + * @arg DAC_RESOLUTION_8BIT : 8-bit resolution + * @arg DAC_RESOLUTION_12BIT : 12-bit resolution + * @retval None + ************************************************************************************************************/ +void DAC_ResolutionConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 ResoSel) +{ + HT_DACCH_TypeDef *DACnCH = (HT_DACCH_TypeDef *)((u32)&HT_DACn->DACCH0 + DAC_Ch * 8 * 4); + + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + Assert_Param(IS_DAC_CHANNEL(DAC_Ch)); + Assert_Param(IS_DAC_RESOLUTION(ResoSel)); + + DACnCH->CR = (DACnCH->CR & ~(1UL << 2)) | ResoSel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified DAC Channel output buffer. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @param DAC_Ch: the DAC channel to configure +* This parameter can be one of the following values: +* @arg DAC_CH0 : DAC channel 0 +* @arg DAC_CH1 : DAC channel 1 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void DAC_OutBufCmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState) +{ + HT_DACCH_TypeDef *DACnCH = (HT_DACCH_TypeDef *)((u32)&HT_DACn->DACCH0 + DAC_Ch * 8 * 4); + + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + Assert_Param(IS_DAC_CHANNEL(DAC_Ch)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + DACnCH->CR = (DACnCH->CR & ~(3UL << 6)) | (2UL << 6); + } + else + { + DACnCH->CR = (DACnCH->CR & ~(3UL << 6)) | (1UL << 6); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified DAC channel. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @param DAC_Ch: the DAC channel to configure +* This parameter can be one of the following values: +* @arg DAC_CH0 : DAC channel 0 +* @arg DAC_CH1 : DAC channel 1 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void DAC_Cmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState) +{ + HT_DACCH_TypeDef *DACnCH = (HT_DACCH_TypeDef *)((u32)&HT_DACn->DACCH0 + DAC_Ch * 8 * 4); + + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + Assert_Param(IS_DAC_CHANNEL(DAC_Ch)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SetBit_BB((u32)&DACnCH->CR, 0); + } + else + { + ResetBit_BB((u32)&DACnCH->CR, 0); + } +} + +/*********************************************************************************************************//** + * @brief Set the data holding register value for the specified DAC channel. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @param DAC_Ch: the DAC channel to configure +* This parameter can be one of the following values: +* @arg DAC_CH0 : DAC channel 0 +* @arg DAC_CH1 : DAC channel 1 + * @param Data: next conversion data. + * @retval None + ************************************************************************************************************/ +void DAC_SetData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 Data) +{ + HT_DACCH_TypeDef *DACnCH = (HT_DACCH_TypeDef *)((u32)&HT_DACn->DACCH0 + DAC_Ch * 8 * 4); + + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + Assert_Param(IS_DAC_CHANNEL(DAC_Ch)); + + DACnCH->DHR = Data; +} + +/*********************************************************************************************************//** + * @brief Return the data output register value of the specified DAC channel. + * @param HT_DACn: where HT_DACn is the selected DAC from the DAC peripherals. + * @param DAC_Ch: the DAC channel to configure +* This parameter can be one of the following values: +* @arg DAC_CH0 : DAC channel 0 +* @arg DAC_CH1 : DAC channel 1 + * @return The selected DAC channel data output value. + ************************************************************************************************************/ +u16 DAC_GetOutData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch) +{ + HT_DACCH_TypeDef *DACnCH = (HT_DACCH_TypeDef *)((u32)&HT_DACn->DACCH0 + DAC_Ch * 8 * 4); + + /* Check the parameters */ + Assert_Param(IS_DAC(HT_DACn)); + Assert_Param(IS_DAC_CHANNEL(DAC_Ch)); + + return ((u16)DACnCH->DOR); +} + + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac_dual16.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac_dual16.c new file mode 100644 index 0000000000..d08f0e0e78 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_dac_dual16.c @@ -0,0 +1,191 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_dac_dual16.c + * @version $Rev:: 7071 $ + * @date $Date:: 2023-07-28 #$ + * @brief This file provides all the DAC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_dac_dual16.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup DAC_DUAL16 DAC_DUAL16 + * @brief DAC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup DAC_DUAL16_Private_Define DAC private definitions + * @{ + */ +#define DAC_POS_RCH 0 +#define DAC_POS_LCH 8 + +#define DAC_TRIG_SOFTWARE_RESET (0x00000000) +#define DAC_TRIG_SOFTWARE_SET (0x00000001) + +#define DAC_RCH_RESET (0xFFFFFFFE) +#define DAC_LCH_RESET (0xFFFFFEFF) +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup DAC_DUAL16_Private_Macro DAC private macros + * @{ + */ +#define IS_DAC(x) (x == HT_DACDUAL16) + +#define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_CH_R) || \ + ((CHANNEL) == DAC_CH_L)) + +#define IS_DAC_DATA_SOURCE(SOURCE) (((SOURCE) == DATA_FROM_UC) || \ + ((SOURCE) == DATA_FROM_MIDI)) + +#define IS_DAC_DATA(DATA) ((DATA) <= 0xFFFF) +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup DAC_DUAL16_Exported_Functions DAC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the DAC peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void DACD16_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.DAC0 = 1; + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure the data source for the DAC channel. + * @param DACx: where DACx is the selected DAC from the DAC peripherals. + * @param DAC_CH_x: the DAC channel to configure + * This parameter can be one of the following values: + * @arg DAC_CH_R : DAC Right Channel selected + * @arg DAC_CH_L : DAC Left Channel selected + * @param DATA_FROM_x: Configure the data source. + * This parameter can be one of the following values: + * @arg DATA_FROM_UC : data and control signal from uC + * @arg DATA_FROM_MIDI : data and control signal from MIDI + * @retval None + ************************************************************************************************************/ +void DACD16_DataSourceConfig(HT_DAC_DUAL16_TypeDef* DACx, DAC_Dual16_Ch DAC_CH_x, DAC_Dual16_Source DATA_FROM_x) +{ + /* Check the parameters */ + Assert_Param(IS_DAC(DACx)); + Assert_Param(IS_DAC_CHANNEL(DAC_CH_x)); + Assert_Param(IS_DAC_DATA_SOURCE(DATA_FROM_x)); + + /* Set the select channel data source */ + if (DAC_CH_x == DAC_CH_R) + { + DACx->CR &= DAC_RCH_RESET; + DACx->CR |= DATA_FROM_x << DAC_POS_RCH; + } + else + { + DACx->CR &= DAC_LCH_RESET; + DACx->CR |= DATA_FROM_x << DAC_POS_LCH; + } +} + +/*********************************************************************************************************//** + * @brief Configure the data source for the DAC channel. + * @param DACx: where DACx is the selected DAC from the DAC peripherals. + * @param DAC_CH_x: the DAC channel to configure + * This parameter can be one of the following values: + * @arg DAC_CH_R : DAC Right Channel selected + * @arg DAC_CH_L : DAC Left Channel selected + * @param Data : Data to be loaded in the selected channel data register. + * @retval None + ************************************************************************************************************/ +void DACD16_SetChannelData(HT_DAC_DUAL16_TypeDef* DACx, DAC_Dual16_Ch DAC_CH_x, u16 Data) +{ + /* Check the parameters */ + Assert_Param(IS_DAC(DACx)); + Assert_Param(IS_DAC_CHANNEL(DAC_CH_x)); + Assert_Param(IS_DAC_DATA(Data)); + + /* Set the select channel data */ + if (DAC_CH_x == DAC_CH_R) + { + DACx->RH = Data; + } + else + { + DACx->LH = Data; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable software start of the channel conversion of the selected DAC . + * @param DACx: where DACx is the selected DAC from the DAC peripherals. + * @param DAC_CH_x: the DAC channel to configure + * This parameter can be one of the following values: + * @arg DAC_CH_R : DAC Right Channel selected + * @arg DAC_CH_L : DAC Left Channel selected + * @retval None + ************************************************************************************************************/ +void DACD16_SoftwareStartConvCmd(HT_DAC_DUAL16_TypeDef* DACx, DAC_Dual16_Ch DAC_CH_x) +{ + /* Check the parameters */ + Assert_Param(IS_DAC(DACx)); + Assert_Param(IS_DAC_CHANNEL(DAC_CH_x)); + + /* Start Conversion */ + if (DAC_CH_x == DAC_CH_R) + { + DACx->TG &= DAC_RCH_RESET ; + DACx->TG |= DAC_TRIG_SOFTWARE_SET << DAC_POS_RCH; + } + else + { + DACx->TG &= DAC_LCH_RESET; + DACx->TG |= DAC_TRIG_SOFTWARE_SET << DAC_POS_LCH; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_div.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_div.c new file mode 100644 index 0000000000..6e596480d3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_div.c @@ -0,0 +1,211 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_div.c + * @version $Rev:: 6656 $ + * @date $Date:: 2023-01-16 #$ + * @brief This file provides all the DIV firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_div.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup DIV DIV + * @brief DIV driver modules + * @{ + */ + +/* Private constants ---------------------------------------------------------------------------------------*/ +#define DIVCR_START (0x00000001) +#define DIVCR_ZEF (0x00000004) +#define DIVCR_COM (0x00000008) + +/* Global variables ----------------------------------------------------------------------------------------*/ +u32 guRemainder; + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup DIV_Exported_Functions DIV exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the DIV peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void DIV_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.DIV = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Calculate the Quotient of dividend/divisor. + * @param dividend + * @param divisor + * @retval The quotient of dividend/divisor + ************************************************************************************************************/ +s32 DIV_Div32(s32 dividend, s32 divisor) +{ + HT_DIV->DDR = dividend; + HT_DIV->DSR = divisor; + HT_DIV->CR = DIVCR_START; + + while ((HT_DIV->CR & DIVCR_COM) != DIVCR_COM); + + #if (DIV_ENABLE_DIVIDE_BY_ZERO_CHECK == 1) + { + if (DIV_IsDivByZero() == TRUE) + { + while (1); + } + } + #endif + + return (HT_DIV->QTR); +} + +/*********************************************************************************************************//** + * @brief Calculate the 32-bit unsigned of dividend/divisor. + * @param dividend + * @param divisor + * @retval The quotient of dividend/divisor + ************************************************************************************************************/ +u32 DIV_uDiv32(u32 dividend, u32 divisor) +{ + u32 uResult = 0; + guRemainder = 0; + if (dividend < divisor) + { + guRemainder = dividend; + return 0; + } + + if (dividend == divisor) + { + return 1; + } + + if (divisor & 0x80000000) + { + guRemainder = dividend - divisor; + return 1; + } + + if (dividend & 0x80000000) + { + HT_DIV->DDR = 0x7FFFFFFF; + HT_DIV->DSR = divisor; + HT_DIV->CR = DIVCR_START; + + while ((HT_DIV->CR & DIVCR_COM) != DIVCR_COM); + #if (DIV_ENABLE_DIVIDE_BY_ZERO_CHECK == 1) + { + if (DIV_IsDivByZero() == TRUE) + { + while (1); + } + } + #endif + + uResult = HT_DIV->QTR; + guRemainder = HT_DIV->RMR; + dividend -= 0x7FFFFFFF; + } + + HT_DIV->DDR = dividend; + HT_DIV->DSR = divisor; + HT_DIV->CR = DIVCR_START; + + while ((HT_DIV->CR & DIVCR_COM) != DIVCR_COM); + #if (DIV_ENABLE_DIVIDE_BY_ZERO_CHECK == 1) + { + if (DIV_IsDivByZero() == TRUE) + { + while (1); + } + } + #endif + + uResult += HT_DIV->QTR; + guRemainder += HT_DIV->RMR; + + if (guRemainder >= divisor) + { + guRemainder -= divisor; + uResult++; + } + + return uResult; +} + +/*********************************************************************************************************//** + * @brief Retuen the remainder of last unsigned dividend/divisor calculatation. + * @retval guRemainder: The remainder of dividend/divisor + ************************************************************************************************************/ +u32 DIV_uGetLastRemainder(void) +{ + return guRemainder; +} + +/*********************************************************************************************************//** + * @brief Calculate the remainder of dividend/divisor. + * @param dividend + * @param divisor + * @retval The remainder of dividend/divisor + ************************************************************************************************************/ +s32 DIV_Mod(s32 dividend, s32 divisor) +{ + DIV_Div32(dividend, divisor); + + return (HT_DIV->RMR); +} + +/*********************************************************************************************************//** + * @brief Get Divide by Zero Case. + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool DIV_IsDivByZero(void) +{ + if ((HT_DIV->CR & DIVCR_ZEF) == DIVCR_ZEF) + { + return TRUE; + } + + return FALSE; +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ebi.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ebi.c new file mode 100644 index 0000000000..2ea64162cd --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ebi.c @@ -0,0 +1,189 @@ +/********************************************************************************************************//** + * @file ht32f5xxxx_ebi.c + * @version $Rev:: 2772 $ + * @date $Date:: 2018-05-15 #$ + * @brief This file provides all the EBI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_ebi.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup EBI EBI + * @brief EBI driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup EBI_Exported_Functions EBI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitializes the EBI peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void EBI_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.EBI = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initializes the EBI peripheral according to the specified parameters in the EBI_InitStruct. + * @param EBI_InitStruct: pointer to a EBI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void EBI_Init(EBI_InitTypeDef* EBI_InitStruct) +{ + u32 tmp; + u32 bank = EBI_InitStruct->EBI_Bank; + + /* Check the parameters */ + Assert_Param(IS_EBI_BANK(EBI_InitStruct->EBI_Bank)); + Assert_Param(IS_EBI_MODE(EBI_InitStruct->EBI_Mode)); + Assert_Param(IS_EBI_IDLECYCLE(EBI_InitStruct->EBI_IdleCycle)); + Assert_Param(IS_EBI_CS_POLARITY(EBI_InitStruct->EBI_ChipSelectPolarity)); + Assert_Param(IS_EBI_ALE_POLARITY(EBI_InitStruct->EBI_AddressLatchPolarity)); + Assert_Param(IS_EBI_WE_POLARITY(EBI_InitStruct->EBI_WriteEnablePolarity)); + Assert_Param(IS_EBI_RE_POLARITY(EBI_InitStruct->EBI_ReadEnablePolarity)); + Assert_Param(IS_EBI_IDLE_CYCLE_TIME(EBI_InitStruct->EBI_IdleCycleTime)); + Assert_Param(IS_EBI_ADDRESS_SETUP_TIME(EBI_InitStruct->EBI_AddressSetupTime)); + Assert_Param(IS_EBI_ADDRESS_HOLD_TIME(EBI_InitStruct->EBI_AddressHoldTime)); + Assert_Param(IS_EBI_WRITE_SETUP_TIME(EBI_InitStruct->EBI_WriteSetupTime)); + Assert_Param(IS_EBI_WRITE_STROBE_TIME(EBI_InitStruct->EBI_WriteStrobeTime)); + Assert_Param(IS_EBI_WRITE_HOLD_TIME(EBI_InitStruct->EBI_WriteHoldTime)); + Assert_Param(IS_EBI_READ_SETUP_TIME(EBI_InitStruct->EBI_ReadSetupTime)); + Assert_Param(IS_EBI_READ_STROBE_TIME(EBI_InitStruct->EBI_ReadStrobeTime)); + + HT_EBI->ATR = EBI_InitStruct->EBI_AddressSetupTime | + (EBI_InitStruct->EBI_AddressHoldTime << 8); + HT_EBI->RTR = EBI_InitStruct->EBI_ReadSetupTime | + (EBI_InitStruct->EBI_ReadStrobeTime << 8) | + (EBI_InitStruct->EBI_ReadHoldTime << 16); + + HT_EBI->WTR = EBI_InitStruct->EBI_WriteSetupTime | + (EBI_InitStruct->EBI_WriteStrobeTime << 8) | + (EBI_InitStruct->EBI_WriteHoldTime << 16); + HT_EBI->PR = EBI_InitStruct->EBI_ChipSelectPolarity | + (EBI_InitStruct->EBI_ReadEnablePolarity << 1) | + (EBI_InitStruct->EBI_WriteEnablePolarity << 2) | + (EBI_InitStruct->EBI_AddressLatchPolarity << 3); + + + /*------------------------- EBI Control Register Configuration -------------------------------------------*/ + tmp = (3 << (bank * 2)) | (0x00001000 << bank) | + (0x00010000 << (bank * 2)) | (0x00020000 << (bank * 2)) | + (0x01000000 << bank); + tmp = HT_EBI->CR & (~tmp); + HT_EBI->CR = (EBI_InitStruct->EBI_Mode << (bank * 2)) | + (EBI_InitStruct->EBI_IdleCycle << bank) | + (EBI_InitStruct->EBI_IdleCycleTime << 28) | tmp; +} + +/*********************************************************************************************************//** + * @brief Fills each EBI_InitStruct member with its default value. + * @param EBI_InitStruct: pointer to an EBI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void EBI_StructInit(EBI_InitTypeDef* EBI_InitStruct) +{ + /* Initialize the EBI structure parameters values */ + EBI_InitStruct->EBI_Bank = EBI_BANK_0; + EBI_InitStruct->EBI_Mode = EBI_MODE_D8A8; + EBI_InitStruct->EBI_IdleCycle = EBI_IDLECYCLE_DISABLE; + EBI_InitStruct->EBI_ChipSelectPolarity = EBI_CHIPSELECTPOLARITY_LOW; + EBI_InitStruct->EBI_AddressLatchPolarity = EBI_ADDRESSLATCHPOLARITY_LOW; + EBI_InitStruct->EBI_WriteEnablePolarity = EBI_WRITEENABLEPOLARITY_LOW; + EBI_InitStruct->EBI_ReadEnablePolarity = EBI_READENABLEPOLARITY_LOW; + EBI_InitStruct->EBI_IdleCycleTime = 0xF; + EBI_InitStruct->EBI_AddressSetupTime = 0xF; + EBI_InitStruct->EBI_AddressHoldTime = 0xF; + EBI_InitStruct->EBI_WriteSetupTime = 0xF; + EBI_InitStruct->EBI_WriteStrobeTime = 0x3F; + EBI_InitStruct->EBI_WriteHoldTime = 0xF; + EBI_InitStruct->EBI_ReadSetupTime = 0xF; + EBI_InitStruct->EBI_ReadStrobeTime = 0x3F; + EBI_InitStruct->EBI_ReadHoldTime = 0xF; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the EBI peripheral. + * @param EBI_Bank: EBI Bank. + * This parameter can be one of the following values: + * @arg EBI_BANK_0 : EBI Bank 0 + * @arg EBI_BANK_1 : EBI Bank 1 + * @arg EBI_BANK_2 : EBI Bank 2 + * @arg EBI_BANK_3 : EBI Bank 3 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EBI_Cmd(u32 EBI_Bank, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EBI_BANK(EBI_Bank)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_EBI->CR |= (0x100 << EBI_Bank); + } + else + { + HT_EBI->CR &= ~(0x100 << EBI_Bank); + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified EBI busy flag has been set. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EBI_GetBusyStatus(void) +{ + if (HT_EBI->SR & 0x1) + { + return SET; + } + else + { + return RESET; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_exti.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_exti.c new file mode 100644 index 0000000000..5ecc7ef97f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_exti.c @@ -0,0 +1,548 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_exti.c + * @version $Rev:: 6745 $ + * @date $Date:: 2023-02-23 #$ + * @brief This file provides all the EXTI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_exti.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup EXTI EXTI + * @brief EXTI driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Private_Define EXTI private definitions + * @{ + */ +/* EXTI EVWUPIEN mask */ +#define WAKUPCR_EVWUPIEN_SET ((u32)0x80000000) +#define WAKUPCR_EVWUPIEN_RESET ((u32)0x7FFFFFFF) + +#if (LIBCFG_EXTI_8CH) + const IRQn_Type gEXTIn_IRQn[16] = { + EXTI0_IRQn, EXTI1_IRQn, EXTI2_IRQn, EXTI3_IRQn, + EXTI4_IRQn, EXTI5_IRQn, EXTI6_IRQn, EXTI7_IRQn, + EXTI0_IRQn, EXTI1_IRQn, EXTI2_IRQn, EXTI3_IRQn, + EXTI4_IRQn, EXTI5_IRQn, EXTI6_IRQn, EXTI7_IRQn, + }; +#else + const IRQn_Type gEXTIn_IRQn[16] = { + EXTI0_IRQn, EXTI1_IRQn, EXTI2_IRQn, EXTI3_IRQn, + EXTI4_IRQn, EXTI5_IRQn, EXTI6_IRQn, EXTI7_IRQn, + EXTI8_IRQn, EXTI9_IRQn, EXTI10_IRQn, EXTI11_IRQn, + EXTI12_IRQn, EXTI13_IRQn, EXTI14_IRQn, EXTI15_IRQn, + }; +#endif +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup EXTI_Exported_Functions EXTI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the EXTI peripheral registers. + * @param EXTI_Channel: can be 0, 1 to 15 to select the EXTI Channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval None + ************************************************************************************************************/ +void EXTI_DeInit(u32 EXTI_Channel) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + tmp = 1 << EXTI_Channel; + + *((u32 *) HT_EXTI + EXTI_Channel) = 0x0; + HT_EXTI->CR &= (~tmp); + HT_EXTI->EDGEFLGR = tmp; + HT_EXTI->EDGESR = tmp; + HT_EXTI->SSCR &= (~tmp); + HT_EXTI->WAKUPCR &= (~tmp); + HT_EXTI->WAKUPPOLR &= (~tmp); + HT_EXTI->WAKUPFLG = tmp; +} + +/*********************************************************************************************************//** + * @brief Initialize the EXTI peripheral. + * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) +{ + u32 regval; + + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_InitStruct->EXTI_Channel)); + Assert_Param(IS_EXTI_DEBOUNCE_TYPE(EXTI_InitStruct->EXTI_Debounce)); + Assert_Param(IS_EXTI_DEBOUNCE_SIZE(EXTI_InitStruct->EXTI_DebounceCnt)); + Assert_Param(IS_EXTI_INT_TYPE(EXTI_InitStruct->EXTI_IntType)); + + /* Set EXTI interrupt configuration */ + regval = (EXTI_InitStruct->EXTI_Debounce << 31) | (EXTI_InitStruct->EXTI_IntType << 28) | (EXTI_InitStruct->EXTI_DebounceCnt); + *((u32 *) HT_EXTI + EXTI_InitStruct->EXTI_Channel) = regval; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified EXTI channelx interrupts. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_IntConfig(u32 EXTI_Channel, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Configure EXTI interrupt */ + if (NewState == ENABLE) + { + HT_EXTI->CR |= (1 << EXTI_Channel); + } + else + { + HT_EXTI->CR &= ~(1 << EXTI_Channel); + } +} + +#if (LIBCFG_EXTI_DEBCNTPRE) +/*********************************************************************************************************//** + * @brief Configure the Debounce Counter prescaler. + * @param EXTI_DebCntPre_DIVn: specify the prescaler value. + * This parameter can be one of the following values: + * @arg EXTI_DBCNTPRE_DIV1 : CK_DBCNT = EXTI_PCLK / 1 + * @arg EXTI_DBCNTPRE_DIV2 : CK_DBCNT = EXTI_PCLK / 2 + * @arg EXTI_DBCNTPRE_DIV4 : CK_DBCNT = EXTI_PCLK / 4 + * @arg EXTI_DBCNTPRE_DIV8 : CK_DBCNT = EXTI_PCLK / 8 + * @arg EXTI_DBCNTPRE_DIV16 : CK_DBCNT = EXTI_PCLK / 16 + * @arg EXTI_DBCNTPRE_DIV32 : CK_DBCNT = EXTI_PCLK / 32 + * @arg EXTI_DBCNTPRE_DIV64 : CK_DBCNT = EXTI_PCLK / 64 + * @arg EXTI_DBCNTPRE_DIV128 : CK_DBCNT = EXTI_PCLK / 128 + * @retval None + ************************************************************************************************************/ +void EXTI_SetDebounceCounterPrescaler(EXTI_DebCntPre_TypeDef EXTI_DBCNTPRE_DIVn) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_DEBOUNCE_COUNTER_PRESCALER(EXTI_DBCNTPRE_DIVn)); + + HT_EXTI->CFGR0 = ((HT_EXTI->CFGR0 & 0xF8FFFFFF) | (EXTI_DBCNTPRE_DIVn << 24)); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure the EXTI channelx event wakeup function. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param EXTI_WakeUpType: determines the type of signal to trigger EXTI interrupt. + * This parameter can be one of the following values: + * @arg EXTI_WAKEUP_HIGH_LEVEL + * @arg EXTI_WAKEUP_LOW_LEVEL + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_WakeupEventConfig(u32 EXTI_Channel, u8 EXTI_WakeUpType, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_EXTI_WAKEUP_TYPE(EXTI_WakeUpType)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == ENABLE) + { + if (EXTI_WakeUpType == EXTI_WAKEUP_HIGH_LEVEL) + { + HT_EXTI->WAKUPPOLR &= ~(1 << EXTI_Channel); + } + else + { + HT_EXTI->WAKUPPOLR |= (1 << EXTI_Channel); + } + + HT_EXTI->WAKUPCR |= (1 << EXTI_Channel); + } + else + { + HT_EXTI->WAKUPCR &= ~(1 << EXTI_Channel); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the EXTI channelx event wakeup interrupt. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_WakeupEventIntConfig(ControlStatus NewState) +{ + if (NewState == ENABLE) + { + /* Set EVWUPIEN bit */ + HT_EXTI->WAKUPCR |= WAKUPCR_EVWUPIEN_SET; + } + else + { + /* Clear EVWUPIEN bit */ + HT_EXTI->WAKUPCR &= WAKUPCR_EVWUPIEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified EXTI channelx edge flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval None + ************************************************************************************************************/ +void EXTI_ClearEdgeFlag(u32 EXTI_Channel) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + tmp = 1 << EXTI_Channel; + + /* Write 1 to clear both edge detection flag */ + HT_EXTI->EDGEFLGR = tmp; + /* Write 1 to clear positive edge detection flag */ + HT_EXTI->EDGESR = tmp; +} + +/*********************************************************************************************************//** + * @brief Clear the specified EXTI channelx wakeup flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval None + ************************************************************************************************************/ +void EXTI_ClearWakeupFlag(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + /* Write 1 to clear wake up flag */ + HT_EXTI->WAKUPFLG = 1 << EXTI_Channel; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx edge flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetEdgeFlag(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + return ((HT_EXTI->EDGEFLGR & (1UL << EXTI_Channel)) ? SET : RESET); +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx edge status. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param EXTI_Edge: can be status of edge that user want to monitor. + * This parameter can be one of the following values: + * @arg EXTI_EDGE_POSITIVE + * @arg EXTI_EDGE_NEGATIVE + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetEdgeStatus(u32 EXTI_Channel, u32 EXTI_Edge) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_EXTI_EDGE(EXTI_Edge)); + + if (HT_EXTI->EDGEFLGR & (1UL << EXTI_Channel)) + { + if (GetBit_BB((u32)&HT_EXTI->EDGESR, EXTI_Channel) ^ EXTI_Edge) + { + return SET; + } + else + { + return RESET; + } + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx wakeup flag. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetWakeupFlagStatus(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + if (HT_EXTI->WAKUPFLG & (1 << EXTI_Channel)) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Activate or Deactivate an EXTI channelx interrupt by software. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void EXTI_SWIntCmd(u32 EXTI_Channel, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == ENABLE) + { + HT_EXTI->SSCR = 1 << EXTI_Channel; + } + else + { + HT_EXTI->SSCR &= ~(1 << EXTI_Channel); + } +} + +/*********************************************************************************************************//** + * @brief Get the specified EXTI channelx software command register bit. + * @param EXTI_Channel: specify the EXTI channel. + * This parameter can be one of the following values: + * @arg EXTI_CHANNEL_0 + * @arg EXTI_CHANNEL_1 + * @arg EXTI_CHANNEL_2 + * @arg EXTI_CHANNEL_3 + * @arg EXTI_CHANNEL_4 + * @arg EXTI_CHANNEL_5 + * @arg EXTI_CHANNEL_6 + * @arg EXTI_CHANNEL_7 + * @arg EXTI_CHANNEL_8 + * @arg EXTI_CHANNEL_9 + * @arg EXTI_CHANNEL_10 + * @arg EXTI_CHANNEL_11 + * @arg EXTI_CHANNEL_12 + * @arg EXTI_CHANNEL_13 + * @arg EXTI_CHANNEL_14 + * @arg EXTI_CHANNEL_15 + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus EXTI_GetSWCmdStatus(u32 EXTI_Channel) +{ + /* Check the parameters */ + Assert_Param(IS_EXTI_CHANNEL(EXTI_Channel)); + + if (HT_EXTI->SSCR & (1 << EXTI_Channel)) + { + return SET; + } + else + { + return RESET; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_flash.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_flash.c new file mode 100644 index 0000000000..18e04c04fa --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_flash.c @@ -0,0 +1,471 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_flash.c + * @version $Rev:: 6657 $ + * @date $Date:: 2023-01-16 #$ + * @brief This file provides all the FLASH firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_flash.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup FLASH FLASH + * @brief FLASH driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Private_Define FLASH private definitions + * @{ + */ + +/* Delay definition */ +#define FLASH_TIMEOUT (0x000FFFFF) + +/* FLASH OCMR */ +#define FLASH_CMD_STADNBY (0x00000000) +#define FLASH_CMD_PROGRAM (0x00000004) +#define FLASH_CMD_PAGEERASE (0x00000008) +#define FLASH_CMD_MASSERASE (0x0000000A) + +/* FLASH OPCR */ +#define FLASH_READY (0x6UL << 1) +#define FLASH_SEND_MAIN (0x00000014) + +/* FLASH CFCR */ +#define CFCR_WAIT_MASK (0xFFFFFFF8) + +#if (LIBCFG_FMC_PREFETCH) +#define FLASH_PREFETCHBUF_ON (0x00000010) +#define FLASH_PREFETCHBUF_OFF (0xFFFFFFEF) +#endif + +#if (LIBCFG_FMC_BRANCHCACHE) +#define FLASH_BRANCHCACHE_ON (0x00001000) +#define FLASH_BRANCHCACHE_OFF (0xFFFFEFFF) +#endif + +#define FLASH_CFCR_MASK (0xFFFFEFE8) +#define FLASH_PREFETCHBUF_AND_BRANCHCACHE_ON (0x00001010) +#define FLASH_PREFETCHBUF_AND_BRANCHCACHE_OFF (0xFFFFEFEF) + +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Private_Macro FLASH private macros + * @{ + */ + +#if (LIBCFG_FMC_PREFETCH) +/** + * @brief Check parameter of the FLASH wait state. + */ +#if (LIBCFG_FMC_WAIT_STATE_2) +#define IS_WAIT_STATE2(x) (x == FLASH_WAITSTATE_2) +#else +#define IS_WAIT_STATE2(x) (0) +#endif + +#define IS_FLASH_WAITSTATE(WAIT) ((WAIT == FLASH_WAITSTATE_0) || \ + (WAIT == FLASH_WAITSTATE_1) || \ + (IS_WAIT_STATE2(WAIT))) +#endif +/** + * @brief Check parameter of the FLASH vector mapping. + */ +#define IS_FLASH_VECTOR_MODE(MODE) ((MODE == FLASH_BOOT_LOADER) || \ + (MODE == FLASH_BOOT_MAIN)) +/** + * @brief Check parameter of the FLASH address. + */ +#define IS_FLASH_ADDRESS(ADDRESS) (ADDRESS < 0x20000000) /* Code 0.5GB Area */ + +/** + * @brief Check parameter of the FLASH interrupt status. + */ +#define IS_FLASH_WC_FLAG(FLAG) ((FLAG & 0x0000001F) != 0) + +/** + * @brief Check parameter of the FLASH interrupt flag. + */ +#define IS_FLASH_FLAG(FLAG) ((FLAG & 0x0003001F) != 0) + +/** + * @brief Check parameter of the FLASH interrupt. + */ +#define IS_FLASH_INT(IT) ((IT & 0x0000001F) != 0) + +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup FLASH_Exported_Functions FLASH exported functions + * @{ + */ +#if (LIBCFG_FMC_PREFETCH) +/*********************************************************************************************************//** + * @brief Configure the FLASH wait state. + * @param FLASH_WAITSTATE_n: Setting of FLASH wait state. + * This parameter can be one of the following values: + * @arg \ref FLASH_WAITSTATE_0 : zero wait state + * @arg \ref FLASH_WAITSTATE_1 : one wait state + * @arg \ref FLASH_WAITSTATE_2 : two wait state + * @retval None + ************************************************************************************************************/ +void FLASH_SetWaitState(u32 FLASH_WAITSTATE_n) +{ + u32 uCFCR; + /* Check the parameters */ + Assert_Param(IS_FLASH_WAITSTATE(FLASH_WAITSTATE_n)); + + /* !!! NOTICE !!! + Before changing wait state, both Pre-fetch function and Branch Cache function must be disabled. + */ + uCFCR = HT_FLASH->CFCR; /* Backup previous settings. */ + + /* Disable Pre-fetch function and Branch Cache. */ + HT_FLASH->CFCR = uCFCR & FLASH_PREFETCHBUF_AND_BRANCHCACHE_OFF; + /* Change wait state. */ + HT_FLASH->CFCR = (uCFCR & FLASH_CFCR_MASK) | FLASH_WAITSTATE_n; + /* Restore previous settings. */ + HT_FLASH->CFCR |= uCFCR & (FLASH_PREFETCHBUF_AND_BRANCHCACHE_ON); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable FLASH pre-fetch buffer. + * @param NewState: This parameter can be ENABLE or DISABLE + * @retval None + ************************************************************************************************************/ +void FLASH_PrefetchBufferCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_FLASH->CFCR |= FLASH_PREFETCHBUF_ON; + } + else + { + HT_FLASH->CFCR &= FLASH_PREFETCHBUF_OFF; + } +} +#endif + +#if (LIBCFG_FMC_BRANCHCACHE) +/*********************************************************************************************************//** + * @brief Enable or Disable FLASH branch cache. + * @param NewState: This parameter can be ENABLE or DISABLE + * @retval None + ************************************************************************************************************/ +void FLASH_BranchCacheCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_FLASH->CFCR |= FLASH_BRANCHCACHE_ON; + } + else + { + HT_FLASH->CFCR &= FLASH_BRANCHCACHE_OFF; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Set vector remapping mode. + * @param FLASH_BOOT_x: Booting mode. + * This parameter can be one of the following values: + * @arg \ref FLASH_BOOT_LOADER : Boot loader mode + * @arg \ref FLASH_BOOT_MAIN : Main FLASH mode + * @retval None + ************************************************************************************************************/ +void FLASH_SetRemappingMode(FLASH_Vector FLASH_BOOT_x) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_VECTOR_MODE(FLASH_BOOT_x)); + + HT_FLASH->VMCR = FLASH_BOOT_x; +} + +/*********************************************************************************************************//** + * @brief Erase a specific FLASH page. + * @param PageAddress: Address of the erased page. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * - \ref FLASH_ERR_ADDR_OUT_OF_RANGE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_ErasePage(u32 PageAddress) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_ADDRESS(PageAddress)); + + HT_FLASH->TADR = PageAddress; + HT_FLASH->OCMR = FLASH_CMD_PAGEERASE; + + return FLASH_WaitForOperationEnd(); +} + +/*********************************************************************************************************//** + * @brief Erase FLASH Option Byte page. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_EraseOptionByte(void) +{ + return FLASH_ErasePage(OPTION_BYTE_BASE); +} + +/*********************************************************************************************************//** + * @brief Erase the entire FLASH. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_MassErase(void) +{ + HT_FLASH->OCMR = FLASH_CMD_MASSERASE; + + return FLASH_WaitForOperationEnd(); +} + +/*********************************************************************************************************//** + * @brief Program one word data. + * @param Address: The specific FLASH address to be programmed. + * @param Data: The specific FLASH data to be programmed. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * - \ref FLASH_ERR_ADDR_OUT_OF_RANGE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_ProgramWordData(u32 Address, u32 Data) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_ADDRESS(Address)); + + HT_FLASH->TADR = Address; + HT_FLASH->WRDR = Data; + HT_FLASH->OCMR = FLASH_CMD_PROGRAM; + + return FLASH_WaitForOperationEnd(); +} + +/*********************************************************************************************************//** + * @brief Program FLASH Option Byte page. + * @param Option: Struct pointer of Option Bytes. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_ProgramOptionByte(FLASH_OptionByte *Option) +{ + s32 i; + u32 CP = ~(Option->MainSecurity | Option->OptionProtect << 1); + u32 checksum = 0; + + for (i = 3; i >= 0; i--) + { + FLASH_ProgramWordData(OB_PP0 + i * 4, ~(Option->WriteProtect[i])); + checksum += ~(Option->WriteProtect[i]); + } + + FLASH_ProgramWordData(OB_CP, CP); + checksum += CP; + + FLASH_ProgramWordData(OB_CHECKSUM, checksum); + + return FLASH_COMPLETE; +} + +/*********************************************************************************************************//** + * @brief Return security status of the FLASH. + * @param Option: Struct pointer of Option Bytes. + * @retval None + ************************************************************************************************************/ +void FLASH_GetOptionByteStatus(FLASH_OptionByte *Option) +{ + s32 i; + + for (i = 3; i >= 0; i--) + { + Option->WriteProtect[i] = ~HT_FLASH->PPSR[i]; + } + + Option->MainSecurity = !(HT_FLASH->CPSR & 1); + Option->OptionProtect = !((HT_FLASH->CPSR >> 1) & 1); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specific FLASH interrupts. + * @param FLASH_INT_x: The specific FLASH interrupt. + * This parameter can be any combination (|) of the following values: + * @arg \ref FLASH_INT_ORFIEN + * @arg \ref FLASH_INT_ITADIEN + * @arg \ref FLASH_INT_OBEIEN + * @arg \ref FLASH_INT_IOCMIEN + * @arg \ref FLASH_INT_OREIEN + * @arg \ref FLASH_INT_ALL + * @param Cmd: This parameter can be ENABLE or DISABLE + * @retval None + ************************************************************************************************************/ +void FLASH_IntConfig(u32 FLASH_INT_x, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_INT(FLASH_INT_x)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + { + HT_FLASH->OIER |= FLASH_INT_x; + } + else + { + HT_FLASH->OIER &= ~FLASH_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Return flag status of the FLASH interrupt. + * @param FLASH_FLAG_x: Flag of the FLASH interrupt. + * This parameter can be any combination (|) of the following values: + * @arg \ref FLASH_FLAG_OREF + * @arg \ref FLASH_FLAG_IOCMF + * @arg \ref FLASH_FLAG_OBEF + * @arg \ref FLASH_FLAG_ITADF + * @arg \ref FLASH_FLAG_ORFF + * @arg \ref FLASH_FLAG_PPEF + * @arg \ref FLASH_FLAG_RORFF + * @retval FlagStatus + * - \ref SET + * - \ref RESET + ************************************************************************************************************/ +FlagStatus FLASH_GetIntStatus(u32 FLASH_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_FLAG(FLASH_FLAG_x)); + + if ((HT_FLASH->OISR & FLASH_FLAG_x) != (u32)RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear specific interrupt flags of FLASH. + * @param FLASH_FLAG_x: interrupt flag of FLASH. + * This parameter can be any combination (|) of the following values: + * @arg \ref FLASH_FLAG_OREF + * @arg \ref FLASH_FLAG_IOCMF + * @arg \ref FLASH_FLAG_OBEF + * @arg \ref FLASH_FLAG_ITADF + * @arg \ref FLASH_FLAG_ORFF + * @retval None + ************************************************************************************************************/ +void FLASH_ClearIntFlag(u32 FLASH_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_FLASH_WC_FLAG(FLASH_FLAG_x)); + + HT_FLASH->OISR = FLASH_FLAG_x; +} + +/*********************************************************************************************************//** + * @brief Wait untill the FLASH operation has finished or time-out has occurred. + * @retval FLASH_State + * - \ref FLASH_COMPLETE + * - \ref FLASH_TIME_OUT + * - \ref FLASH_ERR_WRITE_PROTECTED + * - \ref FLASH_ERR_ADDR_OUT_OF_RANGE + * @note HSI must keep turn on when doing the Flash operation (Erase/Program). + ************************************************************************************************************/ +FLASH_State FLASH_WaitForOperationEnd(void) +{ + u32 Timeout = FLASH_TIMEOUT; + u32 Status; + + HT_FLASH->OIER |= (FLASH_INT_ITADIEN); + HT_FLASH->OPCR = FLASH_SEND_MAIN; + #if (LIBCFG_FMC_CMD_READY_WAIT) + __NOP();__NOP();__NOP();__NOP(); + #endif + + /* Waits till the FLASH operation has finished or time-out has occurred */ + while (Timeout--) + { + if ((HT_FLASH->OPCR & FLASH_READY) == FLASH_READY) + { + break; + } + } + Status = HT_FLASH->OISR; + HT_FLASH->OISR &= ~(FLASH_INT_ITADIEN); + + if (Status & FLASH_FLAG_PPEF) + { + return FLASH_ERR_WRITE_PROTECTED; + } + if (Status & FLASH_FLAG_ITADF) + { + return FLASH_ERR_ADDR_OUT_OF_RANGE; + } + if (Timeout == 0) + { + return FLASH_TIME_OUT; + } + + return FLASH_COMPLETE; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gpio.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gpio.c new file mode 100644 index 0000000000..4f778467de --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gpio.c @@ -0,0 +1,767 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_gpio.c + * @version $Rev:: 6398 $ + * @date $Date:: 2022-10-27 #$ + * @brief This file provides all the GPIO and AFIO firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_gpio.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup GPIO GPIO + * @brief GPIO driver modules + * @{ + */ + + +/* Private function prototypes -----------------------------------------------------------------------------*/ +u32 _GPIO_ClockControl(HT_GPIO_TypeDef* HT_GPIOx, ControlStatus Cmd); +u32 _AFIO_ClockControl(ControlStatus Cmd); + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Private_Macro GPIO private macros + * @{ + */ +#if (AUTO_CK_CONTROL == 1) + #define GPIO_CK_ST u32 isAlreadyOn + #define GPIO_CK_ON() (isAlreadyOn = _GPIO_ClockControl(HT_GPIOx, ENABLE)) + #define GPIO_CK_OFF() if (isAlreadyOn == FALSE) _GPIO_ClockControl(HT_GPIOx, DISABLE) + #define AFIO_CK_ST u32 isAlreadyOn + #define AFIO_CK_ON() (isAlreadyOn = _AFIO_ClockControl(ENABLE)) + #define AFIO_CK_OFF() if (isAlreadyOn == FALSE) _AFIO_ClockControl(DISABLE) +#else + #define GPIO_CK_ST + #define GPIO_CK_ON(...) + #define GPIO_CK_OFF(...) + #define AFIO_CK_ST + #define AFIO_CK_ON(...) + #define AFIO_CK_OFF(...) +#endif +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup GPIO_Exported_Functions GPIO exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitializes the GPIO peripheral registers to their default reset values. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval None + ************************************************************************************************************/ +void GPIO_DeInit(HT_GPIO_TypeDef* HT_GPIOx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + if (HT_GPIOx == HT_GPIOA) + { + RSTCUReset.Bit.PA = 1; + } + else if (HT_GPIOx == HT_GPIOB) + { + RSTCUReset.Bit.PB = 1; + } + #if (LIBCFG_GPIOC) + else if (HT_GPIOx == HT_GPIOC) + { + RSTCUReset.Bit.PC = 1; + } + #endif + #if (LIBCFG_GPIOD) + else if (HT_GPIOx == HT_GPIOD) + { + RSTCUReset.Bit.PD = 1; + } + #endif + #if (LIBCFG_GPIOE) + else if (HT_GPIOx == HT_GPIOE) + { + RSTCUReset.Bit.PE = 1; + } + #endif + #if (LIBCFG_GPIOF) + else if (HT_GPIOx == HT_GPIOF) + { + RSTCUReset.Bit.PF = 1; + } + #endif + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure the direction of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param GPIO_DIR_INorOUT: + * This parameter can be one of below: + * @arg GPIO_DIR_IN : The pins are input mode + * @arg GPIO_DIR_OUT : The pins are output mode + * @retval None + ************************************************************************************************************/ +void GPIO_DirectionConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DIR_Enum GPIO_DIR_INorOUT) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_GPIO_DIR(GPIO_DIR_INorOUT)); + + GPIO_CK_ON(); + + if (GPIO_DIR_INorOUT != GPIO_DIR_IN) + HT_GPIOx->DIRCR |= GPIO_PIN_nBITMAP; + else + HT_GPIOx->DIRCR &= ~GPIO_PIN_nBITMAP; + + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Configure the pull resistor of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param GPIO_PR_x: Selection of Pull resistor. + * This parameter can be one of below: + * @arg GPIO_PR_UP : The pins with internal pull-up resistor + * @arg GPIO_PR_DOWN : The pins with internal pull-down resistor + * @arg GPIO_PR_DISABLE : The pins without pull resistor + * @retval None + ************************************************************************************************************/ +void GPIO_PullResistorConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_PR_Enum GPIO_PR_x) +{ + u32 temp_up, temp_down; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_GPIO_PR(GPIO_PR_x)); + + GPIO_CK_ON(); + temp_up = HT_GPIOx->PUR; + temp_down = HT_GPIOx->PDR; + + #if (LIBCFG_GPIO_PR_STRONG_UP) + temp_up &= ~(GPIO_PIN_nBITMAP << 16); + #endif + temp_up &= ~GPIO_PIN_nBITMAP; + temp_down &= ~GPIO_PIN_nBITMAP; + + switch (GPIO_PR_x) + { + case GPIO_PR_UP: + temp_up |= GPIO_PIN_nBITMAP; + break; + case GPIO_PR_DOWN: + temp_down |= GPIO_PIN_nBITMAP; + break; + case GPIO_PR_DISABLE: + break; + #if (LIBCFG_GPIO_PR_STRONG_UP) + case GPIO_PR_STRONG_UP: + temp_up |= (GPIO_PIN_nBITMAP << 16); + break; + case GPIO_PR_STRONGEST_UP: + temp_up |= (GPIO_PIN_nBITMAP << 16); + temp_up |= GPIO_PIN_nBITMAP; + break; + #endif + default: + break; + } + + HT_GPIOx->PUR = temp_up; + HT_GPIOx->PDR = temp_down; + + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the input control of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void GPIO_InputConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + GPIO_CK_ON(); + if (Cmd != DISABLE) + HT_GPIOx->INER |= GPIO_PIN_nBITMAP; + else + HT_GPIOx->INER &= ~GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Select the driving current of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param GPIO_DV_nMA: + * This parameter can be one of below: + * @arg GPIO_DV_4MA : Select output driving current as 4 mA + * @arg GPIO_DV_8MA : Select output driving current as 8 mA + * @arg GPIO_DV_12MA : Select output driving current as 12 mA + * @arg GPIO_DV_16MA : Select output driving current as 16 mA + * @retval None + ************************************************************************************************************/ +void GPIO_DriveConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, GPIO_DV_Enum GPIO_DV_nMA) +{ + u32 index, temp, CurrentMode = 0, PinPosition = 0; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_GPIO_DV(GPIO_DV_nMA)); + + for (index = 0; index < 16; index++) + { + if ((GPIO_PIN_nBITMAP & 0x0001) == 1) + { + temp = index << 1; + CurrentMode |= ((u32) GPIO_DV_nMA << temp); + PinPosition |= ((u32) 0x03 << temp); + } + GPIO_PIN_nBITMAP >>= 1; + } + + GPIO_CK_ON(); + HT_GPIOx->DRVR &= ~PinPosition; + HT_GPIOx->DRVR |= CurrentMode; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the open drain function of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void GPIO_OpenDrainConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, ControlStatus Cmd) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + GPIO_CK_ON(); + if (Cmd != DISABLE) + HT_GPIOx->ODR |= GPIO_PIN_nBITMAP; + else + HT_GPIOx->ODR &= ~GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +#if LIBCFG_GPIO_SINK_CURRENT_ENHANCED +/*********************************************************************************************************//** + * @brief Select the sink current of specified GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_n: The port pins. + * This parameter can be any combination of GPIO_PIN_x. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void GPIO_SinkConfig(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + Assert_Param(IS_CONTROL_STATUS(Cmd)); + + if (Cmd != DISABLE) + HT_GPIOx->SCER |= GPIO_PIN_n; + else + HT_GPIOx->SCER &= ~GPIO_PIN_n; +} +#endif + +/*********************************************************************************************************//** + * @brief Get the input data of specified port pin. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_n: This parameter can be GPIO_PIN_x. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus GPIO_ReadInBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n) +{ + FlagStatus result; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->DINR & GPIO_PIN_n) != RESET) + result = SET; + else + result = RESET; + + GPIO_CK_OFF(); + return result; +} + +/*********************************************************************************************************//** + * @brief Get the input data of specified GPIO port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval The value of input data register. + ************************************************************************************************************/ +u16 GPIO_ReadInData(HT_GPIO_TypeDef* HT_GPIOx) +{ + u16 uValue; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + uValue = (u16)HT_GPIOx->DINR; + GPIO_CK_OFF(); + return (uValue); +} + +/*********************************************************************************************************//** + * @brief Get the output data of specified port pin. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_n: This parameter can be GPIO_PIN_x. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus GPIO_ReadOutBit(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n) +{ + FlagStatus result; + GPIO_CK_ST; + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->DOUTR & GPIO_PIN_n) != RESET) + result = SET; + else + result = RESET; + + GPIO_CK_OFF(); + return result; +} + +/*********************************************************************************************************//** + * @brief Get the output data of specified GPIO port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval The value of output data register. + ************************************************************************************************************/ +u16 GPIO_ReadOutData(HT_GPIO_TypeDef* HT_GPIOx) +{ + u32 uValue; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + uValue = (u16)HT_GPIOx->DOUTR; + GPIO_CK_OFF(); + return uValue; +} + +/*********************************************************************************************************//** + * @brief Set the selected port bits of output data. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bit to be set. + * This parameter can be any combination of GPIO_PIN_x. + * @retval None + ************************************************************************************************************/ +void GPIO_SetOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->SRR = GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Clear the selected port bits of output data. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bit to be clear. + * This parameter can be any combination of GPIO_PIN_x. + * @retval None + ************************************************************************************************************/ +void GPIO_ClearOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->RR = GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Set or Clear the selected port bits of data. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bits. + * This parameter can be any combination of GPIO_PIN_x. + * @param Status: This parameter can be SET or RESET. + * @retval None + ************************************************************************************************************/ +void GPIO_WriteOutBits(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP, FlagStatus Status) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if (Status != RESET) + HT_GPIOx->SRR = GPIO_PIN_nBITMAP; + else + HT_GPIOx->RR = GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Put data to the specified GPIO data port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param Data: Specify the data to be written to the port data register. + * @retval None + ************************************************************************************************************/ +void GPIO_WriteOutData(HT_GPIO_TypeDef* HT_GPIOx, u16 Data) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->DOUTR = Data; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Lock configuration of GPIO pins. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_nBITMAP: Specify the port bits. + * This parameter can be any combination of GPIO_PIN_x. + * @retval None + ************************************************************************************************************/ +void GPIO_PinLock(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_nBITMAP) +{ + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + HT_GPIOx->LOCKR = (u32)0x5FA00000 | GPIO_PIN_nBITMAP; + GPIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Get the lock state of specified GPIO port. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool GPIO_IsPortLocked(HT_GPIO_TypeDef* HT_GPIOx) +{ + bool result; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->LOCKR >> 16) == 0) + result = FALSE; + else + result = TRUE; + GPIO_CK_OFF(); + return result; +} + +/*********************************************************************************************************//** + * @brief Get the lock state of specified GPIO port pin. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param GPIO_PIN_n: This parameter can be GPIO_PIN_x. + * @retval TRUE or FALSE + ************************************************************************************************************/ +bool GPIO_IsPinLocked(HT_GPIO_TypeDef* HT_GPIOx, u16 GPIO_PIN_n) +{ + bool result; + GPIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO(HT_GPIOx)); + + GPIO_CK_ON(); + if ((HT_GPIOx->LOCKR & GPIO_PIN_n) == 0) + result = FALSE; + else + result = TRUE; + GPIO_CK_OFF(); + return result; +} + +#if (LIBCFG_GPIO_DISABLE_DEBUG_PORT) +/*********************************************************************************************************//** + * @brief Disable DEBUG port to prevent unexpected security lock. + * @retval None + ************************************************************************************************************/ +void GPIO_DisableDebugPort(void) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }}; + CKCUClock.Bit.PA = 1; + CKCUClock.Bit.AFIO = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + AFIO_GPxConfig(GPIO_PA, GPIO_PIN_13, AFIO_FUN_GPIO); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_13, GPIO_PR_DOWN); + + #if defined(USE_HT32F52342_52) + GPIO_InputConfig(HT_GPIOA, GPIO_PIN_13, DISABLE); + #endif + + #if 0 + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_DOWN); + GPIO_PullResistorConfig(HT_GPIOA, GPIO_PIN_12, GPIO_PR_UP); + AFIO_GPxConfig(GPIO_PA, GPIO_PIN_12, AFIO_FUN_GPIO); + #endif +} +#endif + +/*********************************************************************************************************//** + * @brief Convert HT_GPIOx to GPIO_Px + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @retval GPIO_Px: GPIO ID + ************************************************************************************************************/ +u32 GPIO_GetID(HT_GPIO_TypeDef* HT_GPIOx) +{ + // Convert 0x400B0000 ~ 0x400C6000 to 0 ~ 11 + u32 GPIO_Px = (((u32)HT_GPIOx) >> (12 + 1)) & 0x7F; + GPIO_Px -= 0x58; // 0xB0000 >> 13 = 0x58 + + return GPIO_Px; +} + +/*********************************************************************************************************//** + * @brief Deinitialize the AFIO peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void AFIO_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.AFIO = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure alternated mode of GPIO with specified pins. + * @param GPIO_Px: GPIO_PA ~ GPIO_PD. + * @param AFIO_PIN_n: This parameter can be any combination of AFIO_PIN_x. + * @param AFIO_MODE_n: This parameter can be one of the following values: + * @arg AFIO_MODE_DEFAULT : The default I/O function + * @arg AFIO_MODE_1 : Alternated mode 1 + * @arg AFIO_MODE_2 : Alternated mode 2 + * @arg AFIO_MODE_3 : Alternated mode 3 + * @arg AFIO_MODE_4 : Alternated mode 4 + * @arg AFIO_MODE_5 : Alternated mode 5 + * @arg AFIO_MODE_6 : Alternated mode 6 + * @arg AFIO_MODE_7 : Alternated mode 7 + * @arg AFIO_MODE_8 : Alternated mode 8 + * @arg AFIO_MODE_9 : Alternated mode 9 + * @arg AFIO_MODE_10 : Alternated mode 10 + * @arg AFIO_MODE_11 : Alternated mode 11 + * @arg AFIO_MODE_12 : Alternated mode 12 + * @arg AFIO_MODE_13 : Alternated mode 13 + * @arg AFIO_MODE_14 : Alternated mode 14 + * @arg AFIO_MODE_15 : Alternated mode 15 + * @retval None + ************************************************************************************************************/ +void AFIO_GPxConfig(u32 GPIO_Px, u32 AFIO_PIN_n, AFIO_MODE_Enum AFIO_MODE_n) +{ + vu32* pGPxCFGR = ((vu32*)&HT_AFIO->GPACFGR[0]) + GPIO_Px * 2; + u32 index = 0; + u32 Mask = 0, PinMode = 0; + s32 i; + AFIO_CK_ST; + + Assert_Param(IS_AFIO_MODE(AFIO_MODE_n)); + AFIO_CK_ON(); + + for (i = 0; i <= 8; i += 8) + { + Mask = 0; + PinMode = 0; + if (AFIO_PIN_n & (0x00FF << i)) + { + for (index = 0; index < 8; index++) + { + if ((AFIO_PIN_n >> index) & (0x0001 << i)) + { + Mask |= (0xF << (index * 4)); + PinMode |= (AFIO_MODE_n << (index * 4)); + } + } + *pGPxCFGR = (*pGPxCFGR & (~Mask)) | PinMode; + } + pGPxCFGR++; + } + + AFIO_CK_OFF(); +} + +/*********************************************************************************************************//** + * @brief Select the GPIO pin to be used as EXTI channel. + * @param GPIO_PIN_NUM_n: Specify the GPIO pin number to be configured. + * @param GPIO_Px: GPIO_PA ~ GPIO_PF. + * @retval None + ************************************************************************************************************/ +void AFIO_EXTISourceConfig(u32 GPIO_PIN_NUM_n, u32 GPIO_Px) +{ + u8 index = 0; + u32 tmp = 0; + AFIO_CK_ST; + + /* Check the parameters */ + Assert_Param(IS_GPIO_PORT(GPIO_Px)); + Assert_Param(IS_GPIO_PIN_NUM(GPIO_PIN_NUM_n)); + + AFIO_CK_ON(); + + if (GPIO_PIN_NUM_n > 7) + { + #if (LIBCFG_EXTI_8CH) + GPIO_Px += 8; + #else + index = 1; + #endif + GPIO_PIN_NUM_n -= 8; + } + + tmp = HT_AFIO->ESSR[index]; + tmp &= ~((u32)0x0F << (GPIO_PIN_NUM_n * 4)); + tmp |= (u32)GPIO_Px << (GPIO_PIN_NUM_n * 4); + HT_AFIO->ESSR[index] = tmp; + AFIO_CK_OFF(); +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup GPIO_Private_Functions GPIO private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Turn on/Turn off specify GPIO clock. + * @param HT_GPIOx: where HT_GPIOx is the selected GPIO from the GPIO peripherals. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval TRUE or FALSE (TRUE: already turn on, FALSE, Turn on by this call) + ***********************************************************************************************************/ +u32 _GPIO_ClockControl(HT_GPIO_TypeDef* HT_GPIOx, ControlStatus Cmd) +{ + u32 PxENStatus; + /*--------------------------------------------------------------------------------------------------------*/ + /* ((0x400Bx000 & 0x0000F000) >> 12 ) / 2 + 16 = */ + /* (0x0 ~ 0x4) + 16 = 16 ~ 20 for AHBCCR PAEN ~ PEEN bit offset */ + /*--------------------------------------------------------------------------------------------------------*/ + u32 offset = ((((u32)HT_GPIOx) & 0x0000F000) >> 12) / 2 + 16; + + PxENStatus = HT_CKCU->AHBCCR & (1 << offset); + + if (PxENStatus != 0) + { + if (Cmd == DISABLE) + { + HT_CKCU->AHBCCR &= (~(1 << offset)); + } + return TRUE; + } + + HT_CKCU->AHBCCR |= (1 << offset); + return FALSE; +} + +/*********************************************************************************************************//** + * @brief Turn on/Turn off AFIO clock. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval TRUE or FALSE (TRUE: already turn on, FALSE, Turn on by this call) + ***********************************************************************************************************/ +u32 _AFIO_ClockControl(ControlStatus Cmd) +{ + u32 AFIOENStatus; + + AFIOENStatus = HT_CKCU->APBCCR0 & (1 << 14); + + if (AFIOENStatus != 0) + { + if (Cmd == DISABLE) + { + HT_CKCU->APBCCR0 &= (~(1 << 14)); + } + return TRUE; + } + + HT_CKCU->APBCCR0 |= (1 << 14); + return FALSE; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gptm.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gptm.c new file mode 100644 index 0000000000..b824c72b16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_gptm.c @@ -0,0 +1,2 @@ +The SCTM, PWM, GPTM, and MCTM timer have similar architecture. They use the same driver, +"ht32fxxxxx_tm.c/.h" to save the code size. For those timers, please refet to the TM driver/example. diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2c.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2c.c new file mode 100644 index 0000000000..1394eb027d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2c.c @@ -0,0 +1,861 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_i2c.c + * @version $Rev:: 6398 $ + * @date $Date:: 2022-10-27 #$ + * @brief This file provides all the I2C firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_i2c.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup I2C I2C + * @brief I2C driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Private_Define I2C private definitions + * @{ + */ +/* I2C ENI2C mask */ +#define CR_ENI2C_SET ((u32)0x00000008) +#define CR_ENI2C_RESET ((u32)0xFFFFFFF7) + +/* I2C ENGC mask */ +#define CR_ENGC_SET ((u32)0x00000004) +#define CR_ENGC_RESET ((u32)0xFFFFFFFB) + +/* I2C AA mask */ +#define CR_ACK_SET ((u32)0x00000001) +#define CR_ACK_RESET ((u32)0xFFFFFFFE) + +/* I2C PDMANACK mask */ +#define CR_PDMANACK_SET ((u32)0x00000400) +#define CR_PDMANACK_RESET ((u32)0xFFFFFBFF) + +/* I2C ENTOUT mask */ +#define CR_ENTOUT_SET ((u32)0x00001000) +#define CR_ENTOUT_RESET ((u32)0xFFFFEFFF) + +/* I2C COMBFILT mask */ +#define CR_COMBFILTER_SET ((u32)0x00002000) +#define CR_COMBFILTER_RESET ((u32)0xFFFFDFFF) + +/* I2C Device Address 0 and Device Address 1 mask */ +#define ADDR_DEVADDR0_SET ((u32)0x00008000) +#define ADDR_DEVADDR0_RESET ((u32)0xFFFF7FFF) +#define ADDR_DEVADDR1_SET ((u32)0x80000000) +#define ADDR_DEVADDR1_RESET ((u32)0x7FFFFFFF) + +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup I2C_Exported_Functions I2C exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the I2C peripheral registers to their default reset values. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval None + ************************************************************************************************************/ +void I2C_DeInit(HT_I2C_TypeDef* I2Cx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + if (I2Cx == HT_I2C0) + { + RSTCUReset.Bit.I2C0 = 1; + } + #if (LIBCFG_I2C1) + else if (I2Cx == HT_I2C1) + { + RSTCUReset.Bit.I2C1 = 1; + } + #endif + #if (LIBCFG_I2C2) + else if (I2Cx == HT_I2C2) + { + RSTCUReset.Bit.I2C2 = 1; + } + #endif + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the I2Cx peripheral according to the specified parameters in the I2C_InitStruct. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void I2C_Init(HT_I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct) +{ + u32 PCLK_Freq = 0; + s32 sTmp = 0; + s32 SHPGR = 0; + s32 SLPGR = 0; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_GENERAL_CALL(I2C_InitStruct->I2C_GeneralCall)); + Assert_Param(IS_I2C_ACKNOWLEDGE_ADDRESS(I2C_InitStruct->I2C_AddressingMode)); + Assert_Param(IS_I2C_ACKNOWLEDGE(I2C_InitStruct->I2C_Acknowledge)); + Assert_Param(IS_I2C_ADDRESS(I2C_InitStruct->I2C_OwnAddress)); + Assert_Param(IS_I2C_SPEED(I2C_InitStruct->I2C_Speed)); + + #if (LIBCFG_I2C_NO_10BIT_MODE) + I2Cx->CR = (I2Cx->CR & 0xFFFFFFFA) | I2C_InitStruct->I2C_GeneralCall | I2C_InitStruct->I2C_Acknowledge; + #else + I2Cx->CR = (I2Cx->CR & 0xFFFFFF7A) | I2C_InitStruct->I2C_GeneralCall | + I2C_InitStruct->I2C_AddressingMode | I2C_InitStruct->I2C_Acknowledge; + #endif + + #if (LIBCFG_I2C_TWO_DEV_ADDR) + I2Cx->ADDR = (I2Cx->ADDR & 0xFFFF0000) | (ADDR_DEVADDR0_SET | (I2C_InitStruct->I2C_OwnAddress)); + #else + I2Cx->ADDR = I2C_InitStruct->I2C_OwnAddress; + #endif + + if (I2Cx == HT_I2C0) + PCLK_Freq = CKCU_GetPeripFrequency(CKCU_PCLK_I2C0); + #if (LIBCFG_I2C1) + else if (I2Cx == HT_I2C1) + PCLK_Freq = CKCU_GetPeripFrequency(CKCU_PCLK_I2C1); + #endif + #if (LIBCFG_I2C2) + else if (I2Cx == HT_I2C2) + PCLK_Freq = CKCU_GetPeripFrequency(CKCU_PCLK_I2C2); + #endif + + switch (I2Cx->CR & 0xC000) + { + case 0: + { + sTmp = 6; + break; + } + case 0x4000: + { + sTmp = 8; + break; + } + case 0x8000: + { + sTmp = 9; + break; + } + } + + SHPGR = (PCLK_Freq * 9)/(I2C_InitStruct->I2C_Speed * 20) - sTmp - I2C_InitStruct->I2C_SpeedOffset; + SLPGR = (PCLK_Freq * 11)/(I2C_InitStruct->I2C_Speed * 20) - sTmp - I2C_InitStruct->I2C_SpeedOffset; + + SHPGR = (SHPGR < 0) ? 0 : SHPGR; + SLPGR = (SLPGR < 0) ? 0 : SLPGR; + + I2Cx->SHPGR = SHPGR; + I2Cx->SLPGR = SLPGR; +} + +/*********************************************************************************************************//** + * @brief Fill each I2C_InitStruct member with its default value. + * @param I2C_InitStruct: pointer to an I2C_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct) +{ + I2C_InitStruct->I2C_GeneralCall = I2C_GENERALCALL_DISABLE; + I2C_InitStruct->I2C_AddressingMode = I2C_ADDRESSING_7BIT; + I2C_InitStruct->I2C_Acknowledge = I2C_ACK_DISABLE; + I2C_InitStruct->I2C_OwnAddress = 0; + I2C_InitStruct->I2C_Speed = 1000000; + I2C_InitStruct->I2C_SpeedOffset = 0; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified I2C peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_Cmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ENI2C_SET; + } + else + { + I2Cx->CR &= CR_ENI2C_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Generate STOP condition of I2C communication. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval None + ************************************************************************************************************/ +void I2C_GenerateSTOP(HT_I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + I2Cx->CR |= 0x2; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable I2C interrupts. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Int: specify if the I2C interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2C_INT_STA + * @arg I2C_INT_STO + * @arg I2C_INT_ADRS + * @arg I2C_INT_GCS + * @arg I2C_INT_ARBLOS + * @arg I2C_INT_RXNACK + * @arg I2C_INT_BUSERR + * @arg I2C_INT_TOUT + * @arg I2C_INT_RXDNE + * @arg I2C_INT_TXDE + * @arg I2C_INT_RXBF + * @arg I2C_INT_ALL + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_IntConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_INT(I2C_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->IER |= I2C_Int; + } + else + { + I2Cx->IER &= (u32)~I2C_Int; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable I2C General Call. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_GeneralCallCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ENGC_SET; + } + else + { + I2Cx->CR &= CR_ENGC_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable I2C sending acknowledgement. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_AckCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ACK_SET; + } + else + { + I2Cx->CR &= CR_ACK_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Configure own address of the specified I2C. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Address: specify own address of I2C. + * @retval None + ************************************************************************************************************/ +void I2C_SetOwnAddress(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDRESS(I2C_Address)); + + #if (LIBCFG_I2C_TWO_DEV_ADDR) + I2Cx->ADDR = (I2Cx->ADDR & 0xFFFFFF80) | (ADDR_DEVADDR0_SET | I2C_Address); + #else + I2Cx->ADDR = I2C_Address; + #endif +} + +#if (LIBCFG_I2C_TWO_DEV_ADDR) +/*********************************************************************************************************//** + * @brief Configure own address 1 of the specified I2C. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Address: specify own address 1 of I2C. + * @retval None + ************************************************************************************************************/ +void I2C_SetOwnAddress1(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDRESS(I2C_Address)); + + I2Cx->ADDR = (I2Cx->ADDR & 0xFF80FFFF) | (ADDR_DEVADDR1_SET | (I2C_Address << 16)); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable I2C own address. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param Address: specify the ADDR number. + * This parameter can be one of the following values: + * @arg I2C_DEV_ADDR_0 : + * @arg I2C_DEV_ADDR_1 : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_OwnAddressCmd(HT_I2C_TypeDef* I2Cx, I2C_ADDR_Enum Address, ControlStatus NewState) +{ + u32 value = ADDR_DEVADDR0_SET; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDR(Address)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (Address == I2C_DEV_ADDR_1) + { + value = value << 16; + } + + if (NewState != DISABLE) + { + I2Cx->ADDR |= value; + } + else + { + I2Cx->ADDR &= (~value); + } +} +#endif + +/*********************************************************************************************************//** + * @brief Start transmitting to target slave address. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Address: specify the slave address which will be transmitted. + * @param I2C_Direction: This parameter can be I2C_MASTER_READ or I2C_MASTER_WRITE. + * @retval None + ************************************************************************************************************/ +void I2C_TargetAddressConfig(HT_I2C_TypeDef* I2Cx, I2C_AddressTypeDef I2C_Address, u32 I2C_Direction) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDRESS(I2C_Address)); + Assert_Param(IS_I2C_DIRECTION(I2C_Direction)); + + /* Make sure the prior stop command has been finished */ + while (I2Cx->CR & 0x2); + + if (I2C_Direction != I2C_MASTER_WRITE) + { + I2Cx->TAR = I2C_Address | I2C_MASTER_READ; + } + else + { + I2Cx->TAR = I2C_Address | I2C_MASTER_WRITE; + } +} + +/*********************************************************************************************************//** + * @brief Send a data word through the I2Cx peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Data: Byte to be transmitted. + * @retval None + ************************************************************************************************************/ +void I2C_SendData(HT_I2C_TypeDef* I2Cx, u8 I2C_Data) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + I2Cx->DR = I2C_Data; +} + +/*********************************************************************************************************//** + * @brief Return the received data by the I2Cx peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval The value of the received data. + ************************************************************************************************************/ +u8 I2C_ReceiveData(HT_I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + return (u8)I2Cx->DR; +} + +/*********************************************************************************************************//** + * @brief Read the specified I2C register and returns its value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Register: specify the register to read. + * This parameter can be one of the following values: + * @arg I2C_REGISTER_CR : Control Register + * @arg I2C_REGISTER_IER : Interrupt Enable Register + * @arg I2C_REGISTER_ADDR : Address Register + * @arg I2C_REGISTER_SR : Status Register + * @arg I2C_REGISTER_SHPGR : SCL High Period Generation Register + * @arg I2C_REGISTER_SLPGR : SCL Low Period Generation Register + * @arg I2C_REGISTER_DR : Data Register + * @arg I2C_REGISTER_TAR : Target Register + * @retval None + ************************************************************************************************************/ +u32 I2C_ReadRegister(HT_I2C_TypeDef* I2Cx, u8 I2C_Register) +{ + vu32 tmp = 0; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_REGISTER(I2C_Register)); + + tmp = (u32)I2Cx; + tmp += I2C_Register; + return (*(u32 *)tmp); +} + +/*********************************************************************************************************//** + * @brief Check whether the specified I2C flag has been set. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Flag: specify the flag to be check. + * This parameter can be one of the following values: + * @arg I2C_FLAG_STA : I2C start condition transmitted flag (Master mode) + * @arg I2C_FLAG_STO : I2C stop condition detected flag (Slave flag) + * @arg I2C_FLAG_ADRS : I2C address flag + * @arg I2C_FLAG_GCS : I2C general call flag (Slave mode) + * @arg I2C_FLAG_ARBLOS : I2C arbitration loss flag (Master mode) + * @arg I2C_FLAG_RXNACK : I2C received not acknowledge flag + * @arg I2C_FLAG_BUSERR : I2C bus error flag + * @arg I2C_FLAG_RXDNE : I2C Rx data not empty flag + * @arg I2C_FLAG_TXDE : I2C Tx data empty flag + * @arg I2C_FLAG_RXBF : I2C RX buffer full flag + * @arg I2C_FLAG_BUSBUSY : I2C bus busy flag + * @arg I2C_FLAG_MASTER : I2C master mode flag (Master flag) + * @arg I2C_FLAG_TXNRX : I2C transmitter mode flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus I2C_GetFlagStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_FLAG(I2C_Flag)); + + if ((I2Cx->SR & I2C_Flag) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified I2C status has been active. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Status: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg I2C_MASTER_SEND_START + * @arg I2C_MASTER_RECEIVER_MODE + * @arg I2C_MASTER_TRANSMITTER_MODE + * @arg I2C_MASTER_RX_NOT_EMPTY + * @arg I2C_MASTER_RX_NOT_EMPTY_NOBUSY + * @arg I2C_MASTER_TX_EMPTY + * @arg I2C_MASTER_RX_BUFFER_FULL + * @arg I2C_SLAVE_ACK_TRANSMITTER_ADDRESS + * @arg I2C_SLAVE_ACK_RECEIVER_ADDRESS + * @arg I2C_SLAVE_ACK_GCALL_ADDRESS + * @arg I2C_SLAVE_RX_NOT_EMPTY + * @arg I2C_SLAVE_RX_NOT_EMPTY_STOP + * @arg I2C_SLAVE_TX_EMPTY + * @arg I2C_SLAVE_RX_BUFFER_FULL + * @arg I2C_SLAVE_RECEIVED_NACK + * @arg I2C_SLAVE_RECEIVED_NACK_STOP + * @arg I2C_SLAVE_STOP_DETECTED + * @retval SUCCESS or ERROR + ************************************************************************************************************/ +ErrStatus I2C_CheckStatus(HT_I2C_TypeDef* I2Cx, u32 I2C_Status) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_STATUS(I2C_Status)); + + if (I2Cx->SR == I2C_Status) + { + return (SUCCESS); + } + else + { + return (ERROR); + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified I2C flag. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Flag: specify the flag that is to be cleared. + * This parameter can be one of the following values: + * @arg I2C_FLAG_ARBLOS : I2C arbitration flag + * @arg I2C_FLAG_RXNACK : I2C receive not acknowledge flag + * @arg I2C_FLAG_BUSERR : I2C Bus error flag + * @retval None + ************************************************************************************************************/ +void I2C_ClearFlag(HT_I2C_TypeDef* I2Cx, u32 I2C_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_CLEAR_FLAG(I2C_Flag)); + + I2Cx->SR = I2C_Flag; +} + +/*********************************************************************************************************//** + * @brief Set the interval timing of the high period of the I2C clock. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_HighPeriod: specify the high period that is to be set. + * This parameter must be a number between 0 and 0xFFFF. + * @retval None + ************************************************************************************************************/ +void I2C_SetSCLHighPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_HighPeriod) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_SCL_HIGH(I2C_HighPeriod)); + + I2Cx->SHPGR = I2C_HighPeriod; +} + +/*********************************************************************************************************//** + * @brief Set the interval timing of low period of the I2C clock. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_LowPeriod: specify the low period that is to be set. + * This parameter must be a number between 0 and 0xFFFF. + * @retval None + ************************************************************************************************************/ +void I2C_SetSCLLowPeriod(HT_I2C_TypeDef* I2Cx, u32 I2C_LowPeriod) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_SCL_LOW(I2C_LowPeriod)); + + I2Cx->SLPGR = I2C_LowPeriod; +} + +#if (LIBCFG_PDMA) +/*********************************************************************************************************//** + * @brief Enable or Disable the I2Cx PDMA interface. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_PDMAREQ: specify the I2C PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2C_PDMAREQ_TX: Tx PDMA transfer request + * @arg I2C_PDMAREQ_RX: Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_PDMACmd(HT_I2C_TypeDef* I2Cx, u32 I2C_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_PDMA_REQ(I2C_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= I2C_PDMAREQ; + } + else + { + I2Cx->CR &= ~I2C_PDMAREQ; + } +} + +/*********************************************************************************************************//** + * @brief Specify that the next PDMA transfer is the last one. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_PDMANACKCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_PDMANACK_SET; + } + else + { + I2Cx->CR &= CR_PDMANACK_RESET; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified I2C time out function. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_TimeOutCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_ENTOUT_SET; + } + else + { + I2Cx->CR &= CR_ENTOUT_RESET; + } +} + +/*********************************************************************************************************//** + * @brief This function is used to set the I2C timeout value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Timeout: specify the timeout value. + * @retval None + ************************************************************************************************************/ +void I2C_SetTimeOutValue(HT_I2C_TypeDef* I2Cx, u32 I2C_Timeout) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_TIMEOUT(I2C_Timeout)); + + I2Cx->TOUT = (I2C_Timeout | (I2Cx->TOUT & 0xFFFF0000)); +} + +/*********************************************************************************************************//** + * @brief This function is used to set the prescaler of I2C timeout value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Prescaler: specify the I2C time out prescaler value. + * This parameter can be one of the following values: + * @arg I2C_PRESCALER_1 : I2C prescaler set to 1 + * @arg I2C_PRESCALER_2 : I2C prescaler set to 2 + * @arg I2C_PRESCALER_4 : I2C prescaler set to 4 + * @arg I2C_PRESCALER_16 : I2C prescaler set to 16 + * @arg I2C_PRESCALER_32 : I2C prescaler set to 32 + * @arg I2C_PRESCALER_64 : I2C prescaler set to 64 + * @arg I2C_PRESCALER_128 : I2C prescaler set to 128 + * @retval None + ************************************************************************************************************/ +void I2C_SetTimeOutPrescaler(HT_I2C_TypeDef* I2Cx, u32 I2C_Prescaler) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_PRESCALER(I2C_Prescaler)); + + I2Cx->TOUT = (I2C_Prescaler | (I2Cx->TOUT & 0x0000FFFF)); +} + +#if (LIBCFG_I2C_NO_ADDR_MASK == 0) +/*********************************************************************************************************//** + * @brief This function is used to determine the prescaler of I2C timeout value. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param I2C_Mask: specify the bit position of I2C slave address to be masked. + * This parameter can be any combination of the following values: + * @arg I2C_MASKBIT_0 : Bit 0 of I2C slave address is masked + * @arg I2C_MASKBIT_1 : Bit 1 of I2C slave address is masked + * @arg I2C_MASKBIT_2 : Bit 2 of I2C slave address is masked + * @arg I2C_MASKBIT_3 : Bit 3 of I2C slave address is masked + * @arg I2C_MASKBIT_4 : Bit 4 of I2C slave address is masked + * @arg I2C_MASKBIT_5 : Bit 5 of I2C slave address is masked + * @arg I2C_MASKBIT_6 : Bit 6 of I2C slave address is masked + * @arg I2C_MASKBIT_7 : Bit 7 of I2C slave address is masked + * @arg I2C_MASKBIT_8 : Bit 8 of I2C slave address is masked + * @arg I2C_MASKBIT_9 : Bit 9 of I2C slave address is masked + * @retval None + ************************************************************************************************************/ +void I2C_AddressMaskConfig(HT_I2C_TypeDef* I2Cx, u32 I2C_Mask) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_ADDRESS_MASK(I2C_Mask)); + + I2Cx->ADDMR = I2C_Mask; +} +#endif + +/*********************************************************************************************************//** + * @brief Return the received address by the I2Cx peripheral. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @retval The value of the received address. + ************************************************************************************************************/ +u16 I2C_GetAddressBuffer(HT_I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + + return ((u16)I2Cx->ADDSR); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the combinational filter. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2C_CombFilterCmd(HT_I2C_TypeDef* I2Cx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + I2Cx->CR |= CR_COMBFILTER_SET; + } + else + { + I2Cx->CR &= CR_COMBFILTER_RESET; + } +} + +/*********************************************************************************************************//** + * @brief This function is used to determine the filter glitch width of 0~2 PCLK. + * @param I2Cx: where I2Cx is the selected I2C from the I2C peripherals. + * @param Seq_Filter_Select: specify the glitch width of 0~2 PCLK. + * This parameter can be any combination of the following values: + * @arg SEQ_FILTER_DISABLE : sequential filter is disabled + * @arg SEQ_FILTER_1_PCLK : filter glitch width of 1 PCLK + * @arg SEQ_FILTER_2_PCLK : filter glitch width of 2 PCLK + * @retval None + ************************************************************************************************************/ +void I2C_SequentialFilterConfig(HT_I2C_TypeDef* I2Cx, u32 Seq_Filter_Select) +{ + u32 SHPGR = I2Cx->SHPGR; + u32 SLPGR = I2Cx->SLPGR; + + /* Check the parameters */ + Assert_Param(IS_I2C(I2Cx)); + Assert_Param(IS_I2C_SEQ_FILTER_MASK(Seq_Filter_Select)); + + switch (I2Cx->CR & 0xC000) + { + case 0: + if (Seq_Filter_Select == SEQ_FILTER_1_PCLK) + { + if (SHPGR >= 2) + { + SHPGR -= 2; + SLPGR -= 2; + } + } + else if (Seq_Filter_Select == SEQ_FILTER_2_PCLK) + { + if (SHPGR >= 2) + { + SHPGR -= 3; + SLPGR -= 3; + } + } + break; + + case 0x4000: + if (Seq_Filter_Select == SEQ_FILTER_DISABLE) + { + SHPGR += 2; + SLPGR += 2; + } + else if (Seq_Filter_Select == SEQ_FILTER_2_PCLK) + { + if (SHPGR >= 1) + { + SHPGR -= 1; + SLPGR -= 1; + } + } + break; + + case 0x8000: + if (Seq_Filter_Select == SEQ_FILTER_DISABLE) + { + SHPGR += 3; + SLPGR += 3; + } + else if (Seq_Filter_Select == SEQ_FILTER_1_PCLK) + { + SHPGR += 1; + SLPGR += 1; + } + break; + + default: + break; + } + + I2Cx->SHPGR = SHPGR; + I2Cx->SLPGR = SLPGR; + I2Cx->CR = (I2Cx->CR & 0x3FFF) | Seq_Filter_Select; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2s.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2s.c new file mode 100644 index 0000000000..4ca971eed1 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_i2s.c @@ -0,0 +1,336 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_i2s.c + * @version $Rev:: 4829 $ + * @date $Date:: 2020-07-23 #$ + * @brief This file provides all the I2S firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_i2s.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup I2S I2S + * @brief I2S driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Private_Define I2S private definitions + * @{ + */ +#define I2S_EN (1UL) +#define MCLK_OP_EN (1UL << 9) +#define TX_MUTE_EN (1UL << 12) +#define CLK_DIV_EN (1UL << 15) +#define BCLK_INV_EN (1UL << 18) +#define MCLK_INV_EN (1UL << 19) + +#define I2S_SLAVE (1UL << 3) +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup I2S_Exported_Functions I2S exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the I2S peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void I2S_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.I2S = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the I2S peripheral according to the specified parameters in the I2S_InitStruct. + * @param I2S_InitStruct: pointer to a I2S_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void I2S_Init(I2S_InitTypeDef* I2S_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode)); + Assert_Param(IS_I2S_FORMAT(I2S_InitStruct->I2S_Format)); + Assert_Param(IS_I2S_WORD_WIDTH(I2S_InitStruct->I2S_WordWidth)); + Assert_Param(IS_I2S_MCLK_DIV(I2S_InitStruct->I2S_X_Div, I2S_InitStruct->I2S_Y_Div)); + Assert_Param(IS_I2S_BCLK_DIV(I2S_InitStruct->I2S_N_Div)); + + HT_I2S->CR = I2S_InitStruct->I2S_Mode | I2S_InitStruct->I2S_Format | I2S_InitStruct->I2S_WordWidth; + + if (I2S_InitStruct->I2S_BclkInv == ENABLE) + { + HT_I2S->CR |= BCLK_INV_EN; + } + + if (I2S_InitStruct->I2S_MclkInv == ENABLE) + { + HT_I2S->CR |= MCLK_INV_EN; + } + + if ((I2S_InitStruct->I2S_Mode & I2S_SLAVE) == RESET) + { + HT_I2S->CDR = (I2S_InitStruct->I2S_N_Div << 16) | (I2S_InitStruct->I2S_X_Div << 8) | + (I2S_InitStruct->I2S_Y_Div); + HT_I2S->CR |= CLK_DIV_EN; + while (I2S_GetFlagStatus(I2S_FLAG_CLK_RDY) == RESET); + + if (I2S_InitStruct->I2S_MclkOut == ENABLE) + { + HT_I2S->CR |= MCLK_OP_EN; + } + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the I2S peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_Cmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->CR |= I2S_EN; + } + else + { + HT_I2S->CR &= ~I2S_EN; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the Tx mute for the I2S peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_TxMuteCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->CR |= TX_MUTE_EN; + } + else + { + HT_I2S->CR &= ~TX_MUTE_EN; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the I2S PDMA interface. + * @param I2S_PDMAREQ: specify the I2S PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2S_PDMAREQ_TX : Tx PDMA transfer request + * @arg I2S_PDMAREQ_RX : Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_PDMACmd(u32 I2S_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_PDMA_REQ(I2S_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->CR |= I2S_PDMAREQ; + } + else + { + HT_I2S->CR &= I2S_PDMAREQ; + } +} + +/*********************************************************************************************************//** + * @brief Reset the specified I2S FIFO. + * @param I2S_FIFO: specify the FIFO that is to be reset. + * This parameter can be any combination of the following values: + * @arg I2S_TX_FIFO : I2S Tx FIFO + * @arg I2S_RX_FIFO : I2S Rx FIFO + * @retval None + ************************************************************************************************************/ +void I2S_FIFOReset(u32 I2S_FIFO) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_TWO_FIFO(I2S_FIFO)); + + HT_I2S->FCR |= I2S_FIFO; +} + +/*********************************************************************************************************//** + * @brief Set the trigger level of specified I2S FIFO. + * @param I2S_FIFO: specify the FIFO that is to be set. + * This parameter can be any combination of the following values: + * @arg I2S_TX_FIFO : I2S Tx FIFO + * @arg I2S_RX_FIFO : I2S Rx FIFO + * @param I2S_FIFOLevel: Specify the FIFO trigger level. + * @retval None + ************************************************************************************************************/ +void I2S_FIFOTrigLevelConfig(u32 I2S_FIFO, u32 I2S_FIFOLevel) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_TWO_FIFO(I2S_FIFO)); + Assert_Param(IS_I2S_FIFO_LEVEL(I2S_FIFOLevel)); + + if (I2S_FIFO == I2S_TX_FIFO) + { + HT_I2S->FCR = ((HT_I2S->FCR & (~0x0000000F)) | I2S_FIFOLevel); + } + else + { + HT_I2S->FCR = ((HT_I2S->FCR & (~0x000000F0)) | (I2S_FIFOLevel << 4)); + } +} + +/*********************************************************************************************************//** + * @brief Return the status of specified I2S FIFO. + * @param I2S_FIFO: specify the FIFO that is to be checked. + * This parameter can be one of the following values: + * @arg I2S_TX_FIFO : I2S Tx FIFO + * @arg I2S_RX_FIFO : I2S Rx FIFO + * @retval The number of data in specified I2S FIFO. + ************************************************************************************************************/ +u8 I2S_GetFIFOStatus(u32 I2S_FIFO) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_ONE_FIFO(I2S_FIFO)); + + if (I2S_FIFO == I2S_TX_FIFO) + { + return (u8)((HT_I2S->SR >> 24) & 0x0F); + } + else + { + return (u8)(HT_I2S->SR >> 28); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the I2S interrupt. + * @param I2S_Int: specify if the I2S interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2S_INT_TXFIFO_TRI : I2S Tx FIFO trigger level interrupt + * @arg I2S_INT_TXFIFO_UF : I2S Rx FIFO underflow interrupt + * @arg I2S_INT_TXFIFO_OV : I2S Tx FIFO overflow interrupt + * @arg I2S_INT_RXFIFO_TRI : I2S Rx FIFO trigger level interrupt + * @arg I2S_INT_RXFIFO_UV : I2S Rx FIFO underflow interrupt + * @arg I2S_INT_RXFIFO_OV : I2S Rx FIFO overflow interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void I2S_IntConfig(u32 I2S_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_INT(I2S_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_I2S->IER |= I2S_Int; + } + else + { + HT_I2S->IER &= ~I2S_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified I2S flag has been set or not. + * @param I2S_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg I2S_FLAG_TXFIFO_TRI : I2S Tx FIFO trigger level flag + * @arg I2S_FLAG_TXFIFO_UDF : I2S Tx FIFO underflow flag + * @arg I2S_FLAG_TXFIFO_OVF : I2S Tx FIFO overflow flag + * @arg I2S_FLAG_TXFIFO_EMP : I2S Tx FIFO empty flag + * @arg I2S_FLAG_TXFIFO_FUL : I2S Tx FIFO full flag + * @arg I2S_FLAG_RXFIFO_TRI : I2S Rx FIFO trigger level flag + * @arg I2S_FLAG_RXFIFO_UDF : I2S Rx FIFO underflow flag + * @arg I2S_FLAG_RXFIFO_OVF : I2S Rx FIFO overflow flag + * @arg I2S_FLAG_RXFIFO_EMP : I2S Rx FIFO empty flag + * @arg I2S_FLAG_RXFIFO_FUL : I2S Rx FIFO full flag + * @arg I2S_FLAG_RIGHT_CH : I2S right channel flag + * @arg I2S_FLAG_TX_BUSY : I2S Tx busy flag + * @arg I2S_FLAG_CLK_RDY : I2S clock ready flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus I2S_GetFlagStatus(u32 I2S_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_FLAG(I2S_Flag)); + + if (HT_I2S->SR & I2S_Flag) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified I2S flag. + * @param I2S_Flag: specify the flag that is to be cleared. + * This parameter can be any combination of the following values: + * @arg I2S_FLAG_TXFIFO_TRI : I2S Tx FIFO trigger level flag + * @arg I2S_FLAG_TXFIFO_UV : I2S Tx FIFO underflow flag + * @arg I2S_FLAG_TXFIFO_OV : I2S Tx FIFO overflow flag + * @arg I2S_FLAG_RXFIFO_TRI : I2S Rx FIFO trigger level flag + * @arg I2S_FLAG_RXFIFO_UV : I2S Rx FIFO underflow flag + * @arg I2S_FLAG_RXFIFO_OV : I2S Rx FIFO overflow flag + * @retval None + ************************************************************************************************************/ +void I2S_ClearFlag(u32 I2S_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_I2S_FLAG_CLEAR(I2S_Flag)); + + HT_I2S->SR = I2S_Flag; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lcd.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lcd.c new file mode 100644 index 0000000000..eb61db9359 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lcd.c @@ -0,0 +1,577 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_lcd.c + * @version $Rev:: 1704 $ + * @date $Date:: 2017-08-17 #$ + * @brief This file provides all the LCD firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_lcd.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup LCD LCD + * @brief LCD driver modules + * @{ + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup LCD_Exported_Functions LCD exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the LCD peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void LCD_DriverDeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + RSTCUReset.Bit.LCD = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initializes the LCD peripheral according to the specified parameters in the LCD_InitStruct. + * @param LCD_InitStruct: pointer to a LCD_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void LCD_DriverInit(LCD_InitTypeDef* LCD_InitStruct) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD control register. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->FCR = (u32)(LCD_InitStruct->LCD_Prescaler) | + (u32)(LCD_InitStruct->LCD_Divider); + + HT_LCD->CR = (u32)(LCD_InitStruct->LCD_Waveform) | + (u32)(LCD_InitStruct->LCD_Bias) | + (u32)(LCD_InitStruct->LCD_Duty) | + (u32)(LCD_InitStruct->LCD_VoltageSource); +} + +/*********************************************************************************************************//** + * @brief Configure the MCONT mask time. + * @param Sel: specify the mask time. + * This parameter can be: + * @arg LCD_MaskTime_25ns : MCONT mask time is 25 ns + * @arg LCD_MaskTime_40ns : MCONT mask time is 40 ns + * @retval None + ************************************************************************************************************/ +void LCD_MaskTimeConfig(LCD_MaskTime_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD control register. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 24)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable half of the low value resistor (HRLEN). + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void LCD_HalfRLCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_LCD->CR |= (1ul << 15); + } + else + { + HT_LCD->CR &= ~(1ul << 15); + } +} + +/*********************************************************************************************************//** + * @brief Configure the STATIC switch. + * @param Sel: specify the STATIC switch status. + * This parameter can be: + * @arg LCD_Static_Switch_Open : STATIC switch is open during dead time. + * @arg LCD_Static_Switch_close : STATIC switch is closed during dead time. + * @retval None + ************************************************************************************************************/ +void LCD_StaticSwitchConfig(LCD_StaticSwitch_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD control register. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 14)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure MuxCOM7 to be COM7 or SEGx. + * @param Sel: Specify the MuxSEG. + * This parameter can be one of the following values: + * @arg LCD_MUXCOM7_IS_COM7 : + * @arg LCD_MUXCOM7_IS_SEGx :(52341: SEG28, 57352: SEG36) + * @retval None + ************************************************************************************************************/ +void LCD_MuxCOM7Config(LCD_MUXCOM7_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD control register. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 11)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure MuxCOM6 to be COM6 or SEGx. + * @param Sel: Specify the MuxSEG. + * This parameter can be one of the following values: + * @arg LCD_MUXCOM7_IS_COM6 : + * @arg LCD_MUXCOM7_IS_SEGx :(52341: SEG27, 57352: SEG35) + * @retval None + ************************************************************************************************************/ +void LCD_MuxCOM6Config(LCD_MUXCOM6_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 10)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure MuxCOM5 to be COM5 or SEGx. + * @param Sel: Specify the MuxSEG. + * This parameter can be one of the following values: + * @arg LCD_MUXCOM7_IS_COM5 : + * @arg LCD_MUXCOM7_IS_SEGx :(52341: SEG26, 57352: SEG34) + * @retval None + ************************************************************************************************************/ +void LCD_MuxCOM5Config(LCD_MUXCOM5_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 9)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure MuxCOM4 to be COM4 or SEGx. + * @param Sel: Specify the MuxSEG. + * This parameter can be one of the following values: + * @arg LCD_MUXCOM7_IS_COM4 : + * @arg LCD_MUXCOM7_IS_SEGx :(52341: SEG25, 57352: SEG33) + * @retval None + ************************************************************************************************************/ +void LCD_MuxCOM4Config(LCD_MUXCOM4_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 8)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD waveform type. + * @param Sel: specify the LCD waveform type. + * This parameter can be one of the following values: + * @arg LCD_Type_A_Waveform : Type A waveform + * @arg LCD_Type_B_Waveform : Type B waveform + * @retval None + ************************************************************************************************************/ +void LCD_WaveformConfig(LCD_Waveform_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 7)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure LCD Bias Selector. + * @param Sel: Specify LCD Bias Selector. + * This parameter can be one of the following values: + * @arg LCD_Bias_1_4 : Bias 1/4 + * @arg LCD_Bias_1_2 : Bias 1/2 + * @arg LCD_Bias_1_3 : Bias 1/3 + * @arg LCD_Bias_Static : STATIC + * @retval None + ************************************************************************************************************/ +void LCD_BiasConfig(LCD_Bias_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(3ul << 5)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD Duty Selection. + * @param Sel: Specify LCD Duty select. + * This parameter can be one of the following values: + * @arg LCD_Duty_Static : Static duty + * @arg LCD_Duty_1_2 : 1/2 duty + * @arg LCD_Duty_1_3 : 1/3 duty + * @arg LCD_Duty_1_4 : 1/4 duty + * @arg LCD_Duty_1_6 : 1/6 duty + * @arg LCD_Duty_1_8 : 1/8 duty + ************************************************************************************************************/ +void LCD_DutyConfig(LCD_Duty_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(7ul << 2)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD Power Selection. + * @param Sel: Specify LCD Power select. + * This parameter can be one of the following values: + * @arg LCD_VoltageSource_External : External VLCD + * @arg LCD_VoltageSource_Internal : Internal charge pump + * @retval None + ************************************************************************************************************/ +void LCD_VoltageSourceConfig(LCD_VoltageSource_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + HT_LCD->CR = (HT_LCD->CR & ~(1ul << 1)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the LCD peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void LCD_Cmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_LCD->CR |= (1ul << 0); + } + else + { + HT_LCD->CR &= ~(1ul << 0); + } +} + +/*********************************************************************************************************//** + * @brief Configure the LCD 16-bit prescaler. + * @param Sel: specify the LCD 16-bit prescaler setting. + * This parameter can be one of the following values: + * @arg LCD_Prescaler_1 : CK_PS = CK_LCD / 1 + * @arg LCD_Prescaler_2 : CK_PS = CK_LCD / 2 + * @arg LCD_Prescaler_4 : CK_PS = CK_LCD / 4 + * @arg LCD_Prescaler_8 : CK_PS = CK_LCD / 8 + * @arg LCD_Prescaler_16 : CK_PS = CK_LCD / 16 + * @arg LCD_Prescaler_32 : CK_PS = CK_LCD / 32 + * @arg LCD_Prescaler_64 : CK_PS = CK_LCD / 64 + * @arg LCD_Prescaler_128 : CK_PS = CK_LCD / 128 + * @arg LCD_Prescaler_256 : CK_PS = CK_LCD / 256 + * @arg LCD_Prescaler_512 : CK_PS = CK_LCD / 512 + * @arg LCD_Prescaler_1024 : CK_PS = CK_LCD / 1024 + * @arg LCD_Prescaler_2048 : CK_PS = CK_LCD / 2048 + * @arg LCD_Prescaler_4096 : CK_PS = CK_LCD / 4096 + * @arg LCD_Prescaler_8192 : CK_PS = CK_LCD / 8192 + * @arg LCD_Prescaler_16384 : CK_PS = CK_LCD / 16384 + * @arg LCD_Prescaler_32768 : CK_PS = CK_LCD / 32768 + * @retval None + ************************************************************************************************************/ +void LCD_PrescalerConfig(LCD_Prescaler_Enum Sel) +{ + while (LCD_GetFlagStatus(LCD_FLAG_FCRSF) == SET); + HT_LCD->FCR = (HT_LCD->FCR & ~(15ul << 22)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD clock divider. + * @param Sel: specify the LCD clock divider setting. + * This parameter can be one of the following values: + * @arg LCD_Divider_16 : CK_DIV = CK_PS / 16 + * @arg LCD_Divider_17 : CK_DIV = CK_PS / 17 + * @arg LCD_Divider_18 : CK_DIV = CK_PS / 18 + * @arg LCD_Divider_19 : CK_DIV = CK_PS / 19 + * @arg LCD_Divider_20 : CK_DIV = CK_PS / 20 + * @arg LCD_Divider_21 : CK_DIV = CK_PS / 21 + * @arg LCD_Divider_22 : CK_DIV = CK_PS / 22 + * @arg LCD_Divider_23 : CK_DIV = CK_PS / 23 + * @arg LCD_Divider_24 : CK_DIV = CK_PS / 24 + * @arg LCD_Divider_25 : CK_DIV = CK_PS / 25 + * @arg LCD_Divider_26 : CK_DIV = CK_PS / 26 + * @arg LCD_Divider_27 : CK_DIV = CK_PS / 27 + * @arg LCD_Divider_28 : CK_DIV = CK_PS / 28 + * @arg LCD_Divider_29 : CK_DIV = CK_PS / 29 + * @arg LCD_Divider_30 : CK_DIV = CK_PS / 30 + * @arg LCD_Divider_31 : CK_DIV = CK_PS / 31 + * @retval None + ************************************************************************************************************/ +void LCD_DividerConfig(LCD_Divider_Enum Sel) +{ + while (LCD_GetFlagStatus(LCD_FLAG_FCRSF) == SET); + HT_LCD->FCR = (HT_LCD->FCR & ~(15ul << 18)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD Blink Mode Selection. + * @param Sel: Specify LCD Blink Mode Selection. + * This parameter can be one of the following values: + * @arg LCD_BlinkMode_Off : Blink inactive + * @arg LCD_BlinkMode_SEG0_COM0 : SEG0 on COM0 blink + * @arg LCD_BlinkMode_SEG0_AllCOM : SEG0 on All COM blink + * @arg LCD_BlinkMode_AllSEG_AllCOM : All SEG on All COM blink + ************************************************************************************************************/ +void LCD_BlinkModeConfig(LCD_BlinkMode_Enum Sel) +{ + while (LCD_GetFlagStatus(LCD_FLAG_FCRSF) == SET); + HT_LCD->FCR = (HT_LCD->FCR & ~(3ul << 16)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD Blink Frequency Selection. + * @param Sel: Specify LCD Blink Frequency Selection. + * This parameter can be one of the following values: + * @arg LCD_BlinkFrequency_Div8 : Blink frequency = frame rate / 8 + * @arg LCD_BlinkFrequency_Div16 : Blink frequency = frame rate / 16 + * @arg LCD_BlinkFrequency_Div32 : Blink frequency = frame rate / 32 + * @arg LCD_BlinkFrequency_Div64 : Blink frequency = frame rate / 64 + * @arg LCD_BlinkFrequency_Div128 : Blink frequency = frame rate / 128 + * @arg LCD_BlinkFrequency_Div256 : Blink frequency = frame rate / 256 + * @arg LCD_BlinkFrequency_Div512 : Blink frequency = frame rate / 512 + * @arg LCD_BlinkFrequency_Div1024 : Blink frequency = frame rate / 1024 + ************************************************************************************************************/ +void LCD_BlinkFrequencyConfig(LCD_BlinkFrequency_Enum Sel) +{ + while (LCD_GetFlagStatus(LCD_FLAG_FCRSF) == SET); + HT_LCD->FCR = (HT_LCD->FCR & ~(7ul << 13)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD Charge Pump Voltage Selection. + * @param Sel: Specify LCD Charge Pump Voltage Selection. + * This parameter can be one of the following values: + * @arg LCD_ChargePump_2V65 : Charge pump voltage = 2.65 V + * @arg LCD_ChargePump_2V75 : Charge pump voltage = 2.75 V + * @arg LCD_ChargePump_2V85 : Charge pump voltage = 2.85 V + * @arg LCD_ChargePump_2V95 : Charge pump voltage = 2.95 V + * @arg LCD_ChargePump_3V10 : Charge pump voltage = 3.10 V + * @arg LCD_ChargePump_3V25 : Charge pump voltage = 3.25 V + * @arg LCD_ChargePump_3V40 : Charge pump voltage = 3.40 V + * @arg LCD_ChargePump_3V55 : Charge pump voltage = 3.55 V + ************************************************************************************************************/ +void LCD_ChargePumpConfig(LCD_ChargePump_Enum Sel) +{ + /* !!! NOTICE !!! + Must wait until the LCDENS = 0 before change the LCD settings. + */ + #if 0 + while (LCD_GetFlagStatus(LCD_FLAG_ENS) == 1); + #endif + + while (LCD_GetFlagStatus(LCD_FLAG_FCRSF)); + HT_LCD->FCR = (HT_LCD->FCR & ~(7ul << 10)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD Dead Time Duration Selection. + * @param Sel: Specify LCD Dead Time Duration Selection. + This parameter can be one of the following values: + * @arg LCD_Deadtime_0 : No dead time + * @arg LCD_Deadtime_1 : Type A: 1/2 phase period; Type B: 1 phase period + * @arg LCD_Deadtime_2 : Type A: 2/2 phase period; Type B: 2 phase period + * @arg LCD_Deadtime_3 : Type A: 3/2 phase period; Type B: 3 phase period + * @arg LCD_Deadtime_4 : Type A: 4/2 phase period; Type B: 4 phase period + * @arg LCD_Deadtime_5 : Type A: 5/2 phase period; Type B: 5 phase period + * @arg LCD_Deadtime_6 : Type A: 6/2 phase period; Type B: 6 phase period + * @arg LCD_Deadtime_7 : Type A: 7/2 phase period; Type B: 7 phase period + ************************************************************************************************************/ +void LCD_DeadTimeConfig(LCD_DeadTime_Enum Sel) +{ + while (LCD_GetFlagStatus(LCD_FLAG_FCRSF) == SET); + HT_LCD->FCR = (HT_LCD->FCR & ~(7ul << 7)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the LCD High Drive Duration Selection. + * @param Sel: Specify LCD High Drive Duration Selection. + * This parameter LCD_DEAD_Enum can be one of the following values: + * @arg LCD_HighDrive_0 : No high drive + * @arg LCD_HighDrive_1 : High drive duration = 1 CK_PS pulses + * @arg LCD_HighDrive_2 : High drive duration = 2 CK_PS pulses + * @arg LCD_HighDrive_3 : High drive duration = 3 CK_PS pulses + * @arg LCD_HighDrive_4 : High drive duration = 4 CK_PS pulses + * @arg LCD_HighDrive_5 : High drive duration = 5 CK_PS pulses + * @arg LCD_HighDrive_6 : High drive duration = 6 CK_PS pulses + * @arg LCD_HighDrive_7 : High drive duration = 7 CK_PS pulses + * @arg LCD_HighDrive_Static : Static high drive + ************************************************************************************************************/ +void LCD_HighDriveConfig(LCD_HighDrive_Enum Sel) +{ + u32 FCR = HT_LCD->FCR; + + if (Sel == LCD_HighDrive_Static) + { + FCR |= (1ul << 0); + } + else + { + FCR &= ~(1ul << 0); + FCR = (FCR & ~(7ul << 4)) | Sel; + } + + while (LCD_GetFlagStatus(LCD_FLAG_FCRSF)); + HT_LCD->FCR = FCR; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified LCD interrupts. + * @param LCD_INT: Specify the LCD interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg LCD_INT_UDDIE : Update Display Done Interrupt Enable + * @arg LCD_INT_SOFIE : Start of Frame Interrupt Enable + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void LCD_IntConfig(u32 LCD_INT, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_LCD_INT(LCD_INT)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_LCD->IER |= LCD_INT; + } + else + { + HT_LCD->IER &= ~LCD_INT; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified LCD flag has been set. + * @param LCD_FLAG: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * @arg LCD_FLAG_FCRSF : LCD Frame Control Register Synchronization Flag + * @arg LCD_FLAG_RDY : Ready Flag + * @arg LCD_FLAG_UDD : Update Display Done + * @arg LCD_FLAG_UDR : Update Display Request + * @arg LCD_FLAG_SOF : Start of Frame Flag + * @arg LCD_FLAG_ENS : LCD Enabled Status + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus LCD_GetFlagStatus(u32 LCD_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_LCD_FLAG(LCD_FLAG)); + + if ((HT_LCD->SR & LCD_FLAG) != RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief SET LCD Update Display Request. + * @retval None + ************************************************************************************************************/ +void LCD_SetUpdateDisplayRequest(void) +{ + HT_LCD->SR |= LCD_FLAG_UDR; +} + +/*********************************************************************************************************//** + * @brief Clear the specified LCD flag. + * @param LCD_Flag: specify the flag that is to be cleared. + * This parameter can be one of the following values: + * @arg LCD_CLR_UDDC : Update display done clear + * @arg LCD_CLR_SOFC : Start of frame flag clear + * @retval None + ************************************************************************************************************/ +void LCD_ClearFlag(u32 LCD_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_LCD_CLEAR(LCD_Flag)); + + HT_LCD->CLR = LCD_Flag; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ledc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ledc.c new file mode 100644 index 0000000000..37a340dd7f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_ledc.c @@ -0,0 +1,309 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_ledc.c + * @version $Rev:: 6374 $ + * @date $Date:: 2022-10-25 #$ + * @brief This file provides all the LEDC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_ledc.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup LEDC LEDC + * @brief LEDC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup LEDC_Private_Define LEDC private definitions + * @{ + */ +#define RPRE_MASK 0xF000FFFF + +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup LEDC_Exported_Functions LEDC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the LEDC peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void LEDC_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + RSTCUReset.Bit.LEDC = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the LEDC peripheral according to the specified parameters in the LEDC_InitStruct. + * @param LEDC_InitStruct: Pointer to a LEDC_InitTypeDef structure. Please note the following. + 1. When LEDC is started, the LEDC_ClockSource, LEDC_ClockPrescaler and LEDC_DeadTime can't + be changed, so LEDC_Init() will turn off the LED first.You need to restart LEDC by + LEDC_Cmd(ENABEL). + 2. The LEDC_DeadTime number must be less than the LEDC_Prescaler. + Example: + If LEDC_DutyClockNumber selects LEDC_DTYNUM_8, the valid LEDC_DeadTime ranges from 0 to 7. + If LEDC_DutyClockNumber selects LEDC_DTYNUM_16, the valid LEDC_DeadTime ranges from 0 to 15. + If LEDC_DutyClockNumber selects LEDC_DTYNUM_32, the valid LEDC_DeadTime ranges from 0 to 31. + If LEDC_DutyClockNumber selects LEDC_DTYNUM_64, the valid LEDC_DeadTime ranges from 0 to 63. + * @retval None + ************************************************************************************************************/ +void LEDC_Init(LEDC_InitTypeDef* LEDC_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_LEDC_SRC(LEDC_InitStruct->LEDC_ClockSource)); + Assert_Param(IS_LEDC_DTYNUM(LEDC_InitStruct->LEDC_DutyClockNumber)); + Assert_Param(IS_LEDC_PSC(LEDC_InitStruct->LEDC_ClockPrescaler)); + Assert_Param(IS_LEDC_COMEN(LEDC_InitStruct->LEDC_COMxEN)); + Assert_Param(IS_LEDC_DTCR(LEDC_InitStruct->LEDC_DeadTime)); + + /* Disable LEDC */ + HT_LEDC->CR = 0; + + /* LEDC Control Register Configuration */ + HT_LEDC->CR = LEDC_InitStruct->LEDC_ClockSource << 8 |\ + LEDC_InitStruct->LEDC_DutyClockNumber << 12 |\ + LEDC_InitStruct->LEDC_ClockPrescaler << 16; + + /* LEDC COM Enable Register Configuration */ + HT_LEDC->CER = LEDC_InitStruct->LEDC_COMxEN; + + /* LEDC Dead Time Control Register Configuration */ + HT_LEDC->DTCR = LEDC_InitStruct->LEDC_DeadTime; +} + +/*********************************************************************************************************//** + * @brief Select the LEDC timer clock source. + * @param Source: specify the clock source of LEDC. + * @arg LEDC_SRC_PCLK + * @arg LEDC_SRC_LSI : Low speed internal clock. + * @arg LEDC_SRC_LSE : Low speed external clock. + * @retval None + ************************************************************************************************************/ +void LEDC_ClockSourceConfig(LEDC_SRC_Enum Source) +{ + Assert_Param(IS_LEDC_SRC(Source)); + + HT_LEDC->CR = (HT_LEDC->CR & ~(3UL << 8)) | ((u32)Source << 8); +} + +/*********************************************************************************************************//** + * @brief Configure the LEDC prescaler. + * @param Psc: Value of LEDC prescaler: 0~4095 + * This parameter can be one of following values: + * @retval None + ************************************************************************************************************/ +void LEDC_SetPrescaler(u32 Psc) +{ + Assert_Param(IS_LEDC_PSC(Psc)); + + HT_LEDC->CR = (HT_LEDC->CR & RPRE_MASK) | (Psc << 16); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the LEDC. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void LEDC_Cmd(ControlStatus NewState) +{ + if (NewState != DISABLE) + { + HT_LEDC->CR |= (1UL); + } + else + { + HT_LEDC->CR &= ~(1UL); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable Frame interrupt. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void LEDC_IntConfig(ControlStatus NewState) +{ + if (NewState != DISABLE) + { + HT_LEDC->IER |= LEDC_INT_FRAME; + } + else + { + HT_LEDC->IER &= ~LEDC_INT_FRAME; + } +} + +/*********************************************************************************************************//** + * @brief Get the LEDC flag. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus LEDC_GetFlagStatus(void) +{ + if (HT_LEDC->SR & LEDC_FLAG_FRAME) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the LEDC graflag. + * @retval None + ************************************************************************************************************/ +void LEDC_ClearFlagStatus(void) +{ + HT_LEDC->SR |= LEDC_FLAG_FRAME; +} + +/*********************************************************************************************************//** + * @brief Configure COMx's state of LEDC with specified pins. + * @param LEDC_COMxEN: This parameter can be any combination of the following values: + * @arg LEDC_COM0EN : Set LEDC COM0 + * @arg LEDC_COM1EN : Set LEDC COM1 + * @arg LEDC_COM2EN : Set LEDC COM2 + * @arg LEDC_COM3EN : Set LEDC COM3 + * @arg LEDC_COM4EN : Set LEDC COM4 + * @arg LEDC_COM5EN : Set LEDC COM5 + * @arg LEDC_COM6EN : Set LEDC COM6 + * @arg LEDC_COM7EN : Set LEDC COM7 + * @arg LEDC_COM8EN : Set LEDC COM8(Only support 54253 ) + * @arg LEDC_COM9EN : Set LEDC COM9(Only support 54253 ) + * @arg LEDC_COM10EN : Set LEDC COM10(Only support 54253 ) + * @arg LEDC_COM11EN : Set LEDC COM11(Only support 54253 ) + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void LEDC_COMxConfig(u32 LEDC_COMxEN, ControlStatus Cmd) +{ + /* Check the parameters */ + Assert_Param(IS_LEDC_COMEN(LEDC_COMxEN)); + + if (Cmd != DISABLE) + HT_LEDC->CER |= LEDC_COMxEN; + else + HT_LEDC->CER &= ~LEDC_COMxEN; +} + +/*********************************************************************************************************//** + * @brief Configure the dead time duty. The LED brightness can be adjusted by adjusting the dead duty. + * @param LEDC_DeadTimeDuty: Deadtime Clock Numbers. The LEDC_DeadTimeDuty number must be less than the + LEDC_DutyClockNumber(DTYNUM). + Example: + If LEDC_DutyClockNumber selects LEDC_DTYNUM_8, the valid LEDC_DeadTime ranges from 0 to 7. + If LEDC_DutyClockNumber selects LEDC_DTYNUM_16, the valid LEDC_DeadTime ranges from 0 to 15. + If LEDC_DutyClockNumber selects LEDC_DTYNUM_32, the valid LEDC_DeadTime ranges from 0 to 31. + If LEDC_DutyClockNumber selects LEDC_DTYNUM_64, the valid LEDC_DeadTime ranges from 0 to 63. + * @retval None + ************************************************************************************************************/ +void LEDC_SetDeadTimeDuty(u32 LEDC_DeadTimeDuty) +{ + /* Check the parameters */ + Assert_Param(IS_LEDC_DTCR(LEDC_DeadTimeDuty)); + + HT_LEDC->DTCR = LEDC_DeadTimeDuty; +} + +/*********************************************************************************************************//** + * @brief Set the output polarity of COM and SEG. + * @param LEDC_COMxPOL: This parameter can be any combination of the following values: + * @arg LEDC_COM0POL : Set COM0 polarity + * @arg LEDC_COM1POL : Set COM1 polarity + * @arg LEDC_COM2POL : Set COM2 polarity + * @arg LEDC_COM3POL : Set COM3 polarity + * @arg LEDC_COM4POL : Set COM4 polarity + * @arg LEDC_COM5POL : Set COM5 polarity + * @arg LEDC_COM6POL : Set COM6 polarity + * @arg LEDC_COM7POL : Set COM7 polarity + * @arg LEDC_COM8POL : Set COM8 polarity(Only support 54253 ) + * @arg LEDC_COM9POL : Set COM9 polarity(Only support 54253 ) + * @arg LEDC_COM10POL : Set COM10 polarity(Only support 54253 ) + * @arg LEDC_COM11POL : Set COM11 polarity(Only support 54253 ) + * @param LEDC_SEGxPOL: This parameter can be any combination of the following values: + * @arg LEDC_SEG0POL : Set SEG0 polarity + * @arg LEDC_SEG1POL : Set SEG1 polarity + * @arg LEDC_SEG2POL : Set SEG2 polarity + * @arg LEDC_SEG3POL : Set SEG3 polarity + * @arg LEDC_SEG4POL : Set SEG4 polarity + * @arg LEDC_SEG5POL : Set SEG5 polarity + * @arg LEDC_SEG6POL : Set SEG6 polarity + * @arg LEDC_SEG7POL : Set SEG7 polarity + * @param mode: LED layout mode. + * SEG polarity COM polarity + * ------------------------------------------------------- + * @arg COMMON_CATHODE : non-inverted non-inverted + * @arg COMMON_CATHODE_WITH_NPN : non-inverted inverted + * @arg COMMON_ANODE_WITH_PNP : inverted non-inverted + * @arg COMMON_ANODE_WITH_NPN : inverted inverted + * @arg @retval None + ************************************************************************************************************/ +void LEDC_SetPolarityMode(u32 LEDC_COMxPOL, u32 LEDC_SEGxPOL , LEDC_Mode mode) +{ + /* Check the parameters */ + Assert_Param(IS_LEDC_DTCR(mode)); + Assert_Param(IS_LEDC_COMPOL(LEDC_COMxPOL)); + Assert_Param(IS_LEDC_SEGPOL(LEDC_SEGxPOL)); + + switch(mode) + { + case COMMON_CATHODE: + HT_LEDC->PCR &= ~(LEDC_COMxPOL|LEDC_SEGxPOL); + break; + case COMMON_CATHODE_WITH_NPN: + HT_LEDC->PCR |= LEDC_COMxPOL; + HT_LEDC->PCR &= ~(LEDC_SEGxPOL); + break; + case COMMON_ANODE_WITH_PNP: + HT_LEDC->PCR &= ~(LEDC_COMxPOL); + HT_LEDC->PCR |= LEDC_SEGxPOL; + break; + case COMMON_ANODE_WITH_NPN: + HT_LEDC->PCR |= LEDC_COMxPOL|LEDC_SEGxPOL; + break; + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lstm.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lstm.c new file mode 100644 index 0000000000..02180b2308 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_lstm.c @@ -0,0 +1,32 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_lstm.c + * @version $Rev:: 6594 $ + * @date $Date:: 2022-12-27 #$ + * @brief This file provides all the LSTM firmware functions (alias file of RTC). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_rtc.c" + +// This is an alias file to map LSTM to RTC, since the LSTM is almost the same as RTC +// It reduces the maintenance effort. diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_mctm.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_mctm.c new file mode 100644 index 0000000000..d30ac8eced --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_mctm.c @@ -0,0 +1,293 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_mctm.c + * @version $Rev:: 6421 $ + * @date $Date:: 2022-11-03 #$ + * @brief This file provides all the MCTM firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_mctm.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup MCTM MCTM + * @brief MCTM driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Private_Define MCTM private definitions + * @{ + */ +#define CTR_COMPRE 0x00000100ul +#define CTR_COMUS 0x00000200ul + +#define CHBRKCTR_CHMOE 0x00000010ul +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup MCTM_Exported_Functions MCTM exported functions + * @{ + */ + +/*********************************************************************************************************//** + * @brief Configure polarity of the MCTMx channel N. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripheral. + * @param Channel: Specify the MCTM channel. + * This parameter can be one of the following values: + * @arg MCTM_CH_0 : MCTM channel 0 + * @arg MCTM_CH_1 : MCTM channel 1 + * @arg MCTM_CH_2 : MCTM channel 2 + * @arg MCTM_CH_3 : MCTM channel 3 + * @param Pol: Specify the polarity of channel N. + * This parameter can be one of the following values: + * @arg MCTM_CHP_NONINVERTED : active high + * @arg MCTM_CHP_INVERTED : active low + * @retval None + ************************************************************************************************************/ +void MCTM_ChNPolarityConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHP_Enum Pol) +{ + u32 wChpolr; + + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_COMPLEMENTARY_CH(Channel)); + Assert_Param(IS_TM_CHP(Pol)); + + /* Set or reset the CHxN polarity */ + wChpolr = MCTMx->CHPOLR & (~(u32)(0x2 << (Channel << 1))); + MCTMx->CHPOLR = wChpolr | ((Pol << 1) << (Channel << 1)); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the MCTMx channel N. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripheral. + * @param Channel: Specify the MCTM channel. + * This parameter can be one of the following values: + * @arg MCTM_CH_0 : MCTM channel 0 + * @arg MCTM_CH_1 : MCTM channel 1 + * @arg MCTM_CH_2 : MCTM channel 2 + * @arg MCTM_CH_3 : MCTM channel 3 + * @param Control: This parameter can be TM_CHCTL_ENABLE or TM_CHCTL_DISABLE. + * @retval None + ************************************************************************************************************/ +void MCTM_ChannelNConfig(HT_TM_TypeDef* MCTMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_COMPLEMENTARY_CH(Channel)); + Assert_Param(IS_TM_CHCTL(Control)); + + /* Reset the CHxNE Bit */ + MCTMx->CHCTR &= ~(u32)(0x2 << (Channel << 1)); + + /* Set or reset the CHxNE Bit */ + MCTMx->CHCTR |= (u32)(Control << 1) << (Channel << 1); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the channels main output of the MCTMx. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void MCTM_CHMOECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the MCTM Main Output */ + MCTMx->CHBRKCTR |= CHBRKCTR_CHMOE; + } + else + { + /* Disable the MCTM Main Output */ + MCTMx->CHBRKCTR &= ~CHBRKCTR_CHMOE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the break feature, dead time, Lock level, the OSSI, the OSSR State + * and the CHAOE(automatic output enable). + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param CHBRKCTRInit: Point to a MCTM_CHBRKCTRInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void MCTM_CHBRKCTRConfig(HT_TM_TypeDef* MCTMx, MCTM_CHBRKCTRInitTypeDef *CHBRKCTRInit) +{ + u32 wTmpReg; + + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_OSSR_STATE(CHBRKCTRInit->OSSRState)); + Assert_Param(IS_MCTM_OSSI_STATE(CHBRKCTRInit->OSSIState)); + Assert_Param(IS_MCTM_LOCK_LEVEL(CHBRKCTRInit->LockLevel)); + Assert_Param(IS_MCTM_BREAK_STATE(CHBRKCTRInit->Break0)); + Assert_Param(IS_MCTM_BREAK_POLARITY(CHBRKCTRInit->Break0Polarity)); + Assert_Param(IS_MCTM_CHAOE_STATE(CHBRKCTRInit->AutomaticOutput)); + Assert_Param(IS_TM_FILTER(CHBRKCTRInit->BreakFilter)); + + wTmpReg = MCTMx->CHBRKCTR & 0x00000010; // Keep CHMOE + wTmpReg |= (u32)CHBRKCTRInit->BreakFilter << 8; + wTmpReg |= (u32)CHBRKCTRInit->DeadTime << 24; + wTmpReg |= CHBRKCTRInit->LockLevel | CHBRKCTRInit->OSSRState | CHBRKCTRInit->OSSIState; + wTmpReg |= CHBRKCTRInit->Break0 | CHBRKCTRInit->Break0Polarity | CHBRKCTRInit->AutomaticOutput; + + MCTMx->CHBRKCTR = wTmpReg; +} + +/*********************************************************************************************************//** + * @brief Configure the break feature, dead time, Lock level, the OSSI, the OSSR State + * and the CHAOE(automatic output enable). + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param CHBRKCTRInit: Point to a MCTM_CHBRKCTRTypeDef structure. + * @retval None + ************************************************************************************************************/ +void MCTM_CHBRKCTRConfig2(HT_TM_TypeDef* MCTMx, MCTM_CHBRKCTRTypeDef *CHBRKCTRInit) +{ + u32 wTmpReg; + + wTmpReg = MCTMx->CHBRKCTR & 0x00000010; // Keep CHMOE + + wTmpReg |= CHBRKCTRInit->Reg; + + MCTMx->CHBRKCTR = wTmpReg; +} + +/*********************************************************************************************************//** + * @brief Fill each CHBRKCTRInitStruct member with its default value. + * @param CHBRKCTRInitStruct: Point to a MCTM_CHBRKCTRInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void MCTM_CHBRKCTRStructInit(MCTM_CHBRKCTRInitTypeDef* CHBRKCTRInitStruct) +{ + /* Set the default configuration */ + CHBRKCTRInitStruct->OSSRState = MCTM_OSSR_STATE_DISABLE; + CHBRKCTRInitStruct->OSSIState = MCTM_OSSI_STATE_DISABLE; + CHBRKCTRInitStruct->LockLevel = MCTM_LOCK_LEVEL_OFF; + CHBRKCTRInitStruct->DeadTime = 0x00; + CHBRKCTRInitStruct->Break0 = MCTM_BREAK_DISABLE; + CHBRKCTRInitStruct->Break0Polarity = MCTM_BREAK_POLARITY_LOW; + CHBRKCTRInitStruct->BreakFilter = 0; + CHBRKCTRInitStruct->AutomaticOutput = MCTM_CHAOE_DISABLE; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable MCTMx COMPRE function. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void MCTM_COMPRECmd(HT_TM_TypeDef* MCTMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the MCTM COMPRE */ + MCTMx->CTR |= CTR_COMPRE; + } + else + { + /* Disable the MCTM COMPRE */ + MCTMx->CTR &= ~CTR_COMPRE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the MCTMx COMUS function. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param Sel: Specify the COMUS value. + * This parameter can be one of the following values: + * @arg MCTM_COMUS_STIOFF : MCTM capture/compare control bits are updated by setting the UEV2G bit only + * @arg MCTM_COMUS_STION : MCTM capture/compare control bits are updated by both setting the UEV2G bit + * or when a rising edge occurs on STI + * @retval None + ************************************************************************************************************/ +void MCTM_COMUSConfig(HT_TM_TypeDef* MCTMx, MCTM_COMUS_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_MCTM_COMUS(Sel)); + + if (Sel != MCTM_COMUS_STIOFF) + { + /* Set the MCTM COMUS bit */ + MCTMx->CTR |= CTR_COMUS; + } + else + { + /* Clear the MCTM COMUS bit */ + MCTMx->CTR &= ~CTR_COMUS; + } +} + +#if (LIBCFG_MCTM_UEV1DIS) +/*********************************************************************************************************//** + * @brief Enable or Disable Overflow/Underflow update event(does not contain interrupt) of the MCTMx. + * @param MCTMx: where MCTMx is the selected MCTM from the MCTM peripherals. + * @param MCTM_UEV1x: MCTM_UEV1UD or MCTM_UEV1OD. Overflow/underflow request disable control. + * @param NewState: This parameter can be SET or RESET. + * @retval None + ************************************************************************************************************/ +void MCTM_UpdateEventDisable(HT_TM_TypeDef* MCTMx, MCTM_UEV1DIS_Enum MCTM_UEV1x, FlagStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MCTM(MCTMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != RESET) + { + /* Set the update disable bit */ + MCTMx->CNTCFR |= MCTM_UEV1x; + } + else + { + /* Reset the update disable bit */ + MCTMx->CNTCFR &= ~MCTM_UEV1x; + } +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_midi.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_midi.c new file mode 100644 index 0000000000..15369686b3 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_midi.c @@ -0,0 +1,1176 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_midi.c + * @version $Rev:: 6684 $ + * @date $Date:: 2023-01-18 #$ + * @brief This file provides all the MIDI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_midi.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup MIDI MIDI + * @brief MIDI driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup MIDI_Private_Define MIDI private definitions + * @{ + */ +/* MIDI TRIG ST Mask */ +#define TRIG_ST_ENABLE (u32)0x00000400 +#define TRIG_ST_DISABLE (u32)0xFFFFFBFF + +/* MIDI TRIG VM Mask */ +#define TRIG_VM_ENABLE (u32)0x00000200 +#define TRIG_VM_DISABLE (u32)0xFFFFFDFF + +/* MIDI TRIG FR Mask */ +#define TRIG_FR_ENABLE (u32)0x00000100 +#define TRIG_FR_DISABLE (u32)0xFFFFFEFF + +/* MIDI CHAN CHx Mask */ +#define MIDI_CHAN_CHx_MASK (u32)0x0000001F + +/* MIDI FREQ BL Mask */ +#define MIDI_FREQ_BL_MASK (u32)0x0000F000 + +/* MIDI FREQ FR Mask */ +#define MIDI_FREQ_FR_MASK (u32)0x00000FFF + +/* MIDI VOL AR Mask */ +#define MIDI_VOL_AR_MASK (u32)0x80000000 + +/* MIDI VOL ENV Mask */ +#define MIDI_VOL_ENV_MASK (u32)0x60000000 + +/* MIDI VOL VL Mask */ +#define MIDI_VOL_VL_MASK (u32)0x03FF0000 + +/* MIDI VOL VR Mask */ +#define MIDI_VOL_VR_MASK (u32)0x000003FF + +/* MIDI RENUM WBS Mask */ +#define MIDI_RENUM_WBS_MASK (u32)0x00030000 + +/* MIDI RENUM RE Mask */ +#define MIDI_RENUM_RE_MASK (u32)0x00007FFF + +/* MIDI MCUCH0 CH0B Mask */ +#define MIDI_MCUCH0_CH0B_MASK (u32)0xFFFF0000 + +/* MIDI MCUCH0 CH0A Mask */ +#define MIDI_MCUCH0_CH0A_MASK (u32)0x0000FFFF + +/* MIDI MCUCH1 CH1B Mask */ +#define MIDI_MCUCH1_CH1B_MASK (u32)0xFFFF0000 + +/* MIDI MCUCH1 CH1A Mask */ +#define MIDI_MCUCH1_CH1A_MASK (u32)0x0000FFFF + +/* MIDI MCUCH2 CH2B Mask */ +#define MIDI_MCUCH2_CH2B_MASK (u32)0xFFFF0000 + +/* MIDI MCUCH2 CH2A Mask */ +#define MIDI_MCUCH2_CH2A_MASK (u32)0x0000FFFF + +/* MIDI MCUCH3 CH3B Mask */ +#define MIDI_MCUCH3_CH3B_MASK (u32)0xFFFF0000 + +/* MIDI MCUCH3 CH3A Mask */ +#define MIDI_MCUCH3_CH3A_MASK (u32)0x0000FFFF + +/* MIDI CTRL MCUCHEN3 Mask */ +#define MCUCHEN3_ENABLE (u32)0x00008000 +#define MCUCHEN3_DISABLE (u32)0xFFFF7FFF + +/* MIDI CTRL MCUCHEN2 Mask */ +#define MCUCHEN2_ENABLE (u32)0x00004000 +#define MCUCHEN2_DISABLE (u32)0xFFFFBFFF + +/* MIDI CTRL MCUCHEN1 Mask */ +#define MCUCHEN1_ENABLE (u32)0x00002000 +#define MCUCHEN1_DISABLE (u32)0xFFFFDFFF + +/* MIDI CTRL MCUCHEN0 Mask */ +#define MCUCHEN0_ENABLE (u32)0x00001000 +#define MCUCHEN0_DISABLE (u32)0xFFFFEFFF + +/* MIDI CTRL DACDS Mask */ +#define MIDI_CTRL_DACDS_MASK (u32)0x00000700 + +/* MIDI CTRL MUSICEN Mask */ +#define MUSICEN_ENABLE (u32)0x00000080 +#define MUSICEN_DISABLE (u32)0xFFFFFF7F + +/* MIDI CTRL SPIRDEN Mask */ +#define SPIRDEN_ENABLE (u32)0x00000040 +#define SPIRDEN_DISABLE (u32)0xFFFFFFBF + +/* MIDI CTRL SPIDISLOOP Mask */ +#define SPIDISLOOP_ENABLE (u32)0x00000020 +#define SPIDISLOOP_DISABLE (u32)0xFFFFFFDF + +/* MIDI CTRL CHS Mask */ +#define MIDI_CTRL_CHS_MASK (u32)0x00000007 +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup MIDI_Exported_Functions MIDI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the MIDI peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void MIDI_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.MIDI = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the MIDIx peripheral according to the specified parameters in the MIDI_InitStruct. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param MIDI_InitStruct: pointer to a MIDI_InitTypeDef structure that contains the configuration + * information for the specified MIDI peripheral. + * @retval None + ***********************************************************************************************************/ +void MIDI_Init(HT_MIDI_TypeDef* MIDIx, MIDI_InitTypeDef* MIDI_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_CTRL_DACDS(MIDI_InitStruct->MIDI_CTRL_DACDS)); + Assert_Param(IS_MIDI_CTRL_MUSICEN(MIDI_InitStruct->MIDI_CTRL_MUSICEN)); + Assert_Param(IS_MIDI_CTRL_SPIDISLOOP(MIDI_InitStruct->MIDI_CTRL_SPIDISLOOP)); + Assert_Param(IS_MIDI_CTRL_CHS(MIDI_InitStruct->MIDI_CTRL_CHS)); + Assert_Param(IS_MIDI_FREQ_BL(MIDI_InitStruct->MIDI_FREQ_BL)); + Assert_Param(IS_MIDI_FREQ_FR(MIDI_InitStruct->MIDI_FREQ_FR)); + Assert_Param(IS_MIDI_VOL_AR(MIDI_InitStruct->MIDI_VOL_AR)); + Assert_Param(IS_MIDI_VOL_ENV(MIDI_InitStruct->MIDI_VOL_ENV)); + Assert_Param(IS_MIDI_VOL_VL(MIDI_InitStruct->MIDI_VOL_VL)); + Assert_Param(IS_MIDI_VOL_VR(MIDI_InitStruct->MIDI_VOL_VR)); + Assert_Param(IS_MIDI_STADDR(MIDI_InitStruct->MIDI_STADDR)); + Assert_Param(IS_MIDI_RENUM_WBS(MIDI_InitStruct->MIDI_RENUM_WBS)); + Assert_Param(IS_MIDI_RENUM_RE(MIDI_InitStruct->MIDI_RENUM_RE)); + Assert_Param(IS_MIDI_ENDADDR(MIDI_InitStruct->MIDI_ENDADDR)); + Assert_Param(IS_MIDI_CHAN_ST(MIDI_InitStruct->MIDI_CHAN_ST)); + Assert_Param(IS_MIDI_CHAN_VM(MIDI_InitStruct->MIDI_CHAN_VM)); + Assert_Param(IS_MIDI_CHAN_FR(MIDI_InitStruct->MIDI_CHAN_FR)); + Assert_Param(IS_MIDI_CHAN_CHx(MIDI_InitStruct->MIDI_CHAN_CHx)); + + MIDIx->CTRL = ((MIDI_InitStruct->MIDI_CTRL_DACDS) << 8) | + ((MIDI_InitStruct->MIDI_CTRL_MUSICEN) << 7) | + ((MIDI_InitStruct->MIDI_CTRL_SPIDISLOOP) << 6) | + (MIDI_InitStruct->MIDI_CTRL_CHS); + + MIDIx->FREQ = ((MIDI_InitStruct->MIDI_FREQ_BL) << 12) | + (MIDI_InitStruct->MIDI_FREQ_FR); + + MIDIx->VOL = ((MIDI_InitStruct->MIDI_VOL_AR) << 31) | + ((MIDI_InitStruct->MIDI_VOL_ENV) << 29) | + ((MIDI_InitStruct->MIDI_VOL_VL) << 16) | + (MIDI_InitStruct->MIDI_VOL_VR); + + MIDIx->ST_ADDR = MIDI_InitStruct->MIDI_STADDR; + + MIDIx->RE_NUM = ((MIDI_InitStruct->MIDI_RENUM_WBS) << 16) | + (MIDI_InitStruct->MIDI_RENUM_RE); + + MIDIx->END_ADDR = MIDI_InitStruct->MIDI_ENDADDR; + + MIDIx->CHAN = ((MIDI_InitStruct->MIDI_CHAN_ST) << 10) | + ((MIDI_InitStruct->MIDI_CHAN_VM) << 9) | + ((MIDI_InitStruct->MIDI_CHAN_FR) << 8) | + (MIDI_InitStruct->MIDI_CHAN_CHx); +} + +/*********************************************************************************************************//** + * @brief Fill each MIDI_InitStruct member with its default value. + * @param MIDI_InitStruct: pointer to an MIDI_InitTypeDef structure which will be initialized. + * @retval None + ***********************************************************************************************************/ +void MIDI_StructInit(MIDI_InitTypeDef* MIDI_InitStruct) +{ + /* Initialize the MIDI_CTRL_DACDS member */ + MIDI_InitStruct->MIDI_CTRL_DACDS = 0x0; + + /* Initialize the MIDI_CTRL_MUSICEN member */ + MIDI_InitStruct->MIDI_CTRL_MUSICEN = DISABLE; + + /* Initialize the MIDI_CTRL_SPIDISLOOP member */ + MIDI_InitStruct->MIDI_CTRL_SPIDISLOOP = DISABLE; + + /* Initialize the MIDI_CTRL_CHS member */ + MIDI_InitStruct->MIDI_CTRL_CHS = CHS16; + + /* Initialize the MIDI_FREQ_BL member */ + MIDI_InitStruct->MIDI_FREQ_BL = BL0; + + /* Initialize the MIDI_FREQ_FR member */ + MIDI_InitStruct->MIDI_FREQ_FR = 0x0; + + /* Initialize the MIDI_VOL_AR member */ + MIDI_InitStruct->MIDI_VOL_AR = ENV_RELEASE; + + /* Initialize the MIDI_VOL_ENV member */ + MIDI_InitStruct->MIDI_VOL_ENV = ENV_NO; + + /* Initialize the MIDI_VOL_VL member */ + MIDI_InitStruct->MIDI_VOL_VL = 0x3FF; + + /* Initialize the MIDI_VOL_VR member */ + MIDI_InitStruct->MIDI_VOL_VR = 0x3FF; + + /* Initialize the MIDI_STADDR member */ + MIDI_InitStruct->MIDI_STADDR = 0x0; + + /* Initialize the MIDI_RENUM_WBS member */ + MIDI_InitStruct->MIDI_RENUM_WBS = WBS8; + + /* Initialize the MIDI_RENUM_RE member */ + MIDI_InitStruct->MIDI_RENUM_RE = 0x0; + + /* Initialize the MIDI_ENDADDR member */ + MIDI_InitStruct->MIDI_ENDADDR = 0x0; + + /* Initialize the MIDI_CHAN_ST member */ + MIDI_InitStruct->MIDI_CHAN_ST = DISABLE; + + /* Initialize the MIDI_CHAN_VM member */ + MIDI_InitStruct->MIDI_CHAN_VM = DISABLE; + + /* Initialize the MIDI_CHAN_FR member */ + MIDI_InitStruct->MIDI_CHAN_FR = DISABLE; + + /* Initialize the MIDI_CHAN_CHx member */ + MIDI_InitStruct->MIDI_CHAN_CHx = MIDI_CHx0; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified MIDI interrupt. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param MIDI_Int: specify if the MIDI interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg MIDIO_DMAEN : MIDIO DMAEN + * @arg MIDII_DMAEN : MIDII DMAEN + * @arg MIDI_INTEN : MIDI INTEN + * @param NewState: new state of the MIDI interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_IntConfig(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_INT(MIDI_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->IER |= MIDI_Int; + } + else + { + MIDIx->IER &= (u32)~MIDI_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified MIDI flag has been set or not. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param MIDI_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg MIDI_INTF : MIDI int flag + * @retval The new state of MIDI_Flag (SET or RESET). + ***********************************************************************************************************/ +FlagStatus MIDI_GetFlagStatus(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Flag) +{ + FlagStatus bitstatus = RESET; + u32 statusreg = 0; + + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_FLAG(MIDI_Flag)); + + statusreg = MIDIx->SR; + + if ((statusreg & MIDI_Flag) != (u32)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Clear the specified MIDI flag. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param MIDI_Flag: specify the flag that is to be cleared. + * This parameter can be one of the following values: + * @arg MIDI_INTF : MIDI INTF + * @retval None + ***********************************************************************************************************/ +void MIDI_ClearFlag(HT_MIDI_TypeDef* MIDIx, u32 MIDI_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_FLAG_CLEAR(MIDI_Flag)); + + MIDIx->SR = MIDI_Flag; +} + +/*********************************************************************************************************//** + * @brief Configure the Channel for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param MCUCHEN3: this parameter can be ENABLE or DISABLE. + * @param MCUCHEN2: this parameter can be ENABLE or DISABLE. + * @param MCUCHEN1: this parameter can be ENABLE or DISABLE. + * @param MCUCHEN0: this parameter can be ENABLE or DISABLE. + * @param DACDS: specify the clipping and distorting volume of the MIDI. + * @param MUSICEN: this parameter can be ENABLE or DISABLE. + * @param SPIRDEN: this parameter can be ENABLE or DISABLE. + * @param SPIDISLOOP: this parameter can be ENABLE or DISABLE. + * @param CHS: specify channel selection of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL(HT_MIDI_TypeDef* MIDIx, + MIDI_CTRL_MCUCHEN3_Enum MCUCHEN3, MIDI_CTRL_MCUCHEN2_Enum MCUCHEN2, + MIDI_CTRL_MCUCHEN1_Enum MCUCHEN1, MIDI_CTRL_MCUCHEN0_Enum MCUCHEN0, + u8 DACDS, + MIDI_CTRL_MUSICEN_Enum MUSICEN, + MIDI_CTRL_SPIRDEN_Enum SPIRDEN, MIDI_CTRL_SPIDISLOOP_Enum SPIDISLOOP, + MIDI_CTRL_CHS_Enum CHS) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_CTRL_MCUCHEN3(MCUCHEN3)); + Assert_Param(IS_MIDI_CTRL_MCUCHEN2(MCUCHEN2)); + Assert_Param(IS_MIDI_CTRL_MCUCHEN1(MCUCHEN1)); + Assert_Param(IS_MIDI_CTRL_MCUCHEN0(MCUCHEN0)); + Assert_Param(IS_MIDI_CTRL_DACDS(DACDS)); + Assert_Param(IS_MIDI_CTRL_MUSICEN(MUSICEN)); + Assert_Param(IS_MIDI_CTRL_SPIRDEN(SPIRDEN)); + Assert_Param(IS_MIDI_CTRL_SPIDISLOOP(SPIDISLOOP)); + Assert_Param(IS_MIDI_CTRL_CHS(CHS)); + + MIDIx->CTRL = (MCUCHEN3 << 15) | (MCUCHEN2 << 14) | (MCUCHEN1 << 13) | (MCUCHEN0 << 12) | + (DACDS << 8) | + (MUSICEN << 7) | + (SPIRDEN << 6) | (SPIDISLOOP << 5) | + CHS; +} + +/*********************************************************************************************************//** + * @brief Configure the FREQ for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param BL: specify octave of the MIDI. + * @param FR: specify pitch of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_FREQ(HT_MIDI_TypeDef* MIDIx, MIDI_FREQ_BL_Enum BL, u16 FR) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_FREQ_BL(BL)); + Assert_Param(IS_MIDI_FREQ_FR(FR)); + + MIDIx->FREQ = (BL << 12) | FR; +} + +/*********************************************************************************************************//** + * @brief Configure the VOL for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param A_R: specify attack or release of the MIDI. + * @param ENV: specify envelope of the MIDI. + * @param VL: specify left channel of the MIDI. + * @param VR: specify right channel of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_VOL(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_AR_Enum A_R, MIDI_VOL_ENV_Enum ENV, u16 VL, u16 VR) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_VOL_AR(A_R)); + Assert_Param(IS_MIDI_VOL_ENV(ENV)); + Assert_Param(IS_MIDI_VOL_VL(VL)); + Assert_Param(IS_MIDI_VOL_VR(VR)); + + MIDIx->VOL = (A_R << 31) | (ENV << 29) | (VL << 16) | VR; +} + +/*********************************************************************************************************//** + * @brief Configure the Start Address for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param ST_ADDR: specify start address of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_STADDR(HT_MIDI_TypeDef* MIDIx, u32 ST_ADDR) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_STADDR(ST_ADDR)); + + MIDIx->ST_ADDR = ST_ADDR; +} + +/*********************************************************************************************************//** + * @brief Configure the RENUM for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param WBS: specify waveform of the MIDI. + * @param RE: specify repeated code of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_RENUM(HT_MIDI_TypeDef* MIDIx, MIDI_RENUM_WBS_Enum WBS, u16 RE) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_RENUM_WBS(WBS)); + Assert_Param(IS_MIDI_RENUM_RE(RE)); + + MIDIx->RE_NUM = (WBS << 16) | RE; +} + +/*********************************************************************************************************//** + * @brief Configure the End Address for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param END_ADDR: specify end address of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_ENDADDR(HT_MIDI_TypeDef* MIDIx, u32 END_ADDR) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_ENDADDR(END_ADDR)); + + MIDIx->END_ADDR = END_ADDR; +} + +/*********************************************************************************************************//** + * @brief Configure the Channel for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param TRIG_ST: this parameter can be ENABLE or DISABLE. + * @param TRIG_VM: this parameter can be ENABLE or DISABLE. + * @param TRIG_FR: this parameter can be ENABLE or DISABLE. + * @param CHx: specify selected channel of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_CHAN(HT_MIDI_TypeDef* MIDIx, + MIDI_CHAN_ST_Enum TRIG_ST, MIDI_CHAN_VM_Enum TRIG_VM, MIDI_CHAN_FR_Enum TRIG_FR, + u8 CHx) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_CHAN_ST(TRIG_ST)); + Assert_Param(IS_MIDI_CHAN_VM(TRIG_VM)); + Assert_Param(IS_MIDI_CHAN_FR(TRIG_FR)); + Assert_Param(IS_MIDI_CHAN_CHx(CHx)); + + MIDIx->CHAN = (TRIG_ST << 10) | (TRIG_VM << 9) | (TRIG_FR << 8) | CHx; +} + +/*********************************************************************************************************//** + * @brief Configure the MCU CH0 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH0B: specify DATA[31:16] of MCU CH0 of the MIDI. + * @param CH0A: specify DATA[15:0] of MCU CH0 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH0(HT_MIDI_TypeDef* MIDIx, u16 CH0B, u16 CH0A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx11_BH(CH0B)); + Assert_Param(IS_MIDI_MCUCHx11_BL(CH0A)); + + MIDIx->MCU_CH0 = (CH0B << 16) | CH0A; +} + +/*********************************************************************************************************//** + * @brief Configure the MCU CH1 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH1B: specify DATA[31:16] of MCU CH1 of the MIDI. + * @param CH1A: specify DATA[15:0] of MCU CH1 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH1(HT_MIDI_TypeDef* MIDIx, u16 CH1B, u16 CH1A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx12_CH(CH1B)); + Assert_Param(IS_MIDI_MCUCHx12_CL(CH1A)); + + MIDIx->MCU_CH1 = (CH1B << 16) | CH1A; +} + +/*********************************************************************************************************//** + * @brief Configure the MCU CH2 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH2B: specify DATA[31:16] of MCU CH2 of the MIDI. + * @param CH2A: specify DATA[15:0] of MCU CH2 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH2(HT_MIDI_TypeDef* MIDIx, u16 CH2B, u16 CH2A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx13_DH(CH2B)); + Assert_Param(IS_MIDI_MCUCHx13_DL(CH2A)); + + MIDIx->MCU_CH2 = (CH2B << 16) | CH2A; +} + +/*********************************************************************************************************//** + * @brief Configure the MCU CH3 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH3B: specify DATA[31:16] of MCU CH3 of the MIDI. + * @param CH3A: specify DATA[15:0] of MCU CH3 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH3(HT_MIDI_TypeDef* MIDIx, u16 CH3B, u16 CH3A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx14_EH(CH3B)); + Assert_Param(IS_MIDI_MCUCHx14_EL(CH3A)); + + MIDIx->MCU_CH3 = (CH3B << 16) | CH3A; +} + +/*********************************************************************************************************//** + * @brief Configure the FREQ BL for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param BL: specify octave of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_FREQ_BL(HT_MIDI_TypeDef* MIDIx, MIDI_FREQ_BL_Enum BL) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_FREQ_BL(BL)); + + /* Clear BL[3:0] in FREQ */ + MIDIx->FREQ &= (u32)~MIDI_FREQ_BL_MASK; + + /* Set new BL[3:0] in FREQ */ + MIDIx->FREQ |= (BL << 12); +} + +/*********************************************************************************************************//** + * @brief Configure the FREQ FR for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param FR: specify pitch of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_FREQ_FR(HT_MIDI_TypeDef* MIDIx, u16 FR) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_FREQ_FR(FR)); + + /* Clear FR[11:0] in FREQ */ + MIDIx->FREQ &= (u32)~MIDI_FREQ_FR_MASK; + + /* Set new FR[11:0] in FREQ */ + MIDIx->FREQ |= FR; +} + +/*********************************************************************************************************//** + * @brief Configure the VOL AR for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param A_R: specify attack or release of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_VOL_AR(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_AR_Enum A_R) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_VOL_AR(A_R)); + + /* Clear A_R in VOL */ + MIDIx->VOL &= (u32)~MIDI_VOL_AR_MASK; + + /* Set new A_R in VOL */ + MIDIx->VOL |= (A_R << 31); +} + +/*********************************************************************************************************//** + * @brief Configure the VOL ENV for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param ENV: specify envelope of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_VOL_ENV(HT_MIDI_TypeDef* MIDIx, MIDI_VOL_ENV_Enum ENV) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_VOL_ENV(ENV)); + + /* Clear ENV[1:0] in VOL */ + MIDIx->VOL &= (u32)~MIDI_VOL_ENV_MASK; + + /* Set new ENV[1:0] in VOL */ + MIDIx->VOL |= (ENV << 29); +} + +/*********************************************************************************************************//** + * @brief Configure the VOL VL for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param VL: specify left channel of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_VOL_VL(HT_MIDI_TypeDef* MIDIx, u16 VL) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_VOL_VL(VL)); + + /* Clear VL[9:0] in VOL */ + MIDIx->VOL &= (u32)~MIDI_VOL_VL_MASK; + + /* Set new VL[9:0] in VOL */ + MIDIx->VOL |= (VL << 16); +} + +/*********************************************************************************************************//** + * @brief Configure the VOL VR for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param VR: specify right channel of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_VOL_VR(HT_MIDI_TypeDef* MIDIx, u16 VR) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_VOL_VR(VR)); + + /* Clear VR[9:0] in VOL */ + MIDIx->VOL &= (u32)~MIDI_VOL_VR_MASK; + + /* Set new VR[9:0] in VOL */ + MIDIx->VOL |= VR; +} + +/*********************************************************************************************************//** + * @brief Configure the RENUM WBS for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param WBS: specify waveform of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_RENUM_WBS(HT_MIDI_TypeDef* MIDIx, MIDI_RENUM_WBS_Enum WBS) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_RENUM_WBS(WBS)); + + /* Clear WBS[1:0] in RENUM */ + MIDIx->RE_NUM &= (u32)~MIDI_RENUM_WBS_MASK; + + /* Set new WBS[1:0] in RENUM */ + MIDIx->RE_NUM |= (WBS << 16); +} + +/*********************************************************************************************************//** + * @brief Configure the RENUM RE for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param RE: specify repeated code of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_RENUM_RE(HT_MIDI_TypeDef* MIDIx, u16 RE) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_RENUM_RE(RE)); + + /* Clear RE[14:0] in RENUM */ + MIDIx->RE_NUM &= (u32)~MIDI_RENUM_RE_MASK; + + /* Set new RE[14:0] in RENUM */ + MIDIx->RE_NUM |= RE; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable ST ADDR for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CHAN_STCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CHAN |= TRIG_ST_ENABLE; + } + else + { + MIDIx->CHAN &= (TRIG_ST_DISABLE); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable VM for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CHAN_VMCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CHAN |= TRIG_VM_ENABLE; + } + else + { + MIDIx->CHAN &= (TRIG_VM_DISABLE); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable FR for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CHAN_FRCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CHAN |= TRIG_FR_ENABLE; + } + else + { + MIDIx->CHAN &= (TRIG_FR_DISABLE); + } +} + +/*********************************************************************************************************//** + * @brief Configure the Selected Channel for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CHx: specify selected channel of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_CHAN_CHx(HT_MIDI_TypeDef* MIDIx, u8 CHx) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_CHAN_CHx(CHx)); + + /* Clear CHx[4:0] in CHAN */ + MIDIx->CHAN &= (u32)~MIDI_CHAN_CHx_MASK; + + /* Set new CHx[4:0] in CHAN */ + MIDIx->CHAN |= CHx; +} + +/*********************************************************************************************************//** + * @brief Configure the CH0B of MCU CH0 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH0B: specify DATA[31:16] of MCU CH0 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH0_CH0B(HT_MIDI_TypeDef* MIDIx, u16 CH0B) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx11_BH(CH0B)); + + /* Clear CH0B[16:0] in MCUCH0 */ + MIDIx->MCU_CH0 &= (u32)~MIDI_MCUCH0_CH0B_MASK; + + /* Set new CH0B[16:0] in MCUCH0 */ + MIDIx->MCU_CH0 |= (CH0B << 16); +} + +/*********************************************************************************************************//** + * @brief Configure the CH0A of MCU CH0 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH0A: specify DATA[15:0] of MCU CH0 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH0_CH0A(HT_MIDI_TypeDef* MIDIx, u16 CH0A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx11_BL(CH0A)); + + /* Clear CH0B[16:0] in MCUCH0 */ + MIDIx->MCU_CH0 &= (u32)~MIDI_MCUCH0_CH0A_MASK; + + /* Set new CH0B[16:0] in MCUCH0 */ + MIDIx->MCU_CH0 |= CH0A; +} + +/*********************************************************************************************************//** + * @brief Configure the CH1B of MCU CH1 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH1B: specify DATA[31:16] of MCU CH1 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH1_CH1B(HT_MIDI_TypeDef* MIDIx, u16 CH1B) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx12_CH(CH1B)); + + /* Clear CH0B[16:0] in MCUCH0 */ + MIDIx->MCU_CH1 &= (u32)~MIDI_MCUCH1_CH1B_MASK; + + /* Set new CH1B[16:0] in MCUCH1 */ + MIDIx->MCU_CH1 |= (CH1B << 16); +} + +/*********************************************************************************************************//** + * @brief Configure the CH1A of MCU CH1 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH1A: specify DATA[15:0] of MCU CH1 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH1_CH1A(HT_MIDI_TypeDef* MIDIx, u16 CH1A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx12_CL(CH1A)); + + /* Clear CH1A[16:0] in MCUCH1 */ + MIDIx->MCU_CH1 &= (u32)~MIDI_MCUCH1_CH1A_MASK; + + /* Set new CH1A[16:0] in MCUCH1 */ + MIDIx->MCU_CH1 |= CH1A; +} + +/*********************************************************************************************************//** + * @brief Configure the CH2B of MCU CH2 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH2B: specify DATA[31:16] of MCU CH2 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH2_CH2B(HT_MIDI_TypeDef* MIDIx, u16 CH2B) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx13_DH(CH2B)); + + /* Clear CH2B[16:0] in MCUCH2 */ + MIDIx->MCU_CH2 &= (u32)~MIDI_MCUCH2_CH2B_MASK; + + /* Set new CH2B[16:0] in MCUCH2 */ + MIDIx->MCU_CH2 |= (CH2B << 16); +} + +/*********************************************************************************************************//** + * @brief Configure the CH2A of MCU CH2 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH2A: specify DATA[15:0] of MCU CH2 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH2_CH2A(HT_MIDI_TypeDef* MIDIx, u16 CH2A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx13_DL(CH2A)); + + /* Clear CH2A[16:0] in MCUCH2 */ + MIDIx->MCU_CH2 &= (u32)~MIDI_MCUCH2_CH2A_MASK; + + /* Set new CH2A[16:0] in MCUCH2 */ + MIDIx->MCU_CH2 |= CH2A; +} + +/*********************************************************************************************************//** + * @brief Configure the CH3B of MCU CH3 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH3B: specify DATA[31:16] of MCU CH3 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH3_CH3B(HT_MIDI_TypeDef* MIDIx, u16 CH3B) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx14_EH(CH3B)); + + /* Clear CH3B[16:0] in MCUCH3 */ + MIDIx->MCU_CH3 &= (u32)~MIDI_MCUCH3_CH3B_MASK; + + /* Set new CH3B[16:0] in MCUCH3 */ + MIDIx->MCU_CH3 |= (CH3B << 16); +} + +/*********************************************************************************************************//** + * @brief Configure the CH3A of MCU CH3 DATA for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CH3A: specify DATA[15:0] of MCU CH3 of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_MCUCH3_CH3A(HT_MIDI_TypeDef* MIDIx, u16 CH3A) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_MCUCHx14_EL(CH3A)); + + /* Clear CH3A[16:0] in MCUCH3 */ + MIDIx->MCU_CH3 &= (u32)~MIDI_MCUCH3_CH3A_MASK; + + /* Set new CH3A[16:0] in MCUCH3 */ + MIDIx->MCU_CH3 |= CH3A; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable MCU CHEN3 for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_MCUCHEN3(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CTRL |= MCUCHEN3_ENABLE; + } + else + { + MIDIx->CTRL &= MCUCHEN3_DISABLE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable MCU CHEN2 for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_MCUCHEN2(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CTRL |= MCUCHEN2_ENABLE; + } + else + { + MIDIx->CTRL &= MCUCHEN2_DISABLE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable MCU CHEN1 for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_MCUCHEN1(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CTRL |= MCUCHEN1_ENABLE; + } + else + { + MIDIx->CTRL &= MCUCHEN1_DISABLE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable MCU CHEN0 for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_MCUCHEN0(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CTRL |= MCUCHEN0_ENABLE; + } + else + { + MIDIx->CTRL &= MCUCHEN0_DISABLE; + } +} + + +/*********************************************************************************************************//** + * @brief Configure the DACDS for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param DACDS: specify the clipping and distorting volume of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_DACDS(HT_MIDI_TypeDef* MIDIx, u8 DACDS) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_CTRL_DACDS(DACDS)); + + /* Clear DACDS[2:0] in CTRL */ + MIDIx->CTRL &= (u32)~MIDI_CTRL_DACDS_MASK; + + /* Set new DACDS[2:0] in CTRL */ + MIDIx->CTRL |= (DACDS << 8); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable MUSIC Engine for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_MUSICENCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CTRL |= MUSICEN_ENABLE; + } + else + { + MIDIx->CTRL &= MUSICEN_DISABLE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable SPI RDEN for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_SPIRDENCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CTRL |= SPIRDEN_ENABLE; + } + else + { + MIDIx->CTRL &= SPIRDEN_DISABLE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable SPI DISLOOP for the specified MIDI peripheral. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param NewState: new state of the MIDIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_SPIDISLOOPCmd(HT_MIDI_TypeDef* MIDIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + MIDIx->CTRL |= SPIDISLOOP_ENABLE; + } + else + { + MIDIx->CTRL &= SPIDISLOOP_DISABLE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the Channel Selection for the selected MIDI. + * @param MIDIx: where MIDIx is the selected MIDI from the MIDI peripherals. + * @param CHS: specify channel selection of the MIDI. + * @retval None + ***********************************************************************************************************/ +void MIDI_CTRL_CHS(HT_MIDI_TypeDef* MIDIx, u8 CHS) +{ + /* Check the parameters */ + Assert_Param(IS_MIDI(MIDIx)); + Assert_Param(IS_MIDI_CTRL_CHS(CHS)); + + /* Clear CHS[2:0] in CTRL */ + MIDIx->CTRL &= (u32)~MIDI_CTRL_CHS_MASK; + + /* Set new CHS[2:0] in CTRL */ + MIDIx->CTRL |= CHS; +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pdma.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pdma.c new file mode 100644 index 0000000000..4d7929e5ad --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pdma.c @@ -0,0 +1,312 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_pdma.c + * @version $Rev:: 6479 $ + * @date $Date:: 2022-11-23 #$ + * @brief This file provides all the PDMA firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_pdma.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup PDMA PDMA + * @brief PDMA driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup PDMA_Exported_Functions PDMA exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the PDMA peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void PDMA_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.PDMA = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure specific PDMA channel + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param PDMACH_InitStruct: pointer to a PDMACH_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void PDMA_Config(u32 PDMA_CHn, PDMACH_InitTypeDef *PDMACH_InitStruct) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_WIDTH(PDMACH_InitStruct->PDMACH_DataSize)); + Assert_Param(IS_PDMA_PRIO(PDMACH_InitStruct->PDMACH_Priority)); + Assert_Param(IS_PDMA_ADR_MOD(PDMACH_InitStruct->PDMACH_AdrMod)); + Assert_Param(IS_PDMA_BLK_CNT(PDMACH_InitStruct->PDMACH_BlkCnt)); + Assert_Param(IS_PDMA_BLK_LEN(PDMACH_InitStruct->PDMACH_BlkLen)); + + /* PDMA channel x configuration */ + PDMACHx->CR = (PDMACH_InitStruct->PDMACH_DataSize | PDMACH_InitStruct->PDMACH_Priority | PDMACH_InitStruct->PDMACH_AdrMod); + + PDMACHx->SADR = PDMACH_InitStruct->PDMACH_SrcAddr; + + PDMACHx->DADR = PDMACH_InitStruct->PDMACH_DstAddr; + + PDMACHx->TSR = (PDMACH_InitStruct->PDMACH_BlkCnt << 16) | PDMACH_InitStruct->PDMACH_BlkLen; +} + +/*********************************************************************************************************//** + * @brief PDMA_AddrConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param SrcAddr: Source address + * @param DstAddr: Destination address + * @retval None + ************************************************************************************************************/ +void PDMA_AddrConfig(u32 PDMA_CHn, u32 SrcAddr, u32 DstAddr) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + /* transfer address configuration */ + PDMACHx->SADR = SrcAddr; + PDMACHx->DADR = DstAddr; +} + +/*********************************************************************************************************//** + * @brief PDMA_SrcAddrConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param SrcAddr: Source address + * @retval None + ************************************************************************************************************/ +void PDMA_SrcAddrConfig(u32 PDMA_CHn, u32 SrcAddr) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + /* transfer address configuration */ + PDMACHx->SADR = SrcAddr; +} + +/*********************************************************************************************************//** + * @brief PDMA_DstAddrConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param DstAddr: Destination address + * @retval None + ************************************************************************************************************/ +void PDMA_DstAddrConfig(u32 PDMA_CHn, u32 DstAddr) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + /* transfer address configuration */ + PDMACHx->DADR = DstAddr; +} + +/*********************************************************************************************************//** + * @brief PDMA_TranSizeConfig + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param BlkCnt: Number of blocks for a transfer + * @param BlkLen: Number of data for a block + * @retval None + ************************************************************************************************************/ +void PDMA_TranSizeConfig(u32 PDMA_CHn, u16 BlkCnt, u16 BlkLen) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_BLK_CNT(BlkCnt)); + Assert_Param(IS_PDMA_BLK_LEN(BlkLen)); + + /* transfer size configuration */ + PDMACHx->TSR = ((BlkCnt << 16) | BlkLen); +} + +/*********************************************************************************************************//** + * @brief Enable the specific PDMA channel interrupts + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param PDMA_INT_x: PDMA_INT_GE, PDMA_INT_BE, PDMA_INT_HT, PDMA_INT_TC, PDMA_INT_TE + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PDMA_IntConfig(u32 PDMA_CHn, u32 PDMA_INT_x, ControlStatus NewState) +{ + u32 uRegTmp = 0; + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_INT(PDMA_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + #if (LIBCFG_PDMA_CH3FIX) + if (PDMA_CHn == PDMA_CH3) + { + if (PDMA_INT_x & PDMA_INT_BE) + { + uRegTmp |= (PDMA_INT_BE << (PDMA_CH2 * 5)); + } + if (PDMA_INT_x & PDMA_INT_HT) + { + uRegTmp |= (PDMA_INT_HT << (PDMA_CH2 * 5)); + } + } + #endif + + if (NewState != DISABLE) + { + HT_PDMA->IER |= ((PDMA_INT_x << (PDMA_CHn * 5)) | uRegTmp); + } + else + { + HT_PDMA->IER &= ~(PDMA_INT_x << (PDMA_CHn * 5)); + } +} + +/*********************************************************************************************************//** + * @brief Enable a specific PDMA channel + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PDMA_EnaCmd(u32 PDMA_CHn, ControlStatus NewState) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + PDMACHx->CR |= (1UL); + } + else + { + PDMACHx->CR &= ~(1UL); + } +} + +/*********************************************************************************************************//** + * @brief Software trigger a specific PDMA channel + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PDMA_SwTrigCmd(u32 PDMA_CHn, ControlStatus NewState) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + PDMACHx->CR |= (1UL << 1); + } + else + { + PDMACHx->CR &= ~(1UL << 1); + } +} + +/*********************************************************************************************************//** + * @brief Get the specific PDMA channel interrupt flag + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param PDMA_FLAG_x: PDMA_FLAG_GE, PDMA_FLAG_BE, PDMA_FLAG_HT, PDMA_FLAG_TC, PDMA_FLAG_TE + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus PDMA_GetFlagStatus(u32 PDMA_CHn, u32 PDMA_FLAG_x) +{ + /* !!! NOTICE !!! + Must turn on the PDMA IER to get the ISR flag. + For example: PDMA_GetFlagStatus(PDMA_CH0, PDMA_INT_TC, ENABLE); + */ + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_FLAG(PDMA_FLAG_x)); + + if (HT_PDMA->ISR & (PDMA_FLAG_x << PDMA_CHn * 5)) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specific PDMA channel interrupt flags + * @param PDMA_CHn: PDMA_CH0 ~ PDMA_CH5 + * @param PDMA_FLAG_x: PDMA_FLAG_GE, PDMA_FLAG_BE, PDMA_FLAG_HT, PDMA_FLAG_TC, PDMA_FLAG_TE + * @retval None + ************************************************************************************************************/ +void PDMA_ClearFlag(u32 PDMA_CHn, u32 PDMA_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + Assert_Param(IS_PDMA_CLEAR_FLAG(PDMA_FLAG_x)); + + HT_PDMA->ISCR |= (PDMA_FLAG_x << PDMA_CHn * 5); +} + +/*********************************************************************************************************//** + * @brief Get remain block count of the specific PDMA channel + * @retval CBLKCNT + ************************************************************************************************************/ +u16 PDMA_GetRemainBlkCnt(u32 PDMA_CHn) +{ + HT_PDMACH_TypeDef *PDMACHx = (HT_PDMACH_TypeDef *)(HT_PDMA_BASE + PDMA_CHn * 6 * 4); + + /* Check the parameters */ + Assert_Param(IS_PDMA_CH(PDMA_CHn)); + + return ((PDMACHx->CTSR) >> 16); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwm.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwm.c new file mode 100644 index 0000000000..b824c72b16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwm.c @@ -0,0 +1,2 @@ +The SCTM, PWM, GPTM, and MCTM timer have similar architecture. They use the same driver, +"ht32fxxxxx_tm.c/.h" to save the code size. For those timers, please refet to the TM driver/example. diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwrcu.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwrcu.c new file mode 100644 index 0000000000..0ab83cf919 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_pwrcu.c @@ -0,0 +1,846 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_pwrcu.c + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief This file provides all the Power Control Unit firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_pwrcu.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup PWRCU PWRCU + * @brief PWRCU driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Private_Define PWRCU private definitions + * @{ + */ +#define Set_RTCEN SetBit_BB((u32)&HT_CKCU->APBCCR1, 6); +#define Reset_RTCEN ResetBit_BB((u32)&HT_CKCU->APBCCR1, 6); +#define Get_RTCEN GetBit_BB((u32)&HT_CKCU->APBCCR1, 6) + +#define Set_LDOMODE SetBit_BB((u32)&HT_PWRCU->CR, 2) +#define Reset_LDOMODE ResetBit_BB((u32)&HT_PWRCU->CR, 2) + +#define Set_LDOOFF SetBit_BB((u32)&HT_PWRCU->CR, 3) +#define Reset_LDOOFF ResetBit_BB((u32)&HT_PWRCU->CR, 3) + +#define Set_DMOSON SetBit_BB((u32)&HT_PWRCU->CR, 7) +#define Reset_DMOSON ResetBit_BB((u32)&HT_PWRCU->CR, 7) + +#define Set_WUP0EN SetBit_BB((u32)&HT_PWRCU->CR, 8) +#define Reset_WUP0EN ResetBit_BB((u32)&HT_PWRCU->CR, 8) + +#if (LIBCFG_PWRCU_WAKEUP1) +#define Set_WUP1EN SetBit_BB((u32)&HT_PWRCU->CR, 10) +#define Reset_WUP1EN ResetBit_BB((u32)&HT_PWRCU->CR, 10) +#endif + +#if (LIBCFG_PWRCU_V15_READY_SOURCE) +#define Set_V15RDYSC SetBit_BB((u32)&HT_PWRCU->CR, 12) +#define Reset_V15RDYSC ResetBit_BB((u32)&HT_PWRCU->CR, 12) +#endif + +#define Set_DMOSSTS SetBit_BB((u32)&HT_PWRCU->CR, 15) +#define Reset_DMOSSTS ResetBit_BB((u32)&HT_PWRCU->CR, 15) +#define Get_DMOSSTS GetBit_BB((u32)&HT_PWRCU->CR, 15) + +#define Set_BODEN SetBit_BB((u32)&HT_PWRCU->LVDCSR, 0) +#define Reset_BODEN ResetBit_BB((u32)&HT_PWRCU->LVDCSR, 0) + +#define Set_BODRIS SetBit_BB((u32)&HT_PWRCU->LVDCSR, 1) +#define Reset_BODRIS ResetBit_BB((u32)&HT_PWRCU->LVDCSR, 1) + +#define Set_BODF SetBit_BB((u32)&HT_PWRCU->LVDCSR, 3) +#define Reset_BODF ResetBit_BB((u32)&HT_PWRCU->LVDCSR, 3) +#define Get_BODF GetBit_BB((u32)&HT_PWRCU->LVDCSR, 3) + +#define Set_LVDEN SetBit_BB((u32)&HT_PWRCU->LVDCSR, 16) +#define Reset_LVDEN ResetBit_BB((u32)&HT_PWRCU->LVDCSR, 16) + +#define Set_LVDF SetBit_BB((u32)&HT_PWRCU->LVDCSR, 19) +#define Reset_LVDF ResetBit_BB((u32)&HT_PWRCU->LVDCSR, 19) +#define Get_LVDF GetBit_BB((u32)&HT_PWRCU->LVDCSR, 19) + +#define Set_LVDIWEN SetBit_BB((u32)&HT_PWRCU->LVDCSR, 20) +#define Reset_LVDIWEN ResetBit_BB((u32)&HT_PWRCU->LVDCSR, 20) + +#define Set_LVDEWEN SetBit_BB((u32)&HT_PWRCU->LVDCSR, 21) +#define Reset_LVDEWEN ResetBit_BB((u32)&HT_PWRCU->LVDCSR, 21) + +#define SLEEPDEEP_SET 0x04 /*!< Cortex SLEEPDEEP bit */ + +#define PWRRST_SET 0x1 +#define PWRTEST_READY 0x27 +#define TIME_OUT 24000000 +#define WUP0TYPE_MASK 0xFFFCFFFF +#define WUP1TYPE_MASK 0xFFF3FFFF +#define LVDS_MASK 0xFFB9FFFF +#define VREG_V_MASK 0xF3FFFFFF +#define VREG_M_MASK 0xFCFFFFFF +#define PWRRST_SET 0x1 +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup PWRCU_Exported_Functions PWRCU exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize backup domain which contains PWRCU and RTC units. + * @retval None + ************************************************************************************************************/ +void PWRCU_DeInit(void) +{ + HT_PWRCU->CR = PWRRST_SET; + while(HT_PWRCU->CR & 0xFFFFEFFF); /* Skip Bit 12 because it isn't of valuable reference. */ + #if (LIBCFG_PWRCU_NO_PORF) + #else + while (HT_PWRCU->SR); /* Waits until the PWRPORF be cleared by read */ + #endif +} + +#if (!LIBCFG_NO_PWRCU_TEST_REG) +/*********************************************************************************************************//** + * @brief Waits, until the PWRCU can be accessed. + * @retval PWRCU_TIMEOUT or PWRCU_OK + ************************************************************************************************************/ +PWRCU_Status PWRCU_CheckReadyAccessed(void) +{ + u32 wTimeOutCnt = TIME_OUT; + + while (--wTimeOutCnt) + { + if (HT_PWRCU->TEST == PWRTEST_READY) + { + return PWRCU_OK; + } + } + return PWRCU_TIMEOUT; +} +#endif + +/*********************************************************************************************************//** + * @brief Return the flags of PWRCU. + * @retval This function will return one of the following: + * - 0x0000 : There is no flag is set. + * - 0x0001 (PWRCU_FLAG_PWRPOR) : VDD power domain power-on reset flag has been set. + * - 0x0002 (PWRCU_FLAG_PD) : Power-Down flag has been set. + * - 0x0010 (PWRCU_FLAG_POR) : Power-on reset flag has been set. + * - 0x0100 (PWRCU_FLAG_WUP0) : External WAKEUP0 pin flag has been set. + * - 0x0200 (PWRCU_FLAG_WUP1) : External WAKEUP1 pin flag has been set. + ************************************************************************************************************/ +u16 PWRCU_GetFlagStatus(void) +{ + return HT_PWRCU->SR; +} + +#if (LIBCFG_BAKREG) +/*********************************************************************************************************//** + * @brief Return the value of specified backup register. + * @param BAKREGx: Number of backup register. Where x can be 0 ~ 9. + * @return Between 0x0 ~ 0xFFFFFFFF. + ************************************************************************************************************/ +u32 PWRCU_ReadBackupRegister(PWRCU_BAKREG_Enum BAKREGx) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_BAKREG(BAKREGx)); + + return HT_PWRCU->BAKREG[BAKREGx]; +} + +/*********************************************************************************************************//** + * @brief Write the DATA to specified backup register. + * @param BAKREGx : Number of backup registers. Where x can be 0 ~ 9. + * @param DATA : Must between 0x0 ~ 0xFFFFFFFF. + * @retval None + ************************************************************************************************************/ +void PWRCU_WriteBackupRegister(PWRCU_BAKREG_Enum BAKREGx, u32 DATA) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_BAKREG(BAKREGx)); + + HT_PWRCU->BAKREG[BAKREGx] = DATA; +} +#endif + +/*********************************************************************************************************//** + * @brief Enter SLEEP mode. + * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE. + * This parameter can be one of the following values: + * @arg PWRCU_SLEEP_ENTRY_WFE : Enters SLEEP mode via WFE instruction + * @arg PWRCU_SLEEP_ENTRY_WFI : Enters SLEEP mode via WFI instruction + * @retval None + ************************************************************************************************************/ +void PWRCU_Sleep(PWRCU_SLEEP_ENTRY_Enum SleepEntry) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry)); + + /* Clear SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR &= ~(u32)SLEEPDEEP_SET; + + if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE) + { + /* Wait for event */ + __SEV(); + __WFE(); + __WFE(); + } + else + { + /* Wait for interrupt */ + __WFI(); + } +} + +/*********************************************************************************************************//** + * @brief Enter DEEP-SLEEP Mode 1. + * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE. + * This parameter can be one of the following values: + * @arg PWRCU_SLEEP_ENTRY_WFE : Enters SLEEP mode via WFE instruction + * @arg PWRCU_SLEEP_ENTRY_WFI : Enters SLEEP mode via WFI instruction + * @retval None + ************************************************************************************************************/ +void PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_Enum SleepEntry) +{ + u32 uRTCStatus = 0; + /* Check the parameters */ + Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry)); + + uRTCStatus = Get_RTCEN; + Set_RTCEN; + + Reset_DMOSON; + Reset_LDOOFF; + + /* Sets SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SLEEPDEEP_SET; + + if (uRTCStatus == 0) + { + Reset_RTCEN; + } + + if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE) + { + /* Wait for event */ + __SEV(); + __WFE(); + __WFE(); + } + else + { + /* Wait for interrupt */ + __WFI(); + } + + SCB->SCR &= ~(u32)SLEEPDEEP_SET; +} + +/*********************************************************************************************************//** + * @brief Enter DEEP-SLEEP Mode 2. + * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE. + * This parameter can be one of the following values: + * @arg PWRCU_SLEEP_ENTRY_WFE : Enters SLEEP mode via WFE instruction + * @arg PWRCU_SLEEP_ENTRY_WFI : Enters SLEEP mode via WFI instruction + * @retval None + ************************************************************************************************************/ +void PWRCU_DeepSleep2(PWRCU_SLEEP_ENTRY_Enum SleepEntry) +{ + u32 uRTCStatus = 0; + /* Check the parameters */ + Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry)); + + uRTCStatus = Get_RTCEN; + Set_RTCEN; + + if (Get_DMOSSTS == 0) + { + Reset_DMOSON; + Set_DMOSON; + } + Reset_LDOOFF; + + if (uRTCStatus == 0) + { + Reset_RTCEN; + } + + /* Sets SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SLEEPDEEP_SET; + + if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE) + { + /* Wait for event */ + __SEV(); + __WFE(); + __WFE(); + } + else + { + /* Wait for interrupt */ + __WFI(); + } + + SCB->SCR &= ~(u32)SLEEPDEEP_SET; +} + +#if !defined(USE_HT32F52220_30) +/*********************************************************************************************************//** + * @brief Enter DEEP-SLEEP Mode 2. + * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE. + * This parameter can be one of the following values: + * @arg PWRCU_SLEEP_ENTRY_WFE : Enters SLEEP mode via WFE instruction + * @arg PWRCU_SLEEP_ENTRY_WFI : Enters SLEEP mode via WFI instruction + * @retval None + ************************************************************************************************************/ +void PWRCU_DeepSleep2Ex(PWRCU_SLEEP_ENTRY_Enum SleepEntry) +{ + u32 uRTCStatus = 0; + u32 uBackUp[4]; + + /* Check the parameters */ + Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry)); + + uRTCStatus = Get_RTCEN; + Set_RTCEN; + uBackUp[0] = HT_RTC->CMP; + uBackUp[1] = HT_RTC->IWEN; + uBackUp[2] = HT_RTC->CR; + uBackUp[3] = HT_EXTI->WAKUPCR; + + Set_DMOSON; + Reset_LDOOFF; + + /* Sets SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SLEEPDEEP_SET; + + if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE) + { + /* Wait for event */ + __SEV(); + __WFE(); + __WFE(); + } + else + { + /* Wait for interrupt */ + __WFI(); + } + + if (HT_EXTI->WAKUPFLG) + { + HT_EXTI->WAKUPCR &= ~(0xFFFF); + HT_EXTI->WAKUPFLG = 0xFFFF; + HT_RTC->CR &= (~1UL); + HT_RTC->CMP = 1; + HT_RTC->IWEN = (1 << 9); + HT_RTC->CR = (1 << 4) | (1 << 2) | (1 << 0); + __SEV(); + __WFE(); + __WFE(); + HT_RTC->CR &= (~1UL); + rw((u32)&HT_RTC->SR); + + HT_RTC->CMP = uBackUp[0]; + HT_RTC->IWEN = uBackUp[1]; + HT_RTC->CR = uBackUp[2]; + HT_EXTI->WAKUPCR = uBackUp[3]; + } + + SCB->SCR &= ~(u32)SLEEPDEEP_SET; + + if (uRTCStatus == 0) + { + Reset_RTCEN; + } +} +#endif + +#if (!LIBCFG_PWRCU_NO_PD_MODE) +/*********************************************************************************************************//** + * @brief Enter POWER-DOWN Mode. + * @retval None + ************************************************************************************************************/ +void PWRCU_PowerDown(void) +{ + u32 uRTCStatus = 0; + + uRTCStatus = Get_RTCEN; + Set_RTCEN; + + #if (LIBCFG_RTC_LSI_LOAD_TRIM) + { + static u8 isLSITrimLoaded = FALSE; + if (isLSITrimLoaded == FALSE) + { + u32 i = 4800; + isLSITrimLoaded = TRUE; + HT_RTC->CR &= ~(1UL << 2); + /* Insert a delay must > 1 CK_RTC */ + while (i--); + HT_RTC->CR |= (1UL << 2); + while ((HT_CKCU->GCSR & 0x20) == 0); + } + } + #endif + + Reset_DMOSON; + Set_LDOOFF; + + if (uRTCStatus == 0) + { + Reset_RTCEN; + } + + /* Sets SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SLEEPDEEP_SET; + + /* Enters power-down mode */ + __SEV(); + __WFE(); + __WFE(); + + { + u32 X = (16 * 250); + while (X--); + } + + NVIC_SystemReset(); +} +#endif + +/*********************************************************************************************************//** + * @brief Configure LVD voltage level. + * @param Level: Low voltage detect level. + * This parameter can be one of the following: + * VDD 2.0 ~ 3.6V version: + * @arg PWRCU_LVDS_2V25 : 2.25 V + * @arg PWRCU_LVDS_2V4 : 2.40 V + * @arg PWRCU_LVDS_2V55 : 2.55 V + * @arg PWRCU_LVDS_2V7 : 2.70 V + * @arg PWRCU_LVDS_2V85 : 2.85 V + * @arg PWRCU_LVDS_3V : 3.00 V + * @arg PWRCU_LVDS_3V15 : 3.15 V + * @arg PWRCU_LVDS_3V3 : 3.30 V + * VDD 1.65 ~ 3.6V version: + * @arg PWRCU_LVDS_1V75 : 1.75 V + * @arg PWRCU_LVDS_1V95 : 1.95 V + * @arg PWRCU_LVDS_2V15 : 2.15 V + * @arg PWRCU_LVDS_2V35 : 2.35 V + * @arg PWRCU_LVDS_2V55 : 2.55 V + * @arg PWRCU_LVDS_2V75 : 2.75 V + * @arg PWRCU_LVDS_2V95 : 2.95 V + * @arg PWRCU_LVDS_3V15 : 3.15 V + * VDD 5.0V version: + * @arg PWRCU_LVDS_2V65 : 2.65 V + * @arg PWRCU_LVDS_2V85 : 2.85 V + * @arg PWRCU_LVDS_3V05 : 3.05 V + * @arg PWRCU_LVDS_3V25 : 3.25 V + * @arg PWRCU_LVDS_3V45 : 3.45 V + * @arg PWRCU_LVDS_4V25 : 4.25 V + * @arg PWRCU_LVDS_4V45 : 4.45 V + * @arg PWRCU_LVDS_4V65 : 4.65 V + * @retval None + ************************************************************************************************************/ +void PWRCU_SetLVDS(PWRCU_LVDS_Enum Level) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_LVDS(Level)); + + HT_PWRCU->LVDCSR = (HT_PWRCU->LVDCSR & LVDS_MASK) | Level; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable LVD function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_LVDCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + Set_LVDEN; + } + else + { + Reset_LVDEN; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable BOD reset function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_BODCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + Set_BODEN; + } + else + { + Reset_BODEN; + } +} + +/*********************************************************************************************************//** + * @brief Select when the BOD occurs, the action for the cause Reset or Interrupt. + * @param Selection: BOD reset or interrupt selection. + * This parameter can be one of the following values: + * @arg PWRCU_BODRIS_RESET : Reset the whole chip + * @arg PWRCU_BODRIS_INT : Assert interrupt + * @retval None + ************************************************************************************************************/ +void PWRCU_BODRISConfig(PWRCU_BODRIS_Enum Selection) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_BODRIS(Selection)); + + if (Selection != PWRCU_BODRIS_RESET) + { + Set_BODRIS; + } + else + { + Reset_BODRIS; + } +} + +/*********************************************************************************************************//** + * @brief Return the flag status of LVD. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus PWRCU_GetLVDFlagStatus(void) +{ + return (FlagStatus)Get_LVDF; +} + +/*********************************************************************************************************//** + * @brief Return the flag status of BOD. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus PWRCU_GetBODFlagStatus(void) +{ + return (FlagStatus)Get_BODF; +} + +/*********************************************************************************************************//** + * @brief Return the DMOS status. + * @retval This function will return one of the following values: + * - PWRCU_DMOS_STS_ON : DMOS on + * - PWRCU_DMOS_STS_OFF : DMOS off + * - PWRCU_DMOS_STS_OFF_BY_BODRESET : DMOS off caused by brow out reset + ************************************************************************************************************/ +PWRCU_DMOSStatus PWRCU_GetDMOSStatus(void) +{ + u32 wDmosStatus = HT_PWRCU->CR & 0x8080; + + if (wDmosStatus == 0x0) + { + return PWRCU_DMOS_STS_OFF; + } + else if (wDmosStatus == 0x8080) + { + return PWRCU_DMOS_STS_ON; + } + else + { + return PWRCU_DMOS_STS_OFF_BY_BODRESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable DMOS function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_DMOSCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (Get_DMOSSTS == 0) + { + Reset_DMOSON; + } + + if (NewState != DISABLE) + { + Set_DMOSON; + } + else + { + Reset_DMOSON; + } +} + +/*********************************************************************************************************//** + * @brief Configure the LDO operation mode. + * @param Sel: Specify the LDO mode. + * This parameter can be one of the following values: + * @arg PWRCU_LDO_NORMAL : The LDO is operated in normal current mode + * @arg PWRCU_LDO_LOWCURRENT : The LDO is operated in low current mode + * @retval None + ************************************************************************************************************/ +void PWRCU_LDOConfig(PWRCU_LDOMODE_Enum Sel) +{ + u32 uRTCStatus = 0; + + /* Check the parameters */ + Assert_Param(IS_PWRCU_LDOMODE(Sel)); + + uRTCStatus = Get_RTCEN; + Set_RTCEN; + + if (Sel == PWRCU_LDO_NORMAL) + { + Reset_LDOMODE; + } + else + { + Set_LDOMODE; + } + + if (uRTCStatus == 0) + { + Reset_RTCEN; + } +} + +#if (LIBCFG_PWRCU_V15_READY_SOURCE) +/*********************************************************************************************************//** + * @brief Configure VDD15 power good source. + * @param Sel: specifies VDD15 power good source. + * This parameter can be one of the following values: + * @arg PWRCU_V15RDYSC_V33ISO : Vdd15 power good source come from V33_ISO bit in CKCU unit + * @arg PWRCU_V15RDYSC_V15POR : Vdd15 power good source come from Vdd15 power-on reset + * @retval None + ************************************************************************************************************/ +void PWRCU_V15RDYSourceConfig(PWRCU_V15RDYSC_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_V15RDYSC(Sel)); + + if (Sel == PWRCU_V15RDYSC_V33ISO) + { + Reset_V15RDYSC; + } + else + { + Set_V15RDYSC; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the LVD interrupt wakeup function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_LVDIntWakeupConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + Set_LVDIWEN; + } + else + { + Reset_LVDIWEN; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the LVD event wakeup function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_LVDEventWakeupConfig(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + Set_LVDEWEN; + } + else + { + Reset_LVDEWEN; + } +} + +#if (LIBCFG_PWRCU_VREG) +/*********************************************************************************************************//** + * @brief Configure the VREG output voltage. + * @param Volt: VREG output voltage. + * This parameter can be one of the following: + * @arg PWRCU_VREG_4V0 : 4.0 V + * @arg PWRCU_VREG_3V3 : 3.3 V + * @arg PWRCU_VREG_3V0 : 3.0 V + * @arg PWRCU_VREG_2V5 : 2.5 V + * @arg PWRCU_VREG_1V8 : 1.8 V + * @retval None + ************************************************************************************************************/ +void PWRCU_SetVREG(PWRCU_VREG_VOLT_Enum Volt) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_VREG_VOLT(Volt)); + + HT_PWRCU->CR = (HT_PWRCU->CR & VREG_V_MASK) | Volt; +} + +/*********************************************************************************************************//** + * @brief Configure the VREG operation mode. + * @param Mode: VREG operation mode. + * This parameter can be one of the following values: + * @arg PWRCU_VREG_DISABLE : The VREG is disabled + * @arg PWRCU_VREG_ENABLE : The VREG is enabled + * @arg PWRCU_VREG_BYPASS : The VREG is bypassed + * @retval None + ************************************************************************************************************/ +void PWRCU_VREGConfig(PWRCU_VREG_MODE_Enum Mode) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_VREG_MODE(Mode)); + + HT_PWRCU->CR = (HT_PWRCU->CR & VREG_M_MASK) | Mode; +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the external WAKEUP pin function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_WakeupPinCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + Set_WUP0EN; + } + else + { + Reset_WUP0EN; + } +} + +#if (LIBCFG_PWRCU_WAKEUP_V01) +/*********************************************************************************************************//** + * @brief Enable or Disable the external WAKEUP pin function. + * @param Pin: specify the WAKEUP pin number. + * This parameter can be one of the following values: + * @arg PWRCU_WAKEUP_PIN_0 : + * @arg PWRCU_WAKEUP_PIN_1 : + * @param Type: specify the WAKEUP pin type. + * This parameter can be one of the following values: + * @arg PWRCU_WUP_POSITIVE_EDGE : + * @arg PWRCU_WUP_NEGATIVE_EDGE : + * @arg PWRCU_WUP_HIGH_LEVEL : + * @arg PWRCU_WUP_LOW_LEVEL : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void PWRCU_WakeupMultiPinCmd(PWRCU_WUP_Enum Pin, PWRCU_WUPTYPE_Enum Type, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_WAKEUPPIN(Pin)); + Assert_Param(IS_PWRCU_TRIGGERTYPE(Type)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + if (Pin == PWRCU_WAKEUP_PIN_0) + { + HT_PWRCU->CR = (HT_PWRCU->CR & WUP0TYPE_MASK) | (Type << 16); + Set_WUP0EN; + } + else + { + HT_PWRCU->CR = (HT_PWRCU->CR & WUP1TYPE_MASK) | (Type << 18); + Set_WUP1EN; + } + } + else + { + if (Pin == PWRCU_WAKEUP_PIN_0) + Reset_WUP0EN; + else + Reset_WUP1EN; + } +} +#endif + +#if defined(USE_HT32F52342_52) || defined(USE_HT32F5826) +/*********************************************************************************************************//** + * @brief Configure HSI ready counter bit length. + * @param BitLength: HSI ready counter bit length. + * This parameter can be one of following: + * @arg PWRCU_HSIRCBL_4 : 4 bits + * @arg PWRCU_HSIRCBL_5 : 5 bits + * @arg PWRCU_HSIRCBL_6 : 6 bits + * @arg PWRCU_HSIRCBL_7 : 7 bits (Default) + * @retval None + ************************************************************************************************************/ +void PWRCU_HSIReadyCounterBitLengthConfig(PWRCU_HSIRCBL_Enum BitLength) +{ + /* Check the parameters */ + Assert_Param(IS_PWRCU_HSIRCBL(BitLength)); + + HT_PWRCU->HSIRCR = BitLength; +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rstcu.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rstcu.c new file mode 100644 index 0000000000..8c5ced5882 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rstcu.c @@ -0,0 +1,142 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_rstcu.c + * @version $Rev:: 6479 $ + * @date $Date:: 2022-11-23 #$ + * @brief This file provides all the Reset Control Unit firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_rstcu.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup RSTCU RSTCU + * @brief RSTCU driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup RSTCU_Exported_Functions RSTCU exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Check whether the specific global reset flag is set or not. + * @param RSTCU_RSTF: specify the reset flag. + * This parameter can be one of the following values: + * @arg RSTCU_FLAG_SYSRST : Get system reset flag + * @arg RSTCU_FLAG_EXTRST : Get external pin reset flag + * @arg RSTCU_FLAG_WDTRST : Get WDT reset flag + * @arg RSTCU_FLAG_PORST : Get power on reset flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus RSTCU_GetResetFlagStatus(RSTCU_RSTF_TypeDef RSTCU_RSTF) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_RSTCU_FLAG(RSTCU_RSTF)); + + tmp = (HT_RSTCU->GRSR & ((u32)0x1 << RSTCU_RSTF)); + if (tmp != RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specific global reset flag. + * @param RSTCU_RSTF: specify the reset flag. + * This parameter can be one of the following values: + * @arg RSTCU_FLAG_SYSRST : Clear system reset flag + * @arg RSTCU_FLAG_EXTRST : Clear external pin reset flag + * @arg RSTCU_FLAG_WDTRST : Clear WDT reset flag + * @arg RSTCU_FLAG_PORST : Clear power on reset flag + * @retval None + ************************************************************************************************************/ +void RSTCU_ClearResetFlag(RSTCU_RSTF_TypeDef RSTCU_RSTF) +{ + /* Check the parameters */ + Assert_Param(IS_RSTCU_FLAG(RSTCU_RSTF)); + + HT_RSTCU->GRSR = (u32)0x1 << RSTCU_RSTF; /* Write 1 to clear */ +} + +/*********************************************************************************************************//** + * @brief Clear all of the global reset flag. + * @retval None + ************************************************************************************************************/ +void RSTCU_ClearAllResetFlag(void) +{ + HT_RSTCU->GRSR = (u32)0xF; /* Write 1 to clear */ +} + +/*********************************************************************************************************//** + * @brief Peripheral reset function. + * @param Reset: specify the peripheral clock enable bits. + * @param Cmd: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RSTCU_PeripReset(RSTCU_PeripReset_TypeDef Reset, ControlStatus Cmd) +{ + u32 uAHBPRST; + u32 uAPBPRST0; + u32 uAPBPRST1; + + uAHBPRST = HT_RSTCU->AHBPRST; + uAPBPRST0 = HT_RSTCU->APBPRST0; + uAPBPRST1 = HT_RSTCU->APBPRST1; + + uAHBPRST &= ~(Reset.Reg[0]); + uAPBPRST0 &= ~(Reset.Reg[1]); + uAPBPRST1 &= ~(Reset.Reg[2]); + + if (Cmd != DISABLE) + { + uAHBPRST |= Reset.Reg[0]; + uAPBPRST0 |= Reset.Reg[1]; + uAPBPRST1 |= Reset.Reg[2]; + } + + HT_RSTCU->AHBPRST = uAHBPRST; + HT_RSTCU->APBPRST0 = uAPBPRST0; + HT_RSTCU->APBPRST1 = uAPBPRST1; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rtc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rtc.c new file mode 100644 index 0000000000..b4ae956433 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_rtc.c @@ -0,0 +1,393 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_rtc.c + * @version $Rev:: 7336 $ + * @date $Date:: 2023-11-23 #$ + * @brief This file provides all the RTC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_rtc.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup RTC RTC + * @brief RTC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Private_Define RTC private definitions + * @{ + */ +#define RPRE_MASK (0xFFFFF0FF) + +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup RTC_Exported_Functions RTC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the RTC peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void RTC_DeInit(void) +{ + HT_RTC->CR = 0x00000004; + HT_RTC->CMP = 0x0; + HT_RTC->IWEN = 0x0; + HT_RTC->CR |= 0x00000005; + while (HT_RTC->CNT); + HT_RTC->CR = 0x00000F04; + /* Read the RTC_SR register to clear it */ + HT_RTC->SR; +} + +/*********************************************************************************************************//** + * @brief Select the RTC timer clock source. + * @param Source: specify the clock source of RTC and backup domain. + * @arg RTC_SRC_LSI : Low speed internal clock. + * @arg RTC_SRC_LSE : Low speed external clock. + * @retval None + ************************************************************************************************************/ +void RTC_ClockSourceConfig(RTC_SRC_Enum Source) +{ + Assert_Param(IS_RTC_SRC(Source)); + + HT_RTC->CR = (HT_RTC->CR & ~(1UL << 1)) | ((u32)Source << 1); +} + +#if (LIBCFG_RTC_LSI_LOAD_TRIM) +/*********************************************************************************************************//** + * @brief Loads the LSI trim data. + * @retval None + ************************************************************************************************************/ +void RTC_LSILoadTrimData(void) +{ + u32 i = 4800; + u32 isRTCEnable = HT_CKCU->APBCCR1 & (1 << 6); + + HT_CKCU->APBCCR1 |= 1 << 6; + HT_RTC->CR &= ~(1UL << 2); + /* Insert a delay must > 1 CK_RTC */ + while (i--); + HT_RTC->CR |= (1UL << 2); + while ((HT_CKCU->GCSR & 0x20) == 0); + + if (isRTCEnable == 0) + HT_CKCU->APBCCR1 &= ~(1 << 6); +} +#endif + +#if (LIBCFG_LSE) +/*********************************************************************************************************//** + * @brief Select the LSE startup mode. + * @param Mode: specify the LSE startup mode. + * This parameter can be one of the following values: + * @arg RTC_LSESM_NORMAL : Little power consumption but longer startup time. + * @arg RTC_LSESM_FAST : Shortly startup time but higher power consumption. + * @retval None + ************************************************************************************************************/ +void RTC_LSESMConfig(RTC_LSESM_Enum Mode) +{ + Assert_Param(IS_RTC_LSESM(Mode)); + + HT_RTC->CR = (HT_RTC->CR & ~(1UL << 5)) | ((u32)Mode << 5); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the LSE clock. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_LSECmd(ControlStatus NewState) +{ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == DISABLE) + { + HT_RTC->CR &= ~(1UL << 3); + } + else + { + HT_RTC->CR |= (1UL << 3); + } +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the compare match function. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_CMPCLRCmd(ControlStatus NewState) +{ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_RTC->CR |= (1UL << 4); + } + else + { + HT_RTC->CR &= ~(1UL << 4); + } +} + +/*********************************************************************************************************//** + * @brief Configure the RTC prescaler. + * @param Psc: Value of RTC prescaler. + * This parameter can be one of following values: + * @arg RTC_RPRE_1 + * @arg RTC_RPRE_2 + * @arg RTC_RPRE_4 + * @arg RTC_RPRE_8 + * @arg RTC_RPRE_16 + * @arg RTC_RPRE_32 + * @arg RTC_RPRE_64 + * @arg RTC_RPRE_128 + * @arg RTC_RPRE_256 + * @arg RTC_RPRE_512 + * @arg RTC_RPRE_1024 + * @arg RTC_RPRE_2048 + * @arg RTC_RPRE_4096 + * @arg RTC_RPRE_8192 + * @arg RTC_RPRE_16384 + * @arg RTC_RPRE_32768 + * @retval None + ************************************************************************************************************/ +void RTC_SetPrescaler(RTC_RPRE_Enum Psc) +{ + Assert_Param(IS_RTC_PSC(Psc)); + + HT_RTC->CR = (HT_RTC->CR & RPRE_MASK) | Psc; +} + +/*********************************************************************************************************//** + * @brief Return the RTC prescaler setting. + * @retval The prescaler value. It is powered by 2 and max.is 32768. + ************************************************************************************************************/ +u16 RTC_GetPrescaler(void) +{ + u32 prescaler; + + prescaler = HT_RTC->CR >> 8; + + return ((u16)0x1 << prescaler); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the RTC timer. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_Cmd(ControlStatus NewState) +{ + if (NewState != DISABLE) + { + HT_RTC->CR |= (1UL); + } + else + { + HT_RTC->CR &= ~(1UL); + } +} + +/*********************************************************************************************************//** + * @brief Return the counter value. + * @retval Between 0x0 ~ 0xFFFFFFFF. + ************************************************************************************************************/ +u32 RTC_GetCounter(void) +{ + /* !!! NOTICE !!! + A 1/CK_RTC delay time is required if you read the RTC CNT count immediately when the RTC compare match + occurred (in the RTC ISR or the system is wakeup from the DeepSleep1/2). + The CK_RTC can be configured from the LSI or LSE. + */ + return (HT_RTC->CNT); +} + +/*********************************************************************************************************//** + * @brief Configure the compare match value. + * @param Compare: Between 0x0 ~ 0xFFFFFFFF + * @retval None + ************************************************************************************************************/ +void RTC_SetCompare(u32 Compare) +{ + HT_RTC->CMP = Compare; +} + +/*********************************************************************************************************//** + * @brief Return the compare match value. + * @retval Between 0x0 ~ 0xFFFFFFFF. + ************************************************************************************************************/ +u32 RTC_GetCompare(void) +{ + return (HT_RTC->CMP); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified wakeup source. + * @param RTC_WAKEUP Selection of Wakeup source. + * This parameter can be any combination of the following values: + * @arg RTC_WAKEUP_CSEC : Waken up by counter counting. + * @arg RTC_WAKEUP_CM : Waken up by counter compare match with CMP register. + * @arg RTC_WAKEUP_OV : Waken up by counter overflow. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_WakeupConfig(u32 RTC_WAKEUP, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_RTC_WAKEUP(RTC_WAKEUP)); + + if (NewState != DISABLE) + { + HT_RTC->IWEN |= RTC_WAKEUP; + } + else + { + HT_RTC->IWEN &= ~RTC_WAKEUP; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified interrupt source. + * @param RTC_INT: Selection of Wakeup source. + * This parameter can be any combination of the following values: + * @arg RTC_INT_CSEC : Assert interrupt at counter counting + * @arg RTC_INT_CM : Assert interrupt at counter compare match with CMP register + * @arg RTC_INT_OV : Assert interrupt at counter overflow + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_IntConfig(u32 RTC_INT, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_RTC_INT(RTC_INT)); + + if (NewState != DISABLE) + { + HT_RTC->IWEN |= RTC_INT; + } + else + { + HT_RTC->IWEN &= ~RTC_INT; + } +} + +/*********************************************************************************************************//** + * @brief Return the RTC flags. + * @retval RTC_STS register value. + * This parameter can be any combination of following: + * - 0x0 : No flag set + * - 0x1 : Count flag + * - 0x2 : Match flag + * - 0x4 : Overflow flag + * @note RTC_SR is read clear. + ************************************************************************************************************/ +u8 RTC_GetFlagStatus(void) +{ + return ((u8)HT_RTC->SR); +} + +/*********************************************************************************************************//** + * @brief Configure the RTC output function. + * @param WMode: specify the RTC output waveform mode + * This parameter can be one of the following values: + * @arg RTC_ROWM_PULSE : Pulse mode + * @arg RTC_ROWM_LEVEL : Level mode + * @param EventSel: specify the RTC output event selection + * This parameter can be one of the following values: + * @arg RTC_ROES_MATCH : Compare match selected + * @arg RTC_ROES_SECOND : Second clock selected + * @param Pol: specify the RTC output active polarity + * This parameter can be one of the following values: + * @arg RTC_ROAP_HIGH : Active level is high + * @arg RTC_ROAP_LOW : Active level is low + * @note This function will disable RTC output first. + ************************************************************************************************************/ +void RTC_OutConfig(RTC_ROWM_Enum WMode, RTC_ROES_Enum EventSel, RTC_ROAP_Enum Pol) +{ + Assert_Param(IS_RTC_ROWM(WMode)); + Assert_Param(IS_RTC_ROES(EventSel)); + Assert_Param(IS_RTC_ROAP(Pol)); + + HT_RTC->CR &= ~(1UL << 16); + HT_RTC->CR = (HT_RTC->CR & ~(1UL << 18)) | ((u32)WMode << 18); + HT_RTC->CR = (HT_RTC->CR & ~(1UL << 17)) | ((u32)EventSel << 17); + HT_RTC->CR = (HT_RTC->CR & ~(1UL << 19)) | ((u32)Pol << 19); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the RTC output. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void RTC_OutCmd(ControlStatus NewState) +{ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_RTC->CR |= (1UL << 16); + } + else + { + HT_RTC->CR &= ~(1UL << 16); + } +} + +/*********************************************************************************************************//** + * @brief Return the RTCOUT level mode flag. + * @retval SET or RESET + * @note Reads RTC_CR action will clear ROLF flag. + ************************************************************************************************************/ +FlagStatus RTC_GetOutStatus(void) +{ + if (HT_RTC->CR & (1UL << 20)) + { + return SET; + } + else + { + return RESET; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sci.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sci.c new file mode 100644 index 0000000000..72a4c06067 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sci.c @@ -0,0 +1,446 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_sci.c + * @version $Rev:: 6386 $ + * @date $Date:: 2022-10-27 #$ + * @brief This file provides all the SCI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_sci.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup SCI SCI + * @brief SCI driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Private_Define SCI private definitions + * @{ + */ +/* SCI ENSCI mask */ +#define CR_ENSCI_SET ((u32)0x00000020) +#define CR_ENSCI_RESET ((u32)0xFFFFFFDF) + +/* SCI WTEN mask */ +#define CR_WTEN_SET ((u32)0x00000004) +#define CR_WTEN_RESET ((u32)0xFFFFFFFB) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SCI_Exported_Functions SCI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the SCI peripheral registers to their default reset values. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @retval None + ************************************************************************************************************/ +void SCI_DeInit(HT_SCI_TypeDef* SCIx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + if (SCIx == HT_SCI0) + { + RSTCUReset.Bit.SCI0 = 1; + } + #if (LIBCFG_SCI1) + else + { + RSTCUReset.Bit.SCI1 = 1; + } + #endif + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the SCI peripheral according to the specified parameters in the SCI_InitStruct. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_InitStruct: pointer to a SCI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SCI_Init(HT_SCI_TypeDef* SCIx, SCI_InitTypeDef* SCI_InitStruct) +{ + u32 tmpreg; + + /* Check the parameters */ + Assert_Param(IS_SCI_MODE(SCI_InitStruct->SCI_Mode)); + Assert_Param(IS_SCI_RETRY(SCI_InitStruct->SCI_Retry)); + Assert_Param(IS_SCI_CONVENTION(SCI_InitStruct->SCI_Convention)); + Assert_Param(IS_SCI_CARD_POLARITY(SCI_InitStruct->SCI_CardPolarity)); + Assert_Param(IS_SCI_CLOCK_PRESCALER(SCI_InitStruct->SCI_ClockPrescale)); + + + /*------------------------- SCI Control Register Configuration -------------------------------------------*/ + tmpreg = SCIx->CR; + tmpreg &= 0xFFFFFFA4; + + tmpreg |= SCI_InitStruct->SCI_Mode | SCI_InitStruct->SCI_Retry | SCI_InitStruct->SCI_Convention | + SCI_InitStruct->SCI_CardPolarity; + + SCIx->CR = tmpreg; + + /*------------------------- SCI Prescaler Register Configuration -----------------------------------------*/ + SCIx->PSC = SCI_InitStruct->SCI_ClockPrescale; +} + +/*********************************************************************************************************//** + * @brief Initialize the SCI peripheral according to the specified parameters in the SCI_InitStruct. + * @param SCI_InitStruct: pointer to a SCI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SCI_StructInit(SCI_InitTypeDef* SCI_InitStruct) +{ + /* Initialize the SCI_Mode member */ + SCI_InitStruct->SCI_Mode = SCI_MODE_MANUAL; + + /* Initialize the SCI_Retry member */ + SCI_InitStruct->SCI_Retry = SCI_RETRY_NO; + + /* Initialize the SCI_Convention member */ + SCI_InitStruct->SCI_Convention = SCI_CONVENTION_DIRECT; + + /* Initialize the SCI_CardPolarity member */ + SCI_InitStruct->SCI_CardPolarity = SCI_CARDPOLARITY_LOW; + + /* Initialize the SCI_ClockPrescale member */ + SCI_InitStruct->SCI_ClockPrescale = SCI_CLKPRESCALER_1; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SCI peripheral. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_Cmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->CR |= CR_ENSCI_SET; + } + else + { + SCIx->CR &= CR_ENSCI_RESET; + } +} + +/*********************************************************************************************************//** + * @brief This function is used to configure the Elementary Time Unit. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_ETU: specify the SCI Elementary Time Unit. + * @param SCI_Compensation: Enable or Disable the Compensation mode. + * This parameter can be one of the following values: + * @arg SCI_COMPENSATION_ENABLE : Compensation mode enabled + * @arg SCI_COMPENSATION_DISABLE : Compensation mode disabled + * @retval None + ************************************************************************************************************/ +void SCI_ETUConfig(HT_SCI_TypeDef* SCIx, u32 SCI_ETU, u32 SCI_Compensation) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_ETU(SCI_ETU)); + Assert_Param(IS_SCI_ETU_COMPENSATION(SCI_Compensation)); + + SCIx->ETU = SCI_ETU | SCI_Compensation; +} + +/*********************************************************************************************************//** + * @brief This function is used to set the value of SCI GuardTime. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_GuardTime: specify the value of SCI GuardTime value. + * @retval None + ************************************************************************************************************/ +void SCI_SetGuardTimeValue(HT_SCI_TypeDef* SCIx, u16 SCI_GuardTime) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_GUARDTIME(SCI_GuardTime)); + + SCIx->GT = SCI_GuardTime; +} + +/*********************************************************************************************************//** + * @brief This function is used to set the value of SCI Waiting Time. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_WaitingTime: specify the value of SCI Waiting Time value. + * @retval None + ************************************************************************************************************/ +void SCI_SetWaitingTimeValue(HT_SCI_TypeDef* SCIx, u32 SCI_WaitingTime) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_WAITING_TIME(SCI_WaitingTime)); + + SCIx->WT = SCI_WaitingTime; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the Waiting Time Counter. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_WaitingTimeCounterCmd(HT_SCI_TypeDef* SCIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->CR |= CR_WTEN_SET; + } + else + { + SCIx->CR &= CR_WTEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Sends a data byte through the SCI peripheral. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Data: byte to be transmitted. + * @retval None + ************************************************************************************************************/ +void SCI_SendData(HT_SCI_TypeDef* SCIx, u8 SCI_Data) +{ + SCIx->TXB = SCI_Data; +} + +/*********************************************************************************************************//** + * @brief Returns the received data through the SCI peripheral. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @retval The value of the received data. + ************************************************************************************************************/ +u8 SCI_ReceiveData(HT_SCI_TypeDef* SCIx) +{ + return ((u8)SCIx->RXB); +} + +/*********************************************************************************************************//** + * @brief Determines the SCI output clock signal is driven by hardware or software. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_CLKMode: specify the SCI clock pin mode. + * This parameter can be one of the following values: + * @arg SCI_CLK_SOFTWARE : SCI output clock is controlled by software + * @arg SCI_CLK_HARDWARE : SCI output clock is controlled by hardware + * @retval None + ************************************************************************************************************/ +void SCI_ClockModeConfig(HT_SCI_TypeDef* SCIx, u32 SCI_CLKMode) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_CLK_MODE(SCI_CLKMode)); + + if (SCI_CLKMode != SCI_CLK_SOFTWARE) + { + SCIx->CCR |= SCI_CLK_HARDWARE; + } + else + { + SCIx->CCR &= SCI_CLK_SOFTWARE; + } +} + +/*********************************************************************************************************//** + * @brief Output the SCI clock pin low or high by software. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_CLK: specify if the SCI clock pin to be high or low. + * This parameter can be one of the following values: + * @arg SCI_CLK_HIGH : Software drive SCI output clock high + * @arg SCI_CLK_LOW : Software drive SCI output clock low + * @retval None + ************************************************************************************************************/ +void SCI_SoftwareClockCmd(HT_SCI_TypeDef* SCIx, u32 SCI_CLK) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_CLK(SCI_CLK)); + + if (SCI_CLK != SCI_CLK_LOW) + { + SCIx->CCR |= SCI_CLK_HIGH; + } + else + { + SCIx->CCR &= SCI_CLK_LOW; + } +} + +/*********************************************************************************************************//** + * @brief Output the SCI DIO pin low or high by software. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_DIO: specify if the SCI DIO pin to be high or low. + * This parameter can be one of the following values: + * @arg SCI_DIO_HIGH : Drive SCI DIO signal high + * @arg SCI_DIO_LOW : Drive SCI DIO signal low + * @retval None + ************************************************************************************************************/ +void SCI_OutputDIO(HT_SCI_TypeDef* SCIx, u32 SCI_DIO) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_DIO(SCI_DIO)); + + if (SCI_DIO != SCI_DIO_LOW) + { + SCIx->CCR |= SCI_DIO_HIGH; + } + else + { + SCIx->CCR &= SCI_DIO_LOW; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SCI interrupt. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Int: specify the SCI interrupt source to be enabled or disable. + * This parameter can be any combination of the following values: + * @arg SCI_INT_PAR : SCI parity error interrupt + * @arg SCI_INT_RXC : SCI received character interrupt + * @arg SCI_INT_TXC : SCI transmitted character interrupt + * @arg SCI_INT_WT : SCI waiting timer interrupt + * @arg SCI_INT_CARD : SCI card insert/remove interrupt + * @arg SCI_INT_TXBE : SCI transmit buffer empty interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_IntConfig(HT_SCI_TypeDef* SCIx, u32 SCI_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_INT(SCI_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->IER |= SCI_Int; + } + else + { + SCIx->IER &= ~SCI_Int; + } +} + +/*********************************************************************************************************//** + * @brief Get the status of specified SCI flag. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg SCI_FLAG_PAR : SCI parity error flag + * @arg SCI_FLAG_RXC : SCI received character flag + * @arg SCI_FLAG_TXC : SCI transmitted character flag + * @arg SCI_FLAG_WT : SCI waiting timer flag + * @arg SCI_FLAG_CARD : SCI card insert/remove flag + * @arg SCI_FLAG_TXBE : SCI transmit buffer empty flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus SCI_GetFlagStatus(HT_SCI_TypeDef* SCIx, u32 SCI_Flag) +{ + u32 statusreg = 0; + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + Assert_Param(IS_SCI_FLAG(SCI_Flag)); + + statusreg = SCIx->SR; + + if ((statusreg & SCI_Flag) != (u32)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Clears the flag status of specified SCI flag. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_Flag: specify the flag to be cleared. + * This parameter can be one of the following values: + * @arg SCI_FLAG_PAR : SCI parity error flag + * @arg SCI_FLAG_TXC : SCI transmitted character flag + * @arg SCI_FLAG_WT : SCI waiting timer flag + * @retval None + ************************************************************************************************************/ +void SCI_ClearFlag(HT_SCI_TypeDef* SCIx, u32 SCI_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_CLEAR_FLAG(SCI_Flag)); + + if (SCI_Flag != SCI_FLAG_WT) + { + SCIx->SR &= ~SCI_Flag; + } + else + { + SCIx->CR &= CR_WTEN_RESET; + SCIx->CR |= CR_WTEN_SET; + } +} + +#if (LIBCFG_PDMA) +/*********************************************************************************************************//** + * @brief Enable or disables the SCI PDMA interface. + * @param SCIx: where SCIx is the selected SCI from the SCI peripherals. + * @param SCI_PDMAREQ: specify the SCI PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg SCI_PDMAREQ_TX : Tx PDMA transfer request + * @arg SCI_PDMAREQ_RX : Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SCI_PDMACmd(HT_SCI_TypeDef* SCIx, u32 SCI_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SCI_PDMA_REQ(SCI_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SCIx->CR |= SCI_PDMAREQ; + } + else + { + SCIx->CR &= ~SCI_PDMAREQ; + } +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sctm.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sctm.c new file mode 100644 index 0000000000..b824c72b16 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sctm.c @@ -0,0 +1,2 @@ +The SCTM, PWM, GPTM, and MCTM timer have similar architecture. They use the same driver, +"ht32fxxxxx_tm.c/.h" to save the code size. For those timers, please refet to the TM driver/example. diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sled.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sled.c new file mode 100644 index 0000000000..132db84be4 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_sled.c @@ -0,0 +1,289 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_sled.c + * @version $Rev:: 3309 $ + * @date $Date:: 2018-12-12 #$ + * @brief This file provides all the SLED firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_sled.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup SLED SLED + * @brief SLED driver modules + * @{ + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SLED_Exported_Functions SLED exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the specified SLED peripheral registers to their default reset values. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @retval None + ************************************************************************************************************/ +void SLED_DeInit(HT_SLED_TypeDef* SLEDx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + + if (SLEDx == HT_SLED0) + { + RSTCUReset.Bit.SLED0 = 1; + } + #if(LIBCFG_SLED1) + else if (SLEDx == HT_SLED1) + { + RSTCUReset.Bit.SLED1 = 1; + } + #endif + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the specified SLED peripheral according to the specified parameters in the SLED_InitStruct. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @param SLED_InitStruct: pointer to a SLED_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SLED_Init(HT_SLED_TypeDef* SLEDx, SLED_InitTypeDef* SLED_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + + SLEDx->CDR = (SLED_InitStruct->BaudRate << 8) + | (SLED_InitStruct->ClockPrescaler << 0); + + SLEDx->TCR = (SLED_InitStruct->TRST << 16) + | (SLED_InitStruct->T1H << 8) + | (SLED_InitStruct->T0H << 0); + + SLEDx->CR = (SLED_InitStruct->SyncState << 10) + | (SLED_InitStruct->IdleState << 9) + | (SLED_InitStruct->ResetState << 8) + | (SLED_InitStruct->SyncMode << 3) + | (SLED_InitStruct->OutputPolarity << 2); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SLED peripheral. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SLED_Cmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SLEDx->CR |= (1 << 0); + } + else + { + SLEDx->CR &= ~(1 << 0); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SLED output. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SLED_OutputCmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SLEDx->CR |= (1 << 1); + } + else + { + SLEDx->CR &= ~(1 << 1); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SLED PDMA request. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SLED_PDMACmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SLEDx->CR |= (1 << 4); + } + else + { + SLEDx->CR &= ~(1 << 4); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SLED interrupt. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SLED_IntCmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SLEDx->CR |= (1 << 5); + } + else + { + SLEDx->CR &= ~(1 << 5); + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified SLED interrupt flag. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @retval None + ************************************************************************************************************/ +void SLED_ClearIntFlag(HT_SLED_TypeDef* SLEDx) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + + SLEDx->SR |= (1 << 5); +} + +/*********************************************************************************************************//** + * @brief Insert a Reset Code on the specified SLED. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @retval None + ************************************************************************************************************/ +void SLED_InsertResetCode(HT_SLED_TypeDef* SLEDx) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + + SLEDx->CR |= (1 << 15); +} + +/*********************************************************************************************************//** + * @brief Return the FIFO status of the specified SLED. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus SLED_GetResetCodeStatus(HT_SLED_TypeDef* SLEDx) +{ + if ((SLEDx->CR & (1 << 15)) != RESET) + return SET; + else + return RESET; +} + +/*********************************************************************************************************//** + * @brief Return the BUSY status of the specified SLED. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus SLED_GetBusyStatus(HT_SLED_TypeDef* SLEDx) +{ + if (SLEDx->SR & 1) + return SET; + else + return RESET; +} + +/*********************************************************************************************************//** + * @brief Set the specified SLED FIFO trigger level. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @param FifoLevel: specify the FIFO trigger level. + * This parameter can be one of the following values: + * @arg SLED_FIFO_LEVEL_0 : data request will be inserted when FIFO data count is equal to 0 + * @arg SLED_FIFO_LEVEL_1 : data request will be inserted when FIFO data count is less than or equal to 1 + * @arg SLED_FIFO_LEVEL_2 : data request will be inserted when FIFO data count is less than or equal to 2 + * @arg SLED_FIFO_LEVEL_3 : data request will be inserted when FIFO data count is less than or equal to 3 + * @retval None + ************************************************************************************************************/ +void SLED_FIFOTrigLevelConfig(HT_SLED_TypeDef* SLEDx, u8 FifoLevel) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + Assert_Param(IS_SLED_FIFO_LEVEL(FifoLevel)); + + SLEDx->FCR = FifoLevel; +} + +/*********************************************************************************************************//** + * @brief Return the FIFO status of the specified SLED. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @retval The number of data in FIFO. + ************************************************************************************************************/ +u8 SLED_GetFIFOStatus(HT_SLED_TypeDef* SLEDx) +{ + return (SLEDx->FCR >> 24); +} + +/*********************************************************************************************************//** + * @brief Reset the specified SLED FIFO. + * @param SLEDx: where SLEDx is the selected SLED from the SLED peripherals. + * @retval None + ************************************************************************************************************/ +void SLED_FIFOReset(HT_SLED_TypeDef* SLEDx) +{ + /* Check the parameters */ + Assert_Param(IS_SLED(SLEDx)); + + SLEDx->FCR |= (1 << 0); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi.c new file mode 100644 index 0000000000..5515859641 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi.c @@ -0,0 +1,712 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_spi.c + * @version $Rev:: 7322 $ + * @date $Date:: 2023-10-28 #$ + * @brief This file provides all the SPI firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_spi.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup SPI SPI + * @brief SPI driver modules + * @{ + */ + + +#if (LIBCFG_MIDI) +#include "ht32f5xxxx_spi_midi.c" +#endif + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Private_Define SPI private definitions + * @{ + */ +/* SPI SPIEN Mask */ +#define CR0_SPIEN_SET (u32)0x00000001 +#define CR0_SPIEN_RESET (u32)0xFFFFFFFE + +/* SPI SELOEN Mask */ +#define CR0_SELOEN_SET (u32)0x00000008 +#define CR0_SELOEN_RESET (u32)0xFFFFFFF7 + +/* SPI SPI DUALEN Mask */ +#define CR0_DUALEN_SET (u32)0x00000040 +#define CR0_DUALEN_RESET (u32)0xFFFFFFBF + +#if (LIBCFG_QSPI) +/* QSPI QUADEN Mask */ +#define CR0_QUADEN_SET (u32)0x00020000 +#define CR0_QUADEN_RESET (u32)0xFFFDFFFF +/* QSPI QDIODIR Mask */ +#define CR0_QDIODIR_OUT (u32)0x00010000 +#define CR0_QDIODIR_IN (u32)0xFFFEFFFF +#endif + +/* SPI SPI GUADTEN Mask */ +#define CR0_GUADTEN_SET (u32)0x00000080 +#define CR0_GUADTEN_RESET (u32)0xFFFFFF7F + +/* SPI FIFOEN Mask */ +#define FCR_FIFOEN_SET (u32)0x00000400 +#define FCR_FIFOEN_RESET (u32)0xFFFFFBFF + +/* SPI DFL Mask */ +#if (LIBCFG_SPI_DATA_LENGTH_V01) +#define CR1_DFL_MASK (u32)0x00000007 +#else +#define CR1_DFL_MASK (u32)0x0000000F +#endif + +/* SPI FIFO Mask */ +#if (LIBCFG_SPI_FIFO_DEPTH_V01) +#define FCR_FIFO_MASK (u32)0x00000007 +#else +#define FCR_FIFO_MASK (u32)0x0000000F +#endif + +/** + * @} + */ + + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SPI_Exported_Functions SPI exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the SPI peripheral registers to their default reset values. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @retval None + ************************************************************************************************************/ +void SPI_DeInit(HT_SPI_TypeDef* SPIx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + + if (SPIx == HT_SPI0) + { + RSTCUReset.Bit.SPI0 = 1; + } + #if (LIBCFG_SPI1) + else if (SPIx == HT_SPI1) + { + RSTCUReset.Bit.SPI1 = 1; + } + #endif + #if (LIBCFG_QSPI) + else if (SPIx == HT_QSPI) + { + RSTCUReset.Bit.QSPI = 1; + } + #endif + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the SPIx peripheral according to the specified parameters in the SPI_InitStruct. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SPI_Init(HT_SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct) +{ + u32 tmp; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode)); + Assert_Param(IS_SPI_FIFO_SET(SPI_InitStruct->SPI_FIFO)); + Assert_Param(IS_SPI_DATALENGTH(SPI_InitStruct->SPI_DataLength)); + Assert_Param(IS_SPI_SEL_MODE(SPI_InitStruct->SPI_SELMode)); + Assert_Param(IS_SPI_SEL_POLARITY(SPI_InitStruct->SPI_SELPolarity)); + Assert_Param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL)); + Assert_Param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA)); + Assert_Param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit)); + Assert_Param(IS_SPI_FIFO_LEVEL(SPI_InitStruct->SPI_RxFIFOTriggerLevel)); + Assert_Param(IS_SPI_FIFO_LEVEL(SPI_InitStruct->SPI_TxFIFOTriggerLevel)); + Assert_Param(IS_SPI_CLOCK_PRESCALER(SPI_InitStruct->SPI_ClockPrescaler)); + + /*---------------------------- SPIx Control Register 2 Configuration -------------------------------------*/ + tmp = SPI_InitStruct->SPI_CPOL; + if (tmp == SPI_CPOL_LOW) + { + tmp |= (0x100 << SPI_InitStruct->SPI_CPHA); + } + else + { + tmp |= (0x200 >> SPI_InitStruct->SPI_CPHA); + } + + SPIx->CR1 = SPI_InitStruct->SPI_Mode | SPI_InitStruct->SPI_DataLength | + SPI_InitStruct->SPI_SELMode | SPI_InitStruct->SPI_SELPolarity | + SPI_InitStruct->SPI_FirstBit | tmp; + + /*---------------------------- SPIx FIFO Control Register Configuration ----------------------------------*/ + SPIx->FCR = SPI_InitStruct->SPI_FIFO | SPI_InitStruct->SPI_TxFIFOTriggerLevel | + (SPI_InitStruct->SPI_RxFIFOTriggerLevel << 4); + + /*---------------------------- SPIx Clock Prescaler Register Configuration -------------------------------*/ + #if (LIBCFG_SPI_CLK_PRE_V01) + SPIx->CPR = (SPI_InitStruct->SPI_ClockPrescaler - 1); + #else + SPIx->CPR = (SPI_InitStruct->SPI_ClockPrescaler / 2) - 1; + #endif +} + +/*********************************************************************************************************//** + * @brief Fill each SPI_InitStruct member with its default value. + * @param SPI_InitStruct: pointer to an SPI_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct) +{ + /* Initialize the SPI_Mode member */ + SPI_InitStruct->SPI_Mode = SPI_SLAVE; + + /* Initialize the SPI_FIFO member */ + SPI_InitStruct->SPI_FIFO = SPI_FIFO_DISABLE; + + /* Initialize the SPI_DataLength member */ + #if (LIBCFG_SPI_DATA_LENGTH_V01) + SPI_InitStruct->SPI_DataLength = SPI_DATALENGTH_8; + #else + SPI_InitStruct->SPI_DataLength = SPI_DATALENGTH_16; + #endif + + /* Initialize the SPI_SELMode member */ + SPI_InitStruct->SPI_SELMode = SPI_SEL_SOFTWARE; + + /* Initialize the SPI_SELPolarity member */ + SPI_InitStruct->SPI_SELPolarity = SPI_SELPOLARITY_LOW; + + /* Initialize the SPI_CPOL member */ + SPI_InitStruct->SPI_CPOL = SPI_CPOL_LOW; + + /* Initialize the SPI_CPHA member */ + SPI_InitStruct->SPI_CPHA = SPI_CPHA_FIRST; + + /* Initialize the SPI_FirstBit member */ + SPI_InitStruct->SPI_FirstBit = SPI_FIRSTBIT_MSB; + + /* Initialize the SPI_RxFIFOTriggerLevel member */ + SPI_InitStruct->SPI_RxFIFOTriggerLevel = 0; + + /* Initialize the SPI_TxFIFOTriggerLevel member */ + SPI_InitStruct->SPI_TxFIFOTriggerLevel = 0; + + /* Initialize the SPI_ClockPrescaler member */ + SPI_InitStruct->SPI_ClockPrescaler = 2; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SPI peripheral. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_Cmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected SPI peripheral */ + SPIx->CR0 |= CR0_SPIEN_SET; + } + else + { + /* Disable the selected SPI peripheral */ + SPIx->CR0 &= CR0_SPIEN_RESET; + } +} + +#if (!LIBCFG_SPI_NO_MULTI_MASTER) +/*********************************************************************************************************//** + * @brief Enable or Disable the SEL output for the specified SPI peripheral. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_SELOutputCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->CR0 |= CR0_SELOEN_SET; + } + else + { + SPIx->CR0 &= CR0_SELOEN_RESET; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable SPI FIFO. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_FIFOCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->FCR |= FCR_FIFOEN_SET; + } + else + { + SPIx->FCR &= FCR_FIFOEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Configure the data length for the selected SPI. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_DataLength: specify data length of the SPI. + * @retval None + ************************************************************************************************************/ +void SPI_SetDataLength(HT_SPI_TypeDef* SPIx, u16 SPI_DataLength) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_DATALENGTH(SPI_DataLength)); + + /* Clear DFL[x:0] in CR1. + if Datalength is 16-bit mode, then x = 3 + if Datalength is 8-bit mode, then x = 2 */ + SPIx->CR1 &= (u32)~CR1_DFL_MASK; + + /* Set new DFL[x:0] in CR1. + if Datalength is 16-bit mode, then x = 3 + if Datalength is 8-bit mode, then x = 2 */ + SPIx->CR1 |= SPI_DataLength; +} + +/*********************************************************************************************************//** + * @brief SEL pin is configured to be driven by hardware or software. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_SEL: specify the SPI SEL pin mode. + * This parameter can be one of the following values: + * @arg SPI_SEL_HARDWARE : SEL is driven by hardware + * @arg SPI_SEL_SOFTWARE : SEL is driven by software + * @retval None + ************************************************************************************************************/ +void SPI_SELModeConfig(HT_SPI_TypeDef* SPIx, u32 SPI_SEL) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_SEL_MODE(SPI_SEL)); + + if (SPI_SEL != SPI_SEL_SOFTWARE) + { + SPIx->CR1 |= SPI_SEL_HARDWARE; + } + else + { + SPIx->CR1 &= ~SPI_SEL_HARDWARE; + } +} + +/*********************************************************************************************************//** + * @brief Configure the SEL state by software. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_SoftwareSEL: specify if the SPI SEL to be active or inactive. + * This parameter can be one of the following values: + * @arg SPI_SEL_ACTIVE : activate SEL signal + * @arg SPI_SEL_INACTIVE : deactivate SEL signal + * @retval None + ************************************************************************************************************/ +void SPI_SoftwareSELCmd(HT_SPI_TypeDef* SPIx, u32 SPI_SoftwareSEL) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_SOFTWARE_SEL(SPI_SoftwareSEL)); + + if (SPI_SoftwareSEL != SPI_SEL_INACTIVE) + { + SPIx->CR0 |= SPI_SEL_ACTIVE; + } + else + { + SPIx->CR0 &= SPI_SEL_INACTIVE; + } +} + +/*********************************************************************************************************//** + * @brief Send a data through the SPIx peripheral. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Data: the data to be transmitted. + * @retval None + ************************************************************************************************************/ +void SPI_SendData(HT_SPI_TypeDef* SPIx, SPI_DataTypeDef SPI_Data) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_DATA(SPI_Data)); + + SPIx->DR = SPI_Data; +} + +/*********************************************************************************************************//** + * @brief Return the received data through the SPIx peripheral + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @retval The value of the received data. + ************************************************************************************************************/ +SPI_DataTypeDef SPI_ReceiveData(HT_SPI_TypeDef* SPIx) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + + return (SPI_DataTypeDef)SPIx->DR; +} + +/*********************************************************************************************************//** + * @brief Set the value of SPI FIFO Time Out. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Timeout: specify the value of Time Out. + * @retval None + ************************************************************************************************************/ +void SPI_SetTimeOutValue(HT_SPI_TypeDef* SPIx, SPI_TimeoutTypeDef SPI_Timeout) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + + SPIx->FTOCR = SPI_Timeout; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified SPI interrupt. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Int: specify if the SPI interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg SPI_INT_TXBE : SPI Tx buffer empty interrupt + * @arg SPI_INT_TXE : SPI Tx empty interrupt + * @arg SPI_INT_RXBNE : SPI Rx buffer not empty interrupt + * @arg SPI_INT_WC : SPI write collision interrupt + * @arg SPI_INT_RO : SPI read overrun interrupt + * @arg SPI_INT_MF : SPI mode fault interrupt + * @arg SPI_INT_SA : SPI slave abort interrupt + * @arg SPI_INT_TO : SPI time out interrupt + * @arg SPI_INT_ALL : All SPI interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_IntConfig(HT_SPI_TypeDef* SPIx, u32 SPI_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_INT(SPI_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->IER |= SPI_Int; + } + else + { + SPIx->IER &= (u32)~SPI_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified SPI flag has been set or not. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg SPI_FLAG_TXBE : SPI Tx buffer empty flag + * @arg SPI_FLAG_TXE : SPI Tx empty flag + * @arg SPI_FLAG_RXBNE : SPI Rx buffer not empty flag + * @arg SPI_FLAG_WC : SPI write collision flag + * @arg SPI_FLAG_RO : SPI read overrun flag + * @arg SPI_FLAG_MF : SPI mode fault flag + * @arg SPI_FLAG_SA : SPI slave abort flag + * @arg SPI_FLAG_TOUT : SPI time out flag + * @arg SPI_FLAG_BUSY : SPI busy flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus SPI_GetFlagStatus(HT_SPI_TypeDef* SPIx, u32 SPI_Flag) +{ + FlagStatus bitstatus = RESET; + u32 statusreg = 0; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FLAG(SPI_Flag)); + + statusreg = SPIx->SR; + + if ((statusreg & SPI_Flag) != (u32)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Return the status of specified SPI FIFO. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_FIFODirection: specify the FIFO that is to be checked. + * This parameter can be one of the following values: + * @arg SPI_FIFO_TX : + * @arg SPI_FIFO_RX : + * @retval The number of data in Tx FIFO or Rx FIFO. + ************************************************************************************************************/ +u8 SPI_GetFIFOStatus(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection) +{ + u32 tmpreg; + + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FIFO_DIRECTION(SPI_FIFODirection)); + + if (SPI_FIFODirection == SPI_FIFO_TX) + { + tmpreg = SPIx->FSR & FCR_FIFO_MASK; + } + else + { + tmpreg = (SPIx->FSR & (FCR_FIFO_MASK << 4)) >> 4; + } + + return (u8)tmpreg; +} + +/*********************************************************************************************************//** + * @brief Clear the specified SPI flag. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_Flag: specify the flag that is to be cleared. + * This parameter can be one of the following values: + * @arg SPI_FLAG_WC : SPI write collision flag + * @arg SPI_FLAG_RO : SPI read overrun flag + * @arg SPI_FLAG_MF : SPI mode fault flag + * @arg SPI_FLAG_SA : SPI slave abort flag + * @arg SPI_FLAG_TOUT : SPI time out flag + * @retval None + ************************************************************************************************************/ +void SPI_ClearFlag(HT_SPI_TypeDef* SPIx, u32 SPI_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FLAG_CLEAR(SPI_Flag)); + + SPIx->SR = SPI_Flag; +} + +/*********************************************************************************************************//** + * @brief Set the trigger level of SPI FIFO. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_FIFODirection: specify the FIFO that is to be set. + * This parameter can be one of the following values: + * @arg SPI_FIFO_TX : + * @arg SPI_FIFO_RX : + * @param SPI_FIFOLevel: Specify the FIFO trigger level. + * @retval None + ************************************************************************************************************/ +void SPI_FIFOTriggerLevelConfig(HT_SPI_TypeDef* SPIx, u32 SPI_FIFODirection, u8 SPI_FIFOLevel) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_FIFO_DIRECTION(SPI_FIFODirection)); + Assert_Param(IS_SPI_FIFO_LEVEL(SPI_FIFOLevel)); + + if (SPI_FIFODirection == SPI_FIFO_TX) + { + SPIx->FCR = ((SPIx->FCR & (0x00000400 | (FCR_FIFO_MASK << 4))) | SPI_FIFOLevel); + } + else + { + SPIx->FCR = ((SPIx->FCR & (0x00000400 | FCR_FIFO_MASK)) | (SPI_FIFOLevel << 4)); + } +} + +#if (LIBCFG_PDMA) +/*********************************************************************************************************//** + * @brief Enable or Disable the SPIx PDMA interface. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param SPI_PDMAREQ: specify the SPI PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg SPI_PDMAREQ_TX : Tx PDMA transfer request + * @arg SPI_PDMAREQ_RX : Rx PDMA transfer request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_PDMACmd(HT_SPI_TypeDef* SPIx, u32 SPI_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_PDMA_REQ(SPI_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + SPIx->CR0 |= SPI_PDMAREQ; + } + else + { + SPIx->CR0 &= ~SPI_PDMAREQ; + } +} +#endif + +#if (!LIBCFG_SPI_NO_DUAL) +/*********************************************************************************************************//** + * @brief Enable or Disable the SPIx dual port read interface. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_DUALCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + (NewState == ENABLE)?(SPIx->CR0 |= CR0_DUALEN_SET):(SPIx->CR0 &= CR0_DUALEN_RESET); +} +#endif + +#if (LIBCFG_QSPI) +/*********************************************************************************************************//** + * @brief Enable or Disable the QSPI quad port interface. + * @param SPIx: where SPIx is the selected QSPI from the QSPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void QSPI_QuadCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_QSPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == DISABLE) + { + QSPI_DirectionConfig(SPIx, SIO_DIR_IN); + SPIx->CR0 &= CR0_QUADEN_RESET; + } + else + { + SPIx->CR0 |= CR0_QUADEN_SET; + } +} + +/*********************************************************************************************************//** + * @brief Configure the direction of SIO pins in dual or quad mode. + * @param SPIx: where SPIx is the selected QSPI from the QSPI peripherals. + * @param SIO_DIR_INorOUT: + * This parameter can be one of below: + * @arg SIO_DIR_IN : The SIO pins are input mode + * @arg SIO_DIR_OUT : The SIO pins are output mode + * @retval None + ************************************************************************************************************/ +void QSPI_DirectionConfig(HT_SPI_TypeDef* SPIx, SIO_DIR_Enum SIO_DIR_INorOUT) +{ + /* Check the parameters */ + Assert_Param(IS_QSPI(SPIx)); + Assert_Param(IS_SIO_DIR(SIO_DIR_INorOUT)); + + if (SIO_DIR_INorOUT != SIO_DIR_IN) + SPIx->CR0 |= CR0_QDIODIR_OUT; + else + SPIx->CR0 &= CR0_QDIODIR_IN; +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the SPIx guard time selection function. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void SPI_GUARDTCmd(HT_SPI_TypeDef* SPIx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + (NewState == ENABLE) ? (SPIx->CR0 |= CR0_GUADTEN_SET) : (SPIx->CR0 &= CR0_GUADTEN_RESET); +} + +/*********************************************************************************************************//** + * @brief Set the SPIx guard time length. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param Guard_Time: number of SCK to be the guard time length. + * This parameter can be: SPI_GUADTIME_1_SCK to SPI_GUADTIME_16_SCK. + * @retval None + ************************************************************************************************************/ +void SPI_GUARDTConfig(HT_SPI_TypeDef* SPIx, u32 Guard_Time) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_GUADTIME(Guard_Time)); + + SPIx->CR0 = (SPIx->CR0 & 0xF0FF) | (Guard_Time << 8); +} + +/*********************************************************************************************************//** + * @brief Set the SPIx chip select hold time. + * @param SPIx: where SPIx is the selected SPI from the SPI peripherals. + * @param CS_Hold_Time: number of SCK to be the hold time length. + * This parameter can be: 0 ~ 15 + * @retval None + ************************************************************************************************************/ +void SPI_SELHTConfig(HT_SPI_TypeDef* SPIx, u32 CS_Hold_Time) +{ + /* Check the parameters */ + Assert_Param(IS_SPI(SPIx)); + Assert_Param(IS_SPI_SELHOLDTIME(CS_Hold_Time)); + + SPIx->CR0 = (SPIx->CR0 & 0x0FFF) | (CS_Hold_Time << 12); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi_midi.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi_midi.c new file mode 100644 index 0000000000..69a78217ee --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_spi_midi.c @@ -0,0 +1,182 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_spi_midi.c + * @version $Rev:: 7073 $ + * @date $Date:: 2023-07-28 #$ + * @brief This file provides all the SPI firmware functions (MIDI Control). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_spi_midi.h" + + +/* Private macro -------------------------------------------------------------------------------------------*/ +#define IS_MIDICTRL_MODE(MODE) ((MODE == DOR_MODE) || \ + (MODE == DIOR_MODE) || \ + (MODE == QOR_MODE) || \ + (MODE == QIOR_MODE) || \ + (MODE == QPI_MODE) || \ + (MODE == SERIAL_MODE)) + +#define IS_MIDICTRL_CMD_LENGTH(LENGTH) ((LENGTH == MIDICTRL_CMDLENGTH_0) || \ + (LENGTH == MIDICTRL_CMDLENGTH_1) || \ + (LENGTH == MIDICTRL_CMDLENGTH_2) || \ + (LENGTH == MIDICTRL_CMDLENGTH_3) || \ + (LENGTH == MIDICTRL_CMDLENGTH_4) || \ + (LENGTH == MIDICTRL_CMDLENGTH_5) || \ + (LENGTH == MIDICTRL_CMDLENGTH_6) || \ + (LENGTH == MIDICTRL_CMDLENGTH_7) || \ + (LENGTH == MIDICTRL_CMDLENGTH_8)) + +#define IS_MIDICTRL_AD_LENGTH(LENGTH) ((LENGTH == MIDICTRL_ADLENGTH_0) || \ + (LENGTH == MIDICTRL_ADLENGTH_1) || \ + (LENGTH == MIDICTRL_ADLENGTH_2) || \ + (LENGTH == MIDICTRL_ADLENGTH_3) || \ + (LENGTH == MIDICTRL_ADLENGTH_4) || \ + (LENGTH == MIDICTRL_ADLENGTH_5) || \ + (LENGTH == MIDICTRL_ADLENGTH_6) || \ + (LENGTH == MIDICTRL_ADLENGTH_7) || \ + (LENGTH == MIDICTRL_ADLENGTH_8) || \ + (LENGTH == MIDICTRL_ADLENGTH_9) || \ + (LENGTH == MIDICTRL_ADLENGTH_10) || \ + (LENGTH == MIDICTRL_ADLENGTH_11) || \ + (LENGTH == MIDICTRL_ADLENGTH_12) || \ + (LENGTH == MIDICTRL_ADLENGTH_13) || \ + (LENGTH == MIDICTRL_ADLENGTH_14) || \ + (LENGTH == MIDICTRL_ADLENGTH_15) || \ + (LENGTH == MIDICTRL_ADLENGTH_16) || \ + (LENGTH == MIDICTRL_ADLENGTH_17) || \ + (LENGTH == MIDICTRL_ADLENGTH_18) || \ + (LENGTH == MIDICTRL_ADLENGTH_19) || \ + (LENGTH == MIDICTRL_ADLENGTH_20) || \ + (LENGTH == MIDICTRL_ADLENGTH_21) || \ + (LENGTH == MIDICTRL_ADLENGTH_22) || \ + (LENGTH == MIDICTRL_ADLENGTH_23) || \ + (LENGTH == MIDICTRL_ADLENGTH_24)) + +#define IS_MIDICTRL_MODE_LENGTH(LENGTH) ((LENGTH == MIDICTRL_MODELENGTH_0) || \ + (LENGTH == MIDICTRL_MODELENGTH_1) || \ + (LENGTH == MIDICTRL_MODELENGTH_2) || \ + (LENGTH == MIDICTRL_MODELENGTH_3) || \ + (LENGTH == MIDICTRL_MODELENGTH_4) || \ + (LENGTH == MIDICTRL_MODELENGTH_5) || \ + (LENGTH == MIDICTRL_MODELENGTH_6) || \ + (LENGTH == MIDICTRL_MODELENGTH_7) || \ + (LENGTH == MIDICTRL_MODELENGTH_8)) + +#define IS_MIDICTRL_DUMMY_LENGTH(LENGTH) ((LENGTH == MIDICTRL_DUMMYLENGTH_0) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_1) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_2) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_3) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_4) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_5) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_6) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_7) || \ + (LENGTH == MIDICTRL_DUMMYLENGTH_8)) + +#define IS_MIDICTRL_DATA_LENGTH(LENGTH) ((LENGTH == MIDICTRL_DATALENGTH_0) || \ + (LENGTH == MIDICTRL_DATALENGTH_1) || \ + (LENGTH == MIDICTRL_DATALENGTH_2) || \ + (LENGTH == MIDICTRL_DATALENGTH_3) || \ + (LENGTH == MIDICTRL_DATALENGTH_4) || \ + (LENGTH == MIDICTRL_DATALENGTH_5) || \ + (LENGTH == MIDICTRL_DATALENGTH_6) || \ + (LENGTH == MIDICTRL_DATALENGTH_7) || \ + (LENGTH == MIDICTRL_DATALENGTH_8) || \ + (LENGTH == MIDICTRL_DATALENGTH_9) || \ + (LENGTH == MIDICTRL_DATALENGTH_10) || \ + (LENGTH == MIDICTRL_DATALENGTH_11) || \ + (LENGTH == MIDICTRL_DATALENGTH_12) || \ + (LENGTH == MIDICTRL_DATALENGTH_13) || \ + (LENGTH == MIDICTRL_DATALENGTH_14) || \ + (LENGTH == MIDICTRL_DATALENGTH_15) || \ + (LENGTH == MIDICTRL_DATALENGTH_16) || \ + (LENGTH == MIDICTRL_DATALENGTH_17) || \ + (LENGTH == MIDICTRL_DATALENGTH_18) || \ + (LENGTH == MIDICTRL_DATALENGTH_19) || \ + (LENGTH == MIDICTRL_DATALENGTH_20) || \ + (LENGTH == MIDICTRL_DATALENGTH_21) || \ + (LENGTH == MIDICTRL_DATALENGTH_22) || \ + (LENGTH == MIDICTRL_DATALENGTH_23) || \ + (LENGTH == MIDICTRL_DATALENGTH_24) || \ + (LENGTH == MIDICTRL_DATALENGTH_25) || \ + (LENGTH == MIDICTRL_DATALENGTH_26) || \ + (LENGTH == MIDICTRL_DATALENGTH_27) || \ + (LENGTH == MIDICTRL_DATALENGTH_28) || \ + (LENGTH == MIDICTRL_DATALENGTH_29) || \ + (LENGTH == MIDICTRL_DATALENGTH_30) || \ + (LENGTH == MIDICTRL_DATALENGTH_31) || \ + (LENGTH == MIDICTRL_DATALENGTH_32)) + +#define IS_MIDICTRL_CMD_VALUE(VALUE) (VALUE <= 0xFF) +#define IS_MIDICTRL_MODE_VALUE(VALUE) (VALUE <= 0xFF) + +/* Global functions ----------------------------------------------------------------------------------------*/ +/*********************************************************************************************************//** + * @brief Enable or Disable QSPI MIDICTRL. + * @param QSPIx: where QSPIx is the selected QSPI from the QSPI peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void MIDICTRL_Cmd(HT_SPI_TypeDef* QSPIx ,ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + QSPIx->MIDICR0 |= MIDICTRL_ON; + } + else + { + QSPIx->MIDICR0 &= MIDICTRL_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Initialize the QSPIx peripheral MIDICTRL according to the specified parameters in the MIDICTRL_InitStruct. + * @param QSPIx: This parameter can be HT_QSPI. + * @param MIDICTRL_InitStruct: pointer to a MIDICTRL_InitTypeDef structure that contains the configuration + * information for the specified USART peripheral. + * @retval None + ************************************************************************************************************/ +void MIDICTRL_Init(HT_SPI_TypeDef* QSPIx, MIDICTRL_InitTypeDef* MIDICTRL_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_QSPI(QSPIx)); + Assert_Param(IS_MIDICTRL_MODE(MIDICTRL_InitStruct->MIDICTRL_MODE)); + Assert_Param(IS_MIDICTRL_CMD_LENGTH(MIDICTRL_InitStruct->MIDICTRL_CommandLength)); + Assert_Param(IS_MIDICTRL_AD_LENGTH(MIDICTRL_InitStruct->MIDICTRL_AddressLength)); + Assert_Param(IS_MIDICTRL_MODE_LENGTH(MIDICTRL_InitStruct->MIDICTRL_ModeLength)); + Assert_Param(IS_MIDICTRL_DUMMY_LENGTH(MIDICTRL_InitStruct->MIDICTRL_DummyLength)); + Assert_Param(IS_MIDICTRL_DATA_LENGTH(MIDICTRL_InitStruct->MIDICTRL_DataLength)); + Assert_Param(IS_MIDICTRL_CMD_VALUE(MIDICTRL_InitStruct->MIDICTRL_CommandValue)); + Assert_Param(IS_MIDICTRL_MODE_VALUE(MIDICTRL_InitStruct->MIDICTRL_ModeValue)); + + QSPIx->MIDICR0 = (QSPIx->MIDICR0 & 0xF0800000) | MIDICTRL_InitStruct->MIDICTRL_MODE | + MIDICTRL_InitStruct->MIDICTRL_CommandLength | MIDICTRL_InitStruct->MIDICTRL_AddressLength | + MIDICTRL_InitStruct->MIDICTRL_ModeLength | MIDICTRL_InitStruct->MIDICTRL_DummyLength | + MIDICTRL_InitStruct->MIDICTRL_DataLength ; + + QSPIx->MIDICR1 = (QSPIx->MIDICR1 & 0xFFFF0000) | ((MIDICTRL_InitStruct->MIDICTRL_ModeValue) << MDVALUE_POS )| + ((MIDICTRL_InitStruct->MIDICTRL_CommandValue) << CMDVALUE_POS ); +} diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tkey.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tkey.c new file mode 100644 index 0000000000..a6e482d6a0 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tkey.c @@ -0,0 +1,703 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_tkey.c + * @version $Rev:: 5500 $ + * @date $Date:: 2021-07-20 #$ + * @brief This file provides all the TKEY firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_tkey.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup TKEY TKEY + * @brief TKEY driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup TKEY_Private_Define TKEY private definitions + * @{ + */ +#define TKCLKSEL_MASK (0x80000000) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup TKEY_Exported_Functions TKEY exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the TKEY peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void TKEY_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.TKEY = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Configure Touch key IP clock source. + * @param Sel: Specify the Touch key IP clock source.. + * This parameter can be one of the following values: + * @arg TKEY_PCLK : PCLK. + * @arg TKEY_LSI : LSI. + * @retval None + ************************************************************************************************************/ +void TKEY_IPClockConfig(TKEY_IP_CLK_Enum Sel) +{ + Assert_Param(IS_TKEY_IP_CLK(Sel)); + + HT_TKEY->TKCR = (HT_TKEY->TKCR & TKCLKSEL_MASK) | (Sel << 31); +} + +/*********************************************************************************************************//** + * @brief Configure the RefOSC Delay time. + * @param Sel: Specify the periodic auto scan mode time out. + * This parameter can be one of the following values: + * @arg TKEY_RefOSC_DelayTime_0 : 4 RefOSC clock. + * @arg TKEY_RefOSC_DelayTime_1 : 2 RefOSC clock. + * @arg TKEY_RefOSC_DelayTime_2 : 4 RefOSC clock. + * @arg TKEY_RefOSC_DelayTime_3 : 8 RefOSC clock. + * @arg TKEY_RefOSC_DelayTime_4 : 16 RefOSC clock. + * @arg TKEY_RefOSC_DelayTime_5 : 32 RefOSC clock. + * @arg TKEY_RefOSC_DelayTime_6 : 64 RefOSC clock. + * @arg TKEY_RefOSC_DelayTime_7 : 4 RefOSC clock. + * @retval None + ************************************************************************************************************/ +void TKEY_RefOSCDelayTimeConfig(TKEY_RefOSC_DelayTime_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_RefOSC_DelayTime(Sel)); + + HT_TKEY->TKCR = (HT_TKEY->TKCR & ~(7 << 13)) | Sel; +} +/*********************************************************************************************************//** + * @brief Configure the periodic auto scan mode time out. + * @param Sel: Specify the periodic auto scan mode time out. + * This parameter can be one of the following values: + * @arg TKEY_PASM_TIMEOUT_0 : 2^13/FLIRC. + * @arg TKEY_PASM_TIMEOUT_1 : 2^14/FLIRC. + * @arg TKEY_PASM_TIMEOUT_2 : 2^15/FLIRC. + * @arg TKEY_PASM_TIMEOUT_3 : 2^16/FLIRC. + * @arg TKEY_PASM_TIMEOUT_4 : 2^17/FLIRC. + * @arg TKEY_PASM_TIMEOUT_5 : 2^18/FLIRC. + * @retval None + ************************************************************************************************************/ +void TKEY_PASMTimeoutConfig(TKEY_PASM_TIMEOUT_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_PASM_TIMEOUT(Sel)); + + HT_TKEY->TKCR = (HT_TKEY->TKCR & ~(7 << 10)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the periodic auto scan mode period. + * @param Sel: Specify the periodic auto scan mode period. + * This parameter can be one of the following values: + * @arg TKEY_PASM_PERIOD_0 : 2^14/FLIRC. + * @arg TKEY_PASM_PERIOD_1 : 2^13/FLIRC. + * @arg TKEY_PASM_PERIOD_2 : 2^12/FLIRC. + * @arg TKEY_PASM_PERIOD_3 : 2^11/FLIRC. + * @retval None + ************************************************************************************************************/ +void TKEY_PASMPeriodConfig(TKEY_PASM_PERIOD_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_PASM_PERIOD(Sel)); + + HT_TKEY->TKCR = (HT_TKEY->TKCR & ~(3 << 8)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the touch key 16-bit counter clock source. + * @param Sel: Specify the 16-bit counter clock source. + * This parameter can be one of the following values: + * @arg TKEY_TK16S_CLK_0 : TKCLK/16. + * @arg TKEY_TK16S_CLK_1 : TKCLK/32. + * @arg TKEY_TK16S_CLK_2 : TKCLK/64. + * @arg TKEY_TK16S_CLK_3 : TKCLK/128. + * @retval None + ************************************************************************************************************/ +void TKEY_16BitCounterClockConfig(TKEY_TK16S_CLK_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_TK16S_CLK(Sel)); + + HT_TKEY->TKCR = (HT_TKEY->TKCR & ~(3 << 5)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the touch key OSC frequency. + * @param Sel: Specify the Touch Key frequency. + * This parameter can be one of the following values: + * @arg TKEY_TKFS_FREQ_0 : 1MHz. + * @arg TKEY_TKFS_FREQ_1 : 3MHz. + * @arg TKEY_TKFS_FREQ_2 : 7MHz. + * @arg TKEY_TKFS_FREQ_3 : 11MHz. + * @retval None + ************************************************************************************************************/ +void TKEY_OSCFreqConfig(TKEY_TKFS_FREQ_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_TKFS_FREQ(Sel)); + + HT_TKEY->TKCR = (HT_TKEY->TKCR & ~(3 << 3)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the touch key operation mode. + * @param Sel: Specify the Touch Key mode. + * This parameter can be one of the following values: + * @arg TKEY_MODE_AUTOSCAN : Auto scan mode. + * @arg TKEY_MODE_MANUAL : Manual mode. + * @arg TKEY_MODE_PASM : Periodic auto scan mode. + * @retval None + ************************************************************************************************************/ +void TKEY_ModeConfig(TKEY_MODE_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_MODE(Sel)); + + HT_TKEY->TKCR = (HT_TKEY->TKCR & ~(3 << 1)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Touch Key detection control. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TKEY_StartCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_TKEY->TKCR |= (1 << 0); + } + else + { + HT_TKEY->TKCR &= ~(1 << 0); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified TKEY interrupt. + * @param TKEY_Int: specify if the TKEY interrupt source to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg TKEY_INT_TKRCOVE : 8-bit time slot counter overflow interrupt + * @arg TKEY_INT_TKTHE : Touch Key threshold match interrupt + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TKEY_IntConfig(u32 TKEY_Int, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_INT(TKEY_Int)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_TKEY->TKIER |= TKEY_Int; + } + else + { + HT_TKEY->TKIER &= ~TKEY_Int; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified TKEY flag has been set or not. + * @param TKEY_Flag: specify the flag that is to be check. + * This parameter can be one of the following values: + * @arg TKEY_FLAG_TKBUSY : Touch Key busy flag + * @arg TKEY_FLAG_TKCFOV : Touch Key 16-bit C/F counter overflow flag + * @arg TKEY_FLAG_TK16OV : Touch Key 16-bit counter overflow flag + * @arg TKEY_FLAG_TKRCOVF : 8-bit time slot counter overflow flag + * @arg TKEY_FLAG_TKTHF : Touch Key threshold match flag + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus TKEY_GetFlagStatus(u32 TKEY_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_FLAG(TKEY_Flag)); + + if ((HT_TKEY->TKSR & TKEY_Flag) != RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified TKEY flag. + * @param TKEY_Flag: specify the flag that is to be cleared. + * This parameter can be one of the following values: + * @arg TKEY_FLAG_TKCFOV : Touch Key 16-bit C/F counter overflow flag + * @arg TKEY_FLAG_TK16OV : Touch Key 16-bit counter overflow flag + * @arg TKEY_FLAG_TKRCOVF : 8-bit time slot counter overflow flag + * @arg TKEY_FLAG_TKTHF : Touch Key threshold match flag + * @retval None + ************************************************************************************************************/ +void TKEY_ClearFlag(u32 TKEY_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_TKEY_FLAG_CLEAR(TKEY_Flag)); + + HT_TKEY->TKSR = TKEY_Flag; +} + +/*********************************************************************************************************//** + * @brief Get the touch key 16-bit counter value. + * @retval The counter value + ************************************************************************************************************/ +u32 TKEY_Get16BitCounterValue(void) +{ + return HT_TKEY->TKCNTR; +} + +/*********************************************************************************************************//** + * @brief Set the 8-bit time slot counter reload value. + * @param Reload: Specify the counter reload value. + * @retval None + ************************************************************************************************************/ +void TKEY_Set8BitCounterReload(u32 Reload) +{ + HT_TKEY->TKTSCRR = Reload; +} + +/*********************************************************************************************************//** + * @brief Get the 8-bit time slot counter reload value. + * @retval The counter reload value + ************************************************************************************************************/ +u32 TKEY_Get8BitCounterReload(void) +{ + return HT_TKEY->TKTSCRR; +} + +/*********************************************************************************************************//** + * @brief Configure the 8-bit time slot counter clock source. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Sel: Specify the 8-bit time slot counter clock source. + * This parameter can be one of the following values: + * @arg TKM_TSS_CLK_0 : Ref OSC. + * @arg TKM_TSS_CLK_1 : TKCLK/32. + * @arg TKM_TSS_CLK_2 : TKCLK/64. + * @arg TKM_TSS_CLK_3 : TKCLK/128. + * @retval None + ************************************************************************************************************/ +void TKM_TimeSlotCounterClockConfig(TKM_Enum TKMn, TKM_TSS_CLK_Enum Sel) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_TSS_CLK(Sel)); + + TKMx->CR = (TKMx->CR & ~(3 << 8)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the Reference OSC. + * @param TKMn: TKM_0 ~ TKM_5 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TKM_RefOSCCmd(TKM_Enum TKMn, ControlStatus NewState) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + TKMx->CR |= (1 << 7); + } + else + { + TKMx->CR &= ~(1 << 7); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the Key OSC. + * @param TKMn: TKM_0 ~ TKM_5 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TKM_KeyOSCCmd(TKM_Enum TKMn, ControlStatus NewState) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + TKMx->CR |= (1 << 6); + } + else + { + TKMx->CR &= ~(1 << 6); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the Multi-frequency. + * @param TKMn: TKM_0 ~ TKM_5 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TKM_MultiFreqCmd(TKM_Enum TKMn, ControlStatus NewState) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + TKMx->CR |= (1 << 5); + } + else + { + TKMx->CR &= ~(1 << 5); + } +} + +/*********************************************************************************************************//** + * @brief Configure the C/F OSC frequency-hopping. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Sel: Specify the C/F OSC frequency-hopping method. + * This paramter can be one of the following values: + * @arg TKM_SOF_CTRL_SW : + * @arg TKM_SOF_CTRL_HW : + * @retval None + ************************************************************************************************************/ +void TKM_SOFCtrlConfig(TKM_Enum TKMn, TKM_SOF_CTRL_Enum Sel) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_SOF_CTRL(Sel)); + + TKMx->CR = (TKMx->CR & ~(1 << 3)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure the Key OSC and the Reference OSC frequency. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Sel: Specify the OSC frequency. + * This paramter can be one of the following values: + * @arg TKM_SOF_FREQ_0 : 1.020MHz. + * @arg TKM_SOF_FREQ_1 : 1.040MHz. + * @arg TKM_SOF_FREQ_2 : 1.059MHz. + * @arg TKM_SOF_FREQ_3 : 1.074MHz. + * @arg TKM_SOF_FREQ_4 : 1.085MHz. + * @arg TKM_SOF_FREQ_5 : 1.099MHz. + * @arg TKM_SOF_FREQ_6 : 1.111MHz. + * @arg TKM_SOF_FREQ_7 : 1.125MHz. + * @retval None + ************************************************************************************************************/ +void TKM_SOFFreqConfig(TKM_Enum TKMn, TKM_SOF_FREQ_Enum Sel) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_SOF_FREQ(Sel)); + + TKMx->CR = (TKMx->CR & ~(7 << 0)) | Sel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified Touch Key. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TKM_KeyCmd(TKM_Enum TKMn, TKM_KEY_Enum Key, ControlStatus NewState) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + TKMx->KCFGR |= (1 << Key); + } + else + { + TKMx->KCFGR &= ~(1 << Key); + } +} + +/*********************************************************************************************************//** + * @brief Configure the Time Slot X key selection (for auto scan mode & Periodic auto scan mode). + * @param TKMn: TKM_0 ~ TKM_5 + * @param Slot: TKM_TIME_SLOT_0 ~ TKM_TIME_SLOT_3 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @retval None + ************************************************************************************************************/ +void TKM_TimeSlotKeyConfig(TKM_Enum TKMn, TKM_TIME_SLOT_Enum Slot, TKM_KEY_Enum Key) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + u32 offset = (16 + (Slot * 2)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_TIME_SLOT(Slot)); + Assert_Param(IS_TKM_KEY(Key)); + + TKMx->KCFGR = (TKMx->KCFGR & ~(3 << offset)) | (Key << offset); +} + +/*********************************************************************************************************//** + * @brief Configure the Key threshold. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @param Sel: Specify the Key threshold. + * This parameter can be one of the following values: + * @arg TKM_KEY_THR_LOWER : + * @arg TKM_KEY_THR_UPPER : + * @retval None + ************************************************************************************************************/ +void TKM_KeyThresholdConfig(TKM_Enum TKMn, TKM_KEY_Enum Key, TKM_KEY_THR_Enum Sel) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + u32 offset = (8 + Key); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + Assert_Param(IS_TKM_KEY_THR(Sel)); + + TKMx->KCFGR = (TKMx->KCFGR & ~(1 << offset)) | (Sel << offset); +} + +/*********************************************************************************************************//** + * @brief Check whether the specified key threshold match flag has been set or not. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus TKM_GetMatchFlagStatus(TKM_Enum TKMn, TKM_KEY_Enum Key) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + + if ((TKMx->SR & (1 << Key)) != RESET) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified key threshold match flag. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @retval None + ************************************************************************************************************/ +void TKM_ClearMatchFlag(TKM_Enum TKMn, TKM_KEY_Enum Key) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + + TKMx->SR = (1 << Key); +} + +/*********************************************************************************************************//** + * @brief Set the reference OSC capacitor value. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Value: Specify the capacitor value between 0x000 ~ 0x3FF. + * @retval None + ************************************************************************************************************/ +void TKM_SetRefOSCCapacitor(TKM_Enum TKMn, u32 Value) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + + TKMx->ROCPR = Value; +} + +/*********************************************************************************************************//** + * @brief Get the reference OSC capacitor value. + * @param TKMn: TKM_0 ~ TKM_5 + * @retval The capacitor value + ************************************************************************************************************/ +u32 TKM_GetRefOSCCapacitor(TKM_Enum TKMn) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + + return TKMx->ROCPR; +} + +/*********************************************************************************************************//** + * @brief Set the key capacitor value. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @param Value: Specify the capacitor value between 0x000 ~ 0x3FF. + * @retval None + ************************************************************************************************************/ +void TKM_SetKeyCapacitor(TKM_Enum TKMn, TKM_KEY_Enum Key, u32 Value) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + + *(vu32*)((u32)&TKMx->K3CPR + ((3 - Key) * 4)) = Value; +} + +/*********************************************************************************************************//** + * @brief Get the key capacitor value. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @retval The capacitor value + ************************************************************************************************************/ +u32 TKM_GetKeyCapacitor(TKM_Enum TKMn, TKM_KEY_Enum Key) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + + return *(vu32*)((u32)&TKMx->K3CPR + ((3 - Key) * 4)); +} + +/*********************************************************************************************************//** + * @brief Get the 16-bit C/F counter value. + * @param TKMn: TKM_0 ~ TKM_5 + * @retval The counter value + ************************************************************************************************************/ +u32 TKM_Get16BitCFCounterValue(TKM_Enum TKMn) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + + return TKMx->CFCNTR; +} + +/*********************************************************************************************************//** + * @brief Get the key counter value. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @retval None + ************************************************************************************************************/ +u32 TKM_GetKeyCounterValue(TKM_Enum TKMn, TKM_KEY_Enum Key) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + + return *(vu32*)((u32)&TKMx->K3CNTR + ((3 - Key) * 4)); +} + +/*********************************************************************************************************//** + * @brief Set the key threshold value. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @param Value: Specify the key threshold value between 0x0000 ~ 0xFFFF. + * @retval None + ************************************************************************************************************/ +void TKM_SetKeyThreshold(TKM_Enum TKMn, TKM_KEY_Enum Key, u32 Value) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + + *(vu32*)((u32)&TKMx->K3THR + ((3 - Key) * 4)) = Value; +} + +/*********************************************************************************************************//** + * @brief Get the key threshold value. + * @param TKMn: TKM_0 ~ TKM_5 + * @param Key: TKM_KEY_0 ~ TKM_KEY_3 + * @retval The threshold value + ************************************************************************************************************/ +u32 TKEY_GetKeyThreshold(TKM_Enum TKMn, TKM_KEY_Enum Key) +{ + HT_TKM_TypeDef *TKMx = (HT_TKM_TypeDef *)((u32)&HT_TKEY->TKM0 + (TKMn * 0x100)); + + /* Check the parameters */ + Assert_Param(IS_TKM(TKMn)); + Assert_Param(IS_TKM_KEY(Key)); + + return *(vu32*)((u32)&TKMx->K3THR + ((3 - Key) * 4)); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tm.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tm.c new file mode 100644 index 0000000000..1e4a2fe15d --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_tm.c @@ -0,0 +1,1853 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_tm.c + * @version $Rev:: 7059 $ + * @date $Date:: 2023-07-27 #$ + * @brief This file provides all the TM firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_tm.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup TM TM + * @brief TM driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup TM_Private_Define TM private definitions + * @{ + */ +#define CNTCFR_UEVDIS 0x00000001ul +#define CNTCFR_UGDIS 0x00000002ul +#define CNTCFR_DIR 0x01000000ul +#define CNTCFR_CMSEL_MASK ~0x00030000ul +#define CNTCFR_CKDIV_MASK ~0x00000300ul + +#define MDCFR_SPMSET 0x01000000ul +#define MDCFR_TSE 0x00000001ul +#define MDCFR_SMSEL_MASK ~0x00000700ul +#define MDCFR_MMSEL_MASK ~0x00070000ul + +#if 0 +#define TRCFR_ECME 0x01000000ul +#define TRCFR_ETI_POL 0x00010000ul +#define TRCFR_ETI_PSC_MASK ~0x00003000ul +#define TRCFR_ETIF_MASK ~0x00000F00ul +#define TRCFR_ETI_CONF_MASK ~0x00013F00ul +#endif +#define TRCFR_TRSEL_MASK ~0x0000000Ful + +#define CTR_TME 0x00000001ul +#define CTR_CRBE 0x00000002ul +#define CTR_CHCCDS 0x00010000ul + +#define CH0ICFR_CH0SRC 0x80000000ul +#define CHICFR_CHF_MASK ~0x000000FFul +#define CHICFR_CHCCS_MASK ~0x00030000ul +#define CHICFR_CHPSC_MASK ~0x000C0000ul + +#define CHOCFR_REFCE 0x00000008ul +#define CHOCFR_CHPRE 0x00000010ul +#define CHOCFR_IMAE 0x00000020ul +#define CHOCFR_CHOM_MASK ~0x00000107ul + +#define CHPOLR_CH0P 0x00000001ul +#define CHPOLR_CH1P 0x00000004ul +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void _TM_CHx_Config(HT_TM_TypeDef* TMx, TM_CH_Enum Ch, TM_CHP_Enum Pol, TM_CHCCS_Enum Sel, u8 Filter); + +/* Private macro -------------------------------------------------------------------------------------------*/ +#if (LIBCFG_TM_TIFN_5BIT) +#define FILTER_PROCESS(cap) ((cap->Fsampling << 5) + cap->Event) +#else +#define FILTER_PROCESS(cap) ((cap->Fsampling << 4) + cap->Event) +#endif + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup TM_Exported_Functions TM exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the TMx peripheral registers to their default reset values. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval None + ************************************************************************************************************/ +void TM_DeInit(HT_TM_TypeDef* TMx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + #if (!LIBCFG_NO_GPTM0) + if (TMx == HT_GPTM0) + { + RSTCUReset.Bit.GPTM0 = 1; + } + #endif + #if (LIBCFG_GPTM1) + else if (TMx == HT_GPTM1) + { + RSTCUReset.Bit.GPTM1 = 1; + } + #endif + #if (LIBCFG_MCTM0) + else if (TMx == HT_MCTM0) + { + RSTCUReset.Bit.MCTM0 = 1; + } + #endif + #if (LIBCFG_SCTM0) + if (TMx == HT_SCTM0) + { + RSTCUReset.Bit.SCTM0 = 1; + } + #endif + #if (LIBCFG_SCTM1) + else if (TMx == HT_SCTM1) + { + RSTCUReset.Bit.SCTM1 = 1; + } + #endif + #if (LIBCFG_SCTM2) + else if (TMx == HT_SCTM2) + { + RSTCUReset.Bit.SCTM2 = 1; + } + #endif + #if (LIBCFG_SCTM3) + else if (TMx == HT_SCTM3) + { + RSTCUReset.Bit.SCTM3 = 1; + } + #endif + #if (LIBCFG_PWM0) + if (TMx == HT_PWM0) + { + RSTCUReset.Bit.PWM0 = 1; + } + #endif + #if (LIBCFG_PWM1) + else if (TMx == HT_PWM1) + { + RSTCUReset.Bit.PWM1 = 1; + } + #endif + #if (LIBCFG_PWM2) + else if (TMx == HT_PWM2) + { + RSTCUReset.Bit.PWM1 = 1; + } + #endif + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the TMx counter to reload, prescaler, counter mode and repetition counter. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param TimeBaseInit: Point to a \ref TM_TimeBaseInitTypeDef that contains the configuration information. + * @retval None + ************************************************************************************************************/ +void TM_TimeBaseInit(HT_TM_TypeDef* TMx, TM_TimeBaseInitTypeDef* TimeBaseInit) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CNT_MODE(TimeBaseInit->CounterMode)); + Assert_Param(IS_TM_PSC_RLD(TimeBaseInit->PSCReloadTime)); + + /* Set the counter reload value */ + TMx->CRR = TimeBaseInit->CounterReload; + + /* Set the Prescaler value */ + TMx->PSCR = TimeBaseInit->Prescaler; + + /* Select the Counter Mode */ + TMx->CNTCFR &= CNTCFR_CMSEL_MASK; /* CNTCFR_DIR is read only when the timer configured as */ + TMx->CNTCFR &= ~(u32)CNTCFR_DIR; /* Center-aligned mode. Reset mode first and then reset the */ + /* CNTCFR_DIR bit (separate as two steps). */ + + TMx->CNTCFR |= TimeBaseInit->CounterMode; + + #if (LIBCFG_MCTM0) + if (TMx == HT_MCTM0) + { + /* Set the Repetition value */ + TMx->REPR = TimeBaseInit->RepetitionCounter; + } + #endif + + /* To reload the Prescaler value immediatly or next update event */ + TMx->EVGR = TimeBaseInit->PSCReloadTime; +} + +/*********************************************************************************************************//** + * @brief Initialize the TMx channel N output. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param OutInit: Point to a \ref TM_OutputInitTypeDef structure that contains + the configuration information. + * @retval None + ************************************************************************************************************/ +void TM_OutputInit(HT_TM_TypeDef* TMx, TM_OutputInitTypeDef* OutInit) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + OutInit->Channel; + vu32 *pCcr = (vu32*)&TMx->CH0CCR + OutInit->Channel; + vu32 *pAcr = (vu32*)&TMx->CH0ACR + OutInit->Channel; + u8 bChPos = OutInit->Channel << 1; + u32 wTmpMask; + u32 wTmpReg; + + #if (LIBCFG_MCTM0) + if (TMx == HT_MCTM0) + { + wTmpMask = ~(0x3ul << bChPos); + } + else + #endif + { + wTmpMask = ~(0x1ul << bChPos); + } + +#if (LIBCFG_PWM_8_CHANNEL) + if ((OutInit->Channel > TM_CH_3) && (OutInit->Channel <= TM_CH_7) ) + { + u8 bOffset = OutInit->Channel - 4; + pOcfr = (vu32*)&TMx->CH4OCFR + bOffset; + pCcr = (vu32*)&TMx->CH4CR + bOffset; + } +#endif + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(OutInit->Channel)); + Assert_Param(IS_TM_OM(OutInit->OutputMode)); +#if (LIBCFG_PWM_8_CHANNEL) + if ((OutInit->Channel > TM_CH_3) && (OutInit->Channel <= TM_CH_7) ) + { + Assert_Param(IS_TM_OM_NOASYM(OutInit->OutputMode)); + } +#endif + Assert_Param(IS_TM_CHCTL(OutInit->Control)); + Assert_Param(IS_TM_CHP(OutInit->Polarity)); + #if (LIBCFG_MCTM0) + if (TMx == HT_MCTM0) + { + Assert_Param(IS_TM_CHCTL(OutInit->ControlN)); + Assert_Param(IS_TM_CHP(OutInit->PolarityN)); + Assert_Param(IS_MCTM_OIS(OutInit->IdleState)); + Assert_Param(IS_MCTM_OIS(OutInit->IdleStateN)); + } + #endif + + /* Disable the Channel */ + TMx->CHCTR &= wTmpMask; + + /* Set the Output Compare Polarity */ + wTmpReg = TMx->CHPOLR & wTmpMask; + #if (LIBCFG_MCTM0) + if (TMx == HT_MCTM0) + { + wTmpReg |= (u32)(OutInit->Polarity | (OutInit->PolarityN << 1)) << bChPos; + } + else + #endif + { + wTmpReg |= (u32)(OutInit->Polarity) << bChPos; + } + + TMx->CHPOLR = wTmpReg; + + /* Set the Output Idle State */ + #if (LIBCFG_MCTM0) + if (TMx == HT_MCTM0) + { + wTmpReg = TMx->CHBRKCFR & wTmpMask; + wTmpReg |= (u32)(OutInit->IdleState | (OutInit->IdleStateN << 1)) << bChPos; + TMx->CHBRKCFR = wTmpReg; + } + #endif + + /* Select the Output Compare Mode */ + *pOcfr &= CHOCFR_CHOM_MASK; + *pOcfr |= OutInit->OutputMode; + + /* Set the Capture Compare Register value */ + *pCcr = OutInit->Compare; + + /* Set the Asymmetric Compare Register value */ + *pAcr = OutInit->AsymmetricCompare; + + /* Set the channel state */ + #if (LIBCFG_MCTM0) + if (TMx == HT_MCTM0) + { + TMx->CHCTR |= (u32)(OutInit->Control | (OutInit->ControlN << 1)) << bChPos; + } + else + #endif + { + TMx->CHCTR |= (u32)(OutInit->Control) << bChPos; + } +} + +/*********************************************************************************************************//** + * @brief Initialize input capture of the TMx channel. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param CapInit: Point to a \ref TM_CaptureInitTypeDef structure that contains the configuration + * information. + * @retval None + ************************************************************************************************************/ +void TM_CaptureInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit) +{ + u8 Filter; + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(CapInit->Channel)); + Assert_Param(IS_TM_CHP(CapInit->Polarity)); + Assert_Param(IS_TM_CHCCS(CapInit->Selection)); + Assert_Param(IS_TM_CHPSC(CapInit->Prescaler)); + #if (LIBCFG_TM_652XX_V1) + #else + Assert_Param(IS_TM_FILTER(CapInit->Filter)); + #endif + + #if (LIBCFG_TM_652XX_V1) + Filter = FILTER_PROCESS(CapInit); + #else + Filter = CapInit->Filter; + #endif + _TM_CHx_Config(TMx, CapInit->Channel, CapInit->Polarity, CapInit->Selection, Filter); + + /* Set the Input Capture Prescaler value */ + TM_CHPSCConfig(TMx, CapInit->Channel, CapInit->Prescaler); +} + +/*********************************************************************************************************//** + * @brief Configure the TMx to measure an external PWM signal. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param CapInit: Point to a \ref TM_CaptureInitTypeDef structure that contains the configuration + * information. + * @retval None + * @note The CapInit->Channel can only be TM_CH_0 or TM_CH_1. CH2/CH3 are not supported since it cannot be + * the STI source to reset the counter. + ************************************************************************************************************/ +void TM_PwmInputInit(HT_TM_TypeDef* TMx, TM_CaptureInitTypeDef* CapInit) +{ + u8 Filter; + TM_CHP_Enum OppositePol; + TM_CHCCS_Enum OppositeSel; + TM_CH_Enum OppositeChannel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH_PWMI(CapInit->Channel)); + Assert_Param(IS_TM_CHP(CapInit->Polarity)); + Assert_Param(IS_TM_CHCCS(CapInit->Selection)); + Assert_Param(IS_TM_CHPSC(CapInit->Prescaler)); + #if (LIBCFG_TM_652XX_V1) + #else + Assert_Param(IS_TM_FILTER(CapInit->Filter)); + #endif + + /* Select the Opposite Input Polarity */ + if (CapInit->Polarity == TM_CHP_NONINVERTED) + { + OppositePol = TM_CHP_INVERTED; + } + else + { + OppositePol = TM_CHP_NONINVERTED; + } + + /* Select the Opposite Input */ + if (CapInit->Selection == TM_CHCCS_DIRECT) + { + OppositeSel = TM_CHCCS_INDIRECT; + } + else + { + OppositeSel = TM_CHCCS_DIRECT; + } + + /* Can only be TM_CH_0 or TM_CH_1. CH2/CH3 are not supported since it cannot be the STI source to */ + /* reset the counter */ + if (CapInit->Channel == TM_CH_0) + { + OppositeChannel = TM_CH_1; + } + else + { + OppositeChannel = TM_CH_0; + } + + #if (LIBCFG_TM_652XX_V1) + Filter = FILTER_PROCESS(CapInit); + #else + Filter = CapInit->Filter; + #endif + + /* Capture Channel Configuration */ + _TM_CHx_Config(TMx, CapInit->Channel, CapInit->Polarity, CapInit->Selection, Filter); + + /* Set the Input Capture Prescaler value */ + TM_CHPSCConfig(TMx, CapInit->Channel, CapInit->Prescaler); + + /* Opposite Channel Configuration */ + _TM_CHx_Config(TMx, OppositeChannel, OppositePol, OppositeSel, Filter); + + /* Set the Input Capture Prescaler value */ + TM_CHPSCConfig(TMx, OppositeChannel, CapInit->Prescaler); +} + +/*********************************************************************************************************//** + * @brief Fill each TimeBaseInit member with its default value. + * @param TimeBaseInit: Point to a \ref TM_TimeBaseInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void TM_TimeBaseStructInit(TM_TimeBaseInitTypeDef* TimeBaseInit) +{ + /* Set the default configuration */ + TimeBaseInit->CounterMode = TM_CNT_MODE_UP; + TimeBaseInit->CounterReload = 0xFFFF; + TimeBaseInit->Prescaler = 0x0000; + TimeBaseInit->PSCReloadTime = TM_PSC_RLD_IMMEDIATE; + #if (LIBCFG_MCTM0) + TimeBaseInit->RepetitionCounter = 0; + #endif +} + +/*********************************************************************************************************//** + * @brief Fill each OutInit member with its default value. + * @param OutInit: Point to a \ref TM_OutputInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void TM_OutputStructInit(TM_OutputInitTypeDef* OutInit) +{ + /* Set the default configuration */ + OutInit->Channel = TM_CH_0; + OutInit->OutputMode = TM_OM_MATCH_NOCHANGE; + OutInit->Control = TM_CHCTL_DISABLE; + OutInit->Polarity = TM_CHP_NONINVERTED; + #if (LIBCFG_MCTM0) + OutInit->ControlN = TM_CHCTL_DISABLE; + OutInit->PolarityN = TM_CHP_NONINVERTED; + OutInit->IdleState = MCTM_OIS_LOW; + OutInit->IdleStateN = MCTM_OIS_LOW; + #endif + OutInit->Compare = 0x0000; + OutInit->AsymmetricCompare = 0x0000; +} + +/*********************************************************************************************************//** + * @brief Fill each CapInit member with its default value. + * @param CapInit: Point to a \ref TM_CaptureInitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void TM_CaptureStructInit(TM_CaptureInitTypeDef* CapInit) +{ + /* Set the default configuration */ + CapInit->Channel = TM_CH_0; + CapInit->Polarity = TM_CHP_NONINVERTED; + CapInit->Selection = TM_CHCCS_DIRECT; + CapInit->Prescaler = TM_CHPSC_OFF; + #if (LIBCFG_TM_652XX_V1) + CapInit->Fsampling = TM_CHFDIV_1; + CapInit->Event = TM_CHFEV_OFF; + #else + CapInit->Filter = 0x00; + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable TMx counter. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_Cmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the TM Counter */ + TMx->CTR |= CTR_TME; + } + else + { + /* Disable the TM Counter */ + TMx->CTR &= ~CTR_TME; + } +} + +#if (LIBCFG_TM_NO_ITI == 1) +#else +/*********************************************************************************************************//** + * @brief Configure external clock mode of the TMx. Used ITIx as the clock source. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Iti: Trigger source. + * This parameter can be one of the following values: + * @arg TM_TRSEL_ITI0: Internal trigger 0 + * @arg TM_TRSEL_ITI1: Internal trigger 1 + * @arg TM_TRSEL_ITI2: Internal trigger 2 + * @retval None + ************************************************************************************************************/ +void TM_ItiExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Iti) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_ITI(Iti)); + + /* Select the Internal Trigger. Slave mode will be disable in this function */ + TM_StiConfig(TMx, Iti); + + /* Select the STIED as external clock source */ + TMx->MDCFR |= TM_SMSEL_STIED; +} +#endif + +/*********************************************************************************************************//** + * @brief Configure external clock mode of the TMx. Used CHx as the clock source. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the channel source. + * This parameter can be one of the following values: + * @arg TM_TRSEL_TI0BED : TI0 both edge detector + * @arg TM_TRSEL_TI0S0 : Filtered timer input 0 + * @arg TM_TRSEL_TI1S1 : Filtered timer input 1 + * @param Pol: Specify the CHx Polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : active high. + * @arg TM_CHP_INVERTED : active low. + * @param Filter: Specify the filter value. + * This parameter must be a value between 0x0 and 0xF. + * @retval None + ************************************************************************************************************/ +void TM_ChExternalClockConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel, TM_CHP_Enum Pol, u8 Filter) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_TRSEL_CH(Sel)); + Assert_Param(IS_TM_CHP(Pol)); + #if (LIBCFG_TM_652XX_V1) + #else + Assert_Param(IS_TM_FILTER(Filter)); + #endif + + /* Configure the Timer Input Clock Source */ + if (Sel == TM_TRSEL_TI1S1) + { + _TM_CHx_Config(TMx, TM_CH_1, Pol, TM_CHCCS_DIRECT, Filter); + } + else + { + _TM_CHx_Config(TMx, TM_CH_0, Pol, TM_CHCCS_DIRECT, Filter); + } + + /* Select the external clock source. Slave mode will be disable in this function */ + TM_StiConfig(TMx, Sel); + + /* Select the STIED as external clock source */ + TMx->MDCFR |= TM_SMSEL_STIED; +} + +#if 0 +/*********************************************************************************************************//** + * @brief Configure external clock mode of the TMx. Used ETI as the clock source. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param Psc: The external Trigger Prescaler. + * It can be one of the following values: + * @arg TM_ETIPSC_OFF : ETI prescaler off + * @arg TM_ETIPSC_2 : ETIP frequency divided by 2 + * @arg TM_ETIPSC_4 : ETIP frequency divided by 4 + * @arg TM_ETIPSC_8 : ETIP frequency divided by 8 + * @param Pol: The external trigger input polarity. + * It can be one of the following values: + * @arg TM_ETIPOL_NONINVERTED : Active high level or rising edge + * @arg TM_ETIPOL_INVERTED : Active low level or falling edge + * @param Filter: Filter for ETI input. + * This parameter must be a value between 0x00 and 0x0F + * @retval None + ************************************************************************************************************/ +void TM_EtiExternalClockConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_ETIPSC(Psc)); + Assert_Param(IS_TM_ETIPOL(Pol)); + Assert_Param(IS_TM_FILTER(Filter)); + + /* Configure the ETI Clock source */ + TM_EtiConfig(TMx, Psc, Pol, Filter); + + /* Enable the external clock mode */ + TMx->TRCFR |= TRCFR_ECME; +} + +/*********************************************************************************************************//** + * @brief Configure external trigger input (ETI) of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param Psc: The external Trigger Prescaler. + * It can be one of the following values: + * @arg TM_ETIPSC_OFF : ETI prescaler off + * @arg TM_ETIPSC_2 : ETIP frequency divided by 2 + * @arg TM_ETIPSC_4 : ETIP frequency divided by 4 + * @arg TM_ETIPSC_8 : ETIP frequency divided by 8 + * @param Pol: The external trigger input polarity. + * It can be one of the following values: + * @arg TM_ETIPOL_NONINVERTED : Active high level or rising edge + * @arg TM_ETIPOL_INVERTED : Active low level or falling edge + * @param Filter: Filter for ETI input. + * This parameter must be a value between 0x00 and 0x0F + * @retval None + ************************************************************************************************************/ +void TM_EtiConfig(HT_TM_TypeDef* TMx, TM_ETIPSC_Enum Psc, TM_ETIPOL_Enum Pol, u8 Filter) +{ + u32 wTrcfr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_ETIPSC(Psc)); + Assert_Param(IS_TM_ETIPOL(Pol)); + Assert_Param(IS_TM_FILTER(Filter)); + + /* Get TRCFR value with cleared ETI configuration bits */ + wTrcfr = TMx->TRCFR & TRCFR_ETI_CONF_MASK; + + /* Set the prescaler, filter and polarity for ETI input */ + wTrcfr |= (u32)Psc | Pol | ((u32)Filter << 8); + + /* Write to TMx TRCFR */ + TMx->TRCFR = wTrcfr; +} +#endif + +/*********************************************************************************************************//** + * @brief Configure prescaler of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Psc: Specify the prescaler value. + * @param PscReloadTime: Specify the TM prescaler reload time. + * This parameter can be one of the following values: + * @arg TM_PSC_RLD_UPDATE : The prescaler is loaded at the next update event. + * @arg TM_PSC_RLD_IMMEDIATE : The prescaler is loaded immediatly. + * @retval None + ************************************************************************************************************/ +void TM_PrescalerConfig(HT_TM_TypeDef* TMx, u16 Psc, TM_PSC_RLD_Enum PscReloadTime) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_PSC_RLD(PscReloadTime)); + + /* Set the prescaler value */ + TMx->PSCR = Psc; + + /* Set the UEVG bit or not */ + TMx->EVGR = PscReloadTime; +} + +/*********************************************************************************************************//** + * @brief Configure counter mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Mod: Specify the counter mode to be used. + * This parameter can be one of the following values: + * @arg TM_CNT_MODE_UP : TM up counting mode. + * @arg TM_CNT_MODE_DOWN : TM down counting mode. + * @arg TM_CNT_MODE_CA1 : TM center aligned mode 1. + * @arg TM_CNT_MODE_CA2 : TM center aligned mode 2. + * @arg TM_CNT_MODE_CA3 : TM center aligned mode 3. + * @retval None + ************************************************************************************************************/ +void TM_CounterModeConfig(HT_TM_TypeDef* TMx, TM_CNT_MODE_Enum Mod) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CNT_MODE(Mod)); + + /* Reset the CMSEL and DIR Bits */ + TMx->CNTCFR &= CNTCFR_CMSEL_MASK; /* CNTCFR_DIR is read only when the timer configured as */ + TMx->CNTCFR &= ~(u32)CNTCFR_DIR; /* Center-aligned mode. Reset mode first and then reset the */ + /* CNTCFR_DIR bit (separate as two steps). */ + + /* Set the Counter Mode */ + TMx->CNTCFR |= Mod; +} + +/*********************************************************************************************************//** + * @brief Select the STI source. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the STI source. + * This parameter can be one of the following: + * @arg TM_TRSEL_ITI0 : Internal trigger 0. + * @arg TM_TRSEL_ITI1 : Internal trigger 1. + * @arg TM_TRSEL_ITI2 : Internal trigger 2. + * @arg TM_TRSEL_TI0BED : TI0 both edge detector. + * @arg TM_TRSEL_TI0S0 : Filtered channel 0 input. + * @arg TM_TRSEL_TI1S1 : Filtered channel 1 input. + * @arg TM_TRSEL_ETIF : External trigger input. + * @arg TM_TRSEL_UEVG : Trigger by setting UEVG bit. + * @retval None + ************************************************************************************************************/ +void TM_StiConfig(HT_TM_TypeDef* TMx, TM_TRSEL_Enum Sel) +{ + u32 wTrcfr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_TRSEL(Sel)); + + /* Disable slave mode */ + TMx->MDCFR &= MDCFR_SMSEL_MASK; + + /* Get the TRCFR value with cleared TRSEL */ + wTrcfr = TMx->TRCFR & TRCFR_TRSEL_MASK; + + /* Set the STI source */ + TMx->TRCFR |= wTrcfr | Sel; +} + +/*********************************************************************************************************//** + * @brief Configure encoder interface of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param DecoderMod: Specify the TMx decoder mode. + * This parameter can be one of the following values: + * @arg TM_SMSEL_DECODER1 : Counter counts on CH0 edge depending on CH1 level. + * @arg TM_SMSEL_DECODER2 : Counter counts on CH1 edge depending on CH0 level. + * @arg TM_SMSEL_DECODER3 : Counter counts on both CH0 and CH1 edges depending on + * the level of the other input. + * @param CH0P: Specify the CH0 polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : Active high level or rising edge + * @arg TM_CHP_INVERTED : Active low level or falling edge + * @param CH1P: Specify the CH1 polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : Active high level or rising edge + * @arg TM_CHP_INVERTED : Active low level or falling edge + * @retval None + ************************************************************************************************************/ +void TM_DecoderConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum DecoderMod, TM_CHP_Enum CH0P, TM_CHP_Enum CH1P) +{ + u32 wMdcfr, wCh0Icfr, wCh1Icfr, wChpolr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_SMSEL_DECODER(DecoderMod)); + Assert_Param(IS_TM_CHP(CH0P)); + Assert_Param(IS_TM_CHP(CH1P)); + + /* Get the TMx MDCFR register value */ + wMdcfr = TMx->MDCFR; + + /* Get the TMx CH0ICFR & CH1ICFR register value */ + wCh0Icfr = TMx->CH0ICFR; + wCh1Icfr = TMx->CH1ICFR; + + /* Get the TMx CHPOLR register value */ + wChpolr = TMx->CHPOLR; + + /* Set the decoder mode */ + wMdcfr &= MDCFR_SMSEL_MASK; + wMdcfr |= DecoderMod; + + /* Select the channel 0 and the channel 1 as input and clear CH0SRC */ + wCh0Icfr &= CHICFR_CHCCS_MASK & (~CH0ICFR_CH0SRC); + wCh1Icfr &= CHICFR_CHCCS_MASK; + wCh0Icfr |= TM_CHCCS_DIRECT; + wCh1Icfr |= TM_CHCCS_DIRECT; + + /* Set the CH0 and the CH1 polarities */ + wChpolr &= ~(CHPOLR_CH0P | CHPOLR_CH1P); + wChpolr |= (CH0P | (CH1P << 2)); + + /* Write to TMx MDCFR */ + TMx->MDCFR = wMdcfr; + + /* Write to TMx CH0ICFR & CH1ICFR */ + TMx->CH0ICFR = wCh0Icfr; + TMx->CH1ICFR = wCh1Icfr; + + /* Write to TMx CHPOLR */ + TMx->CHPOLR = wChpolr; +} + +/*********************************************************************************************************//** + * @brief Force the TMx CHnOREF waveform to active or inactive level. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @arg TM_CH_4 : TM channel 4 + * @arg TM_CH_5 : TM channel 5 + * @arg TM_CH_6 : TM channel 6 + * @arg TM_CH_7 : TM channel 7 + * @param ForcedAction: Specify the forced action to be set to the output waveform. + * This parameter can be one of the following values: + * @arg TM_OM_FORCED_ACTIVE : Forced active level on CH0OREF + * @arg TM_OM_FORCED_INACTIVE : Forced inactive level on CH0OREF. + * @retval None + ************************************************************************************************************/ +void TM_ForcedOREF(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, TM_OM_Enum ForcedAction) +{ + vu32* pCHnOCFR = ((vu32*)&TMx->CH0OCFR) + (TM_CH_n * 1); +#if (LIBCFG_PWM_8_CHANNEL) + if ((TM_CH_n > TM_CH_3) && (TM_CH_n <= TM_CH_7) ) + { + pCHnOCFR = ((vu32*)&TMx->CH4OCFR) + ((TM_CH_n -4) * 1); + } +#endif + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + Assert_Param(IS_TM_OM_FORCED(ForcedAction)); + + /* Configure The forced output mode */ + *pCHnOCFR = (*pCHnOCFR & CHOCFR_CHOM_MASK) | ForcedAction; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the TMx CRR preload function. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_CRRPreloadCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Set the CRR preload control bit */ + TMx->CTR |= CTR_CRBE; + } + else + { + /* Reset the CRR preload control bit */ + TMx->CTR &= ~CTR_CRBE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the TMx CHxCCR preload function. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @arg TM_CH_4 : TM channel 4 + * @arg TM_CH_5 : TM channel 5 + * @arg TM_CH_6 : TM channel 6 + * @arg TM_CH_7 : TM channel 7 + * @param NewState This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_CHCCRPreloadConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); +#if (LIBCFG_PWM_8_CHANNEL) + if ((Channel > TM_CH_3) && (Channel <= TM_CH_7)) + { + u8 bOffset = Channel - 4; + pOcfr = (vu32*)&TMx->CH4OCFR + bOffset; + } +#endif + /* Enable or disable the channel N CCR preload feature */ + if (NewState != DISABLE) + { + *pOcfr |= CHOCFR_CHPRE; + } + else + { + *pOcfr &= ~CHOCFR_CHPRE; + } +} + +/*********************************************************************************************************//** + * @brief Clear or Safeguard the CHxOREF signal when ETI is active. + * @param TMx: where TMx is the selected TM from the TM peripheral. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param NewState This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_ClearOREFConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Enable or Disable the channel N clear Oref at ETI active function */ + if (NewState != DISABLE) + { + *pOcfr |= CHOCFR_REFCE; + } + else + { + *pOcfr &= ~CHOCFR_REFCE; + } +} + +/*********************************************************************************************************//** + * @brief Configure polarity of the TMx channel N. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @arg TM_CH_4 : TM channel 4 + * @arg TM_CH_5 : TM channel 5 + * @arg TM_CH_6 : TM channel 6 + * @arg TM_CH_7 : TM channel 7 + * @param Pol: Specify the polarity of channel N. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : active high + * @arg TM_CHP_INVERTED : active low + * @retval None + ************************************************************************************************************/ +void TM_ChPolarityConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHP_Enum Pol) +{ + u32 wChpolr; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_CHP(Pol)); + + /* Set or reset the CHx polarity */ + wChpolr = TMx->CHPOLR & (~(u32)(0x1 << (Channel << 1))); + TMx->CHPOLR = wChpolr | (Pol << (Channel << 1)); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the single pulse immediate active function. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @arg TM_CH_4 : TM channel 4 + * @arg TM_CH_5 : TM channel 5 + * @arg TM_CH_6 : TM channel 6 + * @arg TM_CH_7 : TM channel 7 + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + * @note Must configure output mode to PWM1 or PWM2 before invoke this function. + ************************************************************************************************************/ +void TM_ImmActiveConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, ControlStatus NewState) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + +#if (LIBCFG_PWM_8_CHANNEL) + if ((Channel > TM_CH_3) && (Channel <= TM_CH_7) ) + { + u8 bOffset = Channel - 4; + pOcfr = (vu32*)&TMx->CH4OCFR + bOffset; + } +#endif + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Enable or disable the channel N clear CHxOREF at ETI active function */ + if (NewState != DISABLE) + { + *pOcfr |= CHOCFR_IMAE; + } + else + { + *pOcfr &= ~CHOCFR_IMAE; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the TMx channel N. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @arg TM_CH_4 : TM channel 4 + * @arg TM_CH_5 : TM channel 5 + * @arg TM_CH_6 : TM channel 6 + * @arg TM_CH_7 : TM channel 7 + * @param Control: This parameter can be TM_CHCTL_ENABLE or TM_CHCTL_DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_ChannelConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHCTL_Enum Control) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_CHCTL(Control)); + + /* Reset the CHxE Bit */ + TMx->CHCTR &= ~(u32)(0x1 << (Channel << 1)); + + /* Set or reset the CHxE Bit */ + TMx->CHCTR |= (u32)Control << (Channel << 1); +} + +/*********************************************************************************************************//** + * @brief Configure output mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @arg TM_CH_4 : TM channel 4 + * @arg TM_CH_5 : TM channel 5 + * @arg TM_CH_6 : TM channel 6 + * @arg TM_CH_7 : TM channel 7 + * @param Mod: Specify the TM output mode. + * This parameter can be one of the following values: + * @arg TM_OM_MATCH_NOCHANGE : Output dont change on match + * @arg TM_OM_MATCH_INACTIVE : Output inactive on compare match + * @arg TM_OM_MATCH_ACTIVE : Output active on compare match + * @arg TM_OM_MATCH_TOGGLE : Output toggle on compare match + * @arg TM_OM_FORCED_INACTIVE : Output forced inactive + * @arg TM_OM_FORCED_ACTIVE : Output forced active + * @arg TM_OM_PWM1 : PWM1 mode + * @arg TM_OM_PWM2 : PWM2 mode + * @arg TM_OM_ASYMMETRIC_PWM1 : Asymmetric PWM1 mode + * @arg TM_OM_ASYMMETRIC_PWM2 : Asymmetric PWM2 mode + * @retval None + * @note This function disables the selected channel before changing the output mode. + ************************************************************************************************************/ +void TM_OutputModeConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_OM_Enum Mod) +{ + vu32 *pOcfr = (vu32*)&TMx->CH0OCFR + Channel; + +#if (LIBCFG_PWM_8_CHANNEL) + if ((Channel > TM_CH_3) && (Channel <= TM_CH_7) ) + { + u8 bOffset = Channel - 4; + pOcfr = (vu32*)&TMx->CH4OCFR + bOffset; + } +#endif + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_OM(Mod)); +#if (LIBCFG_PWM_8_CHANNEL) + if ((Channel > TM_CH_3) && (Channel <= TM_CH_7) ) + { + Assert_Param(IS_TM_OM_NOASYM(Mod)); + } +#endif + + /* Disable the channel: Reset the CHxE Bit */ + TMx->CHCTR &= ~(u32)(0x1 << (Channel << 1)); + + /* Selects the TM output mode */ + *pOcfr = (*pOcfr & CHOCFR_CHOM_MASK) | Mod; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable update event of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE (default) or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_UpdateCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == DISABLE) + { + /* Set the update disable bit */ + TMx->CNTCFR |= CNTCFR_UEVDIS; + } + else + { + /* Reset the update disable bit */ + TMx->CNTCFR &= ~CNTCFR_UEVDIS; + } +} + +/*********************************************************************************************************//** + * @brief Configure UEVG interrupt function of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be one of the following value: + * @arg ENABLE : Default value. Any of the following events will generate an update event interrupt: + * - Counter overflow/underflow + * - Setting the UEVG bit + * - Update generation through the slave restart mode + * @arg DISABLE : Only counter overflow/underflow generations an update event interrupt. + * @retval None + ************************************************************************************************************/ +void TM_UEVG_IntConfig(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState == DISABLE) + { + /* Set the UEVG interrupt disable bit */ + TMx->CNTCFR |= CNTCFR_UGDIS; + } + else + { + /* Reset the UEVG interrupt disable bit */ + TMx->CNTCFR &= ~CNTCFR_UGDIS; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable hall sensor interface of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_HallInterfaceCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Set the CH0SRC Bit */ + TMx->CH0ICFR |= CH0ICFR_CH0SRC; + } + else + { + /* Reset the CH0SRC Bit */ + TMx->CH0ICFR &= ~CH0ICFR_CH0SRC; + } +} + +/*********************************************************************************************************//** + * @brief Select single pulse mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_SinglePulseModeCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + TMx->MDCFR |= MDCFR_SPMSET; + } + else + { + TMx->MDCFR &= ~MDCFR_SPMSET; + } +} + +/*********************************************************************************************************//** + * @brief Select master trigger output source of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the master trigger output source. + * This parameter can be as follow: + * @arg TM_MMSEL_RESET : Send trigger signal when S/W setting UEVG or slave restart + * @arg TM_MMSEL_ENABLE : The counter enable signal is used as trigger output. + * @arg TM_MMSEL_UPDATE : The update event is used as trigger output. + * @arg TM_MMSEL_CH0CC : Channel 0 capture or compare match occurred as trigger output. + * @arg TM_MMSEL_CH0OREF : The CH0OREF signal is used as trigger output. + * @arg TM_MMSEL_CH1OREF : The CH1OREF signal is used as trigger output. + * @arg TM_MMSEL_CH2OREF : The CH2OREF signal is used as trigger output. + * @arg TM_MMSEL_CH3OREF : The CH3OREF signal is used as trigger output. + * @arg TM_MMSEL_CH4OREF : The CH4OREF signal is used as trigger output. + * @arg TM_MMSEL_CH5OREF : The CH5OREF signal is used as trigger output. + * @arg TM_MMSEL_CH6OREF : The CH6OREF signal is used as trigger output. + * @arg TM_MMSEL_CH7OREF : The CH7OREF signal is used as trigger output. + * @retval None + ************************************************************************************************************/ +void TM_MMSELConfig(HT_TM_TypeDef* TMx, TM_MMSEL_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_MMSEL(Sel)); + + /* Select the MTO source */ + TMx->MDCFR = (TMx->MDCFR & MDCFR_MMSEL_MASK) | Sel; +} + +/*********************************************************************************************************//** + * @brief Select slave mode of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Sel: Specify the timer slave mode. + * This parameter can be one of the following values: + * @arg TM_SMSEL_RESTART : Slave restart counter mode. + * @arg TM_SMSEL_PAUSE : Slave pause counter mode. + * @arg TM_SMSEL_TRIGGER : Slave trigger counter start mode. + * @arg TM_SMSEL_STIED : Used rising edge of STI as prescaler clock source. + * @retval None + ************************************************************************************************************/ +void TM_SlaveModeConfig(HT_TM_TypeDef* TMx, TM_SMSEL_Enum Sel) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_SLAVE_MODE(Sel)); + + /* Select the slave mode */ + TMx->MDCFR = (TMx->MDCFR & MDCFR_SMSEL_MASK) | Sel; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the master & slave TMx synchronous function. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_TimSyncCmd(HT_TM_TypeDef* TMx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Set the TSE Bit */ + TMx->MDCFR |= MDCFR_TSE; + } + else + { + /* Reset the TSE Bit */ + TMx->MDCFR &= ~MDCFR_TSE; + } +} + +/*********************************************************************************************************//** + * @brief Set counter register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Counter: Specify the counter register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetCounter(HT_TM_TypeDef* TMx, u16 Counter) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Set the Counter Register value */ + TMx->CNTR = Counter; +} + +/*********************************************************************************************************//** + * @brief Set counter reload register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Reload: Specify the counter reload register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetCounterReload(HT_TM_TypeDef* TMx, u16 Reload) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Set the counter reload register value */ + TMx->CRR = Reload; +} + +/*********************************************************************************************************//** + * @brief Set channel n capture/compare register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @arg TM_CH_4 : TM channel 4 + * @arg TM_CH_5 : TM channel 5 + * @arg TM_CH_6 : TM channel 6 + * @arg TM_CH_7 : TM channel 7 + * @param Cmp: Specify the CH0CCR register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) +{ + vu32* pCHnCCR = ((vu32*)&TMx->CH0CCR) + (TM_CH_n * 1); + #if (LIBCFG_PWM_8_CHANNEL) + if ((TM_CH_n > TM_CH_3) && (TM_CH_n <= TM_CH_7) ) + { + pCHnCCR = ((vu32*)&TMx->CH4CR) + ((TM_CH_n - 4) * 1); + } + #endif + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + + /* Set the CHnCCR register new value */ + *pCHnCCR = Cmp; +} + +/*********************************************************************************************************//** + * @brief Set channel n asymmetric compare register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Cmp: Specify the CH0ACR register new value. + * @retval None + ************************************************************************************************************/ +void TM_SetAsymmetricCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n, u16 Cmp) +{ + vu32* pCHnACR = ((vu32*)&TMx->CH0ACR) + (TM_CH_n * 1); + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + + /* Set the CHnACR register new value */ + *pCHnACR = Cmp; +} + +/*********************************************************************************************************//** + * @brief Configure input capture prescaler. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Channel: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Psc: Specify the input capture prescaler new value. + * This parameter can be one of the following values: + * @arg TM_CHPSC_OFF : No prescaler + * @arg TM_CHPSC_2 : Capture is done once every 2 events + * @arg TM_CHPSC_4 : Capture is done once every 4 events + * @arg TM_CHPSC_8 : Capture is done once every 8 events + * @retval None + ************************************************************************************************************/ +void TM_CHPSCConfig(HT_TM_TypeDef* TMx, TM_CH_Enum Channel, TM_CHPSC_Enum Psc) +{ + vu32 *pIcfr = (vu32*)&TMx->CH0ICFR + Channel; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(Channel)); + Assert_Param(IS_TM_CHPSC(Psc)); + + /* Reset the CHxPSC bits */ + *pIcfr &= CHICFR_CHPSC_MASK; + + /* Set the capture input prescaler value */ + *pIcfr |= Psc; +} + +/*********************************************************************************************************//** + * @brief Set clock division value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Div: Specify the clock division value. + * This parameter can be one of the following value: + * @arg TM_CKDIV_OFF : fDTS = fCLKIN + * @arg TM_CKDIV_2 : fDTS = fCLKIN / 2 + * @arg TM_CKDIV_4 : fDTS = fCLKIN / 4 + * @arg TM_CKDIV_8 : fDTS = fCLKIN / 8 + * @retval None + ************************************************************************************************************/ +void TM_CKDIVConfig(HT_TM_TypeDef* TMx, TM_CKDIV_Enum Div) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CKDIV(Div)); + + /* Reset the CKDIV Bits */ + TMx->CNTCFR &= CNTCFR_CKDIV_MASK; + + /* Set the CKDIV value */ + TMx->CNTCFR |= Div; +} + +/*********************************************************************************************************//** + * @brief Get channel n capture/compare register value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_CH_n: Specify the TM channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @retval Value of CH0CCR register + ************************************************************************************************************/ +u32 TM_GetCaptureCompare(HT_TM_TypeDef* TMx, TM_CH_Enum TM_CH_n) +{ + vu32* pCHnCCR = ((vu32*)&TMx->CH0CCR) + (TM_CH_n * 1); + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CH(TM_CH_n)); + + #if (LIBCFG_PWM_8_CHANNEL) + if ((TM_CH_n > TM_CH_3) && (TM_CH_n <= TM_CH_7)) + { + pCHnCCR = ((vu32*)&TMx->CH4CR) + ((TM_CH_n - 4) * 1); + } + #endif + + /* Get the CHnCCR register value */ + return (*pCHnCCR); +} + +/*********************************************************************************************************//** + * @brief Get counter value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval Value of Counter register + ************************************************************************************************************/ +u32 TM_GetCounter(HT_TM_TypeDef* TMx) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Get the Counter Register value */ + return TMx->CNTR; +} + +/*********************************************************************************************************//** + * @brief Get prescaler value of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval Value of Prescaler register + ************************************************************************************************************/ +u32 TM_GetPrescaler(HT_TM_TypeDef* TMx) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Get the Prescaler Register value */ + return TMx->PSCR; +} + +/*********************************************************************************************************//** + * @brief Generate TMx events. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_EVENT: Stores the event source. + * This parameter can be any combination of following: + * @arg TM_EVENT_CH0CC : Timer Capture/compare 0 event + * @arg TM_EVENT_CH1CC : Timer Capture/compare 1 event + * @arg TM_EVENT_CH2CC : Timer Capture/compare 2 event + * @arg TM_EVENT_CH3CC : Timer Capture/compare 3 event + * @arg TM_EVENT_CH4CC : Timer Compare 4 event + * @arg TM_EVENT_CH5CC : Timer Compare 5 event + * @arg TM_EVENT_CH6CC : Timer Compare 6 event + * @arg TM_EVENT_CH7CC : Timer Compare 7 event + * @arg TM_EVENT_UEV : Timer update event + * @arg TM_EVENT_UEV2 : Timer update event 2 + * @arg TM_EVENT_TEV : Timer trigger event + * @arg TM_EVENT_BRKEV : Timer break event + * @retval None + ************************************************************************************************************/ +void TM_GenerateEvent(HT_TM_TypeDef* TMx, u32 TM_EVENT) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_EVENT(TM_EVENT)); + + /* Set the event sources */ + TMx->EVGR = TM_EVENT; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified TMx flag has been set. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_FLAG: Specify the flag to be checked. + * This parameter can be one of the following values: + * @arg TM_FLAG_CH0CC : TM Capture/compare 0 flag + * @arg TM_FLAG_CH1CC : TM Capture/compare 1 flag + * @arg TM_FLAG_CH2CC : TM Capture/compare 2 flag + * @arg TM_FLAG_CH3CC : TM Capture/compare 3 flag + * @arg TM_FLAG_CH4CC : TM Compare 4 flag + * @arg TM_FLAG_CH5CC : TM Compare 5 flag + * @arg TM_FLAG_CH6CC : TM Compare 6 flag + * @arg TM_FLAG_CH7CC : TM Compare 7 flag + * @arg TM_FLAG_CH0OC : TM channel 0 overcapture flag + * @arg TM_FLAG_CH1OC : TM channel 1 overcapture flag + * @arg TM_FLAG_CH2OC : TM channel 2 overcapture flag + * @arg TM_FLAG_CH3OC : TM channel 3 overcapture flag + * @arg TM_FLAG_UEV : TM update flag + * @arg TM_FLAG_UEV2 : TM update 2 flag + * @arg TM_FLAG_TEV : TM trigger flag + * @arg TM_FLAG_BRK0 : TM break 0 flag + * @arg TM_FLAG_BRK1 : TM break 1 flag + * @retval The new state of TM_FLAG (SET or RESET). + ************************************************************************************************************/ +FlagStatus TM_GetFlagStatus(HT_TM_TypeDef* TMx, u32 TM_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_FLAG(TM_FLAG)); + + if ((TMx->INTSR & TM_FLAG) != 0) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear flags of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_FLAG: Specify the flag to be cleared. + * This parameter can be any combination of the following values: + * @arg TM_FLAG_CH0CC : TM Capture/compare 0 flag + * @arg TM_FLAG_CH1CC : TM Capture/compare 1 flag + * @arg TM_FLAG_CH2CC : TM Capture/compare 2 flag + * @arg TM_FLAG_CH3CC : TM Capture/compare 3 flag + * @arg TM_FLAG_CH4CC : TM Compare 4 flag + * @arg TM_FLAG_CH5CC : TM Compare 5 flag + * @arg TM_FLAG_CH6CC : TM Compare 6 flag + * @arg TM_FLAG_CH7CC : TM Compare 7 flag + * @arg TM_FLAG_CH0OC : TM channel 0 overcapture flag + * @arg TM_FLAG_CH1OC : TM channel 1 overcapture flag + * @arg TM_FLAG_CH2OC : TM channel 2 overcapture flag + * @arg TM_FLAG_CH3OC : TM channel 3 overcapture flag + * @arg TM_FLAG_UEV : TM update flag + * @arg TM_FLAG_UEV2 : TM update 2 flag + * @arg TM_FLAG_TEV : TM trigger flag + * @arg TM_FLAG_BRK0 : TM break 0 flag + * @arg TM_FLAG_BRK1 : TM break 1 flag + * @retval None + ************************************************************************************************************/ +void TM_ClearFlag(HT_TM_TypeDef* TMx, u32 TM_FLAG) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_FLAG_CLR(TM_FLAG)); + + /* Clear the flags */ + TMx->INTSR = ~TM_FLAG; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified interrupts of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_INT: Specify the TM interrupts sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg TM_INT_CH0CC : TM Capture/compare 0 interrupt + * @arg TM_INT_CH1CC : TM Capture/compare 1 interrupt + * @arg TM_INT_CH2CC : TM Capture/compare 2 interrupt + * @arg TM_INT_CH3CC : TM Capture/compare 3 interrupt + * @arg TM_INT_CH4CC : TM Compare 4 interrupt + * @arg TM_INT_CH5CC : TM Compare 5 interrupt + * @arg TM_INT_CH6CC : TM Compare 6 interrupt + * @arg TM_INT_CH7CC : TM Compare 7 interrupt + * @arg TM_INT_UEV : TM update interrupt + * @arg TM_INT_UEV2 : TM update 2 interrupt + * @arg TM_INT_TEV : TM trigger interrupt + * @arg TM_INT_BRKEV : TM break interrupt + * @arg MCTM_INT_CH0CD : MCTM Channel 0 Count-Down compare interrupt + * @arg MCTM_INT_CH1CD : MCTM Channel 1 Count-Down compare interrupt + * @arg MCTM_INT_CH2CD : MCTM Channel 2 Count-Down compare interrupt + * @arg MCTM_INT_CH3CD : MCTM Channel 3 Count-Down compare interrupt + * @arg TM_INT_VC : TM Velocity clock trigger interrupt + * @arg TM_INT_QC : TM Quadrature decoder CLKPULSE interrupt + * @arg TM_INT_PE : TM Phase error interrupt + * @arg TM_INT_DC : TM Counter direction change interrupt + * @arg MCTM_INT_OVER : MCTM CNTR Overflow interrupt + * @arg MCTM_INT_UNDER : MCTM CNTR Underflow interrupt + * @arg MCTM_INT_RECCDIF : MCTM CCIF or CIDF interrupt flag control by REPR + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_IntConfig(HT_TM_TypeDef* TMx, u32 TM_INT, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_INT(TM_INT)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the interrupt sources */ + TMx->DICTR |= TM_INT; + } + else + { + /* Disable the interrupt sources */ + TMx->DICTR &= ~TM_INT; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the TMx interrupt has occurred. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_INT: Specify the TM interrupt source to be checked. + * This parameter can be one of the following values: + * @arg TM_INT_CH0CC : TM Capture/compare 0 interrupt + * @arg TM_INT_CH1CC : TM Capture/compare 1 interrupt + * @arg TM_INT_CH2CC : TM Capture/compare 2 interrupt + * @arg TM_INT_CH3CC : TM Capture/compare 3 interrupt + * @arg TM_INT_CH4CC : TM Compare 4 interrupt + * @arg TM_INT_CH5CC : TM Compare 5 interrupt + * @arg TM_INT_CH6CC : TM Compare 6 interrupt + * @arg TM_INT_CH7CC : TM Compare 7 interrupt + * @arg TM_INT_UEV : TM update interrupt + * @arg TM_INT_UEV2 : TM update 2 interrupt + * @arg TM_INT_TEV : TM trigger interrupt + * @arg TM_INT_BRKEV : TM break interrupt + * @retval The new state of the TM_INT(SET or RESET) + ************************************************************************************************************/ +FlagStatus TM_GetIntStatus(HT_TM_TypeDef* TMx, u32 TM_INT) +{ + u32 itstatus, itenable; + + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_GET_INT(TM_INT)); + + itstatus = TMx->INTSR & TM_INT; + itenable = TMx->DICTR & TM_INT; + + if ((itstatus != 0) && (itenable != 0)) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Clear interrupt pending bits of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_INT: Specify the TM interrupt to be cleared. + * This parameter can be any combination of the following values: + * @arg TM_INT_CH0CC : TM Capture/compare 0 interrupt + * @arg TM_INT_CH1CC : TM Capture/compare 1 interrupt + * @arg TM_INT_CH2CC : TM Capture/compare 2 interrupt + * @arg TM_INT_CH3CC : TM Capture/compare 3 interrupt + * @arg TM_INT_CH4CC : TM Compare 4 interrupt + * @arg TM_INT_CH5CC : TM Compare 5 interrupt + * @arg TM_INT_CH6CC : TM Compare 6 interrupt + * @arg TM_INT_CH7CC : TM Compare 7 interrupt + * @arg TM_INT_UEV : TM update interrupt + * @arg TM_INT_UEV2 : TM update 2 interrupt + * @arg TM_INT_TEV : TM trigger interrupt + * @arg TM_INT_BRKEV : TM break interrupt + * @retval None + ************************************************************************************************************/ +void TM_ClearIntPendingBit(HT_TM_TypeDef* TMx, u32 TM_INT) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_INT(TM_INT)); + + /* Clear the interrupt pending Bit */ + TMx->INTSR = ~TM_INT; + + /*--------------------------------------------------------------------------------------------------------*/ + /* DSB instruction is added in this function to ensure the write operation which is for clearing interrupt*/ + /* flag is actually completed before exiting ISR. It prevents the NVIC from detecting the interrupt again */ + /* since the write register operation may be pended in the internal write buffer of Cortex-Mx when program*/ + /* has exited interrupt routine. This DSB instruction may be masked if this function is called in the */ + /* beginning of ISR and there are still some instructions before exiting ISR. */ + /*--------------------------------------------------------------------------------------------------------*/ + __DSB(); +} + +/*********************************************************************************************************//** + * @brief Disable slave mode to clock the prescaler directly with the internal clock. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @retval None + ************************************************************************************************************/ +void TM_InternalClockConfig(HT_TM_TypeDef* TMx) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + + /* Disable slave mode to clock the prescaler directly with the internal clock */ + TMx->MDCFR &= MDCFR_SMSEL_MASK; +} + +#if (LIBCFG_PDMA) +/*********************************************************************************************************//** + * @brief Select Channel Capture/Compare PDMA event of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Selection: This parameter can be TM_CHCCDS_CHCCEV or TM_CHCCDS_UEV. + * @retval None + ************************************************************************************************************/ +void TM_CHCCDSConfig(HT_TM_TypeDef* TMx, TM_CHCCDS_Enum Selection) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_CHCCDS(Selection)); + + if (Selection != TM_CHCCDS_CHCCEV) + { + TMx->CTR |= CTR_CHCCDS; + } + else + { + TMx->CTR &= ~CTR_CHCCDS; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified PDMA requests of the TMx. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param TM_PDMA: Specify the TM PDMA requests to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg TM_PDMA_CH0CC : TM Capture/compare 0 PDMA request + * @arg TM_PDMA_CH1CC : TM Capture/compare 1 PDMA request + * @arg TM_PDMA_CH2CC : TM Capture/compare 2 PDMA request + * @arg TM_PDMA_CH3CC : TM Capture/compare 3 PDMA request + * @arg TM_PDMA_UEV : TM update PDMA request + * @arg TM_PDMA_UEV2 : TM update 2 PDMA request + * @arg TM_PDMA_TEV : TM trigger PDMA request + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void TM_PDMAConfig(HT_TM_TypeDef* TMx, u32 TM_PDMA, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_TM(TMx)); + Assert_Param(IS_TM_PDMA(TM_PDMA)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + /* Enable the PDMA request */ + TMx->DICTR |= TM_PDMA; + } + else + { + /* Disable the PDMA request */ + TMx->DICTR &= ~TM_PDMA; + } +} +#endif +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup TM_Private_Functions TM private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Configure the CHx as input. + * @param TMx: where TMx is the selected TM from the TM peripherals. + * @param Ch: Specify the TM Channel. + * This parameter can be one of the following values: + * @arg TM_CH_0 : TM channel 0 + * @arg TM_CH_1 : TM channel 1 + * @arg TM_CH_2 : TM channel 2 + * @arg TM_CH_3 : TM channel 3 + * @param Pol: The input polarity. + * This parameter can be one of the following values: + * @arg TM_CHP_NONINVERTED : Active high level or rising edge + * @arg TM_CHP_INVERTED : Active low level or falling edge + * @param Sel: Specify the input to be used. + * This parameter can be one of the following values: + * @arg TM_CHCCS_DIRECT : TM CHxI is mapped on CHx. + * @arg TM_CHCCS_INDIRECT : TM CH1I is mapped on CH0 (or CH0I->CH1 or CH2I->CH3 or CH3I->CH2). + * @arg TM_CHCCS_TRCED : TM CHx is mapped on TRC. + * @param Filter: Specify the input capture filter. + * This parameter must be a value between 0x00 and 0x0F. + * @retval None + ************************************************************************************************************/ +static void _TM_CHx_Config(HT_TM_TypeDef* TMx, TM_CH_Enum Ch, TM_CHP_Enum Pol, TM_CHCCS_Enum Sel, u8 Filter) +{ + vu32* pIcfr = (vu32*)&TMx->CH0ICFR + Ch; + u32 wIcfr, wChpolr; + + /* Disable the channel N: reset the CHxE bit */ + TMx->CHCTR &= ~((u32)0x1 << (Ch << 1)); + + wIcfr = *pIcfr; + wChpolr = TMx->CHPOLR; + + /* Select the input and set the filter */ + wIcfr &= CHICFR_CHCCS_MASK & CHICFR_CHF_MASK; + wIcfr |= Sel | Filter; + *pIcfr = wIcfr; + + /* Select the polarity bit */ + wChpolr &= ~((u32)0x1 << (Ch << 1)); + wChpolr |= (u32)Pol << (Ch << 1); + TMx->CHPOLR = wChpolr; + + /* Set the CHxE Bit */ + TMx->CHCTR |= (u32)0x1 << (Ch << 1); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usart.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usart.c new file mode 100644 index 0000000000..c0dd366f36 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usart.c @@ -0,0 +1,911 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_usart.c + * @version $Rev:: 7054 $ + * @date $Date:: 2023-07-24 #$ + * @brief This file provides all the USART firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_usart.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup USART USART + * @brief USART driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup USART_Private_Define USART private definitions + * @{ + */ +#define CR_CLEAR_Mask ((u32)0xFFFFE0FC) + +#define USART_BREAK_ON ((u32)0x00004000) +#define USART_BREAK_OFF ((u32)0xFFFFBFFF) + +#define USART_PBE_ON ((u32)0x00000800) +#define USART_SPE_ON ((u32)0x00002000) +#define USART_SPE_OFF ((u32)0xFFFFDFFF) + +#define USART_EN_ON ((u32)0x00000010) + +#define USART_HFCEN_ON ((u32)0x00000008) +#define USART_HFCEN_OFF ((u32)0xFFFFFFF7) + +#define USART_RXTOEN_ON ((u32)0x00000080) + +#define FCR_TL_Mask ((u32)0x00000030) + +#define TRSM_CLEAR_Mask ((u32)0xFFFFFFFB) +#define TPR_TG_Mask ((u32)0xFFFF00FF) +#define ICR_IRDAPSC_Mask ((u32)0xFFFF00FF) +#define TPR_RXTOIC_Mask ((u32)0xFFFFFF80) +#define RS485CR_ADDM_Mask ((u32)0xFFFF00FF) + +#define USART_IRDA_ON ((u32)0x00000001) +#define USART_IRDA_OFF ((u32)0xFFFFFFFE) + +#define USART_INV_ON ((u32)0x00000010) + +#define USART_RS485NMM_ON ((u32)0x00000002) +#define USART_RS485NMM_OFF ((u32)0xFFFFFFFD) + +#define USART_RS485AAD_ON ((u32)0x00000004) +#define USART_RS485AAD_OFF ((u32)0xFFFFFFFB) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup USART_Exported_Functions USART exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the USART/UART peripheral registers to their default reset values. + * @param USARTx: Parameter to select the UxART peripheral. + * @retval None + ************************************************************************************************************/ +void USART_DeInit(HT_USART_TypeDef* USARTx) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + u32 uIPAddr = (u32)USARTx; + + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + switch (uIPAddr) + { + #if (!LIBCFG_NO_USART0) + case HT_USART0_BASE: + { + RSTCUReset.Bit.USART0 = 1; + break; + } + #endif + #if (LIBCFG_USART1) + case HT_USART1_BASE: + { + RSTCUReset.Bit.USART1 = 1; + break; + } + #endif + case HT_UART0_BASE: + { + RSTCUReset.Bit.UART0 = 1; + break; + } + #if (LIBCFG_UART1) + case HT_UART1_BASE: + { + RSTCUReset.Bit.UART1 = 1; + break; + } + #endif + #if (LIBCFG_UART2) + case HT_UART2_BASE: + { + RSTCUReset.Bit.UART2 = 1; + break; + } + #endif + #if (LIBCFG_UART3) + case HT_UART3_BASE: + { + RSTCUReset.Bit.UART3 = 1; + break; + } + #endif + } + + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Initialize the USART/UART peripheral according to the specified parameters in the USART_InitStruct. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_InitStruct: pointer to a USART_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_Init(HT_USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct) +{ + u32 uIPClock = 0; + u32 uIPAddr = (u32)USARTx; + + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_BAUDRATE(USART_InitStruct->USART_BaudRate)); + Assert_Param(IS_USART_WORD_LENGTH(USART_InitStruct->USART_WordLength)); + Assert_Param(IS_USART_STOPBITS(USART_InitStruct->USART_StopBits)); + Assert_Param(IS_USART_PARITY(USART_InitStruct->USART_Parity)); + Assert_Param(IS_USART_MODE(USART_InitStruct->USART_Mode)); + + USARTx->CR = (USARTx->CR & CR_CLEAR_Mask) | USART_InitStruct->USART_StopBits | + USART_InitStruct->USART_WordLength | USART_InitStruct->USART_Parity | + USART_InitStruct->USART_Mode; + + switch (uIPAddr) + { + #if (!LIBCFG_NO_USART0) + case HT_USART0_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_USART0); + break; + } + #endif + #if (LIBCFG_USART1) + case HT_USART1_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_USART1); + break; + } + #endif + case HT_UART0_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_UART0); + break; + } + #if (LIBCFG_UART1) + case HT_UART1_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_UART1); + break; + } + #endif + #if (LIBCFG_UART2) + case HT_UART2_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_UART2); + break; + } + #endif + #if (LIBCFG_UART3) + case HT_UART3_BASE: + { + uIPClock = CKCU_GetPeripFrequency(CKCU_PCLK_UART3); + break; + } + #endif + } + + USARTx->DLR = uIPClock / (u32)USART_InitStruct->USART_BaudRate; +} + +/*********************************************************************************************************//** + * @brief Fill each USART_InitStruct member with its default value. + * @param USART_InitStruct: pointer to a USART_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_StructInit(USART_InitTypeDef* USART_InitStruct) +{ + /* USART_InitStruct members default value */ + USART_InitStruct->USART_BaudRate = 9600; + USART_InitStruct->USART_WordLength = USART_WORDLENGTH_8B; + USART_InitStruct->USART_StopBits = USART_STOPBITS_1; + USART_InitStruct->USART_Parity = USART_PARITY_NO; + USART_InitStruct->USART_Mode = USART_MODE_NORMAL; +} + +/*********************************************************************************************************//** + * @brief USART/UART send data to Tx. + * @param USARTx: Parameter to select the UxART peripheral. + * @param Data: the data to be transmitted. + * @retval None + ************************************************************************************************************/ +void USART_SendData(HT_USART_TypeDef* USARTx, u16 Data) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_DATA(Data)); + + USARTx->DR = Data; +} + +/*********************************************************************************************************//** + * @brief USART/UART receive data from Rx. + * @param USARTx: Parameter to select the UxART peripheral. + * @retval The received data. + ************************************************************************************************************/ +u16 USART_ReceiveData(HT_USART_TypeDef* USARTx) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + return (u16)(USARTx->DR); +} + +/*********************************************************************************************************//** + * @brief Get the specified USART/UART status flags. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_FLAG_x: Specify the flag to be check. + * This parameter can be one of the following values: + * @arg USART_FLAG_RXDNE : + * @arg USART_FLAG_OE : + * @arg USART_FLAG_PE : + * @arg USART_FLAG_FE : + * @arg USART_FLAG_BI : + * @arg USART_FLAG_RXDR : + * @arg USART_FLAG_TOUT : + * @arg USART_FLAG_TXDE : + * @arg USART_FLAG_TXC : + * @arg USART_FLAG_RSADD : + * @arg USART_FLAG_CTSC : + * @arg USART_FLAG_CTSS : + * @arg USART_FLAG_LBD : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus USART_GetFlagStatus(HT_USART_TypeDef* USARTx, u32 USART_FLAG_x) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_FLAG(USART_FLAG_x)); + + if ((USARTx->SR & USART_FLAG_x) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } +} + +/*********************************************************************************************************//** + * @brief Get the specified USART/UART INT status. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_INT_x: Specify if the USART/UART interrupt source. + * This parameter can be one of the following values: + * @arg USART_INT_RXDR : + * @arg USART_INT_TXDE : + * @arg USART_INT_TXC : + * @arg USART_INT_OE : + * @arg USART_INT_PE : + * @arg USART_INT_FE : + * @arg USART_INT_BI : + * @arg USART_INT_RSADD : + * @arg USART_INT_TOUT : + * @arg USART_INT_CTS : + * @arg USART_INT_LBD : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus USART_GetIntStatus(HT_USART_TypeDef* USARTx, u32 USART_INT_x) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_INT(USART_INT_x)); + + if ((USARTx->IER & USART_INT_x) != (u32)RESET) + { + return (SET); + } + else + { + return (RESET); + } +} + +/*********************************************************************************************************//** + * @brief Clear the specified USART/UART flags. + * @param USARTx: where USARTx is the selected USART/UART from the USART/UART peripherals. + * @param USART_Flag: Specify the flag to check. + * This parameter can be any combination of the following values: + * @arg USART_FLAG_OE : + * @arg USART_FLAG_PE : + * @arg USART_FLAG_FE : + * @arg USART_FLAG_BI : + * @arg USART_FLAG_TOUT : + * @arg USART_FLAG_RSADD : + * @arg USART_FLAG_CTSC : + * @arg USART_FLAG_LBD : + * @retval SET or RESET + ************************************************************************************************************/ +void USART_ClearFlag(HT_USART_TypeDef* USARTx, u32 USART_Flag) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_CLEAR_FLAG(USART_Flag)); + + USARTx->SR &= USART_Flag; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART interrupts. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_INT_x: Specify if the USART/UART interrupt source to be enabled or disabled. + * This parameter can be one of the following values: + * @arg USART_INT_RXDR : + * @arg USART_INT_TXDE : + * @arg USART_INT_TXC : + * @arg USART_INT_OE : + * @arg USART_INT_PE : + * @arg USART_INT_FE : + * @arg USART_INT_BI : + * @arg USART_INT_RSADD : + * @arg USART_INT_TOUT : + * @arg USART_INT_CTS : +* @arg USART_INT_LBD : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_IntConfig(HT_USART_TypeDef* USARTx, u32 USART_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_INT(USART_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->IER |= USART_INT_x; + } + else + { + USARTx->IER &= ~USART_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART Tx/Rx. + * @param USARTx: Parameter to select the USART peripheral. + * @param TxRx: This parameter can be USART_CMD_TX or USART_CMD_RX. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_TxRxCmd(HT_USART_TypeDef* USARTx, u32 TxRx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + if (NewState != DISABLE) + { + USARTx->CR |= (USART_EN_ON << TxRx); + } + else + { + USARTx->CR &= ~(USART_EN_ON << TxRx); + } +} + +#if (LIBCFG_PDMA) +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART PDMA interface. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_PDMAREQ: specify the USART/UART PDMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg USART_PDMAREQ_TX + * @arg USART_PDMAREQ_RX + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_PDMACmd(HT_USART_TypeDef* USARTx, u32 USART_PDMAREQ, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_PDMA_REQ(USART_PDMAREQ)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->CR |= USART_PDMAREQ; + } + else + { + USARTx->CR &= ~USART_PDMAREQ; + } +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART break control function. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_ForceBreakCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->CR |= USART_BREAK_ON; + } + else + { + USARTx->CR &= USART_BREAK_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART/UART stick parity function. + * @param USARTx: Parameter to select the UxART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_StickParityCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->CR |= USART_SPE_ON | USART_PBE_ON; + } + else + { + USARTx->CR &= USART_SPE_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Configure the stick parity value of the USART/UART. + * @param USARTx: Parameter to select the UxART peripheral. + * @param USART_StickParity: Specify the stick parity of the USART/UART. + * This parameter can be one of the following values: + * @arg USART_STICK_LOW + * @arg USART_STICK_HIGH + * @retval None + ************************************************************************************************************/ +void USART_StickParityConfig(HT_USART_TypeDef * USARTx, u32 USART_StickParity) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_STICK_PARITY(USART_StickParity)); + + if (USART_StickParity != USART_STICK_HIGH) + { + USARTx->CR |= USART_STICK_LOW; + } + else + { + USARTx->CR &= USART_STICK_HIGH; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified USART guard time. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_GuardTime: Specify the guard time. + * @retval None + ************************************************************************************************************/ +void USART_SetGuardTime(HT_USART_TypeDef* USARTx, u32 USART_GuardTime) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_GUARD_TIME(USART_GuardTime)); + + USARTx->TPR = (USARTx->TPR & TPR_TG_Mask) | (USART_GuardTime << 0x08); +} + +/*********************************************************************************************************//** + * @brief Configure the Tx/Rx FIFO Interrupt Trigger Level. + * @param USARTx: Parameter to select the USART peripheral. + * @param TxRx: This parameter can be USART_CMD_TX or USART_CMD_RX. + * @param USART_tl: Specify the USART Tx/Rx FIFO interrupt trigger level. + * This parameter can be one of the following values: + * @arg USART_RXTL_01 + * @arg USART_RXTL_02 + * @arg USART_RXTL_04 + * @arg USART_RXTL_06 + * @arg USART_TXTL_00 + * @arg USART_TXTL_02 + * @arg USART_TXTL_04 + * @arg USART_TXTL_06 + * @retval None + ************************************************************************************************************/ +void USART_TXRXTLConfig(HT_USART_TypeDef* USARTx, u32 TxRx, u32 USART_tl) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_TL(USART_tl)); + + USARTx->FCR = (USARTx->FCR & ~(FCR_TL_Mask << (TxRx * 2))) | (USART_tl << (TxRx * 2)); +} + +/*********************************************************************************************************//** + * @brief Set the USART FIFO time-out value. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_TimeOut: Specify the time-out value. + * @retval None + ************************************************************************************************************/ +void USART_SetTimeOutValue(HT_USART_TypeDef* USARTx, u32 USART_TimeOut) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_TIMEOUT(USART_TimeOut)); + + USARTx->TPR = (USARTx->TPR & TPR_RXTOIC_Mask) | USART_TimeOut | USART_RXTOEN_ON; +} + +/*********************************************************************************************************//** + * @brief Clear both the write and read point in USART Tx FIFO or Rx FIFO. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_FIFODirection: Determine TX FIFO or Rx FIFO that is to be reset. + * This parameter can be any combination of the following values: + * @arg USART_FIFO_TX + * @arg USART_FIFO_RX + * @retval None + ************************************************************************************************************/ +void USART_FIFOReset(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_FIFO_DIRECTION(USART_FIFODirection)); + + USARTx->FCR |= USART_FIFODirection; +} + +/*********************************************************************************************************//** + * @brief Return the status of specified USART FIFO. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_FIFODirection: specify the FIFO that is to be check. + * This parameter can be one of the following values: + * @arg USART_FIFO_TX + * @arg USART_FIFO_RX + * @retval The number of data in Tx FIFO or Rx FIFO. + ************************************************************************************************************/ +u8 USART_GetFIFOStatus(HT_USART_TypeDef* USARTx, u32 USART_FIFODirection) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_FIFO_DIRECTION(USART_FIFODirection)); + + if (USART_FIFODirection == USART_FIFO_TX) + { + return (u8)((USARTx->FCR & 0xF0000) >> 16); + } + else + { + return (u8)((USARTx->FCR & 0xF000000) >> 24); + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART hardware flow control. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_HardwareFlowControlCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->CR |= USART_HFCEN_ON; + } + else + { + USARTx->CR &= USART_HFCEN_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART IrDA interface. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_IrDACmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->ICR |= USART_IRDA_ON; + } + else + { + USARTx->ICR &= USART_IRDA_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Configure the USART IrDA interface. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_IrDAMode: Specify the USART IrDA mode. + * This parameter can be one of the following values: + * @arg USART_IRDA_LOWPOWER + * @arg USART_IRDA_NORMAL + * @retval None + ************************************************************************************************************/ +void USART_IrDAConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDAMode) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_IRDA_MODE(USART_IrDAMode)); + + if (USART_IrDAMode != USART_IRDA_NORMAL) + { + USARTx->ICR |= USART_IRDA_LOWPOWER; + } + else + { + USARTx->ICR &= USART_IRDA_NORMAL; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified USART IrDA prescaler. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_IrDAPrescaler: Specify the USART IrDA prescaler. + * @retval None + ************************************************************************************************************/ +void USART_SetIrDAPrescaler(HT_USART_TypeDef* USARTx, u32 USART_IrDAPrescaler) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_IRDA_PRESCALER(USART_IrDAPrescaler)); + + USARTx->ICR = (USARTx->ICR & ICR_IRDAPSC_Mask) | (USART_IrDAPrescaler << 0x08); +} + +/*********************************************************************************************************//** + * @brief Enable the IrDA transmitter or receiver. + * @param USARTx: Parameter to select the USART peripheral, x can be 0 or 1. + * @param USART_IrDADirection: Specify the USART IrDA direction select. + * This parameter can be one of the following values: + * @arg USART_IRDA_TX + * @arg USART_IRDA_RX + * @retval None + ************************************************************************************************************/ +void USART_IrDADirectionConfig(HT_USART_TypeDef* USARTx, u32 USART_IrDADirection) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_IRDA_DIRECTION(USART_IrDADirection)); + + if (USART_IrDADirection != USART_IRDA_RX) + { + USARTx->ICR |= USART_IRDA_TX; + } + else + { + USARTx->ICR &= USART_IRDA_RX; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable inverting serial output/input function of IrDA on the specified USART. + * @param USARTx: Parameter to select the USART peripheral. + * @param inout: This parameter can be USART_CMD_OUT or USART_CMD_IN. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_IrDAInvtCmd(HT_USART_TypeDef* USARTx, u32 inout, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->ICR |= (USART_INV_ON << inout); + } + else + { + USARTx->ICR &= ~(USART_INV_ON << inout); + } +} + +/*********************************************************************************************************//** + * @brief Configure the polarity of USART RS485 transmitter enable signal. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_RS485Polarity: Specify the polarity of USART RS485 Tx enable signal. + * This parameter can be one of the following values: + * @arg USART_RS485POL_LOW + * @arg USART_RS485POL_HIGH + * @retval None + ************************************************************************************************************/ +void USART_RS485TxEnablePolarityConfig(HT_USART_TypeDef* USARTx, u32 USART_RS485Polarity) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_RS485_POLARITY(USART_RS485Polarity)); + + if (USART_RS485Polarity != USART_RS485POLARITY_HIGH) + { + USARTx->RCR |= USART_RS485POLARITY_LOW; + } + else + { + USARTx->RCR &= USART_RS485POLARITY_HIGH; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART RS485 normal multi-drop operation mode. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_RS485NMMCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->RCR |= USART_RS485NMM_ON; + } + else + { + USARTx->RCR &= USART_RS485NMM_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the USART RS485 normal multi-drop operation mode. + * @param USARTx: Parameter to select the USART peripheral. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void USART_RS485AADCmd(HT_USART_TypeDef* USARTx, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + USARTx->RCR |= USART_RS485AAD_ON; + } + else + { + USARTx->RCR &= USART_RS485AAD_OFF; + } +} + +/*********************************************************************************************************//** + * @brief Set the specified USART RS485 address match value. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_AddressMatchValue: specify the USART RS485 address match value. + * @retval None + ************************************************************************************************************/ +void USART_SetAddressMatchValue(HT_USART_TypeDef* USARTx, u32 USART_AddressMatchValue) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_ADDRESS_MATCH_VALUE(USART_AddressMatchValue)); + + USARTx->RCR = (USARTx->RCR & RS485CR_ADDM_Mask) | (u32)(USART_AddressMatchValue << 0x08); +} + +/*********************************************************************************************************//** + * @brief Initialize the clock of the USART peripheral according to the specified parameters + * in the USART_ClockInitStruct. + * @param USARTx: Parameter to select the USART peripheral. + * @param USART_SynClock_InitStruct: pointer to a USART_SynClock_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_SynClockInit(HT_USART_TypeDef* USARTx, USART_SynClock_InitTypeDef* USART_SynClock_InitStruct) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_SYNCHRONOUS_CLOCK(USART_SynClock_InitStruct->USART_ClockEnable)); + Assert_Param(IS_USART_SYNCHRONOUS_PHASE(USART_SynClock_InitStruct->USART_ClockPhase)); + Assert_Param(IS_USART_SYNCHRONOUS_POLARITY(USART_SynClock_InitStruct->USART_ClockPolarity)); + Assert_Param(IS_USART_TRANSFER_MODE(USART_SynClock_InitStruct->USART_TransferSelectMode)); + + USARTx->SCR = USART_SynClock_InitStruct->USART_ClockEnable | USART_SynClock_InitStruct->USART_ClockPhase | + USART_SynClock_InitStruct->USART_ClockPolarity; + + USARTx->CR = (USARTx->CR & TRSM_CLEAR_Mask) | USART_SynClock_InitStruct->USART_TransferSelectMode; +} + +/*********************************************************************************************************//** + * @brief Fill each USART_SynClockInitStruct member with its default value. + * @param USART_SynClock_InitStruct: pointer to a USART_SynClock_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void USART_SynClockStructInit(USART_SynClock_InitTypeDef* USART_SynClock_InitStruct) +{ + /* USART_ClockInitStruct members default value */ + USART_SynClock_InitStruct->USART_ClockEnable = USART_SYN_CLOCK_DISABLE; + USART_SynClock_InitStruct->USART_ClockPhase = USART_SYN_CLOCK_PHASE_FIRST; + USART_SynClock_InitStruct->USART_ClockPolarity = USART_SYN_CLOCK_POLARITY_LOW; + USART_SynClock_InitStruct->USART_TransferSelectMode = USART_LSB_FIRST; +} + +#if (LIBCFG_USART_LIN) +/*********************************************************************************************************//** + * @brief USART/UART LIN Mode send break to Tx. + * @param USARTx: where USARTx is the selected USART/UART from the USART/UART peripherals. + * @retval None + ************************************************************************************************************/ +void USART_LIN_SendBreak(HT_USART_TypeDef* USARTx) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + + USARTx->CR |= USART_LINSENDBREAK; +} + + +/*********************************************************************************************************//** + * @brief Configure the break detection length in LIN mode. + * @param USARTx: where USARTx is the selected USART/UART from the USART/UART peripherals. + * @param length: data length in byte. + * This parameter can be one of the following values: + * @arg USART_LINLENGTH_11BIT + * @arg USART_LINLENGTH_10BIT + * @retval None + ************************************************************************************************************/ +void USART_LIN_LengthSelect(HT_USART_TypeDef* USARTx, u32 USART_LIN_Length) +{ + /* Check the parameters */ + Assert_Param(IS_USART(USARTx)); + Assert_Param(IS_USART_LINLENGTH(USART_LIN_Length)); + + if (USART_LIN_Length != USART_LINLENGTH_10BIT) + { + USARTx->CR |= USART_LINLENGTH_11BIT; + } + else + { + USARTx->CR &= USART_LINLENGTH_10BIT; + } +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usbd.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usbd.c new file mode 100644 index 0000000000..a6597e97b7 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_usbd.c @@ -0,0 +1,855 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_usbd.c + * @version $Rev:: 7335 $ + * @date $Date:: 2023-11-09 #$ + * @brief The USB Device Peripheral Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32f5xxxx_usbdchk.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup USBDevice USB Device + * @brief USB Device driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Constant USB Device private constants + * @{ + */ +#define TCR_MASK (0x1FF) +#define EPLEN_MASK ((u32)0x000FFC00) +#define EPBUFA_MASK ((u32)0x000003FF) +#define ISR_EPn_OFFSET (8) + +/* USB Control and Status Register (USBCSR) */ +#define FRES ((u32)0x00000002) /* Force USB Reset */ +#define PDWN ((u32)0x00000004) /* Power Down */ +#define LPMODE ((u32)0x00000008) /* Low-power Mode */ +#define GENRSM ((u32)0x00000020) /* Generate Resume */ +#define ADRSET ((u32)0x00000100) /* Device Address Setting */ +#define SRAMRSTC ((u32)0x00000200) /* USB SRAM reset condition */ +#define DPPUEN ((u32)0x00000400) /* DP Pull Up Enable */ +#define DPWKEN ((u32)0x00000800) /* DP Wake Up Enable */ + +#define EPDIR_IN (1) +#define EPDIR_OUT (0) +/** + * @} + */ + +/* Private variables ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Variable USB Device private variables + * @{ + */ +static u32 gIsFirstPowered = TRUE; +/** + * @} + */ + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Macro USB Device private macros + * @{ + */ +#ifndef USBDCore_LowPower + #define USBDCore_LowPower() PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_WFE) +#endif +/** + * @brief Convert Byte length to Word length + */ +#define ByteLen2WordLen(n) ((n + 3) >> 2) +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void _USBD_CopyMemory(u32 *pFrom, u32 *pTo, u32 len); +static HT_USBEP_TypeDef * _USBD_GetEPTnAddr(USBD_EPTn_Enum USBD_EPTn); +static void _delay(u32 nCount); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Exported_Functions USB Device exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Pre initialization for USBD_Init function. + * @param pDriver: USB initialization structure + * @retval None + ***********************************************************************************************************/ +void USBD_PreInit(USBD_Driver_TypeDef *pDriver) +{ + pDriver->uInterruptMask = _UIER_ALL; + + pDriver->ept[USBD_EPT0].CFGR.word = _EP0_CFG; + pDriver->ept[USBD_EPT0].IER = _EP0_IER; + + #if (_EP1_ENABLE == 1) + pDriver->ept[USBD_EPT1].CFGR.word = _EP1_CFG; + pDriver->ept[USBD_EPT1].IER = _EP1_IER; + #endif + + #if (_EP2_ENABLE == 1) + pDriver->ept[USBD_EPT2].CFGR.word = _EP2_CFG; + pDriver->ept[USBD_EPT2].IER = _EP2_IER; + #endif + + #if (_EP3_ENABLE == 1) + pDriver->ept[USBD_EPT3].CFGR.word = _EP3_CFG; + pDriver->ept[USBD_EPT3].IER = _EP3_IER; + #endif + + #if (_EP4_ENABLE == 1) + pDriver->ept[USBD_EPT4].CFGR.word = _EP4_CFG; + pDriver->ept[USBD_EPT4].IER = _EP4_IER; + #endif + + #if (_EP5_ENABLE == 1) + pDriver->ept[USBD_EPT5].CFGR.word = _EP5_CFG; + pDriver->ept[USBD_EPT5].IER = _EP5_IER; + #endif + + #if (_EP6_ENABLE == 1) + pDriver->ept[USBD_EPT6].CFGR.word = _EP6_CFG; + pDriver->ept[USBD_EPT6].IER = _EP6_IER; + #endif + + #if (_EP7_ENABLE == 1) + pDriver->ept[USBD_EPT7].CFGR.word = _EP7_CFG; + pDriver->ept[USBD_EPT7].IER = _EP7_IER; + #endif + + #if (LIBCFG_USBD_V2) + #if (_EP8_ENABLE == 1) + pDriver->ept[USBD_EPT8].CFGR.word = _EP8_CFG; + pDriver->ept[USBD_EPT8].IER = _EP8_IER; + #endif + + #if (_EP9_ENABLE == 1) + pDriver->ept[USBD_EPT9].CFGR.word = _EP9_CFG; + pDriver->ept[USBD_EPT9].IER = _EP9_IER; + #endif + #endif + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Peripheral initialization. + * @param pDriver: USB initialization structure + * @retval None + ***********************************************************************************************************/ +void USBD_Init(u32 *pDriver) +{ + USBD_Driver_TypeDef *pDrv = (USBD_Driver_TypeDef *)pDriver; + + /* Init USB Device Driver struct */ + USBD_PreInit(pDrv); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Internal DP pull up. + * @param NewState: ENABLE or DISABLE + * @retval None + ***********************************************************************************************************/ +void USBD_DPpullupCmd(ControlStatus NewState) +{ + (NewState == ENABLE)?(HT_USB->CSR |= DPPUEN):(HT_USB->CSR &= ~DPPUEN); +} + +/*********************************************************************************************************//** + * @brief USB Device Wake Up when DP is high level. + * @param NewState: ENABLE or DISABLE + * @retval None + ***********************************************************************************************************/ +void USBD_DPWakeUpCmd(ControlStatus NewState) +{ + (NewState == ENABLE)?(HT_USB->CSR |= DPWKEN):(HT_USB->CSR &= ~DPWKEN); +} + +/*********************************************************************************************************//** + * @brief USB Device Peripheral deinitialization. + * @retval None + ***********************************************************************************************************/ +void USBD_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.USBD = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); + + return; +} + +/*********************************************************************************************************//** + * @brief USB power up procedure. + * @retval None + ***********************************************************************************************************/ +void USBD_PowerUp(u32 *pDriver, u32 uIsSelfPowered) +{ + USBD_Driver_TypeDef *pDrv = (USBD_Driver_TypeDef *)pDriver; + + if (gIsFirstPowered == TRUE) + { + gIsFirstPowered = FALSE; + + if (HT_USB->CSR & 0x40) + { + HT_USB->CSR = (DPPUEN | LPMODE | PDWN); + while((HT_USB->ISR & URSTIE) == 0); + HT_USB->ISR = 0xFFFFFFFF; + if (uIsSelfPowered == FALSE) + { + USBDCore_LowPower(); + } + USBD_EnableINT(pDrv->uInterruptMask); + } + else + { + HT_USB->CSR = (DPWKEN | DPPUEN | LPMODE | PDWN); + while((HT_USB->ISR & URSTIE) == 0); + HT_USB->ISR = 0xFFFFFFFF; + if (uIsSelfPowered == FALSE) + { + USBDCore_LowPower(); + } + USBD_DPWakeUpCmd(DISABLE); + USBD_EnableINT(pDrv->uInterruptMask); + USBD_DPpullupCmd(DISABLE); + _delay(200); + USBD_DPpullupCmd(ENABLE); + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief Enter USB Device Power Down mode. + * @retval None + ***********************************************************************************************************/ +void USBD_PowerOff(void) +{ + HT_USB->CSR |= (LPMODE | PDWN); + return; +} + +/*********************************************************************************************************//** + * @brief Exit USB Device Power Down mode. + * @retval None + ***********************************************************************************************************/ +void USBD_PowerOn(void) +{ + HT_USB->CSR |= 0x00001000; + HT_USB->CSR &= 0x00001400; + return; +} + +/*********************************************************************************************************//** + * @brief USB SRAM reset condition. + * @param NewState: ENABLE or DISABLE + * @retval None + ***********************************************************************************************************/ +void USBD_SRAMResetConditionCmd(ControlStatus NewState) +{ + (NewState == ENABLE)?(HT_USB->CSR |= SRAMRSTC):(HT_USB->CSR &= ~SRAMRSTC); +} + +/*********************************************************************************************************//** + * @brief Disable Default pull resistance of D+ and D-. + * @retval None + ***********************************************************************************************************/ +void USBD_DisableDefaultPull(void) +{ + HT_USB->CSR = FRES; // Clear PDWN and keep FRES = 1 +} + +/*********************************************************************************************************//** + * @brief Generate a resume request to USB Host for Remote Wakeup function. + * @retval None + ***********************************************************************************************************/ +void USBD_RemoteWakeup(void) +{ + HT_USB->CSR |= GENRSM; + return; +} + +/*********************************************************************************************************//** + * @brief Read Endpoint0 SETUP data from USB Buffer. + * @param pBuffer: Buffer for save SETUP data + * @retval None + ***********************************************************************************************************/ +void USBD_ReadSETUPData(u32 *pBuffer) +{ + u32 *pSrc = (u32 *)HT_USB_SRAM_BASE; + + *pBuffer = *pSrc; + *(pBuffer + 1) = *(pSrc + 1); + return; +} + +/*********************************************************************************************************//** + * @brief Set USB Device address. + * @param address: USB address which specified by Host + * @retval None + ***********************************************************************************************************/ +void USBD_SetAddress(u32 address) +{ + HT_USB->CSR |= ADRSET; + HT_USB->DEVAR = address; + return; +} + +/*********************************************************************************************************//** + * @brief Enable USB Device interrupt. + * @param INTFlag: USB Device global interrupt flag + * @arg UGIE | SOFIE | URSTIE | RSMIE | SUSPIE | ESOFIE + * EP0IE | EP1IE | EP2IE | EP3IE | EP4IE | EP5IE | EP6IE | EP7IE | EP8IE | EP9IE + * @retval None + ***********************************************************************************************************/ +void USBD_EnableINT(u32 INTFlag) +{ + HT_USB->IER |= INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Disable USB Device interrupt. + * @param INTFlag: USB Device global interrupt flag + * @arg UGIE | SOFIE | URSTIE | RSMIE | SUSPIE | ESOFIE + * EP0IE | EP1IE | EP2IE | EP3IE | EP4IE | EP5IE | EP6IE | EP7IE | EP8IE | EP9IE + * @retval None + ***********************************************************************************************************/ +void USBD_DisableINT(u32 INTFlag) +{ + HT_USB->IER &= (~INTFlag); + return; +} + +/*********************************************************************************************************//** + * @brief Get active USB Device interrupt flag. + * @retval USB ISR Flag + ***********************************************************************************************************/ +u32 USBD_GetINT(void) +{ + u32 IER = HT_USB->IER | FRESIE; + return (HT_USB->ISR & IER); +} + +/*********************************************************************************************************//** + * @brief Clear USB Device interrupt flag. + * @param INTFlag: USB Device global interrupt flag + * @arg SOFIF | URSTIF | RSMIF | SUSPIF | ESOFIF + * EP0IF | EP1IF | EP2IF | EP3IF | EP4IF | EP5IF | EP6IF | EP7IF | EP8IF | EP9IF + * @retval None + ***********************************************************************************************************/ +void USBD_ClearINT(u32 INTFlag) +{ + HT_USB->ISR = INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Get USB Endpoint number by interrupt flag. + * @param INTFlag: USB Device global interrupt flag + * @arg SOFIF | URSTIF | RSMIF | SUSPIF | ESOFIF + * EP0IF | EP1IF | EP2IF | EP3IF | EP4IF | EP5IF | EP6IF | EP7IF | EP8IF | EP9IF + * @retval USB Endpoint number from USBD_EPT1 ~ USBD_EPT9 + ***********************************************************************************************************/ +USBD_EPTn_Enum USBD_GetEPTnINTNumber(u32 INTFlag) +{ + s32 i; + for (i = MAX_EP_NUM - 1; i > 0; i--) + { + if ((INTFlag >> (i + ISR_EPn_OFFSET)) & SET) + { + return (USBD_EPTn_Enum)i; + } + } + + return USBD_NOEPT; +} + +/*********************************************************************************************************//** + * @brief USB Device Peripheral initialization for Endpoint. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @param pDriver: USB initialization structure + * @retval None + ***********************************************************************************************************/ +void USBD_EPTInit(USBD_EPTn_Enum USBD_EPTn, u32 *pDriver) +{ + USBD_Driver_TypeDef *pDrv = (USBD_Driver_TypeDef *)pDriver; + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + + USBEPn->CFGR = pDrv->ept[USBD_EPTn].CFGR.word; + USBEPn->IER = pDrv->ept[USBD_EPTn].IER; + + USBEPn->ISR = 0xFFFFFFFF; + + USBD_EPTReset(USBD_EPTn); + + return; +} + +/*********************************************************************************************************//** + * @brief Reset Endpoint Status. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTReset(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + USBEPn->CSR = (USBEPn->CSR) & (DTGTX | DTGRX | NAKRX); + return; +} + +/*********************************************************************************************************//** + * @brief Enable Interrupt for Endpoint. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @param INTFlag: Interrupt flag + * @arg OTRXIE | ODRXIE | ODOVIE | ITRXIE | IDTXIE | NAKIE | STLIE | UERIE | + * STRXIE | SDRXIE | SDERIE | ZLRXIE + * @retval None + ***********************************************************************************************************/ +void USBD_EPTEnableINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag) +{ + _USBD_GetEPTnAddr(USBD_EPTn)->IER = INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Get active USB Device Endpoint interrupt. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval USB Endpoint ISR Flag + ***********************************************************************************************************/ +u32 USBD_EPTGetINT(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + u32 IER = USBEPn->IER; + return (USBEPn->ISR & IER); +} + +/*********************************************************************************************************//** + * @brief Clear Interrupt for Endpoint. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @param INTFlag: Interrupt flag + * @arg OTRXIF | ODRXIF | ODOVIF | ITRXIF | IDTXIF | NAKIF | STLIF | UERIF | + * STRXIF | SDRXIF | SDERIF | ZLRXIF + * @retval None + ***********************************************************************************************************/ +void USBD_EPTClearINT(USBD_EPTn_Enum USBD_EPTn, u32 INTFlag) +{ + _USBD_GetEPTnAddr(USBD_EPTn)->ISR = INTFlag; + return; +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n Halt status (STLTX or STLRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval Endpoint Halt Status (1: Endpoint is Halt, 0: Endpoint is not Halt) + ***********************************************************************************************************/ +u32 USBD_EPTGetHalt(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + return (((USBEPn->CSR) & STLTX) ? 1 : 0); + } + else + { + return (((USBEPn->CSR) & STLRX) ? 1 : 0); + } +} + +/*********************************************************************************************************//** + * @brief Send STALL on Endpoint n. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTSendSTALL(USBD_EPTn_Enum USBD_EPTn) +{ + _USBD_GetEPTnAddr(USBD_EPTn)->CSR = STLTX; + return; +} + +/*********************************************************************************************************//** + * @brief Set Endpoint n Halt status (STLTX or STLRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTSetHalt(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + +#if 1 + /* Clean STLIF flag, for USBD_EPTWaitSTALLSent function */ + USBEPn->ISR = STLIF; + USBEPn->CSR = (~(USBEPn->CSR)) & (STLTX | STLRX); +#else + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + /* Clean STLIF flag, for USBD_EPTWaitSTALLSent function */ + USBEPn->ISR = STLIF; + /* Set only when STLTX = 0 */ + USBEPn->CSR = (~(USBEPn->CSR)) & STLTX; + } + else + { + /* Set only when STLRX = 0 */ + USBEPn->CSR = (~(USBEPn->CSR)) & STLRX; + } +#endif + + return; +} + +/*********************************************************************************************************//** + * @brief Clear Endpoint n Halt status (STLTX or STLRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTClearHalt(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + +#if 1 + USBEPn->CSR = (USBEPn->CSR) & (STLTX | STLRX); +#else + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + /* Clear only when STLTX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & STLTX; + } + else + { + /* Clear only when STLRX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & STLRX; + } +#endif + + return; +} + +/*********************************************************************************************************//** + * @brief Wait until STALL transmission is finished + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTWaitSTALLSent(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + u32 uSTALLState = (CFGR->EPDIR == EPDIR_IN) ? ((USBEPn->CSR) & STLTX) : ((USBEPn->CSR) & STLRX); + + if (uSTALLState) + { + while ((USBEPn->ISR & STLIF) == 0); + } + + return; +} + +/*********************************************************************************************************//** + * @brief Clear Endpoint n Data toggle bit (DTGTX or DTGRX). + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval None + ***********************************************************************************************************/ +void USBD_EPTClearDTG(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + +#if 1 + USBEPn->CSR = (USBEPn->CSR) & (DTGTX | DTGRX); +#else + USBD_EPTCFGR_Bit *CFGR = (USBD_EPTCFGR_Bit *)(&(USBEPn->CFGR)); + if (CFGR->EPDIR == EPDIR_IN) + { + /* Clear only when DTGTX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & DTGTX; + } + else + { + /* Clear only when DTGRX = 1 */ + USBEPn->CSR = (USBEPn->CSR) & DTGRX; + } +#endif + return; +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n buffer 0 address. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval USB Endpoint buffer 0 address + ***********************************************************************************************************/ +u32 USBD_EPTGetBuffer0Addr(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + return (HT_USB_SRAM_BASE + (USBEPn->CFGR & EPBUFA_MASK)); +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n buffer 1 address. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval USB Endpoint buffer 1 address + ***********************************************************************************************************/ +u32 USBD_EPTGetBuffer1Addr(USBD_EPTn_Enum USBD_EPTn) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + return (HT_USB_SRAM_BASE + (USBEPn->CFGR & EPBUFA_MASK) + USBD_EPTGetBufferLen(USBD_EPTn)); +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n buffer length. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval USB Endpoint buffer length + ***********************************************************************************************************/ +u32 USBD_EPTGetBufferLen(USBD_EPTn_Enum USBD_EPTn) +{ + return ((_USBD_GetEPTnAddr(USBD_EPTn)->CFGR & EPLEN_MASK) >> 10); +} + +/*********************************************************************************************************//** + * @brief Get Endpoint n Transfer Count. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @param USBD_TCR_n: USBD_TCR_0 or USBD_TCR_1 + * @retval Endpoint Transfer Count + ***********************************************************************************************************/ +u32 USBD_EPTGetTransferCount(USBD_EPTn_Enum USBD_EPTn, USBD_TCR_Enum USBD_TCR_n) +{ + return (((_USBD_GetEPTnAddr(USBD_EPTn)->TCR) >> USBD_TCR_n) & TCR_MASK); +} + +/*********************************************************************************************************//** + * @brief Write IN Data from User buffer to USB buffer. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @param pFrom: Source buffer + * @param len: Length for write IN data + * @retval Total length written by this function + ***********************************************************************************************************/ +u32 USBD_EPTWriteINData(USBD_EPTn_Enum USBD_EPTn, u32 *pFrom, u32 len) +{ + u32 bufferlen = USBD_EPTGetBufferLen(USBD_EPTn); + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + u32 EPTnLen; + u32 *pTo; + + EPTnLen = (USBD_EPTn == USBD_EPT0) ? USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTIN):USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTB0); + + if (len <= bufferlen && EPTnLen == 0) + { + pTo = (u32 *)USBD_EPTGetBuffer0Addr(USBD_EPTn); + _USBD_CopyMemory(pFrom, pTo, ByteLen2WordLen(len)); + USBEPn->TCR = len; + USBEPn->CSR = NAKTX; + return len; + } + else + { + return 0; + } +} + +/*********************************************************************************************************//** + * @brief Read OUT Data from USB buffer to User buffer. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @param pTo: Destination memory + * @param len: Length for read OUT data, set as 0 for discard current OUT data in the USB buffer + * @retval Total length read by this function + ***********************************************************************************************************/ +u32 USBD_EPTReadOUTData(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len) +{ + HT_USBEP_TypeDef *USBEPn = _USBD_GetEPTnAddr(USBD_EPTn); + u32 EPTnLen = 0; + + if (len != 0) + { + EPTnLen = USBD_EPTReadMemory(USBD_EPTn, pTo, len); + } + + if (EPTnLen != 0 || len == 0) + { + USBEPn->CSR = (USBEPn->CSR & NAKRX); + } + + return EPTnLen; +} + +/*********************************************************************************************************//** + * @brief Read memory from endpoint buffer. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @param pTo: Destination buffer + * @param len: Length for read OUT data + * @retval Total length read by this function + ***********************************************************************************************************/ +u32 USBD_EPTReadMemory(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len) +{ + u32 EPTnLen = 0; + u32 *pFrom; + + EPTnLen = (USBD_EPTn == USBD_EPT0) ? USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTOUT):USBD_EPTGetTransferCount(USBD_EPTn, USBD_CNTB0); + + if (EPTnLen <= len) + { + pFrom = (USBD_EPTn == USBD_EPT0) ? (u32 *)USBD_EPTGetBuffer1Addr(USBD_EPTn):(u32 *)USBD_EPTGetBuffer0Addr(USBD_EPTn); + _USBD_CopyMemory(pFrom, pTo, ByteLen2WordLen(EPTnLen)); + } + + return EPTnLen; +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDevice_Private_Function USB Device private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Copy 32 bits memory from pFrom to pTo. + * @param pFrom: Source buffer + * @param pTo: Destination buffer + * @param len: Copy length + * @retval None + ***********************************************************************************************************/ +static void _USBD_CopyMemory(u32 *pFrom, u32 *pTo, u32 len) +{ + s32 i; + u32 uFromAligned = (((u32)pFrom & 0x3) == 0) ? 1 : 0; + u32 uToAligned = (((u32)pTo & 0x3) == 0) ? 1 : 0; + u8 *pFromByte = (u8 *)pFrom; + u8 *pToByte = (u8 *)pTo; + + if (uFromAligned == 0) + { + if (uToAligned == 0) + { + for (i = len - 1; i >= 0; i--) + { + *pToByte++ = *pFromByte++; + *pToByte++ = *pFromByte++; + *pToByte++ = *pFromByte++; + *pToByte++ = *pFromByte++; + } + } + else + { + u32 uTemp = 0; + for (i = 0; i < (s32)len; i++) + { + uTemp = *(pFromByte++) << 0; + uTemp += *(pFromByte++) << 8; + uTemp += *(pFromByte++) << 16; + uTemp += *(pFromByte++) << 24; + pTo[i] = uTemp; + } + } + } + else + { + if (uToAligned == 0) + { + u32 uTemp = 0; + for (i = 0; i < (s32)len; i++) + { + uTemp = pFrom[i]; + *pToByte++ = (uTemp >> 0) & 0xFF; + *pToByte++ = (uTemp >> 8) & 0xFF; + *pToByte++ = (uTemp >> 16) & 0xFF; + *pToByte++ = (uTemp >> 24) & 0xFF; + } + } + else + { + for (i = len - 1; i >= 0; i--) + { + pTo[i] = pFrom[i]; + } + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief Convent USBD_EPTn_Enum to USBEP_TypeDef. + * @param USBD_EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT9 + * @retval USBEP0 ~ USBEP9 + ***********************************************************************************************************/ +static HT_USBEP_TypeDef * _USBD_GetEPTnAddr(USBD_EPTn_Enum USBD_EPTn) +{ + return ((HT_USBEP_TypeDef *)(HT_USBEP0 + USBD_EPTn)); +} + +/*********************************************************************************************************//** + * @brief Inserts a delay time. + * @param nCount: specifies the delay time length. + * @retval None + ***********************************************************************************************************/ +static void _delay(u32 nCount) +{ + u32 i; + + for (i = 0; i < nCount; i++) + { + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_wdt.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_wdt.c new file mode 100644 index 0000000000..b90f5b1fac --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f5xxxx_wdt.c @@ -0,0 +1,343 @@ +/*********************************************************************************************************//** + * @file ht32f5xxxx_wdt.c + * @version $Rev:: 2772 $ + * @date $Date:: 2018-05-15 #$ + * @brief This file provides all the WDT firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f5xxxx_wdt.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup WDT WDT + * @brief WDT driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Private_Define WDT private definitions + * @{ + */ + +/* WDT Restart Key */ +#define RESTART_KEY ((u32)0x5FA00000) + +/* WDT Protect mask */ +#define PRCT_SET ((u32)0x0000CA35) +#define PRCT_RESET ((u32)0x000035CA) + +/* WDT WDTFIEN mask */ +#define MODE0_WDTFIEN_SET ((u32)0x00001000) +#define MODE0_WDTFIEN_RESET ((u32)0xFFFFEFFF) + +/* WDT WDTRSTEN mask */ +#define MODE0_WDTRETEN_SET ((u32)0x00002000) +#define MODE0_WDTRETEN_RESET ((u32)0xFFFFDFFF) + +/* WDT WDTEN mask */ +#define MODE0_WDTEN_SET ((u32)0x00010000) +#define MODE0_WDTEN_RESET ((u32)0xFFFEFFFF) + +/* WDT WDTLOCK mask */ +#define MODE0_WDTLOCK_SET ((u32)0x00000010) +#define MODE0_WDTLOCK_RESET ((u32)0x00000000) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup WDT_Exported_Functions WDT exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the WDT peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void WDT_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.WDT = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the WDT. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_Cmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_WDT->MR0 |= MODE0_WDTEN_SET; + } + else + { + HT_WDT->MR0 &= MODE0_WDTEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Configure the WDT to run or halt in sleep and deep sleep1 mode. + * @param WDT_Mode: + * This parameter can be one of the following values: + * @arg MODE0_WDTSHLT_BOTH : WDT runs in sleep and deep sleep1 mode + * @arg MODE0_WDTSHLT_SLEEP : WDT runs in sleep mode + * @arg MODE0_WDTSHLT_HALT : WDT halts in sleep and deep sleep1 mode + * @retval None + ************************************************************************************************************/ +void WDT_HaltConfig(u32 WDT_Mode) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_WDTSHLT_MODE(WDT_Mode)); + + HT_WDT->MR0 = ((WDT_Mode) | (HT_WDT->MR0 & 0x00013FFF)); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the WDT Reset when WDT meets underflow or error. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_ResetCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_WDT->MR0 |= MODE0_WDTRETEN_SET; + } + else + { + HT_WDT->MR0 &= MODE0_WDTRETEN_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable protection mechanism of the WDT. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_ProtectCmd(ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_WDT->PR = PRCT_SET; + } + else + { + HT_WDT->PR = PRCT_RESET; + } +} + +/*********************************************************************************************************//** + * @brief Set reload value of the WDT. + * @param WDT_WDTV : specify the WDT Reload value. + * This parameter must be a number between 0 and 0x0FFF + * @retval None + ************************************************************************************************************/ +void WDT_SetReloadValue(u16 WDT_WDTV) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_RELOAD(WDT_WDTV)); + + HT_WDT->MR0 = WDT_WDTV | (HT_WDT->MR0 & 0x0000F000); +} + +/*********************************************************************************************************//** + * @brief Get the current reload value of the WDT. + * @retval WDT reload value between 0 and 0x0FFF + ************************************************************************************************************/ +u16 WDT_GetReloadValue(void) +{ + return ((u16)(HT_WDT->MR0 & 0xFFF)); +} + +/*********************************************************************************************************//** + * @brief Set delta value of the WDT. + * @param WDT_WDTD : specify the WDT Delta value. + * This parameter must be a number between 0 and 0x0FFF + * @retval None + ************************************************************************************************************/ +void WDT_SetDeltaValue(u16 WDT_WDTD) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_DELTA(WDT_WDTD)); + + HT_WDT->MR1 = (WDT_WDTD | (HT_WDT->MR1 & 0x00007000)); +} + +/*********************************************************************************************************//** + * @brief Get current delta value of the WDT. + * @retval WDT delta value between 0 and 0x0FFF + ************************************************************************************************************/ +u16 WDT_GetDeltaValue(void) +{ + return ((u16)(HT_WDT->MR1 & 0xFFF)); +} + +/*********************************************************************************************************//** + * @brief Set prescaler value of the WDT. + * @param WDT_PRESCALER: specify the WDT Prescaler value. + * This parameter can be one of the following values: + * @arg WDT_PRESCALER_1 : WDT prescaler set to 1 + * @arg WDT_PRESCALER_2 : WDT prescaler set to 2 + * @arg WDT_PRESCALER_4 : WDT prescaler set to 4 + * @arg WDT_PRESCALER_8 : WDT prescaler set to 8 + * @arg WDT_PRESCALER_16 : WDT prescaler set to 16 + * @arg WDT_PRESCALER_32 : WDT prescaler set to 32 + * @arg WDT_PRESCALER_64 : WDT prescaler set to 64 + * @arg WDT_PRESCALER_128 : WDT prescaler set to 128 + * @retval None + ************************************************************************************************************/ +void WDT_SetPrescaler(u16 WDT_PRESCALER) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_PRESCALER(WDT_PRESCALER)); + + HT_WDT->MR1 = (WDT_PRESCALER | (HT_WDT->MR1 & 0x00000FFF)); +} + +/*********************************************************************************************************//** + * @brief Get the current prescaler value of the WDT. + * @retval WDT prescaler value + ************************************************************************************************************/ +u8 WDT_GetPrescaler(void) +{ + u32 tmp; + + tmp = HT_WDT->MR1 & 0x7000; + tmp >>= 12; + return ((u8)0x1 << tmp); +} + +/*********************************************************************************************************//** + * @brief WDT Restart (Reload WDT Counter) + * @retval None + ************************************************************************************************************/ +void WDT_Restart(void) +{ + HT_WDT->CR = RESTART_KEY | 0x1; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified WDT flag has been set. + * @param WDT_FLAG: specify the flag to be check. + * This parameter can be one of the following values: + * @arg WDT_FLAG_UNDERFLOW : WDT underflow active + * @arg WDT_FLAG_ERROR : WDT error active + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus WDT_GetFlagStatus(u32 WDT_FLAG) +{ + u32 statusreg = 0; + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + Assert_Param(IS_WDT_FLAG(WDT_FLAG)); + + statusreg = HT_WDT->SR; + + if (statusreg != WDT_FLAG) + { + bitstatus = RESET; + } + else + { + bitstatus = SET; + } + + return bitstatus; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the WDTLOCK. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void WDT_LockCmd(ControlStatus NewState) +{ + u32 uRegVale; + + /* Check the parameters */ + Assert_Param(IS_CONTROL_STATUS(NewState)); + + uRegVale = HT_WDT->CSR; + if (NewState != DISABLE) + { + HT_WDT->CSR |= (MODE0_WDTLOCK_SET | (uRegVale & 0x00000001)); + } + else + { + HT_WDT->CSR &= (MODE0_WDTLOCK_RESET | (uRegVale & 0x00000001)); + } +} + +#if (LIBCFG_LSE) +/*********************************************************************************************************//** + * @brief WDT source select. + * @param WDT_SOURCE: LSI or LSE of the WDT source. + * This parameter can be one of the following values: + * @arg WDT_SOURCE_LSI : + * @arg WDT_SOURCE_LSE : + * @retval None + ************************************************************************************************************/ +void WDT_SourceConfig(u32 WDT_SOURCE) +{ + /* Check the parameters */ + Assert_Param(IS_WDT_SOURCE_SELECT(WDT_SOURCE)); + + if (WDT_SOURCE != WDT_SOURCE_LSE) + { + HT_WDT->CSR = WDT_SOURCE_LSI; + } + else + { + HT_WDT->CSR = WDT_SOURCE_LSE; + } +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_adc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_adc.c new file mode 100644 index 0000000000..3071a5ac0a --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_adc.c @@ -0,0 +1,32 @@ +/*********************************************************************************************************//** + * @file ht32f652xx_adc.c + * @version $Rev:: 6921 $ + * @date $Date:: 2023-05-10 #$ + * @brief This file provides all the ADC firmware functions (for backward compatible). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f65xxx_66xxx_adc.c" + +// The original file has been renamed to ht32f65xxx_66xxx_adc.c +// This file is added for backward compatibility. diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_opa.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_opa.c new file mode 100644 index 0000000000..dad9694c5f --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f652xx_opa.c @@ -0,0 +1,32 @@ +/*********************************************************************************************************//** + * @file ht32f652xx_opa.c + * @version $Rev:: 6919 $ + * @date $Date:: 2023-05-10 #$ + * @brief This file provides all the OPA firmware functions (for backward compatible). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f65xxx_66xxx_opa.c" + +// The original file has been renamed to ht32f65xxx_66xxx_opa.c +// This file is added for backward compatibility. diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_adc.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_adc.c new file mode 100644 index 0000000000..88c5d8aced --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_adc.c @@ -0,0 +1,784 @@ +/*********************************************************************************************************//** + * @file ht32f65xxx_66xxx_adc.c + * @version $Rev:: 7367 $ + * @date $Date:: 2023-12-06 #$ + * @brief This file provides all the ADC firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f65xxx_66xxx_adc.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup ADC ADC + * @brief ADC driver modules + * @{ + */ + + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup ADC_Private_Define ADC private definitions + * @{ + */ +#define ADC_ENABLE_BIT (0x00000080) +#define DUAL_MODE_MASK (0x00000003) +#define ADC_SOFTWARE_RESET (0x00000001) +#define LST_SEQ_SET (0x0000001F) +#define TCR_SC_SET (0x00000001) + +#define HLST_SEQ_SET (0x0000001F) +#define HTCR_SC_SET (0x00000001) + +#define OFR_ADOF_MASK (0x00000FFF) +#define OFR_ADAL (1 << 14) +#define OFR_ADOFE (1 << 15) +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @addtogroup ADC_Exported_Functions ADC exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the HT_ADCn peripheral registers to their default reset values. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_DeInit(HT_ADC_TypeDef* HT_ADCn) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + if (HT_ADCn == HT_ADC0) + { + RSTCUReset.Bit.ADC0 = 1; + } + #if (LIBCFG_ADC1) + else if (HT_ADCn == HT_ADC1) + { + RSTCUReset.Bit.ADC1 = 1; + } + #endif + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Reset ADC. + * @param HT_ADCn: is the selected ADC from the ADC peripherals. + * @retval None + ************************************************************************************************************/ +void ADC_Reset(HT_ADC_TypeDef* HT_ADCn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + HT_ADCn->RST |= ADC_SOFTWARE_RESET; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_Cmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->CONV |= ADC_ENABLE_BIT; + } + else + { + HT_ADCn->CONV &= ~(ADC_ENABLE_BIT); + } +} + +#if (LIBCFG_ADC1) +/*********************************************************************************************************//** + * @brief Configure the ADC dual mode. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. (ADC1 only) + * @param DUAL_X: ADC dual mode configuration. + * This parameter can be one of the following values: + * @arg DUAL_INDEPENDENT : Independent mode (dual mode off). + * @arg DUAL_CASCADE_REGULAR : Cascade mode in regular conversion. + * @arg DUAL_CASCADE_REGULAR_H_PRIORITY : Cascade mode in regular/high priority conversion. + * @param HDelayTime: High priority ADC trigger delay. + * This parameter must be between 0x00 to 0xFF. + * @param DelayTime: Regular ADC trigger delay. + * This parameter must be between 0x00 to 0xFF. + * @retval None + ************************************************************************************************************/ +void ADC_DualModeConfig(HT_ADC_TypeDef* HT_ADCn, u32 DUAL_X, u8 HDelayTime, u8 DelayTime) +{ + u32 uTmpReg1, uTmpReg2; + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_DUAL_MODE(DUAL_X)); + + uTmpReg1 = HT_ADCn->CFGR; + uTmpReg2 = (DUAL_MODE_MASK | 0x00FFFF00); + uTmpReg1 &= ~uTmpReg2; + uTmpReg2 = (DUAL_X | HDelayTime << 16 | DelayTime << 8); + uTmpReg1 |= uTmpReg2; + + HT_ADCn->CFGR = uTmpReg1; +} +#endif + +/*********************************************************************************************************//** + * @brief Configure conversion mode and length of list queue for regular group. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_MODE: ADC Cyclic Conversion Mode. + * This parameter can be one of the following values: + * @arg ONE_SHOT_MODE : + * @arg CONTINUOUS_MODE : + * @arg DISCONTINUOUS_MODE : + * @param Length: must between 1 ~ 16 + * @param SubLength: must between 1 ~ 16, only valid for DISCONTINUOUS_MODE. + * @retval None + ************************************************************************************************************/ +void ADC_RegularGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CONVERSION_MODE(ADC_MODE)); + Assert_Param(IS_ADC_REGULAR_LENGTH(Length)); + if (ADC_MODE == DISCONTINUOUS_MODE) + { + Assert_Param(IS_ADC_REGULAR_SUB_LENGTH(SubLength)); + } + + /* Config cyclic conversion mode and length of list queue and sub length for regular group */ + HT_ADCn->CONV = ((u32)(SubLength - 1) << 16) | ((u32)(Length - 1) << 8) | ADC_MODE | (HT_ADCn->CONV & ADC_ENABLE_BIT); +} + +/*********************************************************************************************************//** + * @brief Configure conversion mode and length of list queue for high priority group. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_MODE: ADC Cyclic Conversion Mode. + * This parameter can be one of the following values: + * @arg ONE_SHOT_MODE : + * @arg CONTINUOUS_MODE : + * @arg DISCONTINUOUS_MODE : + * @param Length: must between 1 ~ 4 + * @param SubLength: must between 1 ~ 4 + * @retval None + ************************************************************************************************************/ +void ADC_HPGroupConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_MODE, u8 Length, u8 SubLength) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CONVERSION_MODE(ADC_MODE)); + Assert_Param(IS_ADC_HP_LENGTH(Length)); + Assert_Param(IS_ADC_HP_SUB_LENGTH(SubLength)); + + /* Config cyclic conversion mode and length of list queue and sub length for regular group */ + HT_ADCn->HCONV = ((u32)(SubLength - 1) << 16) | ((u32)(Length - 1) << 8) | ADC_MODE; +} + +/*********************************************************************************************************//** + * @brief Configure the corresponding rank in the sequencer and the sampling time for the regular channel + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected, x must between 0 ~ 7 + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param Rank: The rank in the regular group sequencer. + * This parameter must be between 0 to 7. + * @param SampleClock: Number of sampling clocks. + * This parameter must be between 0x00 to 0xFF. + * @retval None + ************************************************************************************************************/ +void ADC_RegularChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock) +{ + u32 tmpreg1, tmpreg2; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_REGULAR_RANK(Rank)); + Assert_Param(IS_ADC_INPUT_SAMPLING_TIME(SampleClock)); + + /* config sampling clock of correspond ADC input channel */ + HT_ADCn->STR[ADC_CH_n] = SampleClock; + + /* Get the old register value */ + tmpreg1 = HT_ADCn->LST[Rank >> 2]; + /* Calculate the mask to clear */ + tmpreg2 = LST_SEQ_SET << (8 * (Rank & 0x3)); + /* Clear the old SEQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (u32)ADC_CH_n << (8 * (Rank & 0x3)); + /* Set the SEQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + HT_ADCn->LST[Rank >> 2] = tmpreg1; +} + +/*********************************************************************************************************//** + * @brief Configure the corresponding rank in the sequencer and the sample time for the High Priority channel + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected, x must between 0 ~ 7 + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param Rank: The rank in the high priority group sequencer. + * This parameter must be between 0 to 3. + * @param SampleClock: Number of sampling clocks. + * This parameter must be between 0x00 to 0xFF. + * @retval None + ************************************************************************************************************/ +void ADC_HPChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u8 Rank, u8 SampleClock) +{ + u32 tmpreg1, tmpreg2; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_HP_RANK(Rank)); + Assert_Param(IS_ADC_INPUT_SAMPLING_TIME(SampleClock)); + + /* config sampling clock of correspond ADC input channel */ + HT_ADCn->STR[ADC_CH_n] = SampleClock; + + /* Get the old register value */ + tmpreg1 = HT_ADCn->HLST; + /* Calculate the mask to clear */ + tmpreg2 = HLST_SEQ_SET << (8 * (Rank & 0x3)); + /* Clear the old SEQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (u32)ADC_CH_n << (8 * (Rank & 0x3)); + /* Set the SEQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + HT_ADCn->HLST = tmpreg1; +} + +/*********************************************************************************************************//** + * @brief Configure the ADC trigger source for regular channels conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_TRIG_x: + * This parameter can be one of the following values: + * @arg ADC_TRIG_SOFTWARE : S/W trigger + * @arg ADC_TRIG_EXTI_n : where n can be 0 ~ 15 + * @arg ADC_TRIG_MCTMn_MEVx : where n can be 0 + * @arg ADC_TRIG_MCTM0_DMEVx : where n can be 0* + * @arg ADC_TRIG_MCTM0_MEVxDEVz : where n can be 0 + * @arg ADC_TRIG_MCTMn_MTO : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CHmMEV : where n can be 0, m can be 0 ~ 3 + * @arg ADC_TRIG_MCTMn_CHmDEV : where n can be 0, m can be 0 ~ 3 + * @arg ADC_TRIG_MCTMn_CHmMDEV : where n can be 0, m can be 0 ~ 3 + * @arg ADC_TRIG_MCTMn_CHALLMEV : where n can be 0 + * @arg ADC_TRIG_MCTMn_CHALLDEV : where n can be 0 + * @arg ADC_TRIG_MCTMn_CHALLMDEV : where n can be 0 + * @arg ADC_TRIG_BFTMn : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_MTO : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_CMPn : where n can be 0 ~ 3 + * @retval None + ************************************************************************************************************/ +void ADC_RegularTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_TRIG(ADC_TRIG_x)); + + /* Config external trigger conversion source of regular group */ + HT_ADCn->TCR = ADC_TRIG_x & 0x0000001F; + HT_ADCn->TSR = ADC_TRIG_x & (~0x0000001F); +} + +/*********************************************************************************************************//** + * @brief Configure the ADC trigger source for high priority channels conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_TRIG_x: + * This parameter can be one of the following values: + * @arg ADC_TRIG_SOFTWARE : S/W trigger + * @arg ADC_TRIG_EXTI_n : where n can be 0 ~ 15 + * @arg ADC_TRIG_MCTMn_MEVx : where n can be 0 + * @arg ADC_TRIG_MCTM0_DMEVx : where n can be 0* + * @arg ADC_TRIG_MCTM0_MEVxDEVz : where n can be 0 + * @arg ADC_TRIG_MCTMn_MTO : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_MCTMn_CHmMEV : where n can be 0, m can be 0 ~ 3 + * @arg ADC_TRIG_MCTMn_CHmDEV : where n can be 0, m can be 0 ~ 3 + * @arg ADC_TRIG_MCTMn_CHmMDEV : where n can be 0, m can be 0 ~ 3 + * @arg ADC_TRIG_MCTMn_CHALLMEV : where n can be 0 + * @arg ADC_TRIG_MCTMn_CHALLDEV : where n can be 0 + * @arg ADC_TRIG_MCTMn_CHALLMDEV : where n can be 0 + * @arg ADC_TRIG_BFTMn : where n can be 0 ~ 1 + * @arg ADC_TRIG_GPTMn_MTO : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH0O : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH1O : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH2O : where n can be 0 + * @arg ADC_TRIG_GPTMn_CH3O : where n can be 0 + * @arg ADC_TRIG_CMPn : where n can be 0 ~ 3 + * @retval None + ************************************************************************************************************/ +void ADC_HPTrigConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_TRIG_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_TRIG(ADC_TRIG_x)); + + HT_ADCn->HTCR = ADC_TRIG_x & 0x0000001F; + HT_ADCn->HTSR = ADC_TRIG_x & (~0x0000001F); +} + +#if (!LIBCFG_ADC_NO_OFFSET_REG) +/*********************************************************************************************************//** + * @brief Configure the channel data alignment format. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected + * @arg ADC_CH_OPAn : ADC channel for OPAn + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param ADC_ALIGN_x: ADC_ALIGN_RIGHT or ADC_ALIGN_LEFT + * @retval None + ************************************************************************************************************/ +void ADC_ChannelDataAlign(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ADC_ALIGN_Enum ADC_ALIGN_x) +{ + u32 OFRValue; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_ALIGN(ADC_ALIGN_x)); + + OFRValue = HT_ADCn->OFR[ADC_CH_n] & (~(OFR_ADAL)); + OFRValue |= ADC_ALIGN_x; + + HT_ADCn->OFR[ADC_CH_n] = OFRValue; +} + +/*********************************************************************************************************//** + * @brief Configure the offset value for channel offset cancellation. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected + * @arg ADC_CH_OPAn : ADC channel for OPAn + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param OffsetValue: The offset value + * @retval None + ************************************************************************************************************/ +void ADC_ChannelOffsetValue(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, u16 OffsetValue) +{ + u32 OFRValue; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_ADC_OFFSET(OffsetValue)); + + OFRValue = HT_ADCn->OFR[ADC_CH_n] & (~OFR_ADOF_MASK); + OFRValue |= (OffsetValue & 0xFFF); + HT_ADCn->OFR[ADC_CH_n] = OFRValue; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the channel offset cancellation function. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: the ADC channel to configure + * This parameter can be one of the following values: + * @arg ADC_CH_n : ADC Channel x selected + * @arg ADC_CH_OPAn : ADC channel for OPAn + * @arg ADC_CH_GND_VREF : ADC GND VREF selected + * @arg ADC_CH_VDD_VREF : ADC VDD VREF selected + * @param NewState: ENABLE DISABLE + * @retval None + ************************************************************************************************************/ +void ADC_ChannelOffsetCmd(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n, ControlStatus NewState) +{ + u32 OFRValue; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_CHANNEL(ADC_CH_n)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + OFRValue = HT_ADCn->OFR[ADC_CH_n] & (~(OFR_ADOFE)); + + if (NewState == ENABLE) + { + OFRValue |= OFR_ADOFE; + } + + HT_ADCn->OFR[ADC_CH_n] = OFRValue; +} +#endif + +#if (LIBCFG_ADC_TRIG_DELAY) +/*********************************************************************************************************//** + * @brief Configure the ADC Trigger Delay. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. (ADC1 only) + * @param HDelayTime: High priority ADC trigger delay. + * This parameter must be between 0x00 to 0xFF. + * @param DelayTime: Regular ADC trigger delay. + * This parameter must be between 0x00 to 0xFF. + * @retval None + ************************************************************************************************************/ +void ADC_TrigDelayConfig(HT_ADC_TypeDef* HT_ADCn, u8 HDelayTime, u8 DelayTime) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + + HT_ADCn->CFGR = (HDelayTime << 16 | DelayTime << 8); +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable software start of the regular channel conversion of the selected ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_SoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Start Conversion */ + if (NewState != DISABLE) + { + HT_ADCn->TSR |= TCR_SC_SET; + } + else + { + HT_ADCn->TSR &= ~TCR_SC_SET; + } +} + +/*********************************************************************************************************//** + * @brief Enable or Disable software start of the high priority channel conversion of the selected ADC. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_HPSoftwareStartConvCmd(HT_ADC_TypeDef* HT_ADCn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + /* Start Conversion */ + if (NewState != DISABLE) + { + HT_ADCn->HTSR |= HTCR_SC_SET; + } + else + { + HT_ADCn->HTSR &= ~HTCR_SC_SET; + } +} + +/*********************************************************************************************************//** + * @brief Return the result of ADC regular channel conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_REGULAR_DATAn: where n can be 0 ~ 7 + * @retval The Value of data conversion. + ************************************************************************************************************/ +u16 ADC_GetConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_REGULAR_DATAn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_REGULAR_DATA(ADC_REGULAR_DATAn)); + + return ((u16)HT_ADCn->DR[ADC_REGULAR_DATAn]); +} + +/*********************************************************************************************************//** + * @brief Return the result of ADC high priority channel conversion. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_HP_DATAn: where x can be 0 ~ 3 + * @retval The Value of data conversion. + ************************************************************************************************************/ +u16 ADC_GetHPConversionData(HT_ADC_TypeDef* HT_ADCn, u8 ADC_HP_DATAn) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_HP_DATA(ADC_HP_DATAn)); + + return ((u16)HT_ADCn->HDR[ADC_HP_DATAn]); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified ADC interrupts. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the ADC interrupt sources that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_HP_SINGLE_EOC : + * @arg ADC_INT_HP_SUB_GROUP_EOC : + * @arg ADC_INT_HP_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_HP_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_IntConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->IER |= ADC_INT_x; + } + else + { + HT_ADCn->IER &= ~ADC_INT_x; + } +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC interrupt has occurred. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt status to check. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_HP_SINGLE_EOC : + * @arg ADC_INT_HP_SUB_GROUP_EOC : + * @arg ADC_INT_HP_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_HP_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetIntStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + if ((HT_ADCn->ISR & ADC_INT_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Clear the ADC interrupt pending bits. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_INT_x: Specify the interrupt pending bits to be cleared. + * This parameter can be any combination of the following values: + * @arg ADC_INT_SINGLE_EOC : + * @arg ADC_INT_SUB_GROUP_EOC : + * @arg ADC_INT_CYCLE_EOC : + * @arg ADC_INT_HP_SINGLE_EOC : + * @arg ADC_INT_HP_SUB_GROUP_EOC : + * @arg ADC_INT_HP_CYCLE_EOC : + * @arg ADC_INT_DATA_OVERWRITE : + * @arg ADC_INT_HP_DATA_OVERWRITE : + * @arg ADC_INT_AWD_LOWER : + * @arg ADC_INT_AWD_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_ClearIntPendingBit(HT_ADC_TypeDef* HT_ADCn, u32 ADC_INT_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INT(ADC_INT_x)); + + HT_ADCn->ICLR = ADC_INT_x; +} + +/*********************************************************************************************************//** + * @brief Check whether the specified ADC flag has been set. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_FLAG_x: Specify the flag to check. + * This parameter can be any combination of the following values: + * @arg ADC_FLAG_SINGLE_EOC : + * @arg ADC_FLAG_SUB_GROUP_EOC : + * @arg ADC_FLAG_CYCLE_EOC : + * @arg ADC_FLAG_HP_SINGLE_EOC : + * @arg ADC_FLAG_HP_SUB_GROUP_EOC : + * @arg ADC_FLAG_HP_CYCLE_EOC : + * @arg ADC_FLAG_DATA_OVERWRITE : + * @arg ADC_FLAG_HP_DATA_OVERWRITE : + * @arg ADC_FLAG_AWD_LOWER : + * @arg ADC_FLAG_AWD_UPPER : + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus ADC_GetFlagStatus(HT_ADC_TypeDef* HT_ADCn, u32 ADC_FLAG_x) +{ + FlagStatus Status; + + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_FLAG(ADC_FLAG_x)); + + if ((HT_ADCn->IRAW & ADC_FLAG_x) != RESET) + { + Status = SET; + } + else + { + Status = RESET; + } + + return Status; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable Lower/Upper threshold warning of the analog watchdog on single/all channels. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_AWD_x: + * This parameter can be any combination of the following values: + * @arg ADC_AWD_DISABLE : + * @arg ADC_AWD_ALL_LOWER : + * @arg ADC_AWD_ALL_UPPER : + * @arg ADC_AWD_ALL_LOWER_UPPER : + * @arg ADC_AWD_SINGLE_LOWER : + * @arg ADC_AWD_SINGLE_UPPER : + * @arg ADC_AWD_SINGLE_LOWER_UPPER : + * @retval None + ************************************************************************************************************/ +void ADC_AWDConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_AWD_x) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_AWD(ADC_AWD_x)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFFFF8) | ADC_AWD_x; +} + +/*********************************************************************************************************//** + * @brief Configure the analog watchdog that guards single channel. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_CH_n: where n must between 0 ~ 7 + * @retval None + ************************************************************************************************************/ +void ADC_AWDSingleChannelConfig(HT_ADC_TypeDef* HT_ADCn, u8 ADC_CH_n) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_INPUT_CHANNEL(ADC_CH_n)); + + HT_ADCn->WCR = (HT_ADCn->WCR & 0xFFFFF0FF) | ((u32)ADC_CH_n << 8); +} + +/*********************************************************************************************************//** + * @brief Configure the high and low thresholds of the analog watchdog. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param UPPER: must between 0x0000 ~ 0x0FFF + * @param LOWER: must between 0x0000 ~ 0x0FFF + * @retval None + ************************************************************************************************************/ +void ADC_AWDThresholdsConfig(HT_ADC_TypeDef* HT_ADCn, u16 UPPER, u16 LOWER) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_THRESHOLD(UPPER)); + Assert_Param(IS_ADC_THRESHOLD(LOWER)); + + HT_ADCn->LTR = LOWER; + HT_ADCn->UTR = UPPER; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified PDMA request. + * @param HT_ADCn: where HT_ADCn is the selected ADC from the ADC peripherals. + * @param ADC_PDMA_x: Specify the ADC PDMA request that is to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_PDMA_REGULAR_SINGLE : + * @arg ADC_PDMA_REGULAR_SUBGROUP : + * @arg ADC_PDMA_REGULAR_CYCLE : + * @arg ADC_PDMA_HP_SINGLE : + * @arg ADC_PDMA_HP_SUBGROUP : + * @arg ADC_PDMA_HP_CYCLE : + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void ADC_PDMAConfig(HT_ADC_TypeDef* HT_ADCn, u32 ADC_PDMA_x, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_ADC(HT_ADCn)); + Assert_Param(IS_ADC_PDMA(ADC_PDMA_x)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + if (NewState != DISABLE) + { + HT_ADCn->PDMAR |= ADC_PDMA_x; + } + else + { + HT_ADCn->PDMAR &= ~ADC_PDMA_x; + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_opa.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_opa.c new file mode 100644 index 0000000000..6df13c0c01 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_opa.c @@ -0,0 +1,456 @@ + /*********************************************************************************************************//** + * @file ht32f65xxx_66xxx_opa.c + * @version $Rev:: 6932 $ + * @date $Date:: 2023-05-11 #$ + * @brief This file provides all the OPA firmware functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f65xxx_66xxx_opa.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup OPA OPA + * @brief OPA driver modules + * @{ + */ + + +/* Private define ------------------------------------------------------------------------------------------*/ +/** @defgroup OPA_Private_Define OPA private definitions + * @{ + */ +#define OPA_ENABLE (0x00000001ul) +/** + * @} + */ + +/* Private variables ---------------------------------------------------------------------------------------*/ +static u32 gOPAUnProtectKey = 0; + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup OPA_Exported_Functions OPA exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Deinitialize the OPA peripheral registers to their default reset values. + * @retval None + ************************************************************************************************************/ +void OPA_DeInit(void) +{ + RSTCU_PeripReset_TypeDef RSTCUReset = {{0}}; + + RSTCUReset.Bit.OPA = 1; + RSTCU_PeripReset(RSTCUReset, ENABLE); +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the specified OPA peripheral. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals, x can be 0 or 1. + * @param NewState: new state of the HT_OPAn peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None +************************************************************************************************************/ +void OPA_Cmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState) +{ + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + HT_OPAn->CR = gOPAUnProtectKey; + + if (NewState != DISABLE) + { + /* Enable the selected HT_OPAn peripheral */ + HT_OPAn->CR |= OPA_ENABLE; + } + else + { + /* Disable the selected HT_OPAn peripheral */ + HT_OPAn->CR &= ~(u32)OPA_ENABLE; + } +} + +/*********************************************************************************************************//** + * @brief Set the unprotect key. + * @param uUnProtectKey: protect key, shall be OPA_UNPROTECT_KEY + * @retval None + ************************************************************************************************************/ +void OPA_SetUnProtectKey(u32 uUnProtectKey) +{ + gOPAUnProtectKey = uUnProtectKey << 16; +} + +/*********************************************************************************************************//** + * @brief Protect the selected OPA before setting the OPA Control Register. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @retval None + ************************************************************************************************************/ +void OPA_ProtectConfig(HT_OPA_TypeDef* HT_OPAn) +{ + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + + /* Write any value to bit 16 ~ 31 (PROTECT) and keep the other control bir */ + HT_OPAn->CR = HT_OPAn->CR; +} + +/*********************************************************************************************************//** + * @brief Unprotect the selected OPA before setting the OPA Control Register. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @retval None + ************************************************************************************************************/ +void OPA_UnprotectConfig(HT_OPA_TypeDef* HT_OPAn) +{ + u32 CRValue; + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + + /* Set the unlock code corresponding to selected OPA */ + CRValue = HT_OPAn->CR & 0x0000FFFF; + HT_OPAn->CR = gOPAUnProtectKey | CRValue; +} + +#if (LIBCFG_OPA_V2) +/*********************************************************************************************************//** + * @brief Initialize the OPA peripheral according to the specified parameters in the OPA_InitStruct. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param OPA_InitStruct: pointer to a OPA_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void OPA_Init(HT_OPA_TypeDef* HT_OPAn, OPA_InitTypeDef* OPA_InitStruct) +{ + /* !!! NOTICE !!! + Must call the following functions first. + OPA_SetUnProtectKey(OPA_UNPROTECT_KEY); + OPA_UnprotectConfig(); + */ + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_OPA_ScalerEnable(OPA_InitStruct->OPA_ScalerEnable)); + Assert_Param(IS_OPA_ExtPinEnable(OPA_InitStruct->OPA_ExternalPinEnable)); + #if (LIBCFG_OPA_PGA) + Assert_Param(IS_OPA_PGAEnable(OPA_InitStruct->OPA_PGAEnable)); + Assert_Param(IS_OPA_UnitGainEnable(OPA_InitStruct->OPA_UnitGainEnable)); + Assert_Param(IS_OPA_PGA_SEL(OPA_InitStruct->OPA_PGAGain)); + #endif + + #if (LIBCFG_OPA_PGA) + /* avoid both PGA and unit gain active at the same time */ + if (OPA_InitStruct->OPA_UnitGainEnable == OPA_UNITGAIN_ENABLE) + { + OPA_InitStruct->OPA_PGAEnable = OPA_PGA_DISABLE; + } + #endif + + #if (LIBCFG_OPA_PGA) + HT_OPAn->CR = OPA_InitStruct->OPA_ScalerEnable | OPA_InitStruct->OPA_PGAGain | \ + OPA_InitStruct->OPA_ExternalPinEnable | OPA_InitStruct->OPA_PGAEnable | \ + OPA_InitStruct->OPA_UnitGainEnable; + #else + HT_OPAn->CR = OPA_InitStruct->OPA_ScalerEnable | \ + OPA_InitStruct->OPA_ExternalPinEnable; + #endif +} + +/*********************************************************************************************************//** + * @brief Fill each OPA_InitStruct member with its default value. + * @param OPA_InitStruct: pointer to an OPA_InitTypeDef structure. + * @retval None + ************************************************************************************************************/ +void OPA_StructInit(OPA_InitTypeDef* OPA_InitStruct) +{ + /* OPA_InitStruct members default value */ + OPA_InitStruct->OPA_ScalerEnable = OPA_SCALER_DISABLE; + OPA_InitStruct->OPA_ExternalPinEnable = OPA_ExternalPin_DISABLE; + #if (LIBCFG_OPA_PGA) + OPA_InitStruct->OPA_PGAEnable = OPA_PGA_DISABLE; + OPA_InitStruct->OPA_UnitGainEnable = OPA_UNITGAIN_DISABLE; + OPA_InitStruct->OPA_PGAGain = PGA_GAIN_6; + #endif +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the OPA External Input. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void OPA_ExternalInputCmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState) +{ + u32 OPA_CR = (u32)(&HT_OPAn->CR); + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + HT_OPAn->CR = gOPAUnProtectKey; + + if (NewState != DISABLE) + { + SetBit_BB(OPA_CR, 3); + } + else + { + ResetBit_BB(OPA_CR, 3); + } +} + +#if (LIBCFG_OPA_PGA) +/*********************************************************************************************************//** + * @brief Enable or Disable the Unit Gain. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void OPA_UnitGainCmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState) +{ + u32 OPA_CR = (u32)(&HT_OPAn->CR); + u32 CRValue; + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + CRValue = HT_OPAn->CR & (~(0x06UL)); // reset unit gain & PGA + + if (NewState == ENABLE) + { + CRValue |= 0x2; + } + + HT_OPAn->CR = gOPAUnProtectKey; + HT_OPAn->CR = CRValue; +} + +/*********************************************************************************************************//** + * @brief Enable or Disable the PGA. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void OPA_PGACmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState) +{ + u32 OPA_CR = (u32)(&HT_OPAn->CR); + u32 CRValue; + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + CRValue = HT_OPAn->CR & (~(0x06UL)); // reset unit gain & PGA + + if (NewState == ENABLE) + { + CRValue |= 0x4; // set PGA + } + + HT_OPAn->CR = gOPAUnProtectKey; + HT_OPAn->CR = CRValue; +} + +/*********************************************************************************************************//** + * @brief Configure the Gain Selection for the PGA. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param GAIN_SEL : + * This parameter can be one of the following value: + * @arg PGA_GAIN_6 : + * @arg PGA_GAIN_8 : + * @arg PGA_GAIN_12 : + * @arg PGA_GAIN_16 : + * @arg PGA_GAIN_24 : + * @arg PGA_GAIN_32 : + * @arg PGA_GAIN_48 : + * @arg PGA_GAIN_64 : + * @arg PGA_GAIN_5 : + * @arg PGA_GAIN_7 : + * @arg PGA_GAIN_11 : + * @arg PGA_GAIN_15 : + * @arg PGA_GAIN_23 : + * @arg PGA_GAIN_31 : + * @arg PGA_GAIN_47 : + * @arg PGA_GAIN_63 : + * @retval None + ************************************************************************************************************/ +void OPA_PGAGain(HT_OPA_TypeDef* HT_OPAn, u8 bGAIN_SEL) +{ + u32 CRValue; + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_OPA_PGA_SEL(bGAIN_SEL)); + + CRValue = HT_OPAn->CR & (~0x70UL); + CRValue |= (u32)bGAIN_SEL << 4; + + HT_OPAn->CR = gOPAUnProtectKey; + HT_OPAn->CR = CRValue; +} +#endif + +/*********************************************************************************************************//** + * @brief Enable or Disable the 10bit Scaler. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param NewState: This parameter can be ENABLE or DISABLE. + * @retval None + ************************************************************************************************************/ +void OPA_ScalerCmd(HT_OPA_TypeDef* HT_OPAn, ControlStatus NewState) +{ + u32 OPA_CR = (u32)(&HT_OPAn->CR); + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_CONTROL_STATUS(NewState)); + + HT_OPAn->CR = gOPAUnProtectKey; + + if (NewState != DISABLE) + { + SetBit_BB(OPA_CR, 8); + } + else + { + ResetBit_BB(OPA_CR, 8); + } +} + +/*********************************************************************************************************//** + * @brief Set the specified reference value in the data register of the scaler. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param Scaler_Value: value to be loaded in the selected data register. + * @retval None + ************************************************************************************************************/ +void OPA_SetScalerValue(HT_OPA_TypeDef* HT_OPAn, u32 Scaler_Value) +{ + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_OPA_SCALER_VALUE(Scaler_Value)); + + HT_OPAn->DAC = Scaler_Value; +} + +/*********************************************************************************************************//** + * @brief Get the output status of the specified HT_OPAn. + * @param HT_OPAn: where CMPx is the selected OPA from the OPA peripherals. + * @retval SET or RESET + ************************************************************************************************************/ +FlagStatus OPA_GetOutputStatus(HT_OPA_TypeDef* HT_OPAn) +{ + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + + if ((HT_OPAn-> CR & OPA_OUTPUT_HIGH) != 0) + { + return SET; + } + else + { + return RESET; + } +} + +/*********************************************************************************************************//** + * @brief Select OPA Operation Mode. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param MODE: + * This parameter can be one of the following value: + * @arg OPA_OFFSET_CALIBRATION_MODE : + * @arg OPA_NORMAL_MODE : + * @retval None + ************************************************************************************************************/ +void OPA_OFMMode(HT_OPA_TypeDef* HT_OPAn, u8 MODE) +{ + u32 OPA_VOS = (u32)(&HT_OPAn->VOS); + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_OPA_OFMMODE(MODE)); + + if (MODE != OPA_NORMAL_MODE) + { + SetBit_BB(OPA_VOS, 7); + } + else + { + ResetBit_BB(OPA_VOS, 7); + } +} + +/*********************************************************************************************************//** + * @brief Select OPA Operation Mode. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param SEL: + * This parameter can be one of the following value: + * @arg OPA_INPUT_OFFSET_INN : + * @arg OPA_INPUT_OFFSET_INP : + * @retval None + ************************************************************************************************************/ +void OPA_OFM_InputOffsetReferenceSelect(HT_OPA_TypeDef* HT_OPAn, u8 SEL) +{ + u32 OPA_VOS = (u32)(&HT_OPAn->VOS); + + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_OPA_INPUTOFFSET_SEL(SEL)); + + if (SEL != OPA_INPUT_OFFSET_INN) + { + SetBit_BB(OPA_VOS, 6); + } + else + { + ResetBit_BB(OPA_VOS, 6); + } +} + +/*********************************************************************************************************//** + * @brief Configure the input offset calibration voltage for the OPA. + * @param HT_OPAn: where HT_OPAn is the selected OPA from the OPA peripherals. + * @param Data: Set the input offset calibration voltage value. + * @retval None + ************************************************************************************************************/ +void OPA_SetInputOffsetVoltage(HT_OPA_TypeDef* HT_OPAn, u8 Data) +{ + /* Check the parameters */ + Assert_Param(IS_OPA(HT_OPAn)); + Assert_Param(IS_OPA_INPUTOFFSET_VALUE(Data)); + + HT_OPAn->VOS = (HT_OPAn->VOS & 0xFFFFFF70) | (Data & 0x1F); +} +#endif +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_pga.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_pga.c new file mode 100644 index 0000000000..6dacca7f49 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f65xxx_66xxx_pga.c @@ -0,0 +1,49 @@ +/*********************************************************************************************************//** + * @file ht32f65xxx_66xxx_pga.c + * @version $Rev:: 6914 $ + * @date $Date:: 2023-05-10 #$ + * @brief This file provides all the PGA firmware functions. (temporary file, not finish/support yet). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f65xxx_66xxx_pga.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup PGA PGA + * @brief PGA driver modules + * @{ + */ + + + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_cordic.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_cordic.c new file mode 100644 index 0000000000..724e166fbe --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_cordic.c @@ -0,0 +1,49 @@ +/*********************************************************************************************************//** + * @file ht32f66xxx_cordic.c + * @version $Rev:: 6914 $ + * @date $Date:: 2023-05-10 #$ + * @brief This file provides all the CORDIC firmware functions. (temporary file, not finish/support yet). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f66xxx_cordic.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup CORDIC CORDIC + * @brief CORDIC driver modules + * @{ + */ + + + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_pid.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_pid.c new file mode 100644 index 0000000000..d956f5fcf9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/ht32f66xxx_pid.c @@ -0,0 +1,49 @@ +/*********************************************************************************************************//** + * @file ht32f66xxx_pid.c + * @version $Rev:: 6914 $ + * @date $Date:: 2023-05-10 #$ + * @brief This file provides all the PID firmware functions. (temporary file, not finish/support yet). + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32f66xxx_pid.h" + +/** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver + * @{ + */ + +/** @defgroup PID PID + * @brief PID driver modules + * @{ + */ + + + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/printf.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/printf.c new file mode 100644 index 0000000000..4f3515330c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/printf.c @@ -0,0 +1,390 @@ +/*********************************************************************************************************//** + * @file printf.c + * @version $Rev:: 93 $ + * @date $Date:: 2015-11-24 #$ + * @brief Print functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup PRINTF printf re-implementation + * @brief printf related functions + * @{ + */ + + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup PRINTF_Private_Macro printf private macros + * @{ + */ +#define vaStart(list, param) list = (char*)((int)¶m + sizeof(param)) +#define vaArg(list, type) ((type *)(list += sizeof(type)))[-1] +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static const char *FormatItem(const char *f, int a); +static void PutRepChar(const char c, int count); +static int PutString(const char *pString); +static int PutStringReverse(const char *pString, int index); +static void PutNumber(int value, int radix, int width, char fill); + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup PRINTF_Exported_Functions printf exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Print function. + * @param f: Format string. + * @retval String length. + ************************************************************************************************************/ +signed int printf(const char *f, ...) +{ + char *argP; + int i = 0; + + vaStart(argP, f); + while (*f) + { + if (*f == '%') + { + f = FormatItem(f + 1, vaArg(argP, int)); + } + else + { + fputc(*f++, (FILE *)1); + } + i++; + } + return i; +} + +/*********************************************************************************************************//** + * @brief Put string. + * @param pString: String. + * @retval String length. + ************************************************************************************************************/ +signed int puts(const char *pString) +{ + int i; + i = PutString(pString); + fputc('\n', (FILE *)1); + return i; +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup PRINTF_Private_Function printf private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief Format item for print function. + * @param f: Format string. + * @param a: Length of format string. + * @retval Point of string. + ************************************************************************************************************/ +static const char *FormatItem(const char *f, int a) +{ + char c; + int fieldwidth = 0; + int leftjust = FALSE; + int radix = 0; + char fill = ' '; + int i; + + if (*f == '0') + { + fill = '0'; + } + + while ((c = *f++) != 0) + { + if (c >= '0' && c <= '9') + { + fieldwidth = (fieldwidth * 10) + (c - '0'); + } + else + { + switch (c) + { + case '\000': + { + return (--f); + } + case '%': + { + fputc('%', (FILE *)1); + return (f); + } + case '-': + { + leftjust = TRUE; + break; + } + case 'c': + { + if (leftjust) + { + fputc(a & 0x7f, (FILE *)f); + } + if (fieldwidth > 0) + { + PutRepChar(fill, fieldwidth - 1); + } + if (!leftjust) + { + fputc(a & 0x7f, (FILE *)f); + return (f); + } + } + case 's': + { + i = 0; + while (*((char *)(a + i)) !='\0' ) + { + i++; + } + + if (leftjust) + { + PutString((char *)a); + } + + if (fieldwidth > i ) + { + PutRepChar(fill, fieldwidth - i); + } + + if (!leftjust) + { + PutString((char *)a); + } + return (f); + } + case 'l': + { + radix = -10; + f++; + break; + } + case 'd': + case 'i': + { + radix = -10; + break; + } + case 'u': + { + radix = 10; + break; + } + case 'x': + case 'X': + { + radix = 16; + break; + } + case 'o': + { + radix = 8; + break; + } + default: + { + radix = 3; + break; + } + } + } + if (radix) + { + break; + } + } + + if (leftjust) + { + fieldwidth = -fieldwidth; + } + + PutNumber(a, radix, fieldwidth, fill); + + return (f); +} + +/*********************************************************************************************************//** + * @brief Put repeat character. + * @param c: Character. + * @param count: Repeat count + ************************************************************************************************************/ +static void PutRepChar(const char c, int count) +{ + while (count--) + { + fputc(c, (FILE *)1); + } +} + +/*********************************************************************************************************//** + * @brief Put string. + * @param pString: String. + * @retval String length. + ************************************************************************************************************/ +static int PutString(const char *pString) +{ + int i = 0; + while (*pString != '\0') + { + fputc(*pString, (FILE *)1); + pString++; + i++; + } + + return i; +} + +/*********************************************************************************************************//** + * @brief Put string in reversed order. + * @param pString: String. + * @param index: String length + * @retval String length. + ************************************************************************************************************/ +static int PutStringReverse(const char *pString, int index) +{ + int i = 0; + while ((index--) > 0) + { + fputc(pString[index], (FILE *)1); + i++; + } + return i; +} + +/*********************************************************************************************************//** + * @brief Put number. + * @param value: Value of number. + * @param radix: Radix of number. + * @param width: Width of number. + * @param fill: fill character. + ************************************************************************************************************/ +static void PutNumber(int value, int radix, int width, char fill) +{ + char buffer[8]; + int bi = 0; + unsigned int uvalue; + unsigned short digit; + unsigned short left = FALSE; + unsigned short negative = FALSE; + + if (fill == 0) + { + fill = ' '; + } + + if (width < 0) + { + width = -width; + left = TRUE; + } + + if (width < 0 || width > 80) + { + width = 0; + } + + if (radix < 0) + { + radix = -radix; + if (value < 0) + { + negative = TRUE; + value = -value; + } + } + + uvalue = value; + + do + { + if (radix != 16) + { + digit = uvalue % radix; + uvalue = uvalue / radix; + } + else + { + digit = uvalue & 0xf; + uvalue = uvalue >> 4; + } + buffer[bi] = digit + ((digit <= 9) ? '0' : ('A' - 10)); + bi++; + } + while (uvalue != 0); + + if (negative) + { + buffer[bi] = '-'; + bi += 1; + } + + if (width <= bi) + { + PutStringReverse(buffer, bi); + } + else + { + width -= bi; + if (!left) + { + PutRepChar(fill, width); + } + + PutStringReverse(buffer, bi); + + if (left) + { + PutRepChar(fill, width); + } + } +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/syscalls.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/syscalls.c new file mode 100644 index 0000000000..566ad8da78 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32F5xxxx_Driver/src/syscalls.c @@ -0,0 +1,127 @@ +/*********************************************************************************************************//** + * @file syscalls.c + * @version $Rev:: 6830 $ + * @date $Date:: 2023-03-27 #$ + * @brief Implementation of system call related functions. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include +#include +#include +#include + +/** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver + * @{ + */ + +/** @defgroup SYSCALLS System call functions + * @brief System call functions for GNU toolchain + * @{ + */ + + +/* Global variables ----------------------------------------------------------------------------------------*/ +/** @defgroup SYSCALLS_Global_Variable System call global variables + * @{ + */ +#undef errno +extern int errno; +extern int _end; +/** + * @} + */ + +/* Global functions ----------------------------------------------------------------------------------------*/ +/** @defgroup SYSCALLS_Exported_Functions System call exported functions + * @{ + */ +caddr_t _sbrk(int incr) +{ + static unsigned char *heap = NULL; + unsigned char *prev_heap; + + if (heap == NULL) + { + heap = (unsigned char *)&_end; + } + prev_heap = heap; + + heap += incr; + + return (caddr_t) prev_heap; +} + +int link(char *old, char *new) { +return -1; +} + +int _close(int fd) +{ + return -1; +} + +int _fstat(int fd, struct stat *st) +{ + st->st_mode = S_IFCHR; + return 0; +} + +int _isatty(int fd) +{ + return 1; +} + +int _lseek(int fd, int ptr, int dir) +{ + return 0; +} + +int _read(int fd, char *ptr, int len) +{ + return 0; +} + +int _write(int fd, char *ptr, int len) +{ + return len; +} + +void abort(void) +{ + /* Abort called */ + while (1); +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c new file mode 100644 index 0000000000..928fb2ef33 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.c @@ -0,0 +1,426 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_class.c + * @version $Rev:: 1234 $ + * @date $Date:: 2016-10-25 #$ + * @brief The USB Device Class. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_usbd_core.h" +#include "ht32_usbd_class.h" + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDClass USB Device Class + * @brief USB Device Class + * @{ + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Private_Define USB Device Class private definitions + * @{ + */ +#define CLASS_REQ_01_CMD1 (u16)(0x1 << 8) +#define CLASS_REQ_02_CMD2 (u16)(0x2 << 8) +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void USBDClass_MainRoutine(u32 uPara); +static void USBDClass_ClassProcess(void); +static void USBDClass_EPT1Process(void); +static void USBDClass_EPT2Process(void); + +static void USBDClass_Reset(u32 uPara); +static void USBDClass_StartOfFrame(u32 uPara); + +static void USBDClass_Standard_GetDescriptor(USBDCore_Device_TypeDef *pDev); +static void USBDClass_Standard_SetInterface(USBDCore_Device_TypeDef *pDev); +static void USBDClass_Standard_GetInterface(USBDCore_Device_TypeDef *pDev); + +static void USBDClass_Request(USBDCore_Device_TypeDef *pDev); + +static void USBDClass_CMD1(USBDCore_Device_TypeDef *pDev); +static void USBDClass_CMD2(USBDCore_Device_TypeDef *pDev); + +static void USBDClass_Endpoint1(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint2(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint3(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint4(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint5(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint6(USBD_EPTn_Enum EPTn); +static void USBDClass_Endpoint7(USBD_EPTn_Enum EPTn); + +/* Global Function -----------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Exported_Functions USB Device Class exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Class initialization. + * @param pClass: pointer of USBDCore_Class_TypeDef + * @retval None + ***********************************************************************************************************/ +void USBDClass_Init(USBDCore_Class_TypeDef *pClass) +{ + pClass->CallBack_MainRoutine.func = USBDClass_MainRoutine; + //pClass->CallBack_MainRoutine.uPara = (u32)NULL; + + pClass->CallBack_Reset.func = USBDClass_Reset; + pClass->CallBack_Reset.uPara = (u32)NULL; + + pClass->CallBack_StartOfFrame.func = USBDClass_StartOfFrame; + pClass->CallBack_StartOfFrame.uPara = (u32)NULL; + + pClass->CallBack_ClassGetDescriptor = USBDClass_Standard_GetDescriptor; + pClass->CallBack_ClassSetInterface = USBDClass_Standard_SetInterface; + pClass->CallBack_ClassGetInterface = USBDClass_Standard_GetInterface; + + pClass->CallBack_ClassRequest = USBDClass_Request; + pClass->CallBack_EPTn[1] = USBDClass_Endpoint1; + pClass->CallBack_EPTn[2] = USBDClass_Endpoint2; + pClass->CallBack_EPTn[3] = USBDClass_Endpoint3; + pClass->CallBack_EPTn[4] = USBDClass_Endpoint4; + pClass->CallBack_EPTn[5] = USBDClass_Endpoint5; + pClass->CallBack_EPTn[6] = USBDClass_Endpoint6; + pClass->CallBack_EPTn[7] = USBDClass_Endpoint7; + + #ifdef RETARGET_IS_USB + pClass->CallBack_EPTn[RETARGET_RX_EPT] = SERIAL_USBDClass_RXHandler; + #endif + + return; +} +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Private_Functions USB Device Class private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Class main routine. + * @param uPara: Parameter for Class main routine + * @retval None + ***********************************************************************************************************/ +static void USBDClass_MainRoutine(u32 uPara) +{ + USBDClass_ClassProcess(); + USBDClass_EPT1INProcess(); + USBDClass_EPT2OUTProcess(); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Process for application. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_ClassProcess(void) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint 1 Process for application. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_EPT1Process(void) +{ + if (gIsEP1 == TRUE) + { + gIsEP1 = FALSE; + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint 2 Process for application. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_EPT2Process(void) +{ + if (gIsEP2 == TRUE) + { + gIsEP2 = FALSE; + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Reset. + * @param uPara: Parameter for Class Reset. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Reset(u32 uPara) +{ + +} + +/*********************************************************************************************************//** + * @brief USB Class Start of Frame. + * @param uPara: Parameter for Class Start of Frame. + * @retval None + ***********************************************************************************************************/ +static void USBDClass_StartOfFrame(u32 uPara) +{ + +} + +/*********************************************************************************************************//** + * @brief USB Device Class Request + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Request(USBDCore_Device_TypeDef *pDev) +{ + u16 uUSBCmd = *((u16 *)(&(pDev->Request))); + +#ifdef RETARGET_IS_USB + SERIAL_USBDClass_Request(pDev); +#endif + + switch (uUSBCmd) + { + /*------------------------------------------------------------------------------------------------------*/ + /* | bRequest | Data transfer direction | Type | Recipient | Data */ + /*------------------------------------------------------------------------------------------------------*/ + + /*------------------------------------------------------------------------------------------------------*/ + /* | 01_CMD1 | 80_Device-to-Host | 20_Class Request | 1_Interface | 01A1h */ + /*------------------------------------------------------------------------------------------------------*/ + case (CLASS_REQ_01_CMDID0 | REQ_DIR_01_D2H | REQ_TYPE_01_CLS | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld CMD0\t[%02d][%02d]\r\n", __DBG_USBCount, pDev->Request.wValueH, pDev->Request.wLength ); + USBDClass_RequestCMD1(pDev); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 02_CMD2 | 00_Host-to-Device | 20_Class Request | 1_Interface | 0221h */ + /*------------------------------------------------------------------------------------------------------*/ + case (CLASS_REQ_02_GET_IDLE | REQ_DIR_00_H2D | REQ_TYPE_01_CLS | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld CMD1\t[%02d][%02d]\r\n", __DBG_USBCount, pDev->Request.wValueH, pDev->Request.wLength ); + USBDClass_RequestCMD2(pDev); + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Class Standard Request - GET_DESCRIPTOR + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Standard_GetDescriptor(USBDCore_Device_TypeDef *pDev) +{ + u32 type = pDev->Request.wValueH; + + switch (type) + { + case DESC_TYPE_01_XXX + { + pDev->Transfer.pData = (uc8 *)(__BUFFER_POINTER__); + pDev->Transfer.sByteLength = DESC_LEN_XXX; + pDev->Transfer.Action = USB_ACTION_DATAIN; + break; + } + case DESC_TYPE_02_XXX: + { + pDev->Transfer.pData = (uc8 *)(__BUFFER_POINTER__); + pDev->Transfer.sByteLength = DESC_LEN_XXX; + pDev->Transfer.Action = USB_ACTION_DATAIN; + break; + } + } /* switch (type) */ + + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Class Standard Request - SET_INTERFACE + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Standard_SetInterface(USBDCore_Device_TypeDef *pDev) +{ + +} + +/*********************************************************************************************************//** + * @brief USB Device Class Standard Request - GET_INTERFACE + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Standard_GetInterface(USBDCore_Device_TypeDef *pDev) +{ + +} + + + +/*********************************************************************************************************//** + * @brief USB Device Class Request - CMD1 + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_CMD1(USBDCore_Device_TypeDef *pDev) +{ + /* Add your own Class request function here.... + For example.... + + u32 uReportID = pDev->Request.wValueL; + u32 uInterface = pDev->Request.wIndex; + + pDev->Transfer.pData = (uc8 *)&(__IDLE_DURATION_BUFFER[uReportID]); + pDev->Transfer.sByteLength = 1; + pDev->Transfer.Action= USB_ACTION_DATAIN; + + */ + return; +} + +/*********************************************************************************************************//** + * @brief USB Device Class Request - CMD2 + * @param pDev: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void USBDClass_CMD2(USBDCore_Device_TypeDef *pDev) +{ + /* Add your own Class request function here.... + For example.... + + u32 uReportID = pDev->Request.wValueL; + u32 uInterface = pDev->Request.wIndex; + + pDev->Transfer.pData = (uc8 *)&(__IDLE_DURATION_BUFFER[uReportID]); + pDev->Transfer.sByteLength = 1; + pDev->Transfer.Action= USB_ACTION_DATAIN; + + */ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint1(USBD_EPTn_Enum EPTn) +{ + gIsEP1 = TRUE; + + __DBG_USBPrintf("%06ld EP1\t[%02d]", ++__DBG_USBCount, (int)USBDCore_EPTGetBufferLen(EPTn)); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint2(USBD_EPTn_Enum EPTn) +{ + gIsEP2 = TRUE; + __DBG_USBPrintf("%06ld EP2\t[%02d]", ++__DBG_USBCount, (int)USBDCore_EPTGetBufferLen(EPTn)); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint3(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint4(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint5(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint6(USBD_EPTn_Enum EPTn) +{ + return; +} + +/*********************************************************************************************************//** + * @brief USB Class Endpoint handler + * @param EPTn: USB Endpoint number + * @arg USBD_EPT0 ~ USBD_EPT7 + * @retval None + ***********************************************************************************************************/ +static void USBDClass_Endpoint7(USBD_EPTn_Enum EPTn) +{ + return; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h new file mode 100644 index 0000000000..2fe2598bee --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_class.h @@ -0,0 +1,87 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_class.h + * @version $Rev:: 47 $ + * @date $Date:: 2015-11-18 #$ + * @brief The header file of USB Device Class. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_USBD_CLASS_H +#define __HT32_USBD_CLASS_H + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDClass USB Device Class + * @brief USB Device Class + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Private_Define USB Device Class private definitions + * @{ + */ +/* For ht32_usbd_descriptor.c */ +#define CLASS_INF_CLASS (DESC_CLASS_03_XXX) +#define CLASS_INF_SUBCLASS (HID_SUBCLASS_00_NONE) +#define CLASS_INF_PTCO (HID_PROTOCOL_00_NONE) + +/* HID related definition */ +#define DESC_LEN_XXX ((u32)(9)) +#define DESC_LEN_XXX ((u16)(47)) + +#define DESC_TYPE_01_XXX (0x01) +#define DESC_TYPE_02_XXX (0x02) + +#define HID_SUBCLASS_00_NONE (0x00) +#define HID_SUBCLASS_01_BOOT (0x01) + +#define HID_PROTOCOL_00_NONE (0x00) +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USBDClass_Exported_Functions USB Device Class exported functions + * @{ + */ +void USBDClass_Init(USBDCore_Class_TypeDef *pClass); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#endif /* __HT32_USBD_CLASS_H ------------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c new file mode 100644 index 0000000000..c33c0865b9 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.c @@ -0,0 +1,368 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_descriptor.c + * @version $Rev:: 47 $ + * @date $Date:: 2015-11-18 #$ + * @brief The USB Descriptor. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_usbd_core.h" +#include "ht32_usbd_class.h" +#include "ht32_usbd_descriptor.h" + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDDescriptor USB Descriptor + * @brief USB descriptor + * @{ + */ + + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Device descriptor setting +// USB Specification Release number (bcdUSB) +// <0x0200=> USB 2.0 +// <0x0110=> USB 1.1 +// <0x0100=> USB 1.0 +// USB Class code (assigned by the USB-IF) +// <0x00=> Use class information in the Interface Descriptors (0x00) +// <0x02=> Communications and CDC Control (CDC, 0x02) +// <0xDC=> Diagnostic Device (0xDC) +// <0xEF=> Miscellaneous (0xEF) +// <0xFF=> Vendor Specific (0xFF) +// USB Subclass code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Protocol code (assigned by the USB-IF) <0x0-0xFF:1> +// USB Vendor ID <0x0-0xFFFF:1> +// USB Product ID <0x0-0xFFFF:1> +// USB Device Version <0x0-0xFFFF:1> +// USB String descriptor - Manufacturer +// USB String descriptor - Product +// USB String descriptor - Device serial number +// USB Number of possible configurations <0-255:1> +#define DESC_BCDUSB (0x0110) +#define DESC_BDEVCLASS (0x00) +#define DESC_BDEVSUBCLASS (0x00) +#define DESC_BDEVPROTOCOL (0x00) +#define DESC_IDVENDOR (0x04D9) +#define DESC_IDPRODUCT (0x8008) +#define DESC_BCDDEVICE (0x0100) +#define DESC_IMANUFACTURE (1) +#define DESC_IPRODUCT (1) +#define DESC_ISERIALNUM (1) +#define DESC_INUMCONFN (1) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#if (DESC_BDEVCLASS == 0x0 & DESC_BDEVSUBCLASS != 0x0) +#error "DESC_BDEVSUBCLASS must be reset to zero when the DESC_BDEVCLASS is equal to zero." +#endif +#define DESC_WMAXPACKETSIZE0 (_EP0LEN) +#define DESC_STR_MAN (1 * DESC_IMANUFACTURE) +#define DESC_STR_PRD (2 * DESC_IPRODUCT) +#define DESC_STR_SER (3 * DESC_ISERIALNUM) +#define DESC_NUM_STRING (1 + 3) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Device descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_DeviceDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Device descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_DEV, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_01_DEV, // bDescriptorType 1 DEVICE Descriptor Type + DESC_H2B(DESC_BCDUSB), // bcdUSB 2 USB Specification Release Number + DESC_BDEVCLASS, // bDeviceClass 1 Class code (assigned by the USB-IF) + DESC_BDEVSUBCLASS, // bDeviceSubClass 1 Subclass code (assigned by the USB-IF) + DESC_BDEVPROTOCOL, // bDeviceProtocol 1 Protocol code (assigned by the USB-IF) + DESC_WMAXPACKETSIZE0, // wMaxPacketSize0 1 Maximum packet size for endpoint zero + DESC_H2B(DESC_IDVENDOR), // idVendor 2 Vendor ID (assigned by USB-IF) + DESC_H2B(DESC_IDPRODUCT), // idProduct 2 Product ID (assigned by manufacturer) + DESC_H2B(DESC_BCDDEVICE), // bcdDevice 2 Device release number + DESC_STR_MAN, // iManufacturer 1 Index of string descriptor (Manufacturer) + DESC_STR_PRD, // iProduct 1 Index of string descriptor (Product) + DESC_STR_SER, // iSerialNumber 1 Index of string descriptor (Serial Number) + DESC_INUMCONFN, // iNumConfigurations 1 Number of possible configuration +}; + + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration descriptor setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Configuration descriptor setting +// Self-powered +// Bit 6 of bmAttributes +// Remote Wakeup +// Bit 5 of bmAttributes +// USB Device maximum power (mA) < 2-512:2> +#define DESC_BMATTR_SELF_POWER (0) +#define DESC_BMATTR_REMOTE_WAKEUP (1) +#define DESC_BMAXPOWER (100) +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor definition. DO NOT MODIFY. */ +/*----------------------------------------------------------------------------------------------------------*/ +#define DESC_BMATTRIBUTES (0x80 | (DESC_BMATTR_SELF_POWER << 6) | (DESC_BMATTR_REMOTE_WAKEUP << 5)) +#define DESC_TOTAL_LEN DESC_H2B((DESC_LEN_CONFN_T + RETARGET_DLEN)) + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Configuration Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_ConfnDesc[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Configuration descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_CONFN, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_02_CONFN, // bDescriptorType 1 CONFIGURATION Descriptor Type + DESC_TOTAL_LEN, // wTotalLength 2 Total length of data returned for this configuration + 0x01 + RETARGET_INF, // bNumberInterface 1 Number of interfaces supported by this configuration + 0x01, // bConfigurationValue 1 Value to use as an argument to the SetConfiguration() + 0x00, // iConfiguration 1 Index of string descriptor describing this configuration + DESC_BMATTRIBUTES, // bmAttributes 1 Configuration characteristics + // D6: Self-powered, D5: RemoteWakeup + DESC_POWER(DESC_BMAXPOWER), // bMaxPower 1 Maximum power consumption of the USB device (2 mA units) + + /*--------------------------------------------------------------------------------------------------------*/ + /* Interface descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_INF, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_04_INF, // bDescriptorType 1 INTERFACE Descriptor Type + 0x00, // bInterfaceNumber 1 Number of this interface (Zero-based 0) + 0x00, // bAlternateSetting 1 Value used to select this alternate setting + 2, // bNumEndpoints 1 Number of endpoints used by this interface + CLASS_INF_CLASS, // bInterfaceClass 1 Class code (assigned by USB-IF) + CLASS_INF_SUBCLASS, // bInterfaceSubClass 1 Subclass code (assigned by USB-IF) + CLASS_INF_PTCO, // bInterfaceProtocol 1 Protocol code (assigned by USB) + 0x00, // iInterface 1 Index of string descriptor describing this interface + + /*--------------------------------------------------------------------------------------------------------*/ + /* XXX descriptor */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_XXX, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_01_XXX, // bDescriptorType 1 XXX Descriptor type + DESC_H2B(0x0110), // bcdXXX 2 XXX Specification Release Number + 0x21, // bCountryCode 1 Country code of the localized hardware + 0x01, // bNumDescriptors 1 Number of class descriptors (at least 1) + DESC_TYPE_02_XXX, // bDescriptorType 1 REPORT Descriptor Type + DESC_H2B(DESC_LEN_XXXX), // bDescriptorLength 2 Total size of the Report descriptor + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + 0x81, // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x03, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(_EP1LEN), // wMaxPacketSize 2 Maximum packet size + 0x01, // bInterval 1 Interval for polling endpoint + + /*--------------------------------------------------------------------------------------------------------*/ + /* Endpoint */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_LEN_EPT, // bLength 1 Size of this descriptor in bytes + DESC_TYPE_05_EPT, // bDescriptorType 1 ENDPOINT Descriptor Type + 0x02, // bEndpointAddress 1 The address of the endpoint + // Bit 3..0: The endpoint number + // Bit 6..4: Reserved + // Bit 7 : Direction (0 = Out/1 = In) + 0x03, // bmAttribute 1 Endpoint Attribute + // Bit 1..0: Transfer type + // 00 = Control + // 01 = Isochronous + // 10 = Bulk + // 11 = Interrupt + // All other reserved + DESC_H2B(_EP2LEN), // wMaxPacketSize 2 Maximum packet size + 0x01, // bInterval 1 Interval for polling endpoint + + #ifdef RETARGET_IS_USB + #include "ht32_retarget_desc.h" + #endif + +}; + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB String Descriptor */ +/*----------------------------------------------------------------------------------------------------------*/ +__ALIGN4 static uc8 guUSB_StringDescLANGID[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* LANGID (Index = 0) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(1), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_H2B(0x0409), // wLANGID[0] 2 LANGID code zero +}; + +#if (DESC_IMANUFACTURE == 1) +__ALIGN4 static uc8 guUSB_StringDescManufacture[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Manufacture (Index = 1) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(6), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('H'), // bString N UNICODE encoded string + DESC_CHAR('O'), + DESC_CHAR('L'), + DESC_CHAR('T'), + DESC_CHAR('E'), + DESC_CHAR('K'), +}; +#endif + +#if (DESC_IPRODUCT == 1) +__ALIGN4 static uc8 guUSB_StringDescProduct[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Product (Index = 2) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(12), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('U'), // bString N UNICODE encoded string + DESC_CHAR('S'), + DESC_CHAR('B'), + DESC_CHAR('-'), + DESC_CHAR('X'), + DESC_CHAR('X'), + DESC_CHAR('X'), + DESC_CHAR(' '), + DESC_CHAR('D'), + DESC_CHAR('E'), + DESC_CHAR('M'), + DESC_CHAR('O'), +}; +#endif + + +#if (DESC_ISERIALNUM == 1) +__ALIGN4 static u8 guUSB_StringDescSerialNum[] = +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* Serial Number (Index = 3) */ + /*--------------------------------------------------------------------------------------------------------*/ + /* Field Size Description */ + /*----------------------------------------------------------------------------*/ + DESC_STRLEN(12), // bLength 1 Size of this descriptor in bytes + DESC_TYPE_03_STR, // bDescriptorType 1 STRING Descriptor Type + DESC_CHAR('S'), // bString N UNICODE encoded string + DESC_CHAR('N'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), + DESC_CHAR('0'), +}; +#endif + +uc8 *gpStringDesc[DESC_NUM_STRING] = +{ + + guUSB_StringDescLANGID, + + #if (DESC_IMANUFACTURE == 1) + guUSB_StringDescManufacture, + #else + NULL, + #endif + + #if (DESC_IPRODUCT == 1) + guUSB_StringDescProduct, + #else + NULL, + #endif + + #if (DESC_ISERIALNUM == 1) + guUSB_StringDescSerialNum + #else + NULL, + #endif + +}; + +/*********************************************************************************************************//** + * @brief USB Descriptor pointer initialization. + * @param pDesc: pointer of USBDCore_Desc_TypeDef + * @retval None + ***********************************************************************************************************/ +void USBDDesc_Init(USBDCore_Desc_TypeDef *pDesc) +{ + pDesc->pDeviceDesc = guUSB_DeviceDesc; + pDesc->pConfnDesc = guUSB_ConfnDesc; + pDesc->ppStringDesc = gpStringDesc; + pDesc->uStringDescNumber = DESC_NUM_STRING; + + return; +} + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h new file mode 100644 index 0000000000..eebcf440bf --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32_usbd_descriptor.h @@ -0,0 +1,59 @@ +/*********************************************************************************************************//** + * @file example/ht32_usbd_descriptor.h + * @version $Rev:: 47 $ + * @date $Date:: 2015-11-18 #$ + * @brief The USB descriptor. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_USBD_DESCRIPTOR_H +#define __HT32_USBD_DESCRIPTOR_H + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDDescriptor USB Descriptor + * @brief USB descriptor + * @{ + */ + + +/* Exported constants --------------------------------------------------------------------------------------*/ +#define DESC_LEN_CONFN_T (u16)(DESC_LEN_CONFN + DESC_LEN_INF + DESC_LEN_XXX + DESC_LEN_EPT * 2) + +/* Exported functions --------------------------------------------------------------------------------------*/ +void USBDDesc_Init(USBDCore_Desc_TypeDef *pDesc); + + +/** + * @} + */ + +/** + * @} + */ + +#endif /* __HT32_USBD_DESCRIPTOR_H -------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h new file mode 100644 index 0000000000..a5157ea8fa --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/example/ht32fxxxxx_usbdconf.h @@ -0,0 +1,453 @@ +/*********************************************************************************************************//** + * @file example/ht32fxxxxx_usbdconf.h + * @version $Rev:: 47 $ + * @date $Date:: 2015-11-18 #$ + * @brief The configuration file of USB Device Driver. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32FXXXX_USBDCONF_H +#define __HT32FXXXX_USBDCONF_H + +// Enter Low Power mode when Suspended +#define USBDCORE_ENABLE_LOW_POWER (0) +// + +#if (USBDCORE_ENABLE_LOW_POWER == 1) + #define USBDCore_LowPower() PWRCU_DeepSleep1(PWRCU_SLEEP_ENTRY_WFE) +#else + #define USBDCore_LowPower(...) +#endif + +/*----------------------------------------------------------------------------------------------------------*/ +/* USB Interrupt Enable */ +/*----------------------------------------------------------------------------------------------------------*/ +// USB Interrupt Setting (UIER) +// USB Global Interrupt Enable (UGIE) (Default) +// Start Of Frame Interrupt Enable (SOFIE) +// USB Reset Interrupt Enable (URSTIE) (Default) +// Resume Interrupt Enable (RSMIE) (Default) +// Suspend Interrupt Enable (SUSPIE) (Default) +// Expected Start of Frame Interrupt Enable (ESOFE) +// Control Endpoint Interrupt Enable (EP0IE) (Default) +// Endpoint1 Interrupt Enable (EP1IE) +// Endpoint2 Interrupt Enable (EP2IE) +// Endpoint3 Interrupt Enable (EP3IE) +// Endpoint4 Interrupt Enable (EP4IE) +// Endpoint5 Interrupt Enable (EP5IE) +// Endpoint6 Interrupt Enable (EP6IE) +// Endpoint7 Interrupt Enable (EP7IE) +#define _UIER (0x071D) +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint0 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Control Endpoint0 Configuration +// Endpoint Buffer Length (EPLEN) +// <8=> 8 bytes +// <16=> 16 bytes +// <32=> 32 bytes +// <64=> 64 bytes + /* Maximum: 64 Bytes */ +#define _EP0LEN (64) + + +// Control Endpoint0 Interrupt Enable Settings (EP0IER) +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) (Default) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) (Default) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +// SETUP Token Packet Received Interrupt Enable (STRXIE) +// SETUP Data Packet Received Interrupt Enable (SDRXIE) (Default) +// SETUP Data Error Interrupt Enable (SDERIE) +// Zero Length Data Packet Received Interrupt Enable (ZLRXIE) +#define _EP0_IER (0x212) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint1 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint1 Configuration +#define _EP1_ENABLE (1) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP1_CFG_EPADR (1) + +// Endpoint Enable (EPEN) +#define _EP1_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP1_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP1_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP1LEN_TMP (64) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP1_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint2 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint2 Configuration +#define _EP2_ENABLE (1) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP2_CFG_EPADR (2) + +// Endpoint Enable (EPEN) +#define _EP2_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP2_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP2_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP2LEN_TMP (64) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP2_IER (0x002) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint3 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint3 Configuration +#define _EP3_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP3_CFG_EPADR (3) + +// Endpoint Enable (EPEN) +#define _EP3_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <2=> Bulk +// <3=> Interrupt +#define _EP3_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP3_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-64:4> + /* Maximum: 64 Bytes */ +#define _EP3LEN_TMP (8) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP3_IER (0x10) +// +// + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint4 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint4 Configuration +#define _EP4_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP4_CFG_EPADR (4) + +// Endpoint Enable (EPEN) +#define _EP4_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP4_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP4_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP4LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP4_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP4_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint5 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint5 Configuration +#define _EP5_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP5_CFG_EPADR (5) + +// Endpoint Enable (EPEN) +#define _EP5_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP5_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP5_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP5LEN_TMP (8) + + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP5_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP5_IER (0x10) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint6 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint6 Configuration +#define _EP6_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP6_CFG_EPADR (6) + +// Endpoint Enable (EPEN) +#define _EP6_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP6_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP6_CFG_EPDIR (0) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP6LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP6_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP6_IER (0x02) +// +// + + +/*----------------------------------------------------------------------------------------------------------*/ +/* Endpoint7 Configuration Setting */ +/*----------------------------------------------------------------------------------------------------------*/ +// Endpoint7 Configuration +#define _EP7_ENABLE (0) + +// Endpoint Address (EPADR) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 +#define _EP7_CFG_EPADR (7) + +// Endpoint Enable (EPEN) +#define _EP7_CFG_EPEN_TMP (1) + +// Endpoint Transfer Type +// <1=> Isochronous +// <2=> Bulk +// <3=> Interrupt +#define _EP7_TYPR (3) + +// Endpoint Direction (EPDIR) +// <1=> IN +// <0=> OUT +#define _EP7_CFG_EPDIR (1) + +// Endpoint Buffer Length (EPLEN) (in byte) <4-1000:4> + /* Maximum: 1000 Bytes */ +#define _EP7LEN_TMP (8) + +// Single/Double Buffer Selection (SDBS) +// <0=> Single Buffer +// <1=> Double Buffer +#define _EP7_CFG_SDBS (0) + +// Endpoint Interrupt Enable Settings (EPIER) +// Endpoint Interrupt Enable Settings (EPIER) <0x0-0xFF:1> +// OUT Token Packet Received Interrupt Enable (OTRXIE) +// OUT Data Packet Received Interrupt Enable (ODRXIE) +// OUT Data Buffer Overrun Interrupt Enable (ODOVIE) +// IN Token Packet Received Interrupt Enable (ITRXIE) +// IN Data Packet Transmitted Interrupt Enable (IDTXIE) +// NAK Transmitted Interrupt Enable (NAKIE) +// STALL Transmitted Interrupt Enable (STLIE) +// USB Error Interrupt Enable (UERIE) +#define _EP7_IER (0x10) +// +// + +#endif diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h new file mode 100644 index 0000000000..00ff7d8e53 --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/inc/ht32_usbd_core.h @@ -0,0 +1,435 @@ +/*********************************************************************************************************//** + * @file ht32_usbd_core.h + * @version $Rev:: 5656 $ + * @date $Date:: 2021-11-24 #$ + * @brief The header file of standard protocol related function for HT32 USB Device Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +/* Define to prevent recursive inclusion -------------------------------------------------------------------*/ +#ifndef __HT32_USBD_CORE_H +#define __HT32_USBD_CORE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------------------------------------*/ + +/** @addtogroup HT32_USBD_Library + * @{ + */ + +/** @addtogroup USBDCore + * @{ + */ + + +/* Settings ------------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Settings USB Device Core settings + * @{ + */ +/* USBD Debug mode */ +// Enable USB Debug mode +// Dump USB Debug data +#ifndef USBDCORE_DEBUG + #define USBDCORE_DEBUG (0) /*!< Enable USB Debug mode */ + #define USBDCORE_DEBUG_DATA (0) /*!< Dump USB Debug data */ +#endif +/** + * @} + */ + +/* Exported types ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Type USB Device Core exported types + * @{ + */ +/** + * @brief USB Device Request. + */ +typedef __PACKED_H struct +{ + uc8 bmRequestType; + uc8 bRequest; + uc8 wValueL; + uc8 wValueH; + uc16 wIndex; + uc16 wLength; +} __PACKED_F USBDCore_Request_TypeDef; + +/** + * @brief USB Descriptor. + */ +typedef struct +{ + uc8 *pDeviceDesc; /*!< Device Descriptor */ + uc8 *pConfnDesc; /*!< Configuration Descriptor */ + uc8 **ppStringDesc; /*!< String Descriptor */ + u32 uStringDescNumber; /*!< Count of String Descriptor */ +} USBDCore_Desc_TypeDef; + +/** + * @brief STALL, control IN or control OUT. + */ +typedef enum +{ + USB_ACTION_STALL = 0, + USB_ACTION_DATAIN = 1, + USB_ACTION_DATAOUT = 2, +} USBDCore_Action_Enum; + +/** + * @brief Call back function. + */ +typedef struct +{ + void (*func) (u32 uPara); /*!< Call back function pointer */ + u32 uPara; /*!< Parameter of call back function */ +} USBDCore_CallBack_TypeDef; + +/** + * @brief Parameter for control IN/OUT Transfer. + */ +typedef struct +{ + u8 uBuffer[2]; /*!< Temporary buffer */ + uc8 *pData; /*!< Pointer of control IN/OUT Data */ + s32 sByteLength; /*!< Total length for control IN/OUT Transfer */ + USBDCore_Action_Enum Action; /*!< STALL, control IN or control OUT */ + USBDCore_CallBack_TypeDef CallBack_OUT; /*!< Call back function pointer for Control OUT */ +} USBDCore_Transfer_TypeDef; + +/** + * @brief USB Device. + */ +typedef struct +{ + USBDCore_Request_TypeDef Request; /*!< USB Device Request */ + USBDCore_Desc_TypeDef Desc; /*!< USB Descriptor */ + USBDCore_Transfer_TypeDef Transfer; /*!< Parameter for control IN/OUT Transfer */ +} USBDCore_Device_TypeDef; + +/** + * @brief Bit access for CurrentFeature. + */ +typedef __PACKED_H struct _FEATURE_TYPEBIT +{ + unsigned bSelfPowered :1; /*!< Remote Wakeup feature */ + unsigned bRemoteWakeup :1; /*!< Self Powered */ +} __PACKED_F USBDCore_Feature_TypeBit; + +/** + * @brief For Set/ClearFeature and GetStatus request. + */ +typedef __PACKED_H union _FEATURE_TYPEDEF +{ + u8 uByte; /*!< Byte access for CurrentFeature */ + USBDCore_Feature_TypeBit Bits; /*!< Bit access for CurrentFeature */ +} __PACKED_F USBDCore_Feature_TypeDef; + +/** + * @brief Device State. + */ +typedef enum +{ + USB_STATE_UNCONNECTED = 0, + USB_STATE_ATTACHED = 1, + USB_STATE_POWERED = 2, + USB_STATE_SUSPENDED = 3, + USB_STATE_DEFAULT = 4, + USB_STATE_ADDRESS = 5, + USB_STATE_CONFIGURED = 6, +} USBDCore_Status_Enum; + +/** + * @brief USB Device information. + */ +typedef struct +{ + u8 uCurrentConfiguration; /*!< For Set/GetConfiguration request */ + u8 uCurrentInterface; /*!< For Set/GetInterface request */ + volatile USBDCore_Status_Enum CurrentStatus; /*!< Device State */ + USBDCore_Status_Enum LastStatus; /*!< Device State before SUSPEND */ + USBDCore_Feature_TypeDef CurrentFeature; /*!< For Set/ClearFeature and GetStatus request */ + u32 uIsDiscardClearFeature; /*!< Discard ClearFeature flag for Mass Storage */ +} USBDCore_Info_TypeDef; + +typedef void (*USBDCore_CallBackClass_Typedef) (USBDCore_Device_TypeDef *pDev); +typedef void (*USBDCore_CallBackVendor_Typedef) (USBDCore_Device_TypeDef *pDev); +typedef void (*USBDCore_CallBackEPTn_Typedef) (USBD_EPTn_Enum EPTn); + +/** + * @brief USB Class call back function. + */ +typedef struct +{ + USBDCore_CallBack_TypeDef CallBack_MainRoutine; /*!< Class main routine call back function */ + USBDCore_CallBack_TypeDef CallBack_Reset; /*!< Class RESET call back function */ + USBDCore_CallBack_TypeDef CallBack_StartOfFrame; /*!< Class SOF call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassGetDescriptor; /*!< Class Get Descriptor call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassSetInterface; /*!< Set Interface call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassGetInterface; /*!< Get Interface call back function */ + USBDCore_CallBackClass_Typedef CallBack_ClassRequest; /*!< Class Request call back function */ + USBDCore_CallBackVendor_Typedef CallBack_VendorRequest; /*!< Vendor Request call back function */ + USBDCore_CallBackEPTn_Typedef CallBack_EPTn[MAX_EP_NUM]; /*!< Endpoint n call back function */ +} USBDCore_Class_TypeDef; + +/** + * @brief USB Device Power related call back function. + */ +typedef struct +{ + USBDCore_CallBack_TypeDef CallBack_Suspend; +} USBDCore_Power_TypeDef; + +/** + * @brief Major structure of USB Library. + */ +typedef struct +{ + USBDCore_Device_TypeDef Device; /*!< USB Device */ + USBDCore_Info_TypeDef Info; /*!< USB Device information */ + USBDCore_Class_TypeDef Class; /*!< USB Class call back function */ + u32 *pDriver; /*!< USB Device Driver initialization structure */ + USBDCore_Power_TypeDef Power; /*!< USB Device Power related call back function */ +} USBDCore_TypeDef; + +/*----------------------------------------------------------------------------------------------------------*/ +/* Variable architecture of USB Library */ +/*----------------------------------------------------------------------------------------------------------*/ +/* USBCore - USBDCore_TypeDef Major structure of USB Library */ +/* USBCore.Device - USBDCore_Device_TypeDef USB Device */ +/* USBCore.Device.Request - USBDCore_Request_TypeDef USB Device Request */ +/* USBCore.Device.Request.bmRequestType */ +/* USBCore.Device.Request.bRequest */ +/* USBCore.Device.Request.wValueL */ +/* USBCore.Device.Request.wValueH */ +/* USBCore.Device.Request.wIndex */ +/* USBCore.Device.Request.wLength */ +/* USBCore.Device.Desc - USBDCore_Desc_TypeDef USB Descriptor */ +/* USBCore.Device.Desc.pDeviceDesc Device Descriptor */ +/* USBCore.Device.Desc.pConfnDesc Configuration Descriptor */ +/* USBCore.Device.Desc.pStringDesc[DESC_NUM_STRING] String Descriptor */ +/* USBCore.Device.Desc.uStringDescNumber Count of String Descriptor */ +/* USBCore.Device.Transfer - USBDCore_Transfer_TypeDef Parameter for control IN/OUT Transfer */ +/* USBCore.Device.Transfer.uBuffer[2] Temporary buffer */ +/* USBCore.Device.Transfer.pData Pointer of control IN/OUT Data */ +/* USBCore.Device.Transfer.sByteLength Total length for control IN/OUT Transfer */ +/* USBCore.Device.Transfer.Action - USBDCore_Action_Enum STALL, control IN or control OUT */ +/* USBCore.Device.Transfer.CallBack_OUT.func(uPara) Call back function pointer for Control OUT */ +/* USBCore.Device.Transfer.CallBack_OUT.uPara Parameter of Control OUT call back function */ +/* */ +/* USBCore.Info - USBDCore_Info_TypeDef USB Device information */ +/* USBCore.Info.uCurrentConfiguration For Set/GetConfiguration request */ +/* USBCore.Info.uCurrentInterface For Set/GetInterface request */ +/* USBCore.Info.CurrentStatus - USBDCore_Status_Enum Device State */ +/* USBCore.Info.LastStatus - USBDCore_Status_Enum Device State before SUSPEND */ +/* USBCore.Info.CurrentFeature - USBDCore_Feature_TypeDef For Set/ClearFeature and GetStatus request */ +/* USBCore.Info.CurrentFeature.uByte Byte access for CurrentFeature */ +/* USBCore.Info.CurrentFeature.Bits.bRemoteWakeup Remote Wakeup feature */ +/* USBCore.Info.CurrentFeature.Bits.bSelfPowered Self Powered */ +/* USBCore.Info.uIsDiscardClearFeature Discard ClearFeature flag for Mass Storage */ +/* */ +/* USBCore.Class - USBDCore_Class_TypeDef USB Class call back function */ +/* USBCore.Class.CallBack_MainRoutine.func(uPara) Class main routine call back function */ +/* USBCore.Class.CallBack_MainRoutine.uPara Parameter of class main routine */ +/* USBCore.Class.CallBack_Reset.func(uPara) Class RESET call back function */ +/* USBCore.Class.CallBack_Reset.uPara Parameter of RESET call back function */ +/* USBCore.Class.CallBack_StartOfFrame.func(uPara) Class SOF call back function */ +/* USBCore.Class.CallBack_StartOfFrame.uPara Parameter of SOF call back function */ +/* USBCore.Class.CallBack_ClassGetDescriptor(pDev) Class Get Descriptor call back function */ +/* USBCore.Class.CallBack_ClassSetInterface(pDev) Set Interface call back function */ +/* USBCore.Class.CallBack_ClassGetInterface(pDev) Get Interface call back function */ +/* USBCore.Class.CallBack_ClassRequest(pDev) Class Request call back function */ +/* USBCore.Class.CallBack_EPTn[MAX_EP_NUM](EPTn) Endpoint n call back function */ +/* */ +/* USBCore.pDriver USB Device Driver initialization structure */ +/* */ +/* USBCore.Power - USBDCore_Power_TypeDef USB Device Power related call back function */ +/* USBCore.Power.CallBack_Suspend.func(uPara) System low power function for SUSPEND */ +/* USBCore.Power.CallBack_Suspend.uPara Parameter of system low power function */ +/*----------------------------------------------------------------------------------------------------------*/ + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Constant USB Device Core exported constants + * @{ + */ + +/** @defgroup USBDCore_Descriptor Definitions for USB descriptor + * @{ + */ +#define DESC_TYPE_01_DEV (0x1) +#define DESC_TYPE_02_CONFN (0x2) +#define DESC_TYPE_03_STR (0x3) +#define DESC_TYPE_04_INF (0x4) +#define DESC_TYPE_05_EPT (0x5) +#define DESC_TYPE_06_DEV_QLF (0x6) +#define DESC_TYPE_08_INF_PWR (0x8) + +#define DESC_CLASS_00_BY_INF (0x00) +#define DESC_CLASS_01_AUDIO (0x01) +#define DESC_CLASS_02_CDC_CTRL (0x02) +#define DESC_CLASS_03_HID (0x03) +#define DESC_CLASS_05_PHY (0x05) +#define DESC_CLASS_06_STILL_IMG (0x06) +#define DESC_CLASS_07_PRINTER (0x07) +#define DESC_CLASS_08_MASS_STORAGE (0x08) +#define DESC_CLASS_09_HUB (0x09) +#define DESC_CLASS_0A_CDC_DATA (0x0A) +#define DESC_CLASS_0B_SMART_CARD (0x0B) +#define DESC_CLASS_0E_VIDEO (0x0E) +#define DESC_CLASS_0F_PHD (0x0F) +#define DESC_CLASS_FF_VENDOR (0xFF) + +#define DESC_LEN_DEV ((u32)(18)) +#define DESC_LEN_CONFN ((u32)(9)) +#define DESC_LEN_INF ((u32)(9)) +#define DESC_LEN_EPT ((u32)(7)) +/** + * @} + */ + +/** @defgroup USBDCore_Request Definitions for USB Request + * @{ + */ +#define REQ_DIR_00_H2D (0 << 7) +#define REQ_DIR_01_D2H (1 << 7) + +#define REQ_TYPE_00_STD (0 << 5) +#define REQ_TYPE_01_CLS (1 << 5) +#define REQ_TYPE_02_VND (2 << 5) + +#define REQ_REC_00_DEV (0) +#define REQ_REC_01_INF (1) +#define REQ_REC_02_EPT (2) +/** + * @} + */ + +/** + * @brief For USBDCore_EPTReadOUTData function. + */ +#define USB_DISCARD_OUT_DATA (0) + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Macro USB Device Core exported macros + * @{ + */ +#define __DBG_USBPrintf(...) +#define __DBG_USBDump(a, b) + +#if (USBDCORE_DEBUG == 1) + #ifndef RETARGET_IS_USB + extern u32 __DBG_USBCount; + #undef __DBG_USBPrintf + #define __DBG_USBPrintf printf + #if (USBDCORE_DEBUG_DATA == 1) + #undef __DBG_USBDump + void __DBG_USBDump(uc8 *memory, u32 len); + #endif + #endif +#endif + +/** + * @brief Convert Half-Word to Byte for descriptor. + */ +#define DESC_H2B(Val) ((u8)(Val & 0x00FF)), ((u8)((Val & 0xFF00) >> 8)) + +/** + * @brief Padding 0 automatically for String descriptor. + */ +#define DESC_CHAR(c) (c), (0) + +/** + * @brief Calculate String length for String descriptor. + */ +#define DESC_STRLEN(n) (n * 2 + 2) + +/** + * @brief Calculate power for Configuration descriptor. + */ +#define DESC_POWER(mA) (mA / 2) +/** + * @} + */ + +/* Exported functions --------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Functions USB Device Core exported functions + * @{ + */ +#define USBDCore_DeInit API_USB_DEINIT +#define USBDCore_EPTReset API_USB_EPTn_RESET +#define USBDCore_EPTGetBufferLen API_USB_EPTn_GET_BUFFLEN +#define USBDCore_EPTGetTransferCount API_USB_EPTn_GET_CNT +#define USBDCore_EPTSetSTALL API_USB_EPTn_SET_HALT +#define USBDCore_EPTWaitSTALLSent API_USB_EPTn_WAIT_STALL_SENT +#define USBDCore_EPTClearDataToggle API_USB_EPTn_CLR_DTG + +#define USBDCore_EPTWriteINData API_USB_EPTn_WRITE_IN +#define USBDCore_EPTReadOUTData API_USB_EPTn_READ_OUT +#define USBDCore_EPTReadMemory API_USB_EPTn_READ_MEM + +void USBDCore_Init(USBDCore_TypeDef *pCore); +void USBDCore_IRQHandler(USBDCore_TypeDef *pCore); +void USBDCore_MainRoutine(USBDCore_TypeDef *pCore); +u32 USBDCore_IsSuspend(USBDCore_TypeDef *pCore); +u32 USBDCore_GetRemoteWakeUpFeature(USBDCore_TypeDef *pCore); +void USBDCore_TriggerRemoteWakeup(void); +USBDCore_Status_Enum USBDCore_GetStatus(void); + +void USBDCore_EPTReset(USBD_EPTn_Enum USBD_EPTn); +u32 USBDCore_EPTGetBufferLen(USBD_EPTn_Enum USBD_EPTn); +u32 USBDCore_EPTGetTransferCount(USBD_EPTn_Enum USBD_EPTn, USBD_TCR_Enum type); +void USBDCore_EPTSetSTALL(USBD_EPTn_Enum USBD_EPTn); +void USBDCore_EPTWaitSTALLSent(USBD_EPTn_Enum USBD_EPTn); +void USBDCore_EPTClearDataToggle(USBD_EPTn_Enum USBD_EPTn); + +u32 USBDCore_EPTWriteINData(USBD_EPTn_Enum USBD_EPTn, u32 *pFrom, u32 len); +u32 USBDCore_EPTReadOUTData(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +u32 USBDCore_EPTReadMemory(USBD_EPTn_Enum USBD_EPTn, u32 *pTo, u32 len); +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __HT32_USBD_CORE_H -------------------------------------------------------------------------------*/ diff --git a/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c new file mode 100644 index 0000000000..bfc1abbb9c --- /dev/null +++ b/bsp/ht32/libraries/HT32_STD_5xxxx_FWLib/library/HT32_USBD_Library/src/ht32_usbd_core.c @@ -0,0 +1,1037 @@ +/*********************************************************************************************************//** + * @file ht32_usbd_core.c + * @version $Rev:: 3813 $ + * @date $Date:: 2019-05-07 #$ + * @brief The standard protocol related function of HT32 USB Device Library. + ************************************************************************************************************* + * @attention + * + * Firmware Disclaimer Information + * + * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the + * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and + * other intellectual property laws. + * + * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the + * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties + * other than HOLTEK and the customer. + * + * 3. The program technical documentation, including the code, is provided "as is" and for customer reference + * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including + * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including + * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. + * + *

Copyright (C) Holtek Semiconductor Inc. All rights reserved

+ ************************************************************************************************************/ + +/* Includes ------------------------------------------------------------------------------------------------*/ +#include "ht32.h" +#include "ht32_usbd_core.h" + +#ifdef USBD_VENDOR_SUPPORT +#include "ht32_usbd_vendor.c" +#endif + +/** @addtogroup HT32_USBD_Library HT32 USB Device Library + * @{ + */ + +/** @defgroup USBDCore USB Device Core + * @brief USB Device Core standard protocol related function + * @{ + */ + + +/* Private types -------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_TypesDefinitions USB Device Core private types definitions + * @{ + */ +typedef enum +{ + Device = 0, + Interface = 1, + Endpoint = 2, + Other = 3, +} USBDCore_Recipient_Enum; + +typedef enum +{ + ClearFeature = 0, + SetFeature = 1, +} USBDCore_SetClearFeature_Enum; +/** + * @} + */ + +/* Private constants ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Define USB Device Core private definitions + * @{ + */ +/* USBD Debug mode */ +#if (USBDCORE_DEBUG == 1) + #ifdef RETARGET_IS_USB + #warning "USB debug mode can not work when retaget to USB Virtual COM. Turn off automatically." + #undef USBDCORE_DEBUG + #define USBDCORE_DEBUG 0 + #else + u32 __DBG_USBCount; + #warning "USB debug mode has been enabled which degrade the performance." + #warning "After the debug operation, please remember to turn off USB debug mode." + #endif +#endif + +/** @defgroup USBDCore_STD Definition for standard request + * @{ + */ +#define REQ_00_GET_STAT ((u16)(0 << 8)) +#define REQ_01_CLR_FETU ((u16)(1 << 8)) +#define REQ_03_SET_FETU ((u16)(3 << 8)) +#define REQ_05_SET_ADDR ((u16)(5 << 8)) +#define REQ_06_GET_DESC ((u16)(6 << 8)) +#define REQ_07_SET_DESC ((u16)(7 << 8)) +#define REQ_08_GET_CONF ((u16)(8 << 8)) +#define REQ_09_SET_CONF ((u16)(9 << 8)) +#define REQ_10_GET_INF ((u16)(10 << 8)) +#define REQ_11_SET_INF ((u16)(11 << 8)) +#define REQ_12_SYN_FRME ((u16)(12 << 8)) +/** + * @} + */ + +#define DESC_TYPE_01_DEV (0x1) +#define DESC_TYPE_02_CONFN (0x2) +#define DESC_TYPE_03_STR (0x3) +#define USB_NO_DATA (-1) /*!< For Device.Transfer.sByteLength */ +#define BMREQUEST_TYPE_MASK (0x6 << 4) /*!< bmRequestType[6:5] */ +#define USB_FEATURE_REMOTE_WAKEUP (1) + +#define MAX_CONTROL_OUT_SIZE (64) +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------------------------------------*/ +static void _USBDCore_PowerHandler(USBDCore_TypeDef *pCore); +static void _USBDCore_Reset(USBDCore_TypeDef *pCore); +static void _USBDCore_Resume(USBDCore_TypeDef *pCore); +static void _USBDCore_Suspend(USBDCore_TypeDef *pCore); +static void _USBDCore_Setup(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_Request(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_GetStatus(USBDCore_TypeDef *pCore, USBDCore_Recipient_Enum recipient); +static void _USBDCore_Standard_SetClearFeature(USBDCore_TypeDef *pCore, USBDCore_Recipient_Enum recipient, USBDCore_SetClearFeature_Enum type); +static void _USBDCore_Standard_SetAddress(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_GetDescriptor(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_GetConfiguration(USBDCore_TypeDef *pCore); +static void _USBDCore_Standard_SetConfiguration(USBDCore_TypeDef *pCore); +static void _USBDCore_ControlIN(USBDCore_TypeDef *pCore); +static void _USBDCore_ControlOUT(USBDCore_TypeDef *pCore); + +/* Private macro -------------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Macro USB Device Core private macros + * @{ + */ +/** + * @brief Get self powered bit from Device descriptor + */ +#define _GET_SELFPOWERED_FROM_DESC() (((pCore->Device.Desc.pConfnDesc[7]) >> 6) & 0x01) +/** + * @} + */ + +/* Private variables ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Variable USB Device Core private variables + * @{ + */ +USBDCore_TypeDef *pUSBCore; +/** + * @} + */ + + +/* Global Function -----------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Exported_Functions USB Device Core exported functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Core initialization. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +void USBDCore_Init(USBDCore_TypeDef *pCore) +{ + pUSBCore = pCore; + pCore->Info.CurrentStatus = USB_STATE_POWERED; + API_USB_INIT(pCore->pDriver); + __DBG_USBPrintf("\r\n%06ld \r\n", ++__DBG_USBCount); + return; +} + +/*********************************************************************************************************//** + * @brief USB Interrupt Service Routine. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +void USBDCore_IRQHandler(USBDCore_TypeDef *pCore) +{ + u32 USBISRFlag = API_USB_GET_INT(); + u32 USBEPTISRFlag; + USBD_EPTn_Enum EPTn; + + #if (USBDCORE_DEBUG == 1) + u32 USBAddr = HT_USB->DEVAR; + #endif + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB SOF Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_SOF_INT(USBISRFlag)) + { + __DBG_USBPrintf("%06ld SOF[%02d][%02lX]\r\n", ++__DBG_USBCount, pCore->Info.CurrentStatus, USBAddr); + if (pCore->Class.CallBack_StartOfFrame.func != NULL) + { + pCore->Class.CallBack_StartOfFrame.func(pCore->Class.CallBack_StartOfFrame.uPara); + } + API_USB_CLR_SOF_INT(); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB SUSPEND Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_SUSPEND_INT(USBISRFlag)) + { + __DBG_USBPrintf("%06ld SUSPEND[%02d]\r\n", ++__DBG_USBCount, pCore->Info.CurrentStatus); + API_USB_CLR_SUSPEND_INT(); + _USBDCore_Suspend(pCore); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB RESET Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_RESET_INT(USBISRFlag)) + { + if (API_USB_IS_FRES_INT(USBISRFlag)) + { + API_USB_CLR_FRES_INT(); + } + else + { + __DBG_USBPrintf("%06ld RESET[%02d][%02lX]\r\n", ++__DBG_USBCount, pCore->Info.CurrentStatus, USBAddr); + _USBDCore_Reset(pCore); + if (pCore->Class.CallBack_Reset.func != NULL) + { + pCore->Class.CallBack_Reset.func(pCore->Class.CallBack_Reset.uPara); + } + } + API_USB_CLR_RESET_INT(); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB RESUME Interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_RESUME_INT(USBISRFlag)) + { + __DBG_USBPrintf("%06ld RESUME\r\n", ++__DBG_USBCount); + _USBDCore_Resume(pCore); + API_USB_CLR_RESUME_INT(); + } + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB Endpoint 0 interrupt */ + /*--------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_EPTn_INT(USBISRFlag, USBD_EPT0)) + { + USBEPTISRFlag = API_USB_EPTn_GET_INT(USBD_EPT0); + + /*------------------------------------------------------------------------------------------------------*/ + /* Control SETUP Stage */ + /*------------------------------------------------------------------------------------------------------*/ + if (API_USB_IS_SETUP_INT(USBEPTISRFlag)) + { + API_USB_READ_SETUP(&(pCore->Device.Request)); /* Read SETUP Command data from USB Buffer*/ + + __DBG_USBPrintf("%06ld SETUP\t[08]\r\n", ++__DBG_USBCount); + __DBG_USBDump((uc8 *)&(pCore->Device.Request), 8); + + _USBDCore_Setup(pCore); + API_USB_CLR_SETUP_INT(); /* Clear SETUP Interrupt */ + } + + /*------------------------------------------------------------------------------------------------------*/ + /* Control Endpoint 0 IN */ + /*------------------------------------------------------------------------------------------------------*/ + if (API_USB_EPTn_IS_IN_INT(USBEPTISRFlag)) + { + __DBG_USBPrintf("%06ld EP0IN\t[%02ld]", ++__DBG_USBCount, pCore->Device.Transfer.sByteLength); + + _USBDCore_ControlIN(pCore); + API_USB_EPTn_CLR_IN_INT(USBD_EPT0); + } + + /*------------------------------------------------------------------------------------------------------*/ + /* Control Endpoint 0 OUT */ + /*------------------------------------------------------------------------------------------------------*/ + if (API_USB_EPTn_IS_OUT_INT(USBEPTISRFlag)) + { + __DBG_USBPrintf("%06ld EP0OUT\t[%02ld]", ++__DBG_USBCount, pCore->Device.Transfer.sByteLength); + + /*----------------------------------------------------------------------------------------------------*/ + /* Clear interrupt flag before USBDCore_ControlOUT is meaning since USBDCore_ControlOUT clear NAKRX */ + /* bit which will cause another interrupt occur. */ + /*----------------------------------------------------------------------------------------------------*/ + API_USB_EPTn_CLR_OUT_INT(USBD_EPT0); + _USBDCore_ControlOUT(pCore); + } + + /*------------------------------------------------------------------------------------------------------*/ + /* Clear Control Endpoint 0 global interrupt */ + /*------------------------------------------------------------------------------------------------------*/ + API_USB_CLR_EPTn_INT(USBD_EPT0); + + } /* if (API_USB_IS_EP_INT(USBISRFlag, USBD_EPT0)) */ + + + /*--------------------------------------------------------------------------------------------------------*/ + /* USB Endpoint n call back function */ + /*--------------------------------------------------------------------------------------------------------*/ + while ((EPTn = API_USB_GET_EPT_NUM(API_USB_GET_INT())) != USBD_NOEPT) + { + USBEPTISRFlag = API_USB_EPTn_GET_INT((USBD_EPTn_Enum)EPTn); + + if (API_USB_EPTn_IS_INT(USBEPTISRFlag)) + { + API_USB_EPTn_CLR_INT(EPTn); + API_USB_CLR_EPTn_INT(EPTn); + + if (pCore->Class.CallBack_EPTn[EPTn] != NULL) + { + pCore->Class.CallBack_EPTn[EPTn](EPTn); + } + } + } /* while ((EPTn = API_USB_GET_EPTn_NUM(API_USB_GET_INT())) != USBD_NOEPT) */ + + return; +} + +/*********************************************************************************************************//** + * @brief USB Core Main Routine for application. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +void USBDCore_MainRoutine(USBDCore_TypeDef *pCore) +{ + _USBDCore_PowerHandler(pCore); + + /*--------------------------------------------------------------------------------------------------------*/ + /* Class main routine call back function */ + /*--------------------------------------------------------------------------------------------------------*/ + if ((pCore->Class.CallBack_MainRoutine.func != NULL) && (pCore->Info.CurrentStatus == USB_STATE_CONFIGURED)) + { + pCore->Class.CallBack_MainRoutine.func(pCore->Class.CallBack_MainRoutine.uPara); + } + + return; +} + +/*********************************************************************************************************//** + * @brief Return Suspend status + * @param pCore: pointer of USB Device + * @retval TRUE or FALSE + ***********************************************************************************************************/ +u32 USBDCore_IsSuspend(USBDCore_TypeDef *pCore) +{ + return ((pCore->Info.CurrentStatus == USB_STATE_SUSPENDED) ? TRUE : FALSE); +} + +/*********************************************************************************************************//** + * @brief Return remote wake status which set by SET FEATURE standard command + * @param pCore: pointer of USB Device + * @retval TRUE or FALSE + ***********************************************************************************************************/ +u32 USBDCore_GetRemoteWakeUpFeature(USBDCore_TypeDef *pCore) +{ + return (pCore->Info.CurrentFeature.Bits.bRemoteWakeup); +} + +/*********************************************************************************************************//** + * @brief Turn on USB power and remote wakeup the Host + * @retval None + ***********************************************************************************************************/ +void USBDCore_TriggerRemoteWakeup(void) +{ + API_USB_POWER_ON(); /* Turn on USB Power */ + API_USB_REMOTE_WAKEUP(); /* Generate Remote Wakeup request to Host (RESUME) */ + return; +} + +/*********************************************************************************************************//** + * @brief Get USB Device status + * @retval USBDCore_Status_Enum + ***********************************************************************************************************/ +USBDCore_Status_Enum USBDCore_GetStatus(void) +{ + return pUSBCore->Info.CurrentStatus; +} + +/*********************************************************************************************************//** + * @brief Dump memory data for debug purpose. + * @param memory: buffer pointer to dump + * @param len: dump length + * @retval None + ***********************************************************************************************************/ +#if (USBDCORE_DEBUG == 1 && USBDCORE_DEBUG_DATA == 1) +void __DBG_USBDump(uc8 *memory, u32 len) +{ + u32 i; + for (i = 0; i < len; i++) + { + if (i % 8 == 0) + { + if (i != 0) + { + __DBG_USBPrintf("\r\n"); + } + __DBG_USBPrintf("\t\t"); + } + __DBG_USBPrintf("%02X ", *((u8 *)(memory + i))); + } + __DBG_USBPrintf("\r\n"); + + return; +} +#endif +/** + * @} + */ + +/* Private functions ---------------------------------------------------------------------------------------*/ +/** @defgroup USBDCore_Private_Function USB Device Core private functions + * @{ + */ +/*********************************************************************************************************//** + * @brief USB Core Power handler for application. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_PowerHandler(USBDCore_TypeDef *pCore) +{ + API_USB_POWER_UP(pCore->pDriver, pCore->Info.CurrentFeature.Bits.bSelfPowered); + + if (pCore->Info.CurrentStatus == USB_STATE_SUSPENDED) + { + /*------------------------------------------------------------------------------------------------------*/ + /* System Low Power call back function */ + /*------------------------------------------------------------------------------------------------------*/ + if (pCore->Power.CallBack_Suspend.func != NULL) + { + __DBG_USBPrintf("%06ld >LOWPOWER\r\n", ++__DBG_USBCount); + + pCore->Power.CallBack_Suspend.func(pCore->Power.CallBack_Suspend.uPara); + + __DBG_USBPrintf("%06ld pDriver; + + pCore->Device.Transfer.sByteLength = USB_NO_DATA; + pCore->Info.uCurrentConfiguration = 0; + pCore->Info.uCurrentInterface = 0; + pCore->Info.CurrentFeature.Bits.bRemoteWakeup = 0; + pCore->Info.CurrentStatus = USB_STATE_DEFAULT; + pCore->Info.uIsDiscardClearFeature = FALSE; + + API_USB_DEINIT(); + + API_USB_POWER_ON(); + + /* Endpoint 0 initialization */ + API_USB_EPTn_INIT(USBD_EPT0, pCore->pDriver); // To be modify, init from desc + + /* Enable USB interrupt */ + API_USB_ENABLE_INT(pDrv->uInterruptMask); + + return; +} + +/*********************************************************************************************************//** + * @brief USB Resume + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Resume(USBDCore_TypeDef *pCore) +{ + API_USB_POWER_ON(); + pCore->Info.CurrentStatus = pCore->Info.LastStatus; + return; +} + +/*********************************************************************************************************//** + * @brief USB Suspend + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Suspend(USBDCore_TypeDef *pCore) +{ + /*--------------------------------------------------------------------------------------------------------*/ + /* When Device has been suspended, Change CurrentStatus as SUSPEND and then USBDCore_PowerHandler will */ + /* turn off chip power. */ + /*--------------------------------------------------------------------------------------------------------*/ + if (pCore->Info.CurrentStatus >= USB_STATE_POWERED) + { + API_USB_POWER_OFF(); + pCore->Info.LastStatus = pCore->Info.CurrentStatus; + pCore->Info.CurrentStatus = USB_STATE_SUSPENDED; + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Setup Stage + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Setup(USBDCore_TypeDef *pCore) +{ + pCore->Device.Transfer.Action = USB_ACTION_STALL; + pCore->Device.Transfer.sByteLength = 0; + + switch (pCore->Device.Request.bmRequestType & BMREQUEST_TYPE_MASK) + { + /*------------------------------------------------------------------------------------------------------*/ + /* Standard requests */ + /*------------------------------------------------------------------------------------------------------*/ + case REQ_TYPE_00_STD: + { + _USBDCore_Standard_Request(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* Class requests */ + /*------------------------------------------------------------------------------------------------------*/ + case REQ_TYPE_01_CLS: + { + if (pCore->Class.CallBack_ClassRequest != NULL) + { + pCore->Class.CallBack_ClassRequest(&(pCore->Device)); + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* Vendor requests */ + /*------------------------------------------------------------------------------------------------------*/ + case REQ_TYPE_02_VND: + { + if (pCore->Class.CallBack_VendorRequest != NULL) + { + pCore->Class.CallBack_VendorRequest(&(pCore->Device)); + } + /* Add Vendor requests handler here.... */ + #ifdef USBD_VENDOR_SUPPORT + USBDVendor_Request(pCore); + #endif + break; + } + } /* switch (gUSBReq.bmRequestType.byte) */ + + switch (pCore->Device.Transfer.Action) + { + /*------------------------------------------------------------------------------------------------------*/ + /* Control IN */ + /*------------------------------------------------------------------------------------------------------*/ + case USB_ACTION_DATAIN: + { + /*----------------------------------------------------------------------------------------------------*/ + /* When the Control IN length is large than the Host required, transfer the length which specified */ + /* by SETUP Data Packet. */ + /*----------------------------------------------------------------------------------------------------*/ + if (pCore->Device.Transfer.sByteLength > pCore->Device.Request.wLength) + { + pCore->Device.Transfer.sByteLength = pCore->Device.Request.wLength; + } + __DBG_USBPrintf("%06ld EP0IN\t[%02ld]", __DBG_USBCount, pCore->Device.Transfer.sByteLength); + + _USBDCore_ControlIN(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* Control OUT */ + /*------------------------------------------------------------------------------------------------------*/ + case USB_ACTION_DATAOUT: + { + if (pCore->Device.Transfer.sByteLength == 0) + { + API_USB_EPTn_WRITE_IN(USBD_EPT0, (u32 *)0, 0); /* Prepare ZLP ack for Control OUT */ + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* STALL */ + /*------------------------------------------------------------------------------------------------------*/ + default: + { + __DBG_USBPrintf("%06ld EP0 STALL\r\n", __DBG_USBCount); + + API_USB_EPTn_SEND_STALL(USBD_EPT0); + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Stand Request. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_Request(USBDCore_TypeDef *pCore) +{ + u16 USBCmd = *((u16 *)(&(pCore->Device.Request))); + + switch (USBCmd) + { + /*------------------------------------------------------------------------------------------------------*/ + /* | bRequest | Data transfer direction | Type | Recipient | Data */ + /*------------------------------------------------------------------------------------------------------*/ + + /*------------------------------------------------------------------------------------------------------*/ + /* | 00_Get Status | 80_Device-to-Host | 00_Standard Request | 0_Device | 0080h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_00_GET_STAT | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld GET DST\t[%02d]\r\n", __DBG_USBCount, pCore->Info.CurrentFeature.uByte); + _USBDCore_Standard_GetStatus(pCore, Device); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 00_Get Status | 80_Device-to-Host | 00_Standard Request | 1_Interface | 0081h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_00_GET_STAT | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld GET IST\t[%02d]\r\n", __DBG_USBCount, 0); + _USBDCore_Standard_GetStatus(pCore, Interface); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 00_Get Status | 80_Device-to-Host | 00_Standard Request | 2_Endpoint | 0082h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_00_GET_STAT | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_02_EPT): + { + __DBG_USBPrintf("%06ld GET EST\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wIndex); + _USBDCore_Standard_GetStatus(pCore, Endpoint); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 01_Clear Feature | 00_Host-to-Device | 00_Standard Request | 0_Device | 0100h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_01_CLR_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld CLR DFEA\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetClearFeature(pCore, Device, ClearFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 01_Clear Feature | 00_Host-to-Device | 00_Standard Request | 2_Endpoint | 0102h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_01_CLR_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_02_EPT): + { + __DBG_USBPrintf("%06ld CLR EFEA\t[0x%02x]\r\n", __DBG_USBCount, pCore->Device.Request.wIndex); + _USBDCore_Standard_SetClearFeature(pCore, Endpoint, ClearFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 03_Set Feature | 00_Host-to-Device | 00_Standard Request | 0_Device | 0300h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_03_SET_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld SET DFEA\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetClearFeature(pCore, Device, SetFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 03_Set Feature | 00_Host-to-Device | 00_Standard Request | 2_Endpoint | 0302h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_03_SET_FETU | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_02_EPT): + { + __DBG_USBPrintf("%06ld SET EFEA\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wIndex); + _USBDCore_Standard_SetClearFeature(pCore, Endpoint, SetFeature); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 05_Set Address | 00_Host-to-Device | 00_Standard Request | 0_Device | 0500h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_05_SET_ADDR | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld SET ADDR\t[%02d]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetAddress(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 06_Get Descriptor | 80_Device-to-Host | 00_Standard Request | 0_Device | 0680h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_06_GET_DESC | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld GET DDESC\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueH); + _USBDCore_Standard_GetDescriptor(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 06_Get Descriptor | 80_Device-to-Host | 00_Standard Request | 1_Interface | 0681h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_06_GET_DESC | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld GET IDESC\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueH); + if (pCore->Class.CallBack_ClassGetDescriptor != NULL) + { + pCore->Class.CallBack_ClassGetDescriptor((USBDCore_Device_TypeDef *)&(pCore->Device)); + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 08_Get Configuration | 80_Host-to-Device | 00_Standard Request | 0_Device | 0880h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_08_GET_CONF | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld GET CONF\t[%02X]\r\n", __DBG_USBCount, pCore->Info.uCurrentConfiguration); + _USBDCore_Standard_GetConfiguration(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 09_Set Configuration | 00_Host-to-Device | 00_Standard Request | 0_Device | 0900h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_09_SET_CONF | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_00_DEV): + { + __DBG_USBPrintf("%06ld SET CONF\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + _USBDCore_Standard_SetConfiguration(pCore); + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 11_Set Interface | 00_Host-to-Device | 00_Standard Request | 1_Interface | 0B01h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_11_SET_INF | REQ_DIR_00_H2D | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld SET INF\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + if (pCore->Class.CallBack_ClassSetInterface != NULL) + { + pCore->Class.CallBack_ClassSetInterface((USBDCore_Device_TypeDef *)&(pCore->Device)); + } + break; + } + /*------------------------------------------------------------------------------------------------------*/ + /* | 10_Get Interface | 80_Device-to-Host | 00_Standard Request | 1_Interface | 0A81h */ + /*------------------------------------------------------------------------------------------------------*/ + case (REQ_10_GET_INF | REQ_DIR_01_D2H | REQ_TYPE_00_STD | REQ_REC_01_INF): + { + __DBG_USBPrintf("%06ld GET INF\t[%02X]\r\n", __DBG_USBCount, pCore->Device.Request.wValueL); + if (pCore->Class.CallBack_ClassGetInterface != NULL) + { + pCore->Class.CallBack_ClassGetInterface((USBDCore_Device_TypeDef *)&(pCore->Device)); + } + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - GET_STATUS. + * @param pCore: pointer of USB Device + * @param recipient: Recipient + * @arg Device: 0 + * @arg Interface: 1 + * @arg Endpoint: 2 + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_GetStatus(USBDCore_TypeDef *pCore, USBDCore_Recipient_Enum recipient) +{ + pCore->Device.Transfer.uBuffer[1] = 0; + switch (recipient) + { + case Device: + { + pCore->Device.Transfer.uBuffer[0] = pCore->Info.CurrentFeature.uByte; + break; + } + case Interface: + { + pCore->Device.Transfer.uBuffer[0] = 0; + break; + } + case Endpoint: + { + pCore->Device.Transfer.uBuffer[0] = API_USB_EPTn_GET_HALT((USBD_EPTn_Enum)(pCore->Device.Request.wIndex & 0xF)); + break; + } + default: + { + return; + } + } + + pCore->Device.Transfer.pData = (uc8 *)&(pCore->Device.Transfer.uBuffer); + pCore->Device.Transfer.sByteLength = 2; + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - SET_FEATURE / CLEAR_FEATURE. + * @param pCore: pointer of USB Device + * @param recipient: Recipient + * @arg Device: 0 + * @arg Interface: 1 + * @arg Endpoint: 2 + * @param type: + * @arg ClearFeature: 0 + @arg SerFeature: 1 + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_SetClearFeature(USBDCore_TypeDef *pCore, + USBDCore_Recipient_Enum recipient, + USBDCore_SetClearFeature_Enum type) +{ + u32 i; + switch (recipient) + { + case Device: + { + if (pCore->Device.Request.wValueL == USB_FEATURE_REMOTE_WAKEUP) + { + pCore->Info.CurrentFeature.Bits.bRemoteWakeup = type; + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + } + break; + } + case Endpoint: + { + i = pCore->Device.Request.wIndex & 0xF; + if (i != 0) + { + if (type == ClearFeature) + { + if (pCore->Info.uIsDiscardClearFeature == FALSE) + { + API_USB_EPTn_CLR_HALT((USBD_EPTn_Enum)i); + API_USB_EPTn_CLR_DTG((USBD_EPTn_Enum)i); + } + } + else + { + API_USB_EPTn_SET_HALT((USBD_EPTn_Enum)i); + } + } + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + break; + } + default: + { + break; + } + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - SET_ADDRESS. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_SetAddress(USBDCore_TypeDef *pCore) +{ + API_USB_SET_ADDR(pCore->Device.Request.wValueL); + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + pCore->Info.CurrentStatus = USB_STATE_ADDRESS; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - GET_DESCRIPTOR. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_GetDescriptor(USBDCore_TypeDef *pCore) +{ + u32 value = pCore->Device.Request.wValueH; + uc8 *pTemp; + + switch (value) + { + case DESC_TYPE_01_DEV: + { + pCore->Device.Transfer.pData = pCore->Device.Desc.pDeviceDesc; + pCore->Device.Transfer.sByteLength = *(pCore->Device.Desc.pDeviceDesc); + pCore->Device.Transfer.Action= USB_ACTION_DATAIN; + break; + } + case DESC_TYPE_02_CONFN: + { + pCore->Device.Transfer.pData = pCore->Device.Desc.pConfnDesc; + pCore->Device.Transfer.sByteLength = *(u16 *)((pCore->Device.Desc.pConfnDesc) + 2); + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + break; + } + case DESC_TYPE_03_STR: + { + value = pCore->Device.Request.wValueL; + if (value < pCore->Device.Desc.uStringDescNumber) + { + if (*(pCore->Device.Desc.ppStringDesc + value) != NULL) + { + pTemp = *(pCore->Device.Desc.ppStringDesc + value); + pCore->Device.Transfer.pData = (uc8 *)(pTemp); + pCore->Device.Transfer.sByteLength = *(pTemp); + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + } + } + break; + } + } + + #ifdef USBD_VENDOR_SUPPORT + USBDVendor_StandardGetDescriptor(pCore); + #endif + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - GET_CONFIGURATION. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_GetConfiguration(USBDCore_TypeDef *pCore) +{ + pCore->Device.Transfer.pData = &(pCore->Info.uCurrentConfiguration); + pCore->Device.Transfer.sByteLength = 1; + pCore->Device.Transfer.Action= USB_ACTION_DATAIN; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Standard Request - SET_CONFIGURATION. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_Standard_SetConfiguration(USBDCore_TypeDef *pCore) +{ + u32 i; + + pCore->Info.uCurrentConfiguration = pCore->Device.Request.wValueL; + pCore->Device.Transfer.Action= USB_ACTION_DATAIN; + + /* Endpoint n settings */ + for (i = 1; i < MAX_EP_NUM; i++) + { + API_USB_EPTn_INIT((USBD_EPTn_Enum)i, pCore->pDriver); // To be modify, init from desc + } + + pCore->Info.CurrentStatus = USB_STATE_CONFIGURED; + + return; +} + +/*********************************************************************************************************//** + * @brief USB Control IN transfer. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_ControlIN(USBDCore_TypeDef *pCore) +{ + s32 EP0INLen = API_USB_GET_CTRL_IN_LEN(); + u32 len; + + if (pCore->Device.Transfer.sByteLength != USB_NO_DATA && pCore->Device.Transfer.Action == USB_ACTION_DATAIN) + { + if (pCore->Device.Transfer.sByteLength >= EP0INLen) + { + len = EP0INLen; + pCore->Device.Transfer.sByteLength -= len; + } + else + { + len = pCore->Device.Transfer.sByteLength; + pCore->Device.Transfer.sByteLength = USB_NO_DATA; + pCore->Device.Transfer.Action = USB_ACTION_DATAOUT; + } + + __DBG_USBPrintf("[%02ld]\r\n", len); + __DBG_USBDump((uc8 *)pCore->Device.Transfer.pData, len); + + API_USB_EPTn_WRITE_IN(USBD_EPT0, (u32 *)pCore->Device.Transfer.pData, len); + pCore->Device.Transfer.pData = pCore->Device.Transfer.pData + len; + } + else + { + __DBG_USBPrintf("[-1]\r\n"); + } + + return; +} + +/*********************************************************************************************************//** + * @brief USB Control OUT transfer. + * @param pCore: pointer of USB Device + * @retval None + ***********************************************************************************************************/ +static void _USBDCore_ControlOUT(USBDCore_TypeDef *pCore) +{ + u32 len; + + if (pCore->Device.Transfer.sByteLength != USB_NO_DATA && pCore->Device.Transfer.Action == USB_ACTION_DATAOUT) + { + len = API_USB_EPTn_READ_OUT(USBD_EPT0, (u32 *)pCore->Device.Transfer.pData, MAX_CONTROL_OUT_SIZE); + + __DBG_USBPrintf("[%02ld]\r\n", len); + __DBG_USBDump((uc8 *)pCore->Device.Transfer.pData, len); + + pCore->Device.Transfer.pData = pCore->Device.Transfer.pData + len; + pCore->Device.Transfer.sByteLength -= len; + + if (pCore->Device.Transfer.sByteLength == 0) + { + pCore->Device.Transfer.Action = USB_ACTION_DATAIN; + if (pCore->Device.Transfer.CallBack_OUT.func != NULL) + { + pCore->Device.Transfer.CallBack_OUT.func(pCore->Device.Transfer.CallBack_OUT.uPara); + pCore->Device.Transfer.CallBack_OUT.func = NULL; + } + pCore->Device.Transfer.sByteLength = USB_NO_DATA; + API_USB_EPTn_WRITE_IN(USBD_EPT0, (u32 *)0, 0); + } + } + else + { + __DBG_USBPrintf("[-1]\r\n"); + } + + return; +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ diff --git a/bsp/ht32/libraries/Kconfig b/bsp/ht32/libraries/Kconfig new file mode 100644 index 0000000000..80395cb727 --- /dev/null +++ b/bsp/ht32/libraries/Kconfig @@ -0,0 +1,12 @@ +config SOC_FAMILY_HT32 + bool + +config SOC_SERIES_HT32F5 + bool + select ARCH_ARM_CORTEX_M0 + select SOC_FAMILY_HT32 + +config SOC_SERIES_HT32F1 + bool + select ARCH_ARM_CORTEX_M3 + select SOC_FAMILY_HT32 diff --git a/bsp/ht32/libraries/ht32_drivers/SConscript b/bsp/ht32/libraries/ht32_drivers/SConscript new file mode 100644 index 0000000000..10c92e8492 --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/SConscript @@ -0,0 +1,37 @@ +#导入其他模块中的变量 +Import('RTT_ROOT') +Import('rtconfig') + +#导入使用到的模块 +from building import * + +#获取当前目录的路径 +cwd = GetCurrentDir() + +#创建一个列表,用于保存需要使用到的C文件路径 +src = Split(""" +drv_common.c +""") +#drv_common.c +#根据宏定义来对需要用到的C文件进行裁剪 +if GetDepend(['BSP_USING_GPIO']): + src += ['drv_gpio.c'] + +if GetDepend(['BSP_USING_UART']): + src += ['drv_usart.c'] + +if GetDepend(['BSP_USING_SPI']): + src += ['drv_spi.c'] + +if GetDepend(['BSP_USING_I2C']): + src += ['drv_i2c.c'] + +#创建一个列表,用于保存需要包含的H文件路径 +path = [cwd] + +#创建一个组别 +group = DefineGroup('Drivers', src ,depend = [''], CPPPATH = path) + +#返回创建好的组别 +Return('group') + diff --git a/bsp/ht32/libraries/ht32_drivers/drv_common.c b/bsp/ht32/libraries/ht32_drivers/drv_common.c new file mode 100644 index 0000000000..1bdb6a36e1 --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_common.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include +#include "drv_common.h" +#ifdef RT_USING_SERIAL + #include "drv_usart.h" +#endif + +#ifdef RT_USING_FINSH +#include +static void reboot(uint8_t argc, char **argv) +{ + rt_hw_cpu_reset(); +} +MSH_CMD_EXPORT(reboot, Reboot System); +#endif /* RT_USING_FINSH */ + +/* SysTick configuration */ +void rt_hw_systick_init(void) +{ + SYSTICK_ClockSourceConfig(SYSTICK_SRC_STCLK); + SYSTICK_SetReloadValue(SystemCoreClock / 8 / RT_TICK_PER_SECOND); + SYSTICK_IntConfig(ENABLE); + SYSTICK_CounterCmd(SYSTICK_COUNTER_CLEAR); + SYSTICK_CounterCmd(SYSTICK_COUNTER_ENABLE); +} + +/* This is the timer interrupt service routine */ +void SysTick_Handler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + + rt_tick_increase(); + + /* leave interrupt */ + rt_interrupt_leave(); +} + +/* This function is executed in case of error occurrence */ +void _Error_Handler(char *s, int num) +{ + /* User can add his own implementation to report the error return state */ + LOG_E("Error_Handler at file:%s num:%d", s, num); + while (1) + { + } +} + +/* This function will initial HT32 board */ +void rt_hw_board_init(void) +{ + /* Configure the System clock */ + rt_hw_board_clock_init(); + + /* Configure the SysTick */ + rt_hw_systick_init(); + + /* heap initialization */ +#ifdef RT_USING_HEAP + rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); +#endif + + /* board underlying hardware initialization */ +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif + + /* set the shell console output device */ +#ifdef RT_USING_CONSOLE + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); +#endif + +} diff --git a/bsp/ht32/libraries/ht32_drivers/drv_common.h b/bsp/ht32/libraries/ht32_drivers/drv_common.h new file mode 100644 index 0000000000..f35cb885a6 --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_common.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __DRV_COMMON_H__ +#define __DRV_COMMON_H__ + +#include +#include +#ifdef RT_USING_DEVICE + #include +#endif +#include "board.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _Error_Handler(char *s, int num); + +#ifndef Error_Handler +#define Error_Handler() _Error_Handler(__FILE__, __LINE__) +#endif + +#define DMA_NOT_AVAILABLE ((DMA_INSTANCE_TYPE *)0xFFFFFFFFU) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/bsp/ht32/libraries/ht32_drivers/drv_gpio.c b/bsp/ht32/libraries/ht32_drivers/drv_gpio.c new file mode 100644 index 0000000000..5df27aad7b --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_gpio.c @@ -0,0 +1,910 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include "drv_gpio.h" + +#ifdef RT_USING_PIN + +#define __HT32_PIN(index, gpio, pin) \ + { \ + index, HT_GPIO##gpio, GPIO_PIN_##pin \ + } + +struct pin_index +{ + int index; + HT_GPIO_TypeDef *gpio; + uint32_t pin; +}; + +struct pin_irq_map +{ + rt_uint16_t pinbit; + IRQn_Type irqno; +}; + +static const struct pin_index pins[] = +{ +#if defined(HT_GPIOA) + __HT32_PIN(0, A, 0), + __HT32_PIN(1, A, 1), + __HT32_PIN(2, A, 2), + __HT32_PIN(3, A, 3), + __HT32_PIN(4, A, 4), + __HT32_PIN(5, A, 5), + __HT32_PIN(6, A, 6), + __HT32_PIN(7, A, 7), + __HT32_PIN(8, A, 8), + __HT32_PIN(9, A, 9), + __HT32_PIN(10, A, 10), + __HT32_PIN(11, A, 11), + __HT32_PIN(12, A, 12), + __HT32_PIN(13, A, 13), + __HT32_PIN(14, A, 14), + __HT32_PIN(15, A, 15), +#if defined(HT_GPIOB) + __HT32_PIN(16, B, 0), + __HT32_PIN(17, B, 1), + __HT32_PIN(18, B, 2), + __HT32_PIN(19, B, 3), + __HT32_PIN(20, B, 4), + __HT32_PIN(21, B, 5), + __HT32_PIN(22, B, 6), + __HT32_PIN(23, B, 7), + __HT32_PIN(24, B, 8), + __HT32_PIN(25, B, 9), + __HT32_PIN(26, B, 10), + __HT32_PIN(27, B, 11), + __HT32_PIN(28, B, 12), + __HT32_PIN(29, B, 13), + __HT32_PIN(30, B, 14), + __HT32_PIN(31, B, 15), +#if defined(HT_GPIOC) + __HT32_PIN(32, C, 0), + __HT32_PIN(33, C, 1), + __HT32_PIN(34, C, 2), + __HT32_PIN(35, C, 3), + __HT32_PIN(36, C, 4), + __HT32_PIN(37, C, 5), + __HT32_PIN(38, C, 6), + __HT32_PIN(39, C, 7), + __HT32_PIN(40, C, 8), + __HT32_PIN(41, C, 9), + __HT32_PIN(42, C, 10), + __HT32_PIN(43, C, 11), + __HT32_PIN(44, C, 12), + __HT32_PIN(45, C, 13), + __HT32_PIN(46, C, 14), + __HT32_PIN(47, C, 15), +#if defined(HT_GPIOD) + __HT32_PIN(48, D, 0), + __HT32_PIN(49, D, 1), + __HT32_PIN(50, D, 2), + __HT32_PIN(51, D, 3), + __HT32_PIN(52, D, 4), + __HT32_PIN(53, D, 5), + __HT32_PIN(54, D, 6), + __HT32_PIN(55, D, 7), + __HT32_PIN(56, D, 8), + __HT32_PIN(57, D, 9), + __HT32_PIN(58, D, 10), + __HT32_PIN(59, D, 11), + __HT32_PIN(60, D, 12), + __HT32_PIN(61, D, 13), + __HT32_PIN(62, D, 14), + __HT32_PIN(63, D, 15), +#if defined(HT_GPIOE) + __HT32_PIN(64, E, 0), + __HT32_PIN(65, E, 1), + __HT32_PIN(66, E, 2), + __HT32_PIN(67, E, 3), + __HT32_PIN(68, E, 4), + __HT32_PIN(69, E, 5), + __HT32_PIN(70, E, 6), + __HT32_PIN(71, E, 7), + __HT32_PIN(72, E, 8), + __HT32_PIN(73, E, 9), + __HT32_PIN(74, E, 10), + __HT32_PIN(75, E, 11), + __HT32_PIN(76, E, 12), + __HT32_PIN(77, E, 13), + __HT32_PIN(78, E, 14), + __HT32_PIN(79, E, 15), +#if defined(HT_GPIOF) + __HT32_PIN(80, F, 0), + __HT32_PIN(81, F, 1), + __HT32_PIN(82, F, 2), + __HT32_PIN(83, F, 3), + __HT32_PIN(84, F, 4), + __HT32_PIN(85, F, 5), + __HT32_PIN(86, F, 6), + __HT32_PIN(87, F, 7), + __HT32_PIN(88, F, 8), + __HT32_PIN(89, F, 9), + __HT32_PIN(90, F, 10), + __HT32_PIN(91, F, 11), + __HT32_PIN(92, F, 12), + __HT32_PIN(93, F, 13), + __HT32_PIN(94, F, 14), + __HT32_PIN(95, F, 15), +#endif /* defined(HT_GPIOF) */ +#endif /* defined(HT_GPIOE) */ +#endif /* defined(HT_GPIOD) */ +#endif /* defined(HT_GPIOC) */ +#endif /* defined(HT_GPIOB) */ +#endif /* defined(HT_GPIOA) */ +}; + +static const struct pin_irq_map pin_irq_map[] = +{ + {GPIO_PIN_0, EXTI0_IRQn}, + {GPIO_PIN_1, EXTI1_IRQn}, + {GPIO_PIN_2, EXTI2_IRQn}, + {GPIO_PIN_3, EXTI3_IRQn}, + {GPIO_PIN_4, EXTI4_IRQn}, + {GPIO_PIN_5, EXTI5_IRQn}, + {GPIO_PIN_6, EXTI6_IRQn}, + {GPIO_PIN_7, EXTI7_IRQn}, + {GPIO_PIN_8, EXTI8_IRQn}, + {GPIO_PIN_9, EXTI9_IRQn}, + {GPIO_PIN_10, EXTI10_IRQn}, + {GPIO_PIN_11, EXTI11_IRQn}, + {GPIO_PIN_12, EXTI12_IRQn}, + {GPIO_PIN_13, EXTI13_IRQn}, + {GPIO_PIN_14, EXTI14_IRQn}, + {GPIO_PIN_15, EXTI15_IRQn}, +}; + +static struct rt_pin_irq_hdr pin_irq_hdr_tab[] = +{ + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, + {-1, 0, RT_NULL, RT_NULL}, +}; + +#define ITEM_NUM(items) sizeof(items) / sizeof(items[0]) + +static const struct pin_index *get_pin(rt_uint8_t pin) +{ + const struct pin_index *index; + + if (pin < ITEM_NUM(pins)) + { + index = &pins[pin]; + if (index->index == -1) + index = RT_NULL; + } + else + { + index = RT_NULL; + } + return index; +} + +static void ht32_pin_mode(rt_device_t dev, rt_base_t pin, rt_uint8_t mode) +{ + const struct pin_index *index; + index = get_pin(pin); + if (index == RT_NULL) + { + return; + } + + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + if ((index->gpio) == HT_GPIOA) + CKCUClock.Bit.PA = 1; + else if ((index->gpio) == HT_GPIOB) + CKCUClock.Bit.PB = 1; +#if defined(HT_GPIOC) + else if ((index->gpio) == HT_GPIOC) + CKCUClock.Bit.PC = 1; +#endif +#if defined(HT_GPIOD) + else if ((index->gpio) == HT_GPIOD) + CKCUClock.Bit.PD = 1; +#endif +#if defined(HT_GPIOE) + else if ((index->gpio) == HT_GPIOE) + CKCUClock.Bit.PE = 1; +#endif +#if defined(HT_GPIOF) + else if ((index->gpio) == HT_GPIOF) + CKCUClock.Bit.PF = 1; +#endif + CKCUClock.Bit.AFIO = 1; + CKCUClock.Bit.BKP = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + if ((index->gpio) == HT_GPIOA) + AFIO_GPxConfig(GPIO_PA, index->pin, AFIO_MODE_1); + else if ((index->gpio) == HT_GPIOB) + AFIO_GPxConfig(GPIO_PB, index->pin, AFIO_MODE_1); +#if defined(HT_GPIOC) + else if ((index->gpio) == HT_GPIOC) + AFIO_GPxConfig(GPIO_PC, index->pin, AFIO_MODE_1); +#endif +#if defined(HT_GPIOD) + else if ((index->gpio) == HT_GPIOD) + AFIO_GPxConfig(GPIO_PD, index->pin, AFIO_MODE_1); +#endif +#if defined(HT_GPIOE) + else if ((index->gpio) == HT_GPIOE) + AFIO_GPxConfig(GPIO_PE, index->pin, AFIO_MODE_1); +#endif +#if defined(HT_GPIOF) + else if ((index->gpio) == HT_GPIOF) + AFIO_GPxConfig(GPIO_PF, index->pin, AFIO_MODE_1); +#endif + + switch (mode) + { + case PIN_MODE_OUTPUT: + /* output setting */ + GPIO_DirectionConfig(index->gpio, index->pin, GPIO_DIR_OUT); + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_DISABLE); + break; + case PIN_MODE_OUTPUT_OD: + /* output setting: od. */ + GPIO_DirectionConfig(index->gpio, index->pin, GPIO_DIR_OUT); + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_DISABLE); + break; + case PIN_MODE_INPUT: + /* input setting: not pull. */ + GPIO_DirectionConfig(index->gpio, index->pin, GPIO_DIR_IN); + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_DISABLE); + GPIO_InputConfig(index->gpio, index->pin, ENABLE); + break; + case PIN_MODE_INPUT_PULLUP: + /* input setting: pull up. */ + GPIO_DirectionConfig(index->gpio, index->pin, GPIO_DIR_IN); + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_UP); + GPIO_InputConfig(index->gpio, index->pin, ENABLE); + break; + case PIN_MODE_INPUT_PULLDOWN: + /* input setting: pull down. */ + GPIO_DirectionConfig(index->gpio, index->pin, GPIO_DIR_IN); + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_DOWN); + GPIO_InputConfig(index->gpio, index->pin, ENABLE); + break; + default: + break; + } +} + +static void ht32_pin_write(rt_device_t dev, rt_base_t pin, rt_uint8_t value) +{ + const struct pin_index *index; + + index = get_pin(pin); + if (index == RT_NULL) + { + return; + } + if (value == PIN_LOW) + { + GPIO_ClearOutBits(index->gpio, index->pin); + } + else + { + GPIO_SetOutBits(index->gpio, index->pin); + } +} + +static rt_ssize_t ht32_pin_read(rt_device_t dev, rt_base_t pin) +{ + int value; + const struct pin_index *index; + value = PIN_LOW; + + index = get_pin(pin); + if (index == RT_NULL) + { + return value; + } + value = GPIO_ReadInBit(index->gpio, index->pin); + return value; +} + +rt_inline rt_int32_t bit2bitno(rt_uint32_t bit) +{ + rt_uint8_t i; + for (i = 0; i < 32; i++) + { + if ((0x01 << i) == bit) + { + return i; + } + } + return -1; +} + +rt_inline const struct pin_irq_map *get_pin_irq_map(rt_uint32_t pinbit) +{ + rt_int32_t mapindex = bit2bitno(pinbit); + if (mapindex < 0 || mapindex >= ITEM_NUM(pin_irq_map)) + { + return RT_NULL; + } + return &pin_irq_map[mapindex]; +} + +static rt_err_t ht32_pin_attach_irq(struct rt_device *device, + rt_base_t pin, + rt_uint8_t mode, + void (*hdr)(void *args), + void *args) +{ + const struct pin_index *index; + rt_base_t level; + rt_int32_t hdr_index = -1; + + index = get_pin(pin); + if (index == RT_NULL) + { + return RT_ERROR; + } + + hdr_index = bit2bitno(index->pin); + + if (hdr_index < 0 || hdr_index >= ITEM_NUM(pin_irq_map)) + { + return RT_ERROR; + } + + level = rt_hw_interrupt_disable(); + if (pin_irq_hdr_tab[hdr_index].pin == pin && + pin_irq_hdr_tab[hdr_index].hdr == hdr && + pin_irq_hdr_tab[hdr_index].mode == mode && + pin_irq_hdr_tab[hdr_index].args == args) + { + rt_hw_interrupt_enable(level); + return RT_EOK; + } + if (pin_irq_hdr_tab[hdr_index].pin != -1) + { + rt_hw_interrupt_enable(level); + return RT_ERROR; + } + pin_irq_hdr_tab[hdr_index].pin = pin; + pin_irq_hdr_tab[hdr_index].hdr = hdr; + pin_irq_hdr_tab[hdr_index].mode = mode; + pin_irq_hdr_tab[hdr_index].args = args; + rt_hw_interrupt_enable(level); + + return RT_EOK; +} + +static rt_err_t ht32_pin_detach_irq(struct rt_device *device, rt_base_t pin) +{ + const struct pin_index *index; + rt_base_t level; + rt_int32_t hdr_index = -1; + + index = get_pin(pin); + if (index == RT_NULL) + { + return RT_ERROR; + } + + hdr_index = bit2bitno(index->pin); + if (hdr_index < 0 || hdr_index >= ITEM_NUM(pin_irq_map)) + { + return RT_ERROR; + } + + level = rt_hw_interrupt_disable(); + if (pin_irq_hdr_tab[hdr_index].pin == -1) + { + rt_hw_interrupt_enable(level); + return RT_EOK; + } + pin_irq_hdr_tab[hdr_index].pin = -1; + pin_irq_hdr_tab[hdr_index].hdr = RT_NULL; + pin_irq_hdr_tab[hdr_index].mode = 0; + pin_irq_hdr_tab[hdr_index].args = RT_NULL; + rt_hw_interrupt_enable(level); + + return RT_EOK; +} + +static rt_err_t ht32_pin_irq_enable(struct rt_device *device, rt_base_t pin, rt_uint8_t enabled) +{ + const struct pin_index *index; + const struct pin_irq_map *irqmap; + rt_base_t level; + rt_int32_t hdr_index = -1; + EXTI_InitTypeDef EXTI_InitStruct; + + index = get_pin(pin); + if (index == RT_NULL) + { + return RT_ERROR; + } + if (enabled == PIN_IRQ_ENABLE) + { + hdr_index = bit2bitno(index->pin); + if (hdr_index < 0 || hdr_index >= ITEM_NUM(pin_irq_map)) + { + return RT_ERROR; + } + + level = rt_hw_interrupt_disable(); + + if (pin_irq_hdr_tab[hdr_index].pin == -1) + { + rt_hw_interrupt_enable(level); + return RT_ERROR; + } + + irqmap = &pin_irq_map[hdr_index]; + + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + CKCUClock.Bit.AFIO = 1; + CKCUClock.Bit.EXTI = 1; + + if ((index->gpio) == HT_GPIOA) + CKCUClock.Bit.PA = 1; + else if ((index->gpio) == HT_GPIOB) + CKCUClock.Bit.PB = 1; +#if defined(HT_GPIOC) + else if ((index->gpio) == HT_GPIOC) + CKCUClock.Bit.PC = 1; +#endif +#if defined(HT_GPIOD) + else if ((index->gpio) == HT_GPIOD) + CKCUClock.Bit.PD = 1; +#endif +#if defined(HT_GPIOE) + else if ((index->gpio) == HT_GPIOE) + CKCUClock.Bit.PE = 1; +#endif +#if defined(HT_GPIOF) + else if ((index->gpio) == HT_GPIOF) + CKCUClock.Bit.PF = 1; +#endif + + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + if ((index->gpio) == HT_GPIOA) + { + AFIO_GPxConfig(GPIO_PA, index->pin, AFIO_MODE_1); + GPIO_InputConfig(HT_GPIOA, index->pin, ENABLE); + AFIO_EXTISourceConfig(hdr_index, AFIO_ESS_PA); + } + else if ((index->gpio) == HT_GPIOB) + { + AFIO_GPxConfig(GPIO_PB, index->pin, AFIO_MODE_1); + GPIO_InputConfig(HT_GPIOB, index->pin, ENABLE); + AFIO_EXTISourceConfig(hdr_index, AFIO_ESS_PB); + } +#if defined(HT_GPIOC) + else if ((index->gpio) == HT_GPIOC) + { + AFIO_GPxConfig(GPIO_PC, index->pin, AFIO_MODE_1); + GPIO_InputConfig(HT_GPIOC, index->pin, ENABLE); + AFIO_EXTISourceConfig(hdr_index, AFIO_ESS_PC); + } +#endif +#if defined(HT_GPIOD) + else if ((index->gpio) == HT_GPIOD) + { + AFIO_GPxConfig(GPIO_PD, index->pin, AFIO_MODE_1); + GPIO_InputConfig(HT_GPIOD, index->pin, ENABLE); + AFIO_EXTISourceConfig(hdr_index, AFIO_ESS_PD); + } +#endif +#if defined(HT_GPIOE) + else if ((index->gpio) == HT_GPIOE) + { + AFIO_GPxConfig(GPIO_PE, index->pin, AFIO_MODE_1); + GPIO_InputConfig(HT_GPIOE, index->pin, ENABLE); + AFIO_EXTISourceConfig(hdr_index, AFIO_ESS_PE); + } +#endif +#if defined(HT_GPIOF) + else if ((index->gpio) == HT_GPIOF) + { + AFIO_GPxConfig(GPIO_PF, index->pin, AFIO_MODE_1); + GPIO_InputConfig(HT_GPIOF, index->pin, ENABLE); + AFIO_EXTISourceConfig(hdr_index, AFIO_ESS_PF); + } +#endif + + switch (pin_irq_hdr_tab[hdr_index].mode) + { + case PIN_IRQ_MODE_RISING: + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_DOWN); + EXTI_InitStruct.EXTI_IntType = EXTI_POSITIVE_EDGE; + break; + case PIN_IRQ_MODE_FALLING: + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_UP); + EXTI_InitStruct.EXTI_IntType = EXTI_NEGATIVE_EDGE; + break; + case PIN_IRQ_MODE_RISING_FALLING: + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_DISABLE); + EXTI_InitStruct.EXTI_IntType = EXTI_BOTH_EDGE; + break; + case PIN_IRQ_MODE_HIGH_LEVEL: + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_DOWN); + EXTI_InitStruct.EXTI_IntType = EXTI_HIGH_LEVEL; + break; + case PIN_IRQ_MODE_LOW_LEVEL: + GPIO_PullResistorConfig(index->gpio, index->pin, GPIO_PR_UP); + EXTI_InitStruct.EXTI_IntType = EXTI_LOW_LEVEL; + break; + default: + rt_hw_interrupt_enable(level); + return RT_ERROR; + } + + EXTI_InitStruct.EXTI_Channel = hdr_index; + + EXTI_InitStruct.EXTI_Debounce = EXTI_DEBOUNCE_DISABLE; + EXTI_InitStruct.EXTI_DebounceCnt = 0; + EXTI_Init(&EXTI_InitStruct); + + EXTI_IntConfig(hdr_index, ENABLE); + + NVIC_EnableIRQ((irqmap->irqno)); + rt_hw_interrupt_enable(level); + } + + else if (enabled == PIN_IRQ_DISABLE) + { + irqmap = get_pin_irq_map(index->pin); + if (irqmap == RT_NULL) + { + return RT_ERROR; + } + if ((irqmap->irqno) == EXTI0_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_0, DISABLE); + else if ((irqmap->irqno) == EXTI1_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_1, DISABLE); + else if ((irqmap->irqno) == EXTI2_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_2, DISABLE); + else if ((irqmap->irqno) == EXTI3_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_3, DISABLE); + else if ((irqmap->irqno) == EXTI4_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_4, DISABLE); + else if ((irqmap->irqno) == EXTI5_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_5, DISABLE); + else if ((irqmap->irqno) == EXTI6_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_6, DISABLE); + else if ((irqmap->irqno) == EXTI7_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_7, DISABLE); + else if ((irqmap->irqno) == EXTI8_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_8, DISABLE); + else if ((irqmap->irqno) == EXTI9_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_9, DISABLE); + else if ((irqmap->irqno) == EXTI10_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_10, DISABLE); + else if ((irqmap->irqno) == EXTI11_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_11, DISABLE); + else if ((irqmap->irqno) == EXTI12_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_12, DISABLE); + else if ((irqmap->irqno) == EXTI13_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_13, DISABLE); + else if ((irqmap->irqno) == EXTI14_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_14, DISABLE); + else if ((irqmap->irqno) == EXTI15_IRQn) + EXTI_IntConfig(EXTI_CHANNEL_15, DISABLE); + } + else + { + return RT_ERROR; + } + return RT_EOK; +} + +const static struct rt_pin_ops _ht32_pin_ops = +{ + .pin_mode = ht32_pin_mode, + .pin_write = ht32_pin_write, + .pin_read = ht32_pin_read, + .pin_attach_irq = ht32_pin_attach_irq, + .pin_detach_irq = ht32_pin_detach_irq, + .pin_irq_enable = ht32_pin_irq_enable, + .pin_get = NULL, +}; + +int rt_hw_pin_init(void) +{ + int result; + + result = rt_device_pin_register("pin", &_ht32_pin_ops, RT_NULL); + + return result; +} +INIT_BOARD_EXPORT(rt_hw_pin_init); + +rt_inline void pin_irq_hdr(int irqno) +{ + if (pin_irq_hdr_tab[irqno].hdr) + { + pin_irq_hdr_tab[irqno].hdr(pin_irq_hdr_tab[irqno].args); + } +} +#ifdef SOC_SERIES_HT32F5 +void EXTI0_1_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_0, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_0); + pin_irq_hdr(0); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_1, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_1); + pin_irq_hdr(1); + } + rt_interrupt_leave(); +} + +void EXTI2_3_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_2, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_2); + pin_irq_hdr(2); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_3, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_3); + pin_irq_hdr(3); + } + rt_interrupt_leave(); +} + +void EXTI4_15_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_4, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_4); + pin_irq_hdr(4); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_5, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_5); + pin_irq_hdr(5); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_6, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_6); + pin_irq_hdr(6); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_7, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_7); + pin_irq_hdr(7); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_8, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_8); + pin_irq_hdr(8); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_9, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_9); + pin_irq_hdr(9); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_10, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_10); + pin_irq_hdr(10); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_11, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_11); + pin_irq_hdr(11); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_12, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_12); + pin_irq_hdr(12); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_13, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_13); + pin_irq_hdr(13); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_14, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_14); + pin_irq_hdr(14); + } + else if (EXTI_GetEdgeStatus(EXTI_CHANNEL_15, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_15); + pin_irq_hdr(15); + } + rt_interrupt_leave(); +} +#endif + +#ifdef SOC_SERIES_HT32F1 +void EXTI0_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_0, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_0); + pin_irq_hdr(0); + } + rt_interrupt_leave(); +} +void EXTI1_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_1, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_1); + pin_irq_hdr(1); + } + rt_interrupt_leave(); +} +void EXTI2_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_2, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_2); + pin_irq_hdr(2); + } + rt_interrupt_leave(); +} +void EXTI3_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_3, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_3); + pin_irq_hdr(3); + } + rt_interrupt_leave(); +} +void EXTI4_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_4, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_4); + pin_irq_hdr(4); + } + rt_interrupt_leave(); +} +void EXTI5_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_5, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_5); + pin_irq_hdr(5); + } + rt_interrupt_leave(); +} +void EXTI6_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_6, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_6); + pin_irq_hdr(6); + } + rt_interrupt_leave(); +} +void EXTI7_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_7, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_7); + pin_irq_hdr(7); + } + rt_interrupt_leave(); +} +void EXTI8_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_8, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_8); + pin_irq_hdr(8); + } + rt_interrupt_leave(); +} +void EXTI9_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_9, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_9); + pin_irq_hdr(9); + } + rt_interrupt_leave(); +} +void EXTI10_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_10, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_10); + pin_irq_hdr(10); + } + rt_interrupt_leave(); +} +void EXTI11_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_11, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_11); + pin_irq_hdr(11); + } + rt_interrupt_leave(); +} +void EXTI12_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_12, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_12); + pin_irq_hdr(12); + } + rt_interrupt_leave(); +} +void EXTI13_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_13, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_13); + pin_irq_hdr(13); + } + rt_interrupt_leave(); +} +void EXTI14_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_14, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_14); + pin_irq_hdr(14); + } + rt_interrupt_leave(); +} +void EXTI15_IRQHandler(void) +{ + rt_interrupt_enter(); + if (EXTI_GetEdgeStatus(EXTI_CHANNEL_15, EXTI_EDGE_POSITIVE)) + { + EXTI_ClearEdgeFlag(EXTI_CHANNEL_15); + pin_irq_hdr(15); + } + rt_interrupt_leave(); +} +#endif + +#endif diff --git a/bsp/ht32/libraries/ht32_drivers/drv_gpio.h b/bsp/ht32/libraries/ht32_drivers/drv_gpio.h new file mode 100644 index 0000000000..01ec12fc24 --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_gpio.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __DRV_GPIO_H__ +#define __DRV_GPIO_H__ + +#include +#include +#include "drv_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define __HT32_PORT(port) HT_GPIO##port##_BASE + +#define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__HT32_PORT(PORTx) - (rt_base_t)HT_GPIOA_BASE)/(0x2000UL) )) + PIN) + +#ifdef __cplusplus +} +#endif + +#endif /* __DRV_GPIO_H__ */ diff --git a/bsp/ht32/libraries/ht32_drivers/drv_i2c.c b/bsp/ht32/libraries/ht32_drivers/drv_i2c.c new file mode 100644 index 0000000000..edf98127c5 --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_i2c.c @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include "drv_i2c.h" + +#ifdef RT_USING_I2C +#if !defined(BSP_USING_I2C0) && !defined(BSP_USING_I2C1) + #error "Please define at least one BSP_USING_I2Cx" + /* this driver can be disabled at menuconfig RT-Thread Components Device Drivers */ +#endif + +struct ht32_i2c_config +{ + HT_I2C_TypeDef *i2c_x; + const char *i2c_name; + IRQn_Type irq; +}; + +struct ht32_i2c +{ + struct ht32_i2c_config *config; + struct rt_i2c_bus_device i2c_bus; +}; + +enum +{ +#ifdef BSP_USING_I2C0 + I2C0_INDEX, +#endif +#ifdef BSP_USING_I2C1 + I2C1_INDEX, +#endif +}; + +static struct ht32_i2c_config i2c_config[] = +{ +#ifdef BSP_USING_I2C0 + {HT_I2C0, "i2c0", I2C0_IRQn}, +#endif +#ifdef BSP_USING_I2C1 + {HT_I2C1, "i2c1", I2C1_IRQn}, +#endif +}; + +static struct ht32_i2c i2cs[sizeof(i2c_config) / sizeof(i2c_config[0])] = {0}; + +static rt_size_t ht32_i2c_init(struct ht32_i2c *i2c_drv) +{ + struct ht32_i2c_config *i2c_config = i2c_drv->config; + + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; +#ifdef BSP_USING_I2C0 + if (HT_I2C0 == i2c_config->i2c_x) + { + CKCUClock.Bit.I2C0 = 1; + } +#endif +#ifdef BSP_USING_I2C1 + if (HT_I2C1 == i2c_config->i2c_x) + { + CKCUClock.Bit.I2C1 = 1; + } +#endif + CKCUClock.Bit.AFIO = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + ht32_i2c_gpio_init(i2c_config->i2c_x); + + I2C_InitTypeDef I2C_InitStructure; + I2C_InitStructure.I2C_GeneralCall = DISABLE; + I2C_InitStructure.I2C_AddressingMode = I2C_ADDRESSING_7BIT; + I2C_InitStructure.I2C_Acknowledge = DISABLE; + I2C_InitStructure.I2C_OwnAddress = 0x00; + I2C_InitStructure.I2C_Speed = 400000; + I2C_InitStructure.I2C_SpeedOffset = 0; + + I2C_Init(i2c_config->i2c_x, &I2C_InitStructure); + I2C_Cmd(i2c_config->i2c_x, ENABLE); + + return RT_EOK; +} + +static int ht32_i2c_read(struct ht32_i2c_config *hi2c, + rt_uint16_t slave_address, + rt_uint8_t *p_buffer, + rt_uint16_t data_byte) +{ + uint16_t date_num = 0; + uint8_t data = 0xFF; + + I2C_TargetAddressConfig(hi2c->i2c_x, slave_address, I2C_MASTER_READ); + while (!I2C_CheckStatus(hi2c->i2c_x, I2C_MASTER_SEND_START)); + while (!I2C_CheckStatus(hi2c->i2c_x, I2C_MASTER_RECEIVER_MODE)); + I2C_AckCmd(hi2c->i2c_x, ENABLE); + while (date_num < data_byte) + { + date_num++; + + while (!I2C_CheckStatus(hi2c->i2c_x, I2C_MASTER_RX_NOT_EMPTY)); + data = I2C_ReceiveData(hi2c->i2c_x); + + if (date_num == (data_byte - 1)) + { + I2C_AckCmd(hi2c->i2c_x, DISABLE); + } + if (p_buffer != RT_NULL) + { + *p_buffer++ = data; + } + } + I2C_GenerateSTOP(hi2c->i2c_x); + while (I2C_ReadRegister(hi2c->i2c_x, I2C_REGISTER_SR) & 0x80000); + + return 0; +} + +static int ht32_i2c_write(struct ht32_i2c_config *hi2c, + uint16_t slave_address, + uint8_t *p_buffer, + uint16_t data_byte) +{ + uint16_t date_num = data_byte; + + I2C_TargetAddressConfig(hi2c->i2c_x, slave_address, I2C_MASTER_WRITE); + + while (!I2C_CheckStatus(hi2c->i2c_x, I2C_MASTER_SEND_START)); + + while (!I2C_CheckStatus(hi2c->i2c_x, I2C_MASTER_TRANSMITTER_MODE)); + while (date_num--) + { + while (!I2C_CheckStatus(hi2c->i2c_x, I2C_MASTER_TX_EMPTY)); + I2C_SendData(hi2c->i2c_x, *p_buffer++); + } + + while (!I2C_CheckStatus(hi2c->i2c_x, I2C_MASTER_TX_EMPTY)); + I2C_GenerateSTOP(hi2c->i2c_x); + while (I2C_ReadRegister(hi2c->i2c_x, I2C_REGISTER_SR) & 0x80000); + return 0; +} + +static rt_ssize_t ht32_master_xfer(struct rt_i2c_bus_device *bus, + struct rt_i2c_msg msgs[], + rt_uint32_t num) +{ + struct ht32_i2c *i2c_instance; + struct rt_i2c_msg *msg; + rt_uint32_t i; + + i2c_instance = rt_container_of(bus, struct ht32_i2c, i2c_bus); + RT_ASSERT(bus != RT_NULL); + RT_ASSERT(msgs != RT_NULL); + + for (i = 0; i < num; i++) + { + msg = &msgs[i]; + + if (msg->flags & RT_I2C_RD) + { + if (ht32_i2c_read(i2c_instance->config, msg->addr, msg->buf, msg->len) != 0) + { + return i; + } + } + else + { + if (ht32_i2c_write(i2c_instance->config, msg->addr, msg->buf, msg->len) != 0) + { + return i; + } + } + } + return i; +} + +static struct rt_i2c_bus_device_ops ht32_i2c_ops = +{ + .master_xfer = ht32_master_xfer, + .slave_xfer = RT_NULL, + .i2c_bus_control = RT_NULL +}; + +int rt_hw_i2c_init(void) +{ + int i; + rt_err_t result; + rt_size_t obj_num = sizeof(i2cs) / sizeof(struct ht32_i2c); + + for (i = 0; i < obj_num; i++) + { + i2cs[i].config = &i2c_config[i]; + i2cs[i].i2c_bus.parent.user_data = (void *)&i2cs[i]; + i2cs[i].i2c_bus.ops = &ht32_i2c_ops; + + ht32_i2c_init(&i2cs[i]); + result = rt_i2c_bus_device_register(&i2cs[i].i2c_bus, i2cs[i].config->i2c_name); + } + return result; +} +INIT_BOARD_EXPORT(rt_hw_i2c_init); + +#endif /* RT_USING_I2C */ diff --git a/bsp/ht32/libraries/ht32_drivers/drv_i2c.h b/bsp/ht32/libraries/ht32_drivers/drv_i2c.h new file mode 100644 index 0000000000..186aa12b53 --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_i2c.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __DRV_I2C_H__ +#define __DRV_I2C_H__ + +#include +#include +#ifdef RT_USING_DEVICE + #include +#endif +#include "drv_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __DRV_I2C_H__ */ + diff --git a/bsp/ht32/libraries/ht32_drivers/drv_spi.c b/bsp/ht32/libraries/ht32_drivers/drv_spi.c new file mode 100644 index 0000000000..c01867c909 --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_spi.c @@ -0,0 +1,352 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include +#include "drv_spi.h" + +#ifdef RT_USING_SPI +#if !defined(BSP_USING_SPI0) && !defined(BSP_USING_SPI1) + #error "Please define at least one BSP_USING_SPIx" +#endif + +struct ht32_spi_config +{ + HT_SPI_TypeDef *spi_x; + const char *spi_name; + IRQn_Type irq; +}; + +struct ht32_spi +{ + struct ht32_spi_config *config; + struct rt_spi_bus spi_bus; +}; + +struct ht32_spi_cs +{ + HT_GPIO_TypeDef *gpio_x; + uint32_t gpio_pin; +}; + +enum +{ +#ifdef BSP_USING_SPI0 + SPI0_INDEX, +#endif +#ifdef BSP_USING_SPI1 + SPI1_INDEX, +#endif +}; + +static struct ht32_spi_config spi_config[] = +{ +#ifdef BSP_USING_SPI0 + {HT_SPI0, "spi0", SPI0_IRQn}, +#endif +#ifdef BSP_USING_SPI1 + {HT_SPI1, "spi1", SPI1_IRQn}, +#endif +}; + +static struct ht32_spi spis[sizeof(spi_config) / sizeof(spi_config[0])] = {0}; + +/* attach the spi device to spi bus, this function must be used after initialization */ +rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, HT_GPIO_TypeDef *cs_gpiox, uint16_t cs_gpio_pin) +{ + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + + RT_ASSERT(bus_name != RT_NULL); + RT_ASSERT(device_name != RT_NULL); + + rt_err_t result; + struct rt_spi_device *spi_device; + struct ht32_spi_cs *cs_pin; + + if ((cs_gpiox) == HT_GPIOA) + { + CKCUClock.Bit.PA = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + AFIO_GPxConfig(GPIO_PA, cs_gpio_pin, AFIO_FUN_GPIO); + } + else if ((cs_gpiox) == HT_GPIOB) + { + CKCUClock.Bit.PB = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + AFIO_GPxConfig(GPIO_PB, cs_gpio_pin, AFIO_FUN_GPIO); + } +#if defined(HT_GPIOC) + else if ((cs_gpiox) == HT_GPIOC) + { + CKCUClock.Bit.PC = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + AFIO_GPxConfig(GPIO_PC, cs_gpio_pin, AFIO_FUN_GPIO); + } +#endif +#if defined(HT_GPIOD) + else if ((cs_gpiox) == HT_GPIOD) + { + CKCUClock.Bit.PD = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + AFIO_GPxConfig(GPIO_PD, cs_gpio_pin, AFIO_FUN_GPIO); + } +#endif +#if defined(HT_GPIOE) + else if ((cs_gpiox) == HT_GPIOE) + { + CKCUClock.Bit.PE = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + AFIO_GPxConfig(GPIO_PE, cs_gpio_pin, AFIO_FUN_GPIO); + } +#endif +#if defined(HT_GPIOF) + else if ((cs_gpiox) == HT_GPIOF) + { + CKCUClock.Bit.PF = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + AFIO_GPxConfig(GPIO_PF, cs_gpio_pin, AFIO_FUN_GPIO); + } +#endif + GPIO_PullResistorConfig(cs_gpiox, cs_gpio_pin, GPIO_PR_DISABLE); + GPIO_WriteOutBits(cs_gpiox, cs_gpio_pin, SET); + GPIO_DirectionConfig(cs_gpiox, cs_gpio_pin, GPIO_DIR_OUT); + + /* attach the device to spi bus */ + spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device)); + RT_ASSERT(spi_device != RT_NULL); + cs_pin = (struct ht32_spi_cs *)rt_malloc(sizeof(struct ht32_spi_cs)); + RT_ASSERT(cs_pin != RT_NULL); + cs_pin->gpio_x = cs_gpiox; + cs_pin->gpio_pin = cs_gpio_pin; + result = rt_spi_bus_attach_device(spi_device, device_name, bus_name, (void *)cs_pin); + + if (result != RT_EOK) + { + LOG_D("%s attach to %s faild, %d\n", device_name, bus_name, result); + } + + RT_ASSERT(result == RT_EOK); + + LOG_D("%s attach to %s done", device_name, bus_name); + + return result; +} + +static rt_err_t ht32_configure(struct rt_spi_device *device, struct rt_spi_configuration *configuration) +{ + struct rt_spi_bus *spi_bus = (struct rt_spi_bus *)device->bus; + struct ht32_spi *spi_instance = (struct ht32_spi *)spi_bus->parent.user_data; + + SPI_InitTypeDef SPI_InitStructure; + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + + RT_ASSERT(device != RT_NULL); + RT_ASSERT(configuration != RT_NULL); +#ifdef BSP_USING_SPI0 + if (HT_SPI0 == spi_instance->config->spi_x) + { + CKCUClock.Bit.SPI0 = 1; + } +#endif +#ifdef BSP_USING_SPI1 + if (HT_SPI1 == spi_instance->config->spi_x) + { + CKCUClock.Bit.SPI1 = 1; + } +#endif + CKCUClock.Bit.AFIO = 1; + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + ht32_spi_gpio_init(spi_instance->config->spi_x); + + /* data_width */ + if (configuration->data_width <= 8) + { + SPI_InitStructure.SPI_DataLength = SPI_DATALENGTH_8; + } + else if (configuration->data_width <= 16) + { + SPI_InitStructure.SPI_DataLength = SPI_DATALENGTH_16; + } + else + { + return RT_ERROR; + } + + /* Set the polarity and phase of the SPI */ + switch (configuration->mode & RT_SPI_MODE_3) + { + case RT_SPI_MODE_0: + SPI_InitStructure.SPI_CPOL = SPI_CPOL_LOW; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_FIRST; + break; + case RT_SPI_MODE_1: + SPI_InitStructure.SPI_CPOL = SPI_CPOL_LOW; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_SECOND; + break; + case RT_SPI_MODE_2: + SPI_InitStructure.SPI_CPOL = SPI_CPOL_HIGH; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_FIRST; + break; + case RT_SPI_MODE_3: + SPI_InitStructure.SPI_CPOL = SPI_CPOL_HIGH; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_SECOND; + break; + } + + /* Set the SPI as a master or slave */ + SPI_InitStructure.SPI_Mode = (configuration->mode & RT_SPI_SLAVE) ? (SPI_SLAVE) : (SPI_MASTER); + + /* Set the data high or low first */ + SPI_InitStructure.SPI_FirstBit = (configuration->mode & RT_SPI_MSB) ? (SPI_FIRSTBIT_MSB) : (SPI_FIRSTBIT_LSB); + + /* SEL uses software by default */ + SPI_InitStructure.SPI_SELMode = SPI_SEL_SOFTWARE; + + /* SEL effective level */ + SPI_InitStructure.SPI_SELPolarity = (configuration->mode & RT_SPI_CS_HIGH) ? (SPI_SELPOLARITY_HIGH) : (SPI_SELPOLARITY_LOW); + + /* Configure the SCK clock frequency of the SPI */ + if (configuration->max_hz < 0xFFFF) + { + SPI_InitStructure.SPI_ClockPrescaler = ((configuration->max_hz) & 0xFFFF); + } + else + { + return RT_ERROR; + } + + SPI_InitStructure.SPI_FIFO = SPI_FIFO_DISABLE; + SPI_InitStructure.SPI_RxFIFOTriggerLevel = 0; + SPI_InitStructure.SPI_TxFIFOTriggerLevel = 0; + SPI_Init(spi_instance->config->spi_x, &SPI_InitStructure); +#if (!LIBCFG_SPI_NO_MULTI_MASTER) + SPI_SELOutputCmd(spi_instance->config->spi_x, ENABLE); +#endif + + SPI_Cmd(spi_instance->config->spi_x, ENABLE); + return RT_EOK; +} + +static rt_ssize_t ht32_xfer(struct rt_spi_device *device, struct rt_spi_message *message) +{ + struct rt_spi_bus *ht32_spi_bus = (struct rt_spi_bus *)device->bus; + struct ht32_spi *spi_instance = (struct ht32_spi *)ht32_spi_bus->parent.user_data; + struct rt_spi_configuration *config = &device->config; + struct ht32_spi_cs *ht32_spi_cs = device->parent.user_data; + + RT_ASSERT(device != NULL); + RT_ASSERT(message != NULL); + + /* take cs */ + if (message->cs_take) + { + GPIO_ClearOutBits(ht32_spi_cs->gpio_x, ht32_spi_cs->gpio_pin); + LOG_D("spi take cs\n"); + } + + if (config->data_width <= 8) + { + const rt_uint8_t *send_ptr = message->send_buf; + rt_uint8_t *recv_ptr = message->recv_buf; + rt_uint32_t size = message->length; + + LOG_D("spi poll transfer start: %d\n", size); + + while (size--) + { + rt_uint8_t data = 0xFF; + + if (send_ptr != RT_NULL) + { + data = *send_ptr++; + } + + /* wait until the transmit buffer is empty */ + while (SPI_GetFlagStatus(spi_instance->config->spi_x, SPI_FLAG_TXE) == RESET); + /* send the byte */ + SPI_SendData(spi_instance->config->spi_x, data); + + /* wait until a data is received */ + while (SPI_GetFlagStatus(spi_instance->config->spi_x, SPI_INT_RXBNE) == RESET); + /* get the received data */ + data = SPI_ReceiveData(spi_instance->config->spi_x); + + if (recv_ptr != RT_NULL) + { + *recv_ptr++ = data; + } + } + LOG_D("spi poll transfer finsh\n"); + } + else if (config->data_width <= 16) + { + const rt_uint16_t *send_ptr = message->send_buf; + rt_uint16_t *recv_ptr = message->recv_buf; + rt_uint32_t size = message->length; + + while (size--) + { + rt_uint16_t data = 0xFF; + + if (send_ptr != RT_NULL) + { + data = *send_ptr++; + } + + /* wait until the transmit buffer is empty */ + while (SPI_GetFlagStatus(spi_instance->config->spi_x, SPI_FLAG_TXE) == RESET); + /* send the byte */ + SPI_SendData(spi_instance->config->spi_x, data); + + /* wait until a data is received */ + while (SPI_GetFlagStatus(spi_instance->config->spi_x, SPI_INT_RXBNE) == RESET); + /* get the received data */ + data = SPI_ReceiveData(spi_instance->config->spi_x); + + if (recv_ptr != RT_NULL) + { + *recv_ptr++ = data; + } + } + } + + /* release cs */ + if (message->cs_release) + { + GPIO_SetOutBits(ht32_spi_cs->gpio_x, ht32_spi_cs->gpio_pin); + LOG_D("spi release cs\n"); + } + + return message->length; +} + +static struct rt_spi_ops ht32_spi_ops = +{ + .configure = ht32_configure, + .xfer = ht32_xfer +}; + +int rt_hw_spi_init(void) +{ + int i; + rt_err_t result; + rt_size_t obj_num = sizeof(spis) / sizeof(struct ht32_spi); + + for (i = 0; i < obj_num; i++) + { + spis[i].config = &spi_config[i]; + spis[i].spi_bus.parent.user_data = (void *)&spis[i]; + result = rt_spi_bus_register(&spis[i].spi_bus, spis[i].config->spi_name, &ht32_spi_ops); + } + return result; +} +INIT_BOARD_EXPORT(rt_hw_spi_init); + +#endif /* RT_USING_SPI */ diff --git a/bsp/ht32/libraries/ht32_drivers/drv_spi.h b/bsp/ht32/libraries/ht32_drivers/drv_spi.h new file mode 100644 index 0000000000..65e63a5d3a --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_spi.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __DRV_SPI_H__ +#define __DRV_SPI_H__ + +#include +#include +#include "drv_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* public function */ +rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, HT_GPIO_TypeDef *cs_gpiox, uint16_t cs_gpio_pin); + +#ifdef __cplusplus +} +#endif + +#endif /* __DRV_SPI_H__ */ diff --git a/bsp/ht32/libraries/ht32_drivers/drv_usart.c b/bsp/ht32/libraries/ht32_drivers/drv_usart.c new file mode 100644 index 0000000000..7e108e5f1a --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_usart.c @@ -0,0 +1,372 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#include "drv_usart.h" + +#ifdef RT_USING_SERIAL +#if !defined(BSP_USING_USART0) && !defined(BSP_USING_USART1) && \ + !defined(BSP_USING_UART0) && !defined(BSP_USING_UART1) && \ + !defined(BSP_USING_UART2) && !defined(BSP_USING_UART3) + #error "Please define at least one BSP_USING_UARTx" +#endif + +struct ht32_usart +{ + char *name; + HT_USART_TypeDef *usart_x; + IRQn_Type irq; + struct rt_serial_device serial; +}; + +enum +{ +#ifdef BSP_USING_USART0 + USART0_INDEX, +#endif +#ifdef BSP_USING_USART1 + USART1_INDEX, +#endif +#ifdef BSP_USING_UART0 + UART0_INDEX, +#endif +#ifdef BSP_USING_UART1 + UART1_INDEX, +#endif +#ifdef BSP_USING_UART2 + UART2_INDEX, +#endif +#ifdef BSP_USING_UART3 + UART3_INDEX, +#endif + +}; + +static struct ht32_usart usart_config[] = +{ +#ifdef BSP_USING_USART0 + { + "usart0", + HT_USART0, + USART0_IRQn, + RT_NULL + }, +#endif +#ifdef BSP_USING_USART1 + { + "usart1", + HT_USART1, + USART1_IRQn, + RT_NULL + }, +#endif +#ifdef BSP_USING_UART0 + { + "uart0", + HT_UART0, + UART0_IRQn, + RT_NULL + }, +#endif +#ifdef BSP_USING_UART1 + { + "uart1", + HT_UART1, + UART1_IRQn, + RT_NULL + }, +#endif +#ifdef BSP_USING_UART2 + { + "uart2", + HT_UART2, + UART0_UART2_IRQn, + RT_NULL + }, +#endif +#ifdef BSP_USING_UART3 + { + "uart3", + HT_UART3, + UART1_UART3_IRQn, + RT_NULL + }, +#endif +}; + +static rt_err_t ht32_configure(struct rt_serial_device *serial, struct serial_configure *cfg) +{ + + CKCU_PeripClockConfig_TypeDef CKCUClock = {{0}}; + USART_InitTypeDef USART_InitStructure = {0}; + + struct ht32_usart *usart_instance = (struct ht32_usart *)serial->parent.user_data; + + RT_ASSERT(serial != RT_NULL); + RT_ASSERT(cfg != RT_NULL); + + CKCUClock.Bit.AFIO = 1; + + if ((usart_instance->usart_x) == HT_UART0) + CKCUClock.Bit.UART0 = 1; +#if defined(HT_USART0) + else if ((usart_instance->usart_x) == HT_USART0) + CKCUClock.Bit.USART0 = 1; +#endif +#if defined(HT_USART1) + else if ((usart_instance->usart_x) == HT_USART1) + CKCUClock.Bit.USART1 = 1; +#endif +#if defined(HT_UART1) + else if ((usart_instance->usart_x) == HT_UART1) + CKCUClock.Bit.UART1 = 1; +#endif +#if defined(HT_UART2) + else if ((usart_instance->usart_x) == HT_UART2) + CKCUClock.Bit.UART2 = 1; +#endif +#if defined(HT_UART3) + else if ((usart_instance->usart_x) == HT_UART3) + CKCUClock.Bit.UART3 = 1; +#endif + CKCU_PeripClockConfig(CKCUClock, ENABLE); + + /* UART gpio init */ + ht32_usart_gpio_init((void *)usart_instance->usart_x); + + /* baud rate */ + USART_InitStructure.USART_BaudRate = (cfg->baud_rate); + + /* data width */ + switch (cfg->data_bits) + { + case DATA_BITS_7: + USART_InitStructure.USART_WordLength = USART_WORDLENGTH_7B; + break; + case DATA_BITS_8: + USART_InitStructure.USART_WordLength = USART_WORDLENGTH_8B; + break; + case DATA_BITS_9: + USART_InitStructure.USART_WordLength = USART_WORDLENGTH_9B; + break; + default: + USART_InitStructure.USART_WordLength = USART_WORDLENGTH_8B; + break; + } + + /* stop bit */ + switch (cfg->stop_bits) + { + case STOP_BITS_1: + USART_InitStructure.USART_StopBits = USART_STOPBITS_1; + break; + case STOP_BITS_2: + USART_InitStructure.USART_StopBits = USART_STOPBITS_2; + break; + default: + USART_InitStructure.USART_StopBits = USART_STOPBITS_1; + break; + } + + switch (cfg->parity) + { + case PARITY_NONE: + USART_InitStructure.USART_Parity = USART_PARITY_NO; + break; + case PARITY_ODD: + USART_InitStructure.USART_Parity = USART_PARITY_ODD; + break; + case PARITY_EVEN: + USART_InitStructure.USART_Parity = USART_PARITY_EVEN; + break; + default: + USART_InitStructure.USART_Parity = USART_PARITY_NO; + break; + } + + /* UART mode */ + USART_InitStructure.USART_Mode = USART_MODE_NORMAL; + /* UART init */ + USART_Init((usart_instance->usart_x), &USART_InitStructure); + /*UART enable */ + USART_TxCmd((usart_instance->usart_x), ENABLE); + USART_RxCmd((usart_instance->usart_x), ENABLE); + + return RT_EOK; +} + +static rt_err_t ht32_control(struct rt_serial_device *serial, int cmd, void *arg) +{ + struct ht32_usart *usart; + + RT_ASSERT(serial != RT_NULL); + usart = (struct ht32_usart *) serial->parent.user_data; + RT_ASSERT(usart != RT_NULL); + + switch (cmd) + { + case RT_DEVICE_CTRL_CLR_INT: + NVIC_DisableIRQ(usart->irq); + USART_IntConfig(usart->usart_x, USART_INT_RXDR, DISABLE); + break; + case RT_DEVICE_CTRL_SET_INT: + NVIC_EnableIRQ(usart->irq); + USART_IntConfig(usart->usart_x, USART_INT_RXDR, ENABLE); + break; + } + return RT_EOK; +} + +static int ht32_putc(struct rt_serial_device *serial, char c) +{ + struct ht32_usart *usart; + + RT_ASSERT(serial != RT_NULL); + usart = (struct ht32_usart *) serial->parent.user_data; + RT_ASSERT(usart != RT_NULL); + + while ((usart->usart_x->SR & USART_FLAG_TXC) == 0); + usart->usart_x->DR = (u8)c; + + return 1; +} + +static int ht32_getc(struct rt_serial_device *serial) +{ + int ch; + struct ht32_usart *usart; + + RT_ASSERT(serial != RT_NULL); + usart = (struct ht32_usart *) serial->parent.user_data; + RT_ASSERT(usart != RT_NULL); + + ch = -1; + if (USART_GetFlagStatus(usart->usart_x, USART_FLAG_RXDR) != RESET) + { + ch = USART_ReceiveData(usart->usart_x); + } + return ch; +} + +static rt_ssize_t ht32_dma_transmit(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction) +{ + return RT_ERROR; +} + +static const struct rt_uart_ops ht32_usart_ops = +{ + .configure = ht32_configure, + .control = ht32_control, + .putc = ht32_putc, + .getc = ht32_getc, + .dma_transmit = ht32_dma_transmit, +}; + +int rt_hw_usart_init(void) +{ + rt_size_t obj_num; + int index; + + obj_num = sizeof(usart_config) / sizeof(struct ht32_usart); + struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; + rt_err_t result = 0; + + for (index = 0; index < obj_num; index++) + { + usart_config[index].serial.ops = &ht32_usart_ops; + usart_config[index].serial.config = config; + + /* register uart device */ + result = rt_hw_serial_register(&usart_config[index].serial, + usart_config[index].name, + RT_DEVICE_FLAG_RDWR | + RT_DEVICE_FLAG_INT_RX | + RT_DEVICE_FLAG_INT_TX, + &usart_config[index]); + RT_ASSERT(result == RT_EOK); + } + + return result; +} +INIT_BOARD_EXPORT(rt_hw_usart_init); + +static void usart_isr(struct rt_serial_device *serial) +{ + + struct ht32_usart *usart = (struct ht32_usart *)serial->parent.user_data; + RT_ASSERT(usart != RT_NULL); + + if ((USART_GetFlagStatus(usart->usart_x, USART_FLAG_RXDR) != RESET) && ((usart->usart_x->IER & USART_INT_RXDR) != RESET)) + { + rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); + } +} + +#ifdef BSP_USING_USART0 +void USART0_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + usart_isr(&usart_config[USART0_INDEX].serial); + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif +#ifdef BSP_USING_USART1 +void USART1_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + usart_isr(&usart_config[USART1_INDEX].serial); + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif +#ifdef BSP_USING_UART0 +void UART0_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + usart_isr(&usart_config[UART0_INDEX].serial); + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif +#ifdef BSP_USING_UART1 +void UART1_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + usart_isr(&usart_config[UART1_INDEX].serial); + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif +#ifdef BSP_USING_UART2 +void UART2_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + usart_isr(&usart_config[UART2_INDEX].serial); + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif +#ifdef BSP_USING_UART3 +void UART3_IRQHandler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + usart_isr(&usart_config[UART3_INDEX].serial); + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif + +#endif /* RT_USING_SERIAL */ diff --git a/bsp/ht32/libraries/ht32_drivers/drv_usart.h b/bsp/ht32/libraries/ht32_drivers/drv_usart.h new file mode 100644 index 0000000000..19fdaf68df --- /dev/null +++ b/bsp/ht32/libraries/ht32_drivers/drv_usart.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2006-2024, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2024-04-08 QT-one first version + */ + +#ifndef __DRV_UART_H__ +#define __DRV_UART_H__ + +#include +#include +#include "drv_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __DRV_USART_H__ */ diff --git a/bsp/ht32/tools/sdk_dist.py b/bsp/ht32/tools/sdk_dist.py new file mode 100644 index 0000000000..2383b82a90 --- /dev/null +++ b/bsp/ht32/tools/sdk_dist.py @@ -0,0 +1,40 @@ +import os +import sys +import shutil +cwd_path = os.getcwd() +sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + +def bsp_update_kconfig_library(dist_dir): + # change RTT_ROOT in Kconfig + if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): + return + + with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f: + data = f.readlines() + with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f: + found = 0 + for line in data: + if line.find('RTT_ROOT') != -1: + found = 1 + if line.find('../libraries') != -1 and found: + position = line.find('../libraries') + line = line[0:position] + 'libraries/Kconfig"\n' + found = 0 + f.write(line) + +# BSP dist function +def dist_do_building(BSP_ROOT, dist_dir): + from mkdist import bsp_copy_files + import rtconfig + + print("=> copy ht32 bsp library") + library_dir = os.path.join(dist_dir, 'libraries') + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') + bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), + os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + + print("=> copy bsp drivers") + bsp_copy_files(os.path.join(library_path, 'ht32_drivers'), os.path.join(library_dir, 'ht32_drivers')) + shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + bsp_update_kconfig_library(dist_dir) +

@JbNZEMVbEuHUAE_D#BqJx?zt;-YChh7 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 %#0x(a7)Pc?^tNFG`QZa!d1kN1EmL8j>YFkJ_ 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�mhC%^Jkkc|U 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 z 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